private SimpleNode(FactorNode factor, List <IToken> tokens, List <FactorNode> factors, IScopedTable <IEntityType, string> parentTypeTable) { Factor = factor; Tokens = tokens; Factors = factors; ParentTypeTable = parentTypeTable; }
public static Either <ParseException, Pair <List <IToken>, SimpleNode> > Parse(List <IToken> tokens, IScopedTable <IEntityType, string> parentTypeTable) { Console.WriteLine("SimpleNode"); var maybeFactor = FactorNode.Parse(tokens, parentTypeTable); if (maybeFactor.IsLeft) { return(maybeFactor.LeftToList()[0]); } var factor = maybeFactor.RightToList()[0].Second; var tokenlist = new List <IToken>(); var factors = new List <FactorNode>(); tokens = maybeFactor.RightToList()[0].First; while (tokens.Count > 0) { if (tokens[0] is NewLineSymbolToken || tokens[0] is CommentToken) { tokens = tokens.Skip(1).ToList(); } else { break; } } while (true) { if (tokens.Count < 1) { break; } if (!(tokens[0] is MultiplyOperatorToken || tokens[0] is DivideOperatorToken || tokens[0] is ModOperatorToken)) { break; } tokens = tokens.Skip(1).ToList(); var maybeFactor2 = FactorNode.Parse(tokens, parentTypeTable); if (maybeFactor2.IsLeft) { return(maybeFactor2.LeftToList()[0]); } tokens = maybeFactor2.RightToList()[0].First; while (tokens.Count > 0) { if (tokens[0] is NewLineSymbolToken || tokens[0] is CommentToken) { tokens = tokens.Skip(1).ToList(); } else { break; } } } while (tokens.Count > 0) { if (tokens[0] is NewLineSymbolToken || tokens[0] is CommentToken) { tokens = tokens.Skip(1).ToList(); } else { break; } } return(new Pair <List <IToken>, SimpleNode>(tokens, new SimpleNode(factor, tokenlist, factors, parentTypeTable))); }