6 PARSER_BEGIN(FiqlParser)
7 package org.opendaylight.controller.northbound.commons.query;
9 import java.util.regex.*;
11 /*package*/ class FiqlParser {
12 public static Expression parse(String query) throws ParseException {
13 FiqlParser parser = new FiqlParser(new java.io.StringReader(query));
14 return parser.START();
18 PARSER_END(FiqlParser)
27 <#ALPHA : ( ["a"-"z", "A"-"Z", "0"-"9"] )+ >
31 <NUM : ("+"|"-")?(["0"-"9"])+"."(["0"-"9"])* >
42 <EQ : ("==" | "=eq=") >
44 <NE : ("!=" | "=ne=") >
46 <LT : ("=lt=" | "<") >
48 <LE : ("=le=" | "<=") >
50 <GT : ("=gt=" | ">") >
52 <GE : ("=ge=" | ">=") >
57 <AND : (";" | "and") >
64 <STRING : ( ~["\"", "'", "(", ")", ";", ",", "=", "<", ">", "!", "~", " "] )+ >
66 <DQ_STRING : ( "\"" ( ~["\""] )* "\"" ) >
68 <SQ_STRING : ( "'" ( ~["'"] )* "'" ) >
86 ExpressionBuilder builder = new ExpressionBuilder();
90 t = TERM() { builder.withTerm(t); }
92 (<AND> t = TERM()) { builder.withAnd().withTerm(t); }
94 (<OR> t = TERM() ) { builder.withOr().withTerm(t); }
97 return builder.build();
105 CompareExpression.OP op;
110 ( <EQ> {op=CompareExpression.OP.EQ;} |
111 <RE> {op=CompareExpression.OP.RE;} |
112 <NE> {op=CompareExpression.OP.NE;} |
113 <LT> {op=CompareExpression.OP.LT;} |
114 <LE> {op=CompareExpression.OP.LE;} |
115 <GT> {op=CompareExpression.OP.GT;} |
116 <GE> {op=CompareExpression.OP.GE;}
118 ( arg = <STRING> | arg = <DQ_STRING> | arg = <SQ_STRING> | arg = <NUM>)
119 ) { return new CompareExpression(op, selector.image, arg.image); }
122 <LPAREN> exp = EXPR() <RPAREN>