From 8e7089a5d6ba1f4f50a90133bb50bc5c6c554aff Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Thu, 13 Jun 2024 11:00:06 +0200 Subject: Set up visitor (#3) Co-authored-by: geno --- src/ast/nodes/AtomNode.java | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src/ast/nodes/AtomNode.java (limited to 'src/ast/nodes/AtomNode.java') diff --git a/src/ast/nodes/AtomNode.java b/src/ast/nodes/AtomNode.java new file mode 100644 index 0000000..fa81f92 --- /dev/null +++ b/src/ast/nodes/AtomNode.java @@ -0,0 +1,45 @@ +package com.clp.project.ast.nodes; + +import java.util.ArrayList; + +import com.clp.project.semanticanalysis.SemanticError; +import com.clp.project.semanticanalysis.SymbolTable; +import com.clp.project.ast.types.*; + +/** + * Node for the `atom` statement of the grammar. + */ +public class AtomNode implements Node { + protected String val; + + public AtomNode(String val) { + this.val = val; + } + + @Override + public ArrayList checkSemantics(SymbolTable ST, int _nesting) { + return new ArrayList(); + } + + // FIXME: this type for atom + @Override + public Type typeCheck() { + return new AtomType(); + } + + // TODO: add code generation for atom node + @Override + public String codeGeneration() { + return ""; + } + + @Override + public String toPrint(String prefix) { + if (val != null) { + return prefix + "Atom(" + val + ")\n"; + } + + return prefix + "Atom(null)\n"; + + } +} -- cgit v1.2.3-18-g5258