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/CompNode.java | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/ast/nodes/CompNode.java (limited to 'src/ast/nodes/CompNode.java') diff --git a/src/ast/nodes/CompNode.java b/src/ast/nodes/CompNode.java new file mode 100644 index 0000000..6deb51c --- /dev/null +++ b/src/ast/nodes/CompNode.java @@ -0,0 +1,41 @@ +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 `comp_op` statement of the grammar. + */ +public class CompNode implements Node { + private TerminalNode op; + + public CompNode(TerminalNode op) { + this.op = op; + } + + @Override + public ArrayList checkSemantics(SymbolTable ST, int _nesting) { + return new ArrayList(); + } + + // TODO: it should be boolean, right? + @Override + public Type typeCheck() { + return new VoidType(); + } + + // TODO: add code generation for CompNode + @Override + public String codeGeneration() { + return ""; + } + + @Override + public String toPrint(String prefix) { + return prefix + "CompNode(" + op + ")\n"; + } +} -- cgit v1.2.3-18-g5258