public Node ElseIfList() { var elseIfList = new ElseIfList(); while (CurrentToken == TokenCategory.ELSE) { var elseToken = Expect(TokenCategory.ELSE); if (CurrentToken == TokenCategory.IF) { elseIfList.Add(ElseIf(elseToken)); } else if (CurrentToken == TokenCategory.BRACKETS_OPEN) { elseIfList.Add(Else(elseToken)); } } return(elseIfList); }
public Node If() { var n1 = new If(); n1.AnchorToken = Expect(TokenType.IF); Expect(TokenType.PARENTHESIS_OPEN); n1.Add(Expression()); Expect(TokenType.PARENTHESIS_CLOSE); Expect(TokenType.BLOCK_BEGIN); var n2 = new StatementList(); while (firstOfStatement.Contains(CurrentToken)) { n2.Add(Statement()); } n1.Add(n2); var n3 = new ElseIfList(); Expect(TokenType.BLOCK_END); while (CurrentToken == TokenType.ELSEIF) { var nelsif = new ElseIf(); nelsif.AnchorToken = Expect(TokenType.ELSEIF); Expect(TokenType.PARENTHESIS_OPEN); nelsif.Add(Expression()); Expect(TokenType.PARENTHESIS_CLOSE); Expect(TokenType.BLOCK_BEGIN); var stmtList = new StatementList(); while (firstOfStatement.Contains(CurrentToken)) { stmtList.Add(Statement()); } nelsif.Add(stmtList); n3.Add(nelsif); Expect(TokenType.BLOCK_END); } n1.Add(n3); var els = new Else(); if (CurrentToken == TokenType.ELSE) { els.AnchorToken = Expect(TokenType.ELSE); Expect(TokenType.BLOCK_BEGIN); var stmtList = new StatementList(); while (firstOfStatement.Contains(CurrentToken)) { stmtList.Add(Statement()); } els.Add(stmtList); Expect(TokenType.BLOCK_END); } n1.Add(els); return(n1); }
//If side function// public Node If() { var result = new If() { AnchorToken = Expect(TokenCategory.IF) }; Expect(TokenCategory.PARENTHESIS_OPEN); result.Add(Expression()); Expect(TokenCategory.PARENTHESIS_CLOSE); Expect(TokenCategory.CURLY_BRACKET_OPEN); result.Add(StmtList()); Expect(TokenCategory.CURLY_BRACKET_CLOSE); var elseIfListr = new ElseIfList(); while (elsif.Contains(CurrentToken)) { elseIfListr.Add(elseif()); } result.Add(elseIfListr); var elser = new Else(); if (CurrentToken == TokenCategory.ELSE) { elser = new Else() { AnchorToken = Expect(TokenCategory.ELSE) }; Expect(TokenCategory.CURLY_BRACKET_OPEN); elser.Add(StmtList()); Expect(TokenCategory.CURLY_BRACKET_CLOSE); } result.Add(elser); return(result); }
public Node ElseIf() { var node = new ElseIfList(); while (CurrentToken == TokenCategory.ELSEIF) { var node_elseif = new ElseIf(); Expect(TokenCategory.ELSEIF); Expect(TokenCategory.OPENEDPAR); node_elseif.Add(Expr()); Expect(TokenCategory.CLOSEDPAR); Expect(TokenCategory.OPENEDCURLY); node_elseif.Add(StmtList()); Expect(TokenCategory.CLOSEDCURLY); node.Add(node_elseif); } return(node); }
public Node ElseIf() { //elseif(‹expr›){‹stmt-list›} * var n = new ElseIfList(); while (CurrentToken == TokenCategory.ELSEIF) { var n1 = new ElseIf(); Expect(TokenCategory.ELSEIF); Expect(TokenCategory.OPENEDPAR); n1.Add(Expr()); Expect(TokenCategory.CLOSEDPAR); Expect(TokenCategory.OPENEDCURLY); n1.Add(StmtList()); Expect(TokenCategory.CLOSEDCURLY); n.Add(n1); } return(n); }
public Node ElseIfList() { var elseIfList = new ElseIfList(); while (Current == TokenCategory.ELSEIF) { var elseIf = new ElseIf() { AnchorToken = Expect(TokenCategory.ELSEIF) }; Expect(TokenCategory.OPEN_PARENTHESIS); elseIf.Add(Expr()); Expect(TokenCategory.CLOSE_PARENTHESIS); Expect(TokenCategory.OPEN_BRACKET); elseIf.Add(StmtList()); Expect(TokenCategory.CLOSE_BRACKET); elseIfList.Add(elseIf); } return(elseIfList); }
public Node ElseIfList() { var result = new ElseIfList(); while (CurrentToken == TokenCategory.ELIF) { var elifNode = new ElseIf(); var elif = Expect(TokenCategory.ELIF); Expect(TokenCategory.PARENTHESIS_OPEN); var expr = Expression(); elifNode.Add(expr); Expect(TokenCategory.PARENTHESIS_CLOSE); Expect(TokenCategory.BRACKET_OPEN); var stmtList = StmtList(); elifNode.Add(stmtList); Expect(TokenCategory.BRACKET_CLOSE); elifNode.AnchorToken = elif; result.Add(elifNode); } return(result); }
public Node If() { var result = new If() { AnchorToken = Expect(TokenCategory.IF) }; result.Add(Expression()); Expect(TokenCategory.THEN); if (firstOfStatement.Contains(CurrentToken)) { var statementList = new StatementList(); while (firstOfStatement.Contains(CurrentToken)) { statementList.Add(Statement()); } result.Add(statementList); } var elseIfList = new ElseIfList(); if (CurrentToken == TokenCategory.ELSEIF) { while (CurrentToken == TokenCategory.ELSEIF) { var elseIf = new ElseIf() { AnchorToken = Expect(TokenCategory.ELSEIF) }; elseIf.Add(Expression()); Expect(TokenCategory.THEN); if (firstOfStatement.Contains(CurrentToken)) { var statementList = new StatementList(); while (firstOfStatement.Contains(CurrentToken)) { statementList.Add(Statement()); } elseIf.Add(statementList); } elseIfList.Add(elseIf); } } result.Add(elseIfList); var els = new Else(); if (CurrentToken == TokenCategory.ELSE) { els.AnchorToken = Expect(TokenCategory.ELSE); if (firstOfStatement.Contains(CurrentToken)) { var statementList = new StatementList(); while (firstOfStatement.Contains(CurrentToken)) { statementList.Add(Statement()); } els.Add(statementList); } } result.Add(els); Expect(TokenCategory.END); Expect(TokenCategory.SEMICOLON); return(result); }