-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First implementation og nql grammar treetop
- Loading branch information
Eduardo Neira
committed
Sep 6, 2019
1 parent
7220d7e
commit d52e110
Showing
2 changed files
with
99 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
ruby-2.3.0 | ||
ruby-2.4.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
module Rasti | ||
module DB | ||
module NQL | ||
|
||
grammar Filter | ||
|
||
rule sentence | ||
optional_space sentence:proposition optional_space <Sentence> | ||
end | ||
|
||
rule proposition | ||
left:conjunction mandatory_space 'OR' mandatory_space right:proposition <Disjunction> / | ||
conjunction | ||
end | ||
|
||
rule conjunction | ||
left:statement mandatory_space 'AND' mandatory_space right:conjunction <Conjunction> / | ||
statement | ||
end | ||
|
||
rule statement | ||
parenthesis_sentence / | ||
comparison | ||
end | ||
|
||
rule parenthesis_sentence | ||
'(' optional_space sentence optional_space ')' <Parens> | ||
end | ||
|
||
rule comparison | ||
left:field optional_space comparator:comparator optional_space right:basic <Comparison> | ||
end | ||
|
||
rule field | ||
tables:(field_name '.')* name:field_name <Field> | ||
end | ||
|
||
rule comparator | ||
'>='/ | ||
'<='/ | ||
'>' / | ||
'<' / | ||
'!='/ | ||
'=' / | ||
':' / | ||
'!:'/ | ||
'~' | ||
end | ||
|
||
rule basic | ||
integer / | ||
float / | ||
boolean / | ||
time / | ||
string | ||
end | ||
|
||
rule optional_space | ||
[\s\t\n]* | ||
end | ||
|
||
rule mandatory_space | ||
[\s\t\n]+ | ||
end | ||
|
||
rule field_name | ||
[a-z]+ | ||
end | ||
|
||
rule string | ||
value: character+ <StringConstant> | ||
end | ||
|
||
rule character | ||
[a-zA-ZÁÀÄÂÃÅĀĂǍáàäâãåāăǎÉÈËÊĒĔĖĚéèëêēĕėěÍÌÏÎĨĬǏíìïîĩĭǐÓÒÖÔÕŌŎŐǑóòöôõōŏőǒÚÙÜÛŨŪŬŮŰǓúùüûũūŭůűǔÑñçÇ%&@#\+\-_=ß'\?!$\*\/] | ||
end | ||
|
||
rule boolean | ||
value:('true'i / 'false'i) <BooleanConstant> | ||
end | ||
|
||
rule float | ||
value:(digit+ ('.' digit+)?) <FloatConstant> | ||
end | ||
|
||
rule integer | ||
value:digit+ <IntegerConstant> | ||
end | ||
|
||
rule digit | ||
[0-9] | ||
end | ||
|
||
end | ||
|
||
end | ||
end | ||
end |