1 | parser grammar FCSParser; |
---|
2 | options { tokenVocab=FCSLexer; } |
---|
3 | /* |
---|
4 | * Parser for FCS Core FCS-QL version 2.0 |
---|
5 | * 20150501- /ljo |
---|
6 | */ |
---|
7 | query |
---|
8 | : main_query within_part? |
---|
9 | ; |
---|
10 | |
---|
11 | /* for debugging */ |
---|
12 | parse |
---|
13 | : (t=. |
---|
14 | {System.out.printf("text: %-7s type: %s \n", |
---|
15 | $t.text, tokenNames[$t.type]);} |
---|
16 | )* |
---|
17 | ; |
---|
18 | |
---|
19 | //main_query |
---|
20 | // : simple_query |
---|
21 | // | main_query OR main_query /* or */ |
---|
22 | // | main_query main_query /* sequence */ |
---|
23 | // | main_query QUANTIFIER /* quatification */ |
---|
24 | // ; |
---|
25 | |
---|
26 | main_query |
---|
27 | : simple_query |
---|
28 | | simple_query OR main_query /* or */ |
---|
29 | | simple_query main_query /* sequence */ |
---|
30 | | simple_query QUANTIFIER /* quatification */ |
---|
31 | ; |
---|
32 | |
---|
33 | /* |
---|
34 | simple_query |
---|
35 | : implicit_query |
---|
36 | | segment_query |
---|
37 | ; |
---|
38 | */ |
---|
39 | |
---|
40 | simple_query |
---|
41 | : LPAREN main_query RPAREN /* grouping */ |
---|
42 | | implicit_query |
---|
43 | | segment_query |
---|
44 | ; |
---|
45 | |
---|
46 | implicit_query |
---|
47 | : flagged_regexp |
---|
48 | ; |
---|
49 | |
---|
50 | segment_query |
---|
51 | : L_SQUARE_BRACKET expression? R_SQUARE_BRACKET /* [ expression? ] */ |
---|
52 | ; |
---|
53 | |
---|
54 | within_part |
---|
55 | : simple_within_part |
---|
56 | ; |
---|
57 | |
---|
58 | simple_within_part |
---|
59 | : WITHIN SIMPLE_WITHIN_SCOPE |
---|
60 | ; |
---|
61 | |
---|
62 | //expression |
---|
63 | // : basic_expression # basicExpression |
---|
64 | // | expression OR expression # orExpression /* or */ |
---|
65 | // | expression AND expression # andExpression /* and */ |
---|
66 | // | LPAREN expression RPAREN # groupedExpression /* grouping */ |
---|
67 | // | NOT expression # notExpression /* not */ |
---|
68 | // ; |
---|
69 | |
---|
70 | expression |
---|
71 | : basic_expression # basicExpression |
---|
72 | | expression OR expression # orExpression /* or */ |
---|
73 | | expression AND expression # andExpression /* and */ |
---|
74 | ; |
---|
75 | |
---|
76 | /* |
---|
77 | basic_expression |
---|
78 | : attribute OPERATOR flagged_regexp |
---|
79 | ; |
---|
80 | */ |
---|
81 | |
---|
82 | basic_expression |
---|
83 | : LPAREN expression RPAREN # groupedExpression /* grouping */ |
---|
84 | | NOT expression # notExpression /* not */ |
---|
85 | | attribute OPERATOR flagged_regexp #basicAttrOpFlaggedRegex |
---|
86 | ; |
---|
87 | |
---|
88 | |
---|
89 | attribute |
---|
90 | : SIMPLE_ATTRIBUTE # simpleAttribute |
---|
91 | | QUALIFIED_ATTRIBUTE # qualifiedAttribute |
---|
92 | ; |
---|
93 | |
---|
94 | flagged_regexp |
---|
95 | : REGEXP # regexp |
---|
96 | | REGEXP FWD_SLASH REGEXP_FLAG+ # flaggedRegexp |
---|
97 | ; |
---|