static void Main(string[] args) { if (args.Length < 1) { Console.WriteLine("No file passed in"); return; } if (!File.Exists(args[0])) { Console.WriteLine("File Doesn't exist"); } Lexical lex = new Lexical(args[0]); Parser pars = new Parser(lex); if (pars.Parse()) { StreamWriter writer = new StreamWriter("Icode.txt"); foreach (Quad q in pars.Icode) { writer.WriteLine(q.ToString()); } writer.Close(); IcodeParser iParser = new IcodeParser(pars.SymbolTb, pars.Icode); iParser.Parse(); writer = new StreamWriter("Tcode.asm"); foreach (Quad q in iParser.GetTcode()) { writer.WriteLine(q.ToString()); } writer.Close(); } }
public Parser(Lexical lex) { SymbolTb = new SymbolTable(); _lex = lex; _sas = new Stack<Sar>(); _op = new Stack<OperatorAction>(); _pass2 = false; _numberOfErrors = 0; Icode = new List<Quad>(); _labelStack = new Stack<string>(); _staticInitICode = new List<Quad>(); }
public void LexTest() { Lexical lex = new Lexical("test1.txt"); Token tok; do { lex.NextToken(); tok = lex.GetToken(); } while (tok.Type != LexemeType.EOF); Console.ReadLine(); }
public void Semantics() { Lexical lex = new Lexical("sem.txt"); Parser pars = new Parser(lex); pars.Parse(); }
public void Compiliation_Unit_Test() { Lexical lex = new Lexical("test1.txt"); Parser pars = new Parser(lex); pars.Compiliation_Unit(); }