sophiajt / new-nu-parser

23 stars 10 forks source link

More explicit `.next()` and `.peek()` behavior #9

Open sholderbach opened 11 months ago

sholderbach commented 11 months ago

One thing I mentally trip over a bit is what .next() will and will not do for you.

As things stand Parser.next() will skip horizontal whitespace for you and then return the next token if there is one left.

.peek() uses the .next() implementation to let you check for tokens. But this carries over the assumptions from .next().

For example in .simple_expression() this means that the range and path access would still try to be parsed even if there is whitespace between the first expression part and the .. or ..