nearley
nearley copied to clipboard
Number with commas
I am using the standard Nearley definition of a Number (see below) but I don't know how Nearley supports ranges. i.e. digits{1,3}
Here's what I'm using for number
number ->
digits "." digits {% (data) => Number(data[0] + "." + data[2]) %}
// Trying to figure out digits{1,3} "," digits
| digits {% (data) => Number(data.join("")) %}
digits ->
digit {% id %}
| digit digits {% (data) => data.join("") %}
digit -> [0-9] {% id %}
Thanks