From b50c7e99603e9f85d82d700d62c16c4fcef88715 Mon Sep 17 00:00:00 2001 From: Geno <48206120+gabrielegenovese@users.noreply.github.com> Date: Thu, 11 Jul 2024 12:57:56 +0200 Subject: Code generation (#20) Co-authored-by: geno Co-authored-by: Santo Cariotti --- src/ast/nodes/CompOpNode.java | 48 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 src/ast/nodes/CompOpNode.java (limited to 'src/ast/nodes/CompOpNode.java') diff --git a/src/ast/nodes/CompOpNode.java b/src/ast/nodes/CompOpNode.java new file mode 100644 index 0000000..7997052 --- /dev/null +++ b/src/ast/nodes/CompOpNode.java @@ -0,0 +1,48 @@ +package ast.nodes; + +import java.util.ArrayList; + +import semanticanalysis.SemanticError; +import semanticanalysis.SymbolTable; +import ast.types.*; +import org.antlr.v4.runtime.tree.TerminalNode; + +/** + * Node for the `comp_op` statement of the grammar. + */ +public class CompOpNode implements Node { + + private final TerminalNode op; + + public CompOpNode(TerminalNode op) { + this.op = op; + } + + public String getOp() { + return op.toString(); + } + + @Override + public ArrayList checkSemantics(SymbolTable ST, int _nesting, FunctionType ft) { + return new ArrayList<>(); + } + + // TODO: it should be boolean, right? + @Override + public Type typeCheck() { + return new VoidType(); + } + + /** + * The code generation for this operation is in `ExprNode`. + */ + @Override + public String codeGeneration() { + return ""; + } + + @Override + public String toPrint(String prefix) { + return prefix + "CompOpNode(" + op + ")\n"; + } +} -- cgit v1.2.3-18-g5258