/// <summary> /// Initializes a new instance of the <see cref="MiniPLInterpreter.StatementCheckVisitor"/> class. /// </summary> /// <param name="analyzer">Analyzer.</param> public StatementCheckVisitor(SemanticAnalyzer analyzer) { this.analyzer = analyzer; this.typeChecker = new TypeCheckingVisitor(analyzer); // We tend to return a lot of VoidProperties here, // but since we don't do anything with them, we // use one global VoidProperty object and pass it // anytime we need to pass one. this.voidProperty = new VoidProperty(); }
static void Main(string[] args) { string codeExamples = File.ReadAllText("CodeExamples.txt"); Lexer lexer = new Lexer(codeExamples); Parser parser = new Parser(lexer); SemanticAnalyzer semanticAnalyzer = new SemanticAnalyzer(parser); semanticAnalyzer.Analyze(); Interpreter interpreter = new Interpreter(semanticAnalyzer); interpreter.Interpret(); }
/// <summary> /// Compiles the source code of the given filepath. /// </summary> /// <param name="filePath">File path.</param> public SyntaxTree Compile(string filePath) { Init(filePath); // initialize the compiler SyntaxTree syntaxTree = this.parser.Parse(); // parse the source code into an AST // if any errors were found during the parse, return null if (lexicalAndSyntacticalErrors()) { return(null); } // perform semantic analysis semanticAnalyzer = new SemanticAnalyzer(syntaxTree, symbolTable); semanticAnalyzer.Analyze(); // return the AST return(syntaxTree); }
public Interpreter(SemanticAnalyzer semanticAnalyzer) { this.semanticAnalyzer = semanticAnalyzer; this.tree = semanticAnalyzer.tree; this.globalMemory = new Dictionary <object, object>(); }
private VoidProperty voidProperty; // as with the StatementCheckVisitor, use this to pass all voids public TypeCheckingVisitor(SemanticAnalyzer analyzer) { this.analyzer = analyzer; this.voidProperty = new VoidProperty(); }