/// <summary> /// Name: Add /// Input: LexicalAnalyzer /// Output: N/A /// Description: Adds the token to a list of all tokens, for the soul purpose of being /// displayed for Assignment 1 /// </summary> /// <param name="lex"></param> public static void Add(LexicalAnalyzer lex) { if (lex.Token == Tokens.emptyT) { return; } AllTokens.Add(new TokenObject { token = lex.Token, lexeme = lex.Lexeme, value = lex.Value, valueR = lex.ValueR, lineNumber = lex.LineNumber, literal = lex.Literal }); }
static void Main(string[] args) { LexicalAnalyzer lexicalAnalyzer = new LexicalAnalyzer(); IdentifiersTable ident; TokenTable table = lexicalAnalyzer.analyze("Input5.txt", out ident); lexicalAnalyzer.printResults("Tokens.txt"); SyntaxAnalyzer syntaxAnalyzer = new SyntaxAnalyzer(table, ident, lexicalAnalyzer); syntaxAnalyzer.analyze(); SyntaxTree tree = syntaxAnalyzer.getTree(); tree.printItselfToTheFile("Tree.txt"); SemanticAnalyzer semanticAnalyzer = new SemanticAnalyzer(tree); semanticAnalyzer.analyze(); Generator generator = new Generator(); generator.generateExe(tree); Console.ReadLine(); }
/// <summary> /// Name: Parser /// Input: LexicalAnalyzer /// Output: N/A /// Description: Constructor for the parser class. Takes in and initalizes the /// lexical analyzer and also primes the parser with the first token. /// </summary> /// <param name="lex"></param> public Parser(LexicalAnalyzer lex, SymbolTable symTab) { mySymTab = symTab; myLex = lex; myLex.GetNextToken(); //Prime the parser }