internal Parser(icode scr, Expr expr) : this() { _scanner = scr; if (_expressionScopeStack == null) { _expressionScopeStack = new Stack<Expr>(); } _expressionScopeStack.Push(expr); }
private void Compile(string iFileName) { try { Debug.Assert(null != iFileName); icode icode = null; if (!File.Exists(iFileName)) { Console.WriteLine(String.Format("The file {0} does not exist", iFileName)); return; } icode = new icode(@"output.txt", new System.IO.FileStream(iFileName, System.IO.FileMode.Open)); System.Console.BackgroundColor = ConsoleColor.Blue; System.ConsoleColor color = System.Console.ForegroundColor; System.Console.ForegroundColor = ConsoleColor.White; System.Console.WriteLine("Parsing"); var parser = new NireLang.Parser(icode); parser.foo(); Debug.Assert(null != parser); using (new ParserContext(ParserContextEnum.None)) { parser.Parse(); } Expr expr = parser.GetIntermededateCode(); var il = new GenerateIL(); il.InitGenerator(expr); System.Console.ForegroundColor = ConsoleColor.Red; System.Console.WriteLine("Compiling"); if (parser.WriteErrors()) { return; } } catch (NireExecutionException nex) { Console.WriteLine(nex.Message); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }
private void SetUpParser(string statement) { NireLang.icode scanner = new icode(statement); NireLang.Parser parse = new Parser(scanner, new BlockDeclExpr()); parse.ParseStatementExpression(); var bin = parse.BinaryExpression; WalkTree(bin); }
internal Parser(icode scr) : this() { Contract.EnsuresOnThrow<ArgumentNullException>(_scanner == null, "the scanner is not set"); //_scanner = scr; }