Remix.run Logo
▲ mbaranturkmen 7 hours ago

How does the parser decide _where_ to split the statement?

▲mrkeen 5 hours ago | parent [-]

Each parser blindly follows its own rules.

If pDigit saw "123 ", according to TFA's design, it would return (1, "23 ").

If PInt saw the "123 ", it would return (123, " ").

You could approximate pInt in terms of pDigit via:

  PInt = many1 pDigit
(Ignoring negatives, int maxvalue, and many1 implies 1-or-more, not 0-or-more.)

I say "according to TFA's design" because I've been arguing elsewhere that parsers must return Either<Error,(T, Remainder)> not (T, Remainder)