public FilterNode Filter(string value) { FilterNode filterNode = new FilterNode(); filterNode.Text = value; Match(TokenType.FILTER); Token nextToken = CurrentToken(); do { if (nextToken.Type_ != TokenType.OPENSQUAREBRACKET) { var abstractSyntaxTreeNode = BuildSubAST(nextToken.Type_, nextToken.Text); filterNode.FilterItems.Add(abstractSyntaxTreeNode); } else { Match(TokenType.OPENSQUAREBRACKET); } nextToken = CurrentToken(); }while (nextToken.Type_ != TokenType.CLOSESQUAREBRACKET); Match(TokenType.CLOSESQUAREBRACKET); return(filterNode); }
public ObjectNode IdentObject(ObjectNode objectNode) { Match(TokenType.IDENT); var currentToken = CurrentToken(); if (!symbolTable.ContainsKey(objectNode.Name)) { symbolTable.Add(objectNode.Name, objectNode); } currentToken = CurrentToken(); if (currentToken.Type_ == TokenType.IDENT) { objectNode.PropertyName = currentToken.Text; Match(TokenType.IDENT); } else if (currentToken.Type_ == TokenType.FILTER) { FilterNode filterNode = Filter(currentToken.Text); objectNode.Filter = filterNode; } ConsumeNextToken(); currentToken = CurrentToken(); if (currentToken.Type_ == TokenType.POINT) { Match(TokenType.POINT); currentToken = CurrentToken(); } if (currentToken.Type_ == TokenType.FILTER) { FilterNode filterNode = Filter(currentToken.Text); objectNode.Filter = filterNode; currentToken = CurrentToken(); } if (currentToken.Type_ == TokenType.POINT) { Match(TokenType.POINT); currentToken = CurrentToken(); } if (currentToken.Type_ == TokenType.AVERAGE) { objectNode.AggregateFunction = new AggregateAverageNode(); Match(TokenType.AVERAGE); } else if (currentToken.Type_ == TokenType.SUM) { objectNode.AggregateFunction = new AggregateSumNode(); Match(TokenType.SUM); } else if (currentToken.Type_ == TokenType.COUNT) { objectNode.AggregateFunction = new AggregateCountNode(); Match(TokenType.COUNT); } else if (currentToken.Type_ == TokenType.MIN) { objectNode.AggregateFunction = new AggregateMinNode(); Match(TokenType.MIN); } else if (currentToken.Type_ == TokenType.MAX) { objectNode.AggregateFunction = new AggregateMaxNode(); Match(TokenType.MAX); } return(objectNode); }
public CollectionNode Collection(string value) { CollectionNode collectionNode = new CollectionNode(); Match(TokenType.COLLECTION); ConsumeNextToken(); var currentToken = CurrentToken(); if (currentToken.Type_ == TokenType.IDENT) { VariableNode variableNode = CollectionIdent(currentToken.Text); collectionNode.Value = variableNode; Match(TokenType.IDENT); } else if (currentToken.Type_ == TokenType.FILTER) { FilterNode filterNode = Filter(currentToken.Text); collectionNode.Filter = filterNode; } ConsumeNextToken(); currentToken = CurrentToken(); if (currentToken.Type_ == TokenType.POINT) { Match(TokenType.POINT); currentToken = CurrentToken(); } if (currentToken.Type_ == TokenType.FILTER) { FilterNode filterNode = Filter(currentToken.Text); collectionNode.Filter = filterNode; currentToken = CurrentToken(); } if (currentToken.Type_ == TokenType.POINT) { Match(TokenType.POINT); currentToken = CurrentToken(); } if (currentToken.Type_ == TokenType.AVERAGE) { collectionNode.AggregateFunction = new AggregateAverageNode(); Match(TokenType.AVERAGE); } else if (currentToken.Type_ == TokenType.SUM) { collectionNode.AggregateFunction = new AggregateSumNode(); Match(TokenType.SUM); } else if (currentToken.Type_ == TokenType.COUNT) { collectionNode.AggregateFunction = new AggregateCountNode(); Match(TokenType.COUNT); } else if (currentToken.Type_ == TokenType.MIN) { collectionNode.AggregateFunction = new AggregateMinNode(); Match(TokenType.MIN); } else if (currentToken.Type_ == TokenType.MAX) { collectionNode.AggregateFunction = new AggregateMaxNode(); Match(TokenType.MAX); } else { Rewind(); } return(collectionNode); }