-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathlogical_query_parser.treetop
More file actions
81 lines (62 loc) · 1.14 KB
/
logical_query_parser.treetop
File metadata and controls
81 lines (62 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
grammar LogicalQueryParser
rule exp
sp* exp:(logic_exp / paren_exp / literal_exp / literal) sp* <ExpNode>
end
rule logic_exp
lexp:(paren_exp / literal_exp / literal) logic:(and / or) rexp:exp <LogicExpNode>
end
rule paren_exp
negative:not* lparen exp rparen rexp:exp* <ParenExpNode>
end
rule literal_exp
literal sp+ exp <LiteralExpNode>
end
rule literal
negative:not* word <LiteralNode>
end
rule word
(quoted_word / unquoted_word) <WordNode>
end
rule quoted_word
'"' ('\"' / !'"' .)* '"'
end
rule unquoted_word
!ope atom+ / ope atom+
end
rule lparen
'(' <LParenNode>
end
rule rparen
')' <RParenNode>
end
rule and
sp+ and_ope sp+ <AndNode>
end
rule or
sp+ or_ope sp+ <OrNode>
end
rule not
(not_ope sp+ / not_sym sp*) <NotNode>
end
rule ope
and_ope / or_ope / not_ope
end
rule and_ope
'AND' / 'and' / '&&' / '&'
end
rule or_ope
'OR' / 'or' / '||' / '|'
end
rule not_ope
'NOT' / 'not'
end
rule not_sym
'-' / '-' / '-'
end
rule sp
' ' / ' '
end
rule atom
!(lparen / rparen / sp) .
end
end