I took the grammar we use in YAZ, removed the Semantic rules and
shortened it a bit. This is not the grammar one would put up on the ZNG
site, but it might be useful to Alan and others implementing this.
Note that a YACC grammar does not include the lexical description of
tokens. That's outside of the scope. Trying to make a BNF for the
lexical rules is actually quite complicated. Hence I would recommend
that official CQL grammar does not do it. It's better to say: a term
consists of the following characters.. It may also include all other
characters when escaped with a backslash and so on.
What I would like (and Alan it seems) is that modifiers whether boolean
or relation modifiers have the form
/id=value or even /id relation value
This is more generic than
/value
Granted, /value is shorter but it requires (for prox) a specific
ordering. What's worse allowing _both_ forms results in an ambiguous
grammar.
In the following all terminals are upper case and so are quoted
characters, non-terminals are lower case. This is BNF, not EBNF.
-- Adam
%token TERM AND OR NOT PROX GE LE NE
%%
cqlQuery:
searchClause
| cqlQuery boolean searchClause
;
searchClause:
'(' cqlQuery ')'
| term
| index relation searchClause
| '>' term '=' term cqlQuery
| '>' term cqlQuery
;
boolean: operator modifiers;
operator: AND | OR | NOT | PROX;
relation: baseRelation modifiers ;
modifiers:
modifiers opts term
|
;
opts: opts '/' | '/';
baseRelation: '=' | '>' | '<' | GE | LE | NE | TERM ;
index: term;
term: TERM | AND | OR | NOT | PROX ;
%%
|