public override object Visit (While whileStatement) { var result = new WhileStatement (WhilePosition.Begin); var location = LocationsBag.GetLocations (whileStatement); result.AddChild (new CSharpTokenNode (Convert (whileStatement.loc), "while".Length), WhileStatement.WhileKeywordRole); if (location != null) result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), WhileStatement.Roles.LPar); result.AddChild ((INode)whileStatement.expr.Accept (this), WhileStatement.Roles.Condition); if (location != null) result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), WhileStatement.Roles.RPar); result.AddChild ((INode)whileStatement.Statement.Accept (this), WhileStatement.Roles.EmbeddedStatement); return result; }
public override object Visit (Do doStatement) { var result = new WhileStatement (WhilePosition.End); var location = LocationsBag.GetLocations (doStatement); result.AddChild (new CSharpTokenNode (Convert (doStatement.loc), "do".Length), WhileStatement.DoKeywordRole); result.AddChild ((AstNode)doStatement.EmbeddedStatement.Accept (this), WhileStatement.Roles.EmbeddedStatement); if (location != null) result.AddChild (new CSharpTokenNode (Convert (location[0]), "while".Length), WhileStatement.WhileKeywordRole); if (location != null) result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), WhileStatement.Roles.LPar); result.AddChild ((AstNode)doStatement.expr.Accept (this), WhileStatement.Roles.Condition); if (location != null) { result.AddChild (new CSharpTokenNode (Convert (location[2]), 1), WhileStatement.Roles.RPar); result.AddChild (new CSharpTokenNode (Convert (location[3]), 1), WhileStatement.Roles.Semicolon); } return result; }
public override object Visit(While whileStatement) { var result = new WhileStatement(); var location = LocationsBag.GetLocations(whileStatement); result.AddChild(new CSharpTokenNode(Convert(whileStatement.loc), WhileStatement.WhileKeywordRole), WhileStatement.WhileKeywordRole); if (location != null) result.AddChild(new CSharpTokenNode(Convert(location [0]), Roles.LPar), Roles.LPar); if (whileStatement.expr != null) result.AddChild((Expression)whileStatement.expr.Accept(this), Roles.Condition); if (location != null && location.Count > 1) result.AddChild(new CSharpTokenNode(Convert(location [1]), Roles.RPar), Roles.RPar); if (whileStatement.Statement != null) result.AddChild((Statement)whileStatement.Statement.Accept(this), Roles.EmbeddedStatement); return result; }
public WhileStatement whileStatement() { EnterRule_whileStatement(); EnterRule("whileStatement", 18); TraceIn("whileStatement", 18); WhileStatement st = default(WhileStatement); Condition condition34 = default(Condition); List<Statement> statement35 = default(List<Statement>); st = new WhileStatement(); try { DebugEnterRule(GrammarFileName, "whileStatement"); DebugLocation(370, 5); try { // D:\\projects\\repository\\ifmo\\Компиляторы\\PascalCompiler\\PascalCompiler\\Grammar\\Pascal.g:375:6: ( WHILE condition DO statement SEMI ) DebugEnterAlt(1); // D:\\projects\\repository\\ifmo\\Компиляторы\\PascalCompiler\\PascalCompiler\\Grammar\\Pascal.g:375:8: WHILE condition DO statement SEMI { DebugLocation(375, 8); Match(input,WHILE,Follow._WHILE_in_whileStatement1249); DebugLocation(376, 7); PushFollow(Follow._condition_in_whileStatement1257); condition34=condition(); PopFollow(); DebugLocation(377, 7); st.SetCond(condition34); DebugLocation(380, 7); Match(input,DO,Follow._DO_in_whileStatement1273); DebugLocation(381, 7); PushFollow(Follow._statement_in_whileStatement1281); statement35=statement(); PopFollow(); DebugLocation(382, 7); foreach(var child in statement35) { st.AddChild(child); } DebugLocation(388, 7); Match(input,SEMI,Follow._SEMI_in_whileStatement1297); } } catch (RecognitionException e) { throw e; } finally { TraceOut("whileStatement", 18); LeaveRule("whileStatement", 18); LeaveRule_whileStatement(); } DebugLocation(389, 5); } finally { DebugExitRule(GrammarFileName, "whileStatement"); } return st; }