Exemplo n.º 1
0
        public String parseQuery(String fiqlQuery)
        {
            var lexer = new Lexer(fiqlQuery);
            //lexer.trace += Console.WriteLine;
            var tokens = lexer.lex();

            List <String> illegalIdentifiers = tokens
                                               .Where(token => token.symbol == Symbol.ident)
                                               .Select(token => token.data)
                                               .Where(identifier => !fields.Contains(identifier))
                                               .Distinct()
                                               .ToList();

            if (illegalIdentifiers.Count() > 0)
            {
                throw new ParseException("These identifiers are not valid fields: " +
                                         String.Join(", ", illegalIdentifiers));
            }

            var parser = new Parser(tokens);

            //parser.trace += Console.WriteLine;
            Ast.Disjunction tree         = parser.parse();
            var             sqlGenerator = new SQLGenererator();

            return(sqlGenerator.Visit(tree));
        }
Exemplo n.º 2
0
 public String Visit(Ast.Disjunction condition)
 {
     return("(" +
            String.Join(" OR ", condition.Children
                        .Select(child => child.Accept(this)))
            + ")");
 }
Exemplo n.º 3
0
        private Ast.Disjunction condition()
        {
            trace("FIQLParser.Parser.condition()");
            var conditionNode = new Ast.Disjunction();

            conditionNode.AddChild(booleanTerm());
            while (accept(Symbol.comma))
            {
                conditionNode.AddChild(booleanTerm());
            }
            return(conditionNode);
        }