/// <summary> /// Performs the compilation process /// </summary> public void Compile() { // Tokenize Write("Tokenising..."); List <Token> tokens = Tokenizer.GetAllTokens(); if (Reporter.HasErrors) { return; } WriteLine("Done"); //WriteLine(string.Join("\n", tokens)); // Parse Write("Parsing..."); ProgramNode tree = Parser.Parse(tokens); if (Reporter.HasErrors) { return; } WriteLine("Done."); //Display the Abstract Syntax Tree WriteLine(TreePrinter.ToString(tree)); //Identify Write("Identifying..."); Identifier.PerformIdentification(tree); if (Reporter.HasErrors) { return; } WriteLine("Done"); //Type check Write("Type Checking..."); if (Reporter.HasErrors) { return; } WriteLine("Done"); WriteLine(TreePrinter.ToString(tree)); }
/// <summary> /// Performs the compilation process /// </summary> public void Compile() { // Tokenize Write("Tokenising..."); List <Token> tokens = Tokenizer.GetAllTokens(); // changed this to spit out wats up rather than just killing the process //if (Reporter.TokenizerHasErrors) return; WriteLine("Done"); // Parse Write("Parsing..."); ProgramNode tree = Parser.Parse(tokens); // by returning it here it kills the process //if (Reporter.ParserHasErrors) return; WriteLine("Done"); // Identify Write("Identifying..."); Identifier.PerformIdentification(tree); //if (Reporter.ParserHasErrors) return; WriteLine("Done"); // Type check Write("Type Checking..."); Checker.PerformTypeChecking(tree); //if (Reporter.CheckingHasErrors) return; WriteLine("Done"); WriteLine(TreePrinter.ToString(tree)); // Code generation Write("Generating code..."); TargetCode targetCode = Generator.GenerateCodeFor(tree); //if (Reporter.HasErrors) return; WriteLine("Done"); // Output Write("Writing to file..."); Writer.WriteToFiles(targetCode); //if (Reporter.HasErrors) return; WriteLine("Done"); }
/// <summary> /// Performs the compilation process /// </summary> public void Compile() { // Tokenize Write("Tokenising..."); List <Token> tokens = Tokenizer.GetAllTokens(); if (Reporter.HasErrors) { return; } WriteLine("Done"); //WriteLine(string.Join("\n", tokens)); //Parse Write("Parsing..."); //Parser.Parse(tokens); ProgramNode tree = Parser.Parse(tokens); if (Reporter.HasErrors) { WriteLine("ERRORS"); return; } WriteLine("Done"); //WriteLine(TreePrinter.ToString(tree)); Write("Identifying..."); Identifier.PerformIdentification(tree); if (Reporter.HasErrors) { return; } WriteLine("Done"); //WriteLine(TreePrinter.ToString(tree)); //Type checking Write("Type Checking..."); Checker.PerformTypeChecking(tree); if (Reporter.HasErrors) { return; } WriteLine("Done"); WriteLine(TreePrinter.ToString(tree)); // Code generation Write("Generating code..."); TargetCode targetCode = Generator.GenerateCodeFor(tree); if (Reporter.HasErrors) { return; } WriteLine("Done"); // Output Write("Writing to file..."); Writer.WriteToFiles(targetCode); if (Reporter.HasErrors) { return; } WriteLine("Done"); }