How do I add carriage return to possible whitespace values in nearley?

45 Views Asked by At

I'm using nearley but it's failing when running on some CRLF files. Right now I've solved it by commenting the whitespace builtin import and instead redoing it with \r like this:

# Whitespace: `_` is optional, `__` is mandatory.
_  -> wschar:* {% function(d) {return null;} %}
__ -> wschar:+ {% function(d) {return null;} %}

wschar -> [ \t\n\r\v\f] {% id %}

It would be great to be able to do something like wschar -> [ \t\n\r\v\f] {% id %} and base it from the builtin file but doing so creates an infinite loop.

Thanks, any help is appreciated.

1

There are 1 best solutions below

0
On

Well it was easier than expected. You can always add more definitions to already existing names so adding this line fixes it.

wschar -> [\r] {% id %}