kkoch986 / js-parse

A generic node.js based LR(1) shift-reduce parser.
12 stars 1 forks source link

solve issue of overlapping terminals #9

Open kkoch986 opened 10 years ago

kkoch986 commented 10 years ago

big problem in the lexer currently, consider a digit which would match [0-9] and a non-zero-digit which would match [1-9].

Solution i initially went with was to create terminals which created unique ranges i.e. zero and one_through_nine and wrote digit and non-zero-digit as productions like

digit -> zero | one_through_nine
non-zero-digit -> one_through_nine

This is a working solution, but far from ideal in my opinion. What im currently considering is modifying the production definition to allow constraints, but this is leading to reduce-reduce conflicts because the name of the token still matches as digit (in a slightly more complex case).

Going to keep working on the second solution, but also looking for a third.