Class Compiler
- java.lang.Object
-
- compilation.Compiler
-
public final class Compiler extends java.lang.ObjectThe Compiler class is used to run the full compilation process on a String of code.It takes a String as input and runs the entire compilation process on it, producing a SourceOutput object which contains the result. Each Compiler object contains its own SymbolTable instance, and initialises with REPL mode set to false by default.
- Since:
- 1.0
-
-
Constructor Summary
Constructors Constructor Description Compiler()Constructs a Compiler object initialised with an empty SymbolTable.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SourceOutputcompile(java.lang.String sourceText)Compiles a String of code, generating a SourceOutput object containing the result.voidprintParseTree()Print the ParseTree generated from the latest compilation.voidprintSymbolTable()Print the SymbolTable generated from the latest compilation.
-
-
-
Method Detail
-
compile
public SourceOutput compile(java.lang.String sourceText)
Compiles a String of code, generating a SourceOutput object containing the result.The String passed to this method is subjected to the full compilation process: - Lexical analysis (performed by the Lexer class) - Syntax analysis (performed by the Parser class) - Semantic analysis (performed by the TypeChecker class) - Evaluation (performed by the Evaluator class) The SourceOutput contains both the evaluated result and List of Errors and Exceptions that may have occurred.
- Parameters:
sourceText- The String of code to be compiled- Returns:
- A SourceOutput object containing the result
-
printParseTree
public void printParseTree()
Print the ParseTree generated from the latest compilation.This may only be run after the 'compile' method has been called.
-
printSymbolTable
public void printSymbolTable()
Print the SymbolTable generated from the latest compilation.This may only be run after the 'compile' method has been called.
-
-