source: VirtualCollectionRegistry/trunk/VirtualCollectionRegistry/src/main/antlr3/eu/clarin/cmdi/virtualcollectionregistry/query/VCRQL.g @ 213

Last change on this file since 213 was 213, checked in by oschonef, 14 years ago
  • implement basic search feature
  • Property svn:eol-style set to native
File size: 1.5 KB
Line 
1grammar VCRQL;
2
3options {
4  output = AST;
5  ASTLabelType = CommonTree;
6}
7
8tokens {
9    EQ = '=';
10    NE = '!=';
11    OR = 'or';
12    AND = 'and';
13    OPEN = '(';
14    CLOSE = ')';
15    QUERY;
16    EXPRESSION;
17    ENTITY;
18}
19
20@header {
21package eu.clarin.cmdi.virtualcollectionregistry.query;
22}
23
24@lexer::header {
25package eu.clarin.cmdi.virtualcollectionregistry.query;
26}
27
28query
29    : expression -> ^(QUERY<QueryNode> expression)
30    ;
31
32expression
33    : logicalOrExpression
34    ;
35
36logicalOrExpression
37    : logicalAndExpression (OR<BooleanNode>^ logicalAndExpression)*
38    ;
39
40logicalAndExpression
41    : primaryExpression (AND<BooleanNode>^ primaryExpression)*
42    ;
43   
44primaryExpression
45    : atom
46    | OPEN expression CLOSE -> expression
47    ;
48
49atom
50    : component EQ<RelationNode>^ STRING<ValueNode>
51    | component NE<RelationNode>^ STRING<ValueNode>
52    ;
53
54component
55    : ENTITY_NAME '.' PROPERTY_NAME
56        -> ENTITY<EntityNode>[$ENTITY_NAME,$PROPERTY_NAME]
57    ;
58
59ENTITY_NAME
60    : 'vc' | 'creator'
61    ;
62
63PROPERTY_NAME
64    : ('a'..'z' | 'A' .. 'Z' | '0'..'9')+
65    ;
66
67STRING
68    : '"' ( ESCAPE_SEQUENCE | ~( '\u0000'..'\u001f' | '\\' | '\"' ) )* '"'
69    ;
70
71fragment
72ESCAPE_SEQUENCE
73    :   '\\' (UNICODE_ESCAPE | 'b' | 't' | 'n' | 'f' | 'r' | '\"' | '\'' | '\\')
74    ;
75
76fragment
77UNICODE_ESCAPE
78    : 'u' HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT
79    ;
80
81fragment
82HEX_DIGIT
83    : '0'..'9' | 'A'..'F' | 'a'..'f'
84    ;
85
86fragment
87DIGIT
88    : '0'..'9'
89    ;
90
91WS
92    : ( ' ' | '\t' | '\r' | '\n' )+ { $channel=HIDDEN; }
93    ;
Note: See TracBrowser for help on using the repository browser.