kach / nearley

📜🔜🌲 Simple, fast, powerful parser toolkit for JavaScript.
https://nearley.js.org
MIT License
3.57k stars 231 forks source link

Matching using number ranges #552

Open jnbbender opened 3 years ago

jnbbender commented 3 years ago

I am having difficulty translating some lex into nearley, specifically the range operator. Let's assume I need either 1 through 3 digits. In lex I'd have: [0-9]{1,3}

The closest I can think of in nearley is digit (digit digit:?):?

But that's not really practical for things such as [0-9]{1,9}

Any ideas?

averynortonsmith commented 3 years ago

You probably want to use a tokenizer for full regex support