private Statement ParseBlock() { Eat(TokenKind.LeftBrace); int start = GetStart(); List<Statement> statements = new List<Statement>(); try { _openParen++; while (!MaybeEat(TokenKind.RightBrace)) { var stmt = ParseStatement(); if (stmt == null) return null; statements.Add(stmt); } } finally { _openParen--; } Statement ret = new SuiteStatement(statements.ToArray()); ret.SetLoc(_globalParent, start, GetEnd()); return ret; }
private TotemAst ParseFileWorker(bool makeModule, bool returnValue) { _globalParent = new TotemAst(makeModule, false, _context); StartParsing(); List<Statement> l = new List<Statement>(); while (true) { if (MaybeEat(TokenKind.EndOfFile)) break; Statement s = ParseStatement(); l.Add(s); } Statement[] stmts = l.ToArray(); if (returnValue && stmts.Length > 0) { ExpressionStatement exprStmt = stmts[stmts.Length - 1] as ExpressionStatement; if (exprStmt != null) { var retStmt = new ReturnStatement(exprStmt.Expression); stmts[stmts.Length - 1] = retStmt; retStmt.SetLoc(_globalParent, exprStmt.Expression.IndexSpan); } } SuiteStatement ret = new SuiteStatement(stmts); ret.SetLoc(_globalParent, 0, GetEnd()); return FinishParsing(ret); }
public override bool Walk(SuiteStatement node) { node.Parent = _currentScope; return base.Walk(node); }