public static GATNode _selectionStmt(this LL1Processor ll1) { var node = new GATNode(); node.generator = SelectionStmt; WordContainer.Advance(WordType.IF); WordContainer.Advance(WordType.BRACKET_L); var expression = ll1._expression(); WordContainer.Advance(WordType.BRACKET_R); var statement = ll1._statement(); node.AddChild(expression); //0 node.AddChild(GATNode.CodeNode()); //1 node.AddChild(statement); //2 var next = WordContainer.GetWordType(); if (next == WordType.ELSE) { WordContainer.Advance(WordType.ELSE); var elseStatement = ll1._statement(); node.AddChild(GATNode.CodeNode()); //3 node.AddChild(GATNode.LabelNode()); //4 node.AddChild(elseStatement); //5 } node.AddChild(GATNode.LabelNode()); //3-6 return(node); }
public static GATNode _program(this LL1Processor ll1) { var node = new GATNode(); node.generator = program; var declarationList = ll1._declarationList(); node.AddChild(GATNode.CodeNode()); //0 node.AddChild(declarationList); //1 WordContainer.Advance(WordType.HASHTAG); return(node); }
public static GATNode _iterationStmt(this LL1Processor ll1) { var node = new GATNode(); node.generator = IterationStmt; WordContainer.Advance(WordType.WHILE); WordContainer.Advance(WordType.BRACKET_L); node.AddChild(GATNode.LabelNode());//0 var expression = ll1._expression(); node.AddChild(expression); //1 node.AddChild(GATNode.CodeNode()); //2 WordContainer.Advance(WordType.BRACKET_R); var statement = ll1._statement(); node.AddChild(statement); //3 node.AddChild(GATNode.CodeNode()); //4 node.AddChild(GATNode.LabelNode()); //5 return(node); }