Closed jnbbender closed 3 years ago
Different rules which define limits on a number. For example, num0 is in the range 0-31, num1 is in range 32-1500, etc.
I have the following:
start -> num0 num0 -> number {% function(d,l,reject) { if (d <=31) return d; else reject; } %} num1 -> number {% function(d,l,reject) { if (d <=1500) return d; else reject; } %} number -> digits "." digits {% (data) => Number(data[0] + "." + data[2]) %} | digits {% (data) => Number(data.join("")) %} digits -> digit {% id %} | digit digits {% (data) => data.join("") %} digit -> [0-9] {% id %}
So when I test with the following nearley-test -i "28" grammar.js I get 2 results, which figures since this is pretty ambiguous. Is there a way to define number ranges?
nearley-test -i "28" grammar.js
Thanks
Different rules which define limits on a number. For example, num0 is in the range 0-31, num1 is in range 32-1500, etc.
I have the following:
So when I test with the following
nearley-test -i "28" grammar.js
I get 2 results, which figures since this is pretty ambiguous. Is there a way to define number ranges?Thanks