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 _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); }
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); }