windows-nt/Source/XPSP1/NT/inetsrv/query/qutil/querylib/bnf.txt
2020-09-26 16:20:57 +08:00

157 lines
4.4 KiB
Plaintext

This BNF strictly shows the syntax of the query language. While some
semantic checking is done at the parser level, most of the real semantic
checking goes on in the query engine.
Query : QExpr
| QExpr COMMA_TOKEN Query
QExpr : QTerm
| QTerm OR_TOKEN QExpr
QTerm : (NOT_TOKEN) QProp (W_OPEN_TOKEN Weight W_CLOSE_TOKEN)
| (NOT_TOKEN) QProp (W_OPEN_TOKEN Weight W_CLOSE_TOKEN) AND_TOKEN QTerm
QProp : QFactor
| PROP_TOKEN property QFactor
| PROP_REGEX_TOKEN property (EQUAL_TOKEN) REGEX
| PROP_NATLANG_TOKEN property QPhrase
QFactor : QGroup
| OPEN_TOKEN Query CLOSE_TOKEN
| OP_TOKEN phrase
QGroup : QPhrase
| QPhrase PROX_TOKEN QProp
QPhrase : phrase(FUZZY_TOKEN | FUZ2_TOKEN)
| REGEX
| QUOTES_TOKEN extended_phrase(FUZZY_TOKEN | FUZ2_TOKEN)
property : phrase
| C_OPEN_TOKEN ((phrase COMMA_TOKEN)*phrase) C_CLOSE_TOKEN
Weight : DIGITS
# Note: the branch taken for parsing a "phrase" depends on the data-type
# of the current property.
phrase : STRING_PHRASE
| INTEGER_PHRASE
| FLOAT_PHRASE
| BOOL_PHRASE
| DATE_PHRASE
| CURRENCY_PHRASE
| GUID_PHRASE
STRING_PHRASE : ANY
INTEGER_PHRASE : (-)DIGITS
FLOAT_PHRASE : (-)DIGITS(.DIGITS)
BOOL_PHRASE : T
| TRUE
| FALSE
| ANY # -- assumed to be FALSE
# yyyy/mm/dd hh:mm:ss
DATE_PHRASE : -[DIGITS PERIOD]+
| DIGITS/DIGITS/DIGITS
| DIGITS/DIGITS/DIGITS DIGITS:DIGITS:DIGITS
| DIGITS/DIGITS/DIGITS DIGITS:DIGITS:DIGITS:MILLISECONDS
PERIOD : h | n | s | y | m | d | w
CURRENCY_PHRASE : DIGITS.DIGITS # dollars.cents
GUID_PHRASE : %08lX-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X
DIGITS : [0-9]+
ANY : any sequence excluding {}!&|~*@#()[],=<>\n\"^$
ANYEXCEPTQUOTE : any sequence excluding "
# note: the real parsing of REGEX expressions is done in the query engine.
# The parsing that the query parser does is just enough to hand off the
# string to the query engine. The BNF for this is in the Query Language
# Help page.
REGEX : QUOTES_TOKEN ANYEXCEPTQUOTE QUOTES_TOKEN
| any sequence before SPACE_TOKEN
| any sequence before a ) not preceeded by a !
# the XOF_TOKEN after OPERATOR here is only meaningful for vector properties
OP_TOKEN : OPERATOR (XOF_TOKEN)
OPERATOR : EQUAL_TOKEN
| NOT_EQUAL_TOKEN
| GREATER_TOKEN
| GREATER_EQUAL_TOKEN
| LESS_TOKEN
| LESS_EQUAL_TOKEN
| XOF_TOKEN
XOF_TOKEN : ALLOF_TOKEN
| SOMEOF_TOKEN
C_OPEN_TOKEN : {
C_CLOSE_TOKEN : }
OPEN_TOKEN : (
CLOSE_TOKEN : )
AND_TOKEN : &
| and
OR_TOKEN : |
| or
NOT_TOKEN : !
| not
NOT_EQUAL_TOKEN : !=
SPACE_TOKEN : ' '
GREATER_TOKEN : >
GREATER_EQUAL_TOKEN : >=
LESS_TOKEN : <
LESS_EQUAL_TOKEN : <=
PROX_TOKEN : ~
| near
QUOTES_TOKEN : "
PROP_TOKEN : @
PROP_REGEX_TOKEN : #
PROP_NATLANG_TOKEN : $
EQUAL_TOKEN : =
FUZZY_TOKEN : *
FUZ2_TOKEY : **
W_OPEN_TOKEN : [
W_CLOSE_TOKEN : ]
COMMA_TOKEN : ,
ALLOF_TOKEN : ^a
SOMEOF_TOKEN : ^s