public static GATNode _statement(this LL1Processor ll1) { var node = new GATNode(); var next = WordContainer.GetWordType(); if (ExpressionStmtProc.first.Contains(next)) { var expressionStmt = ll1._expressionStmt(); node.AddChild(expressionStmt); node.generator = Statement1; return(node); } var offset = 0; switch (WordContainer.GetWordType(offset)) { case WordType.BRACE_L: { var compoundStmt = ll1._compoundStmt(); node.AddChild(compoundStmt); node.generator = Statement2; break; } case WordType.IF: { var selectionStmt = ll1._selectionStmt(); node.AddChild(selectionStmt); node.generator = Statement3; break; } case WordType.WHILE: { var iterationStmt = ll1._iterationStmt(); node.AddChild(iterationStmt); node.generator = Statement4; break; } case WordType.RETURN: { var returnStmt = ll1._returnStmt(); node.AddChild(returnStmt); node.generator = Statement5; break; } default: { throw new BNFException(); } } return(node); }
public static GATNode _funDeclaration(this LL1Processor ll1) { var node = new GATNode(); var typeSpecifier = ll1._typeSpecifier(); var id = WordContainer.Advance(WordType.ID); WordContainer.Advance(WordType.BRACKET_L); var param = ll1._params(); WordContainer.Advance(WordType.BRACKET_R); var compoundStmt = ll1._compoundStmt(); // node.name = id.value; // node.generator = FunDeclaration; node.AddChild(typeSpecifier); //0 node.AddChild(id); //1 node.AddChild(param); //2 node.AddChild(GATNode.LabelNode()); //3 node.AddChild(compoundStmt); //4 return(node); }