Skip to content

Commit

Permalink
First implementation og nql grammar treetop
Browse files Browse the repository at this point in the history
  • Loading branch information
Eduardo Neira committed Sep 6, 2019
1 parent 7220d7e commit d52e110
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ruby-2.3.0
ruby-2.4.5
98 changes: 98 additions & 0 deletions lib/rasti/db/nql/grammar.treetop
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

0 comments on commit d52e110

Please sign in to comment.