I want to parse a string like this
10 | 1 2 3
every number after the "|" has to be less than the first number, here 10.
I wrote following grammar to process it:
start = expr
expr = limit:number "|" (n:number " " &{ return n < limit})+
number = n:[0-9]+ { return parseInt(n.join(""), 10); }
In this example, it doesn't work since PEGJS cannot access it. Is there any way to access limit without using global variable ?
Thanks for your help.
Regards,
Chin-Lung Chang