thinkt4nk
5/25/2016 - 1:37 PM

soql.bnf

QUERY ::= 'SELECT' ('COUNT()' | (FIELD ( ',' FIELD)*))
'FROM' (NAME ('AS' ? NAME)? ('USING' NAME)?) ( ',' NAME ('AS' ? NAME)? ('USING' NAME)?)*
('WHERE' CONDITIONEXPR )?
('ORDER BY' ORDERBYEXPR)?
('LIMIT' POSINTEGER )?
FIELD ::= NAME | '(' QUERY ')'
CONDITIONEXPR ::= ANDEXPR | OREXPR | NOTEXPR | SIMPLEEXPR
ANDEXPR ::= 'AND' SIMPLEEXPR
OREXPR ::= 'OR' SIMPLEEXPR
NOTEXPR ::= 'NOT' SIMPLEEXPR
SIMPLEEXPR ::= '(' CONDITIONEXPR ')' | FIELDEXPR | SETEXPR
FIELDEXPR ::= NAME OPERATOR VALUE
SETEXPR ::= ( NAME ('includes' | 'excludes' | 'in' | 'not' 'in') '(' VALUE
 (',' VALUE)* ')' )
ORDERBYEXPR ::= NAME ('asc' | 'desc')? ('nulls' ('first'|'last'))? (',' NAME ('asc' | 'desc')? ('nulls' ('first'|'last'))?)*
OPERATOR ::= '=' | '!=' | '<' | '<=' | '>' | '>=' | 'like'
LOGICALOPERATOR ::= 'AND' | 'OR ' | 'NOT'
VALUE ::= STRING_LITERAL | NUMBER | DATE | DATETIME | NULL | TRUE | FALSE | DATEFORMULA
DATEFORMULA ::= TODAY | TOMORROW | LAST_WEEK | THIS_WEEK | NEXT_WEEK | THIS_MONTH
 | LAST_MONTH | NEXT_MONTH | LAST_90_DAYS | NEXT_90_DAYS | LAST_N_DAYS ':' NUMBER
 | NEXT_N_DAYS ':' NUMBER
NAME ::= LETTER (NAMECHAR)*
LETTER ::= 'a'..'z' | 'A'..'Z'
NAMECHAR ::= LETTER | DIGIT | '_' | '.'
DATE ::= YEAR '-' MONTH '-' DAY
DATETIME ::= DATE 'T' HOUR ':' MINUTE ':' SECOND ('Z' | (('+' |'-') HOUR ':' MINUTE))
YEAR ::= DIGIT DIGIT DIGIT DIGIT
MONTH ::= '0' '1'..'9' | '1' ('0' | '1' | '2')
DAY ::= '0' '1'..'9' | '1'..'2' DIGIT | '3' ('0' | '1')
HOUR ::= '0'..'1' DIGIT | '2' '0'..'3'
MINUTE ::= '0'..'5' DIGIT
SECOND ::= '0'..'5' DIGIT | '60'
NULL ::= 'null'
TRUE ::= 'true'
FALSE ::= 'false'
NUMBER ::= '.' POSINTEGER | INTEGER '.' POSINTEGER
INTEGER ::= ('+' | '-')? POSINTEGER
POSINTEGER ::= DIGIT+
DIGIT ::= '0'..'9'
STRING LITERAL ::= "'" (ESC_CHAR | ~("'"|'\''"
ESC_CHAR ::= '\'n' | 'r' | 't' | 'b' | 'f' | '"' | "'" | '\'
WS ::= S+
S ::= ' ' | '' | '