/// <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); semanticAnalyzer.Analyze(); // return the AST return(syntaxTree); }
/// <summary> /// Initializes a new instance of the <see cref="Compiler.StatementCheckVisitor"/> class. /// </summary> /// <param name="analyzer">Analyzer.</param> public StatementCheckVisitor(SemanticAnalyzer analyzer) { this.analyzer = analyzer; this.returnStatements = new List <ReturnStatement> (); this.typeChecker = new TypeCheckingVisitor(); }