Joined May 2014
·

Nimrod

Israel
·
·

Posted to Beginning parsers with PEG.js over 1 year ago

well explained.
i have a question though (i think it is tricky, i am missing something!):

in the grammar part, i wrote this:
rootexpression = simplecondition

simplecondition = analogcondition / timecondition

analogcondition = ws (!analogoperator inputname)+ ws analogoperator ws analogvalue ws

timecondition = ws "time" ws timeoperator ws timevalue ws
analogoperator = "=="

timeoperator = "=="

analogvalue = integer

timevalue = digit digit ":" digit digit ":" digit digit

ws "whitespace" = [ \t\n\r]*

integer = digit+

digit = [0-9]

input_name = alphanum

alphanum = [a-zA-Z0-9]

and in the test part - i just write this: time == 10:10:00
for some reason, the parser wont recognize it, and it should.
if i write this: time == 10
it will accept it - as it matches "analogcondition"
how can i make it recognize the time
condition as well?!
(i know it should recognize the timecondition because when i remove the "analogcondition" from the simple condition rule - it matches).

Thanks,
Jim.

Achievements
1 Karma
0 Total ProTip Views