diff options
author | Santo Cariotti <santo@dcariotti.me> | 2024-06-13 11:00:06 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-13 11:00:06 +0200 |
commit | 8e7089a5d6ba1f4f50a90133bb50bc5c6c554aff (patch) | |
tree | d4a627e56a199720f7d811af5756402e76628864 /src/ast/nodes/DottedNameNode.java | |
parent | 1c8761901b26c0be4d61f3aed5ec0495a558a0e7 (diff) |
Set up visitor (#3)
Co-authored-by: geno <gabriele.genovese2@studio.unibo.it>
Diffstat (limited to 'src/ast/nodes/DottedNameNode.java')
-rw-r--r-- | src/ast/nodes/DottedNameNode.java | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/ast/nodes/DottedNameNode.java b/src/ast/nodes/DottedNameNode.java new file mode 100644 index 0000000..342950a --- /dev/null +++ b/src/ast/nodes/DottedNameNode.java @@ -0,0 +1,51 @@ +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.*; +import org.antlr.v4.runtime.tree.TerminalNode; + +/** + * Node for the `dooted_name` statement of the grammar. + */ +public class DottedNameNode implements Node { + protected ArrayList<TerminalNode> names; + + public DottedNameNode(ArrayList<TerminalNode> names) { + this.names = names; + } + + @Override + public ArrayList<SemanticError> checkSemantics(SymbolTable ST, int _nesting) { + ArrayList<SemanticError> errors = new ArrayList<SemanticError>(); + + return errors; + } + + @Override + public Type typeCheck() { + return new VoidType(); + } + + // NOTE: we do not provide code generation for this node in the same way + // we do not want to do this for the import stm. + @Override + public String codeGeneration() { + return ""; + } + + @Override + public String toPrint(String prefix) { + String str = prefix + "DottedName\n"; + + prefix += " "; + for (var name : names) { + str += prefix + name.toString() + "\n"; + } + + return str; + } + +} |