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/Node.java | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/ast/nodes/Node.java (limited to 'src/ast/nodes/Node.java') diff --git a/src/ast/nodes/Node.java b/src/ast/nodes/Node.java new file mode 100644 index 0000000..f807745 --- /dev/null +++ b/src/ast/nodes/Node.java @@ -0,0 +1,36 @@ +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.*; + +/** + * Base interface for a Node. + */ +public interface Node { + /** + * Checks semantics for a given node for a SymbolTable ST and a level of + * nesting. + * Returns a list of `SemanticError`. + */ + ArrayList checkSemantics(SymbolTable ST, int _nesting); + + /** + * Checks the type for a given node. If there's any error, returns an + * `ErrorType`. + */ + Type typeCheck(); + + /** + * Returns a string for the Python Virtual Machine. + */ + String codeGeneration(); + + /** + * Returns a string for a given node with a prefix. + * It used when an AST wants to be visualized on screen. + */ + String toPrint(String prefix); +} -- cgit v1.2.3-18-g5258