public Node For() { var result = new For() { AnchorToken = Expect(TokenCategory.FOR) }; result.Add(new Identifier() { AnchorToken = Expect(TokenCategory.IDENTIFIER) }); Expect(TokenCategory.IN); result.Add(Expression()); var dostatement = new Do() { AnchorToken = Expect(TokenCategory.DO) }; while (firstOfStatement.Contains(CurrentToken)) { dostatement.Add(Statement()); } Expect(TokenCategory.END); Expect(TokenCategory.SEMICOL); result.Add(dostatement); return(result); }
public Node StmtDoWhile() { var statementDo = new Do() { AnchorToken = Expect(TokenCategory.DO) }; Expect(TokenCategory.BRACKETS_OPEN); statementDo.Add(StmtList()); Expect(TokenCategory.BRACKETS_CLOSE); var statementWhile = new Do_While() { AnchorToken = Expect(TokenCategory.WHILE) }; statementDo.Add(statementWhile); Expect(TokenCategory.PARENTHESIS_OPEN); statementWhile.Add(Expr()); Expect(TokenCategory.PARENTHESIS_CLOSE); Expect(TokenCategory.SEMICOLON); return(statementDo); }