public class RSQLParser extends Object implements RSQLParserConstants
RSQL is a language designed for searching entries in RESTful services. It's based on URI-friendly syntax FIQL (Feed Item Query Language), so it can be used for parsing FIQL as well.
Grammar
expression = [ "(" ],
( constraint | expression ),
[ logical-operator, ( constraint | expression ) ],
[ ")" ];
constraint = selector, comparison-operator, argument;
logical-operator = ";" | " and " | "," | " or ";
comparison-operator = "==" | "=" | "!=" | "=lt=" | "<" | "=le=" | "<=" |
"=gt=" | ">" | "=ge=" | ">=";
selector = qname, { ("/" | "."), qname };
qname = identifier, [ ":", identifier ];
identifier = ? ["a"-"z","A"-"Z","_","0"-"9","-"]+ ?
argument = arg_ws | arg_sq | arg_dq;
argument-ws = ? ( ~["(", ")", ";", ",", " "] )+ ?;
argument-sq = ? "'" ~["'"]+ "'" ?;
argument-dq = ? "\"" ~["\""]+ "\"" ?;
Semantics
Logical operators:
Comparison operators:
Generated by JavaCC 5.0
| Modifier and Type | Field and Description |
|---|---|
static String |
ENCODING |
Token |
jj_nt
Next token.
|
Token |
token
Current token.
|
RSQLParserTokenManager |
token_source
Generated Token Manager.
|
| Constructor and Description |
|---|
RSQLParser(InputStream stream)
Constructor with InputStream.
|
RSQLParser(InputStream stream,
String encoding)
Constructor with InputStream and supplied encoding
|
RSQLParser(Reader stream)
Constructor.
|
RSQLParser(RSQLParserTokenManager tm)
Constructor with generated Token Manager.
|
| Modifier and Type | Method and Description |
|---|---|
String |
argument()
<ARGUMENT> : (~["(",")",";",","," "])+ | ("'"(~["'"])+"'") | ("\""(~["\""] )+"\"")
|
Comparison |
comparison()
<COMPARISON> : ("=="|"=lt="|"=le="|"=gt="|"=ge="|"="|"!="|"<"|"<="|">"|">=")
|
Expression |
conjunction()
conjunction -> constraint ( <AND> conjunction )? |
Expression |
constraint()
constraint -> <SELECTOR> <COMPARISON> <ARGUMENT>
| <LPAREN> disjunction <RPAREN> |
void |
disable_tracing()
Disable tracing.
|
Expression |
disjunction()
disjunction -> conjunction ( <OR> disjunction )? |
void |
enable_tracing()
Enable tracing.
|
ParseException |
generateParseException()
Generate ParseException.
|
Token |
getNextToken()
Get the next Token.
|
Token |
getToken(int index)
Get the specific Token.
|
Expression |
input()
input -> disjunction |
static Expression |
parse(String expression)
Parse given query expression and build query tree.
|
void |
ReInit(InputStream stream)
Reinitialise.
|
void |
ReInit(InputStream stream,
String encoding)
Reinitialise.
|
void |
ReInit(Reader stream)
Reinitialise.
|
void |
ReInit(RSQLParserTokenManager tm)
Reinitialise.
|
String |
selector()
<SELECTOR> : <#QNAME> ( ["/","."] <#QNAME> )*
<#QNAME> : <#IDENTIFIER> (":" <#IDENTIFIER> )?
<#IDENTIFIER> : ( ["a"-"z","A"-"Z","_","0"-"9","-"] )+
|
public static final String ENCODING
public RSQLParserTokenManager token_source
public Token token
public Token jj_nt
public RSQLParser(InputStream stream)
public RSQLParser(InputStream stream, String encoding)
public RSQLParser(Reader stream)
public RSQLParser(RSQLParserTokenManager tm)
public static Expression parse(String expression) throws ParseException, TokenMgrError
expression - ParseExceptionTokenMgrErrorpublic final Expression input() throws ParseException
input -> disjunction ParseExceptionpublic final Expression disjunction() throws ParseException
disjunction -> conjunction ( <OR> disjunction )? ParseExceptionpublic final Expression conjunction() throws ParseException
conjunction -> constraint ( <AND> conjunction )? ParseExceptionpublic final Expression constraint() throws ParseException
constraint -> <SELECTOR> <COMPARISON> <ARGUMENT>
| <LPAREN> disjunction <RPAREN> ParseExceptionpublic final Comparison comparison() throws ParseException
<COMPARISON> : ("=="|"=lt="|"=le="|"=gt="|"=ge="|"="|"!="|"<"|"<="|">"|">=")
ParseExceptionpublic final String selector() throws ParseException
<SELECTOR> : <#QNAME> ( ["/","."] <#QNAME> )*
<#QNAME> : <#IDENTIFIER> (":" <#IDENTIFIER> )?
<#IDENTIFIER> : ( ["a"-"z","A"-"Z","_","0"-"9","-"] )+
ParseExceptionpublic final String argument() throws ParseException
<ARGUMENT> : (~["(",")",";",","," "])+ | ("'"(~["'"])+"'") | ("\""(~["\""] )+"\"")
ParseExceptionpublic void ReInit(InputStream stream)
public void ReInit(InputStream stream, String encoding)
public void ReInit(Reader stream)
public void ReInit(RSQLParserTokenManager tm)
public final Token getNextToken()
public final Token getToken(int index)
public ParseException generateParseException()
public final void enable_tracing()
public final void disable_tracing()
Copyright © 2011–2014. All rights reserved.