public static Either <ParseException, Pair <List <IToken>, StatementNode> > Parse(List <IToken> tokens, SymT symT, IScopedTable <IEntityType, string> parentTypeTable) { Console.WriteLine("StatementNode"); var maybeAssignment = AssignmentNode.Parse(tokens, parentTypeTable); if (maybeAssignment.IsRight) { tokens = maybeAssignment.RightToList()[0].First; return(new Pair <List <IToken>, StatementNode>(tokens, new StatementNode( maybeAssignment.RightToList()[0].Second, parentTypeTable))); } var maybeRoutineCall = RoutineCallNode.Parse(tokens, symT, parentTypeTable); if (maybeRoutineCall.IsRight) { tokens = maybeRoutineCall.RightToList()[0].First; return(new Pair <List <IToken>, StatementNode>(tokens, new StatementNode( maybeRoutineCall.RightToList()[0].Second, parentTypeTable))); } var maybeWhileLoop = WhileLoopNode.Parse(tokens, symT, parentTypeTable); if (maybeWhileLoop.IsRight) { tokens = maybeWhileLoop.RightToList()[0].First; return(new Pair <List <IToken>, StatementNode>(tokens, new StatementNode( maybeWhileLoop.RightToList()[0].Second, parentTypeTable))); } var maybeForLoop = ForLoopNode.Parse(tokens, symT, parentTypeTable); if (maybeForLoop.IsRight) { tokens = maybeForLoop.RightToList()[0].First; return(new Pair <List <IToken>, StatementNode>(tokens, new StatementNode( maybeForLoop.RightToList()[0].Second, parentTypeTable))); } var maybeIfStatement = IfStatementNode.Parse(tokens, symT, parentTypeTable); if (maybeIfStatement.IsRight) { tokens = maybeIfStatement.RightToList()[0].First; return(new Pair <List <IToken>, StatementNode>(tokens, new StatementNode( maybeIfStatement.RightToList()[0].Second, parentTypeTable))); } return(NotAStatementException); }
private StatementNode(RoutineCallNode routineCall, IScopedTable <IEntityType, string> parentTypeTable) { RoutineCall = routineCall; ParentTypeTable = parentTypeTable; }