You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
alter does not consume leading whitespace according to the new whitespace parser.
Reproduction Steps
This issue was originally found in gigaparsec, and I do not have scala installed, so this will be in haskell.
Assume the lexical description has whitespaceIsContextDependent = True, and the default whitespace parser does not consider newlines (\n) to be whitespace.
Then consider this expression parser:
spaceOrNewLine =Just (\c -> c ==''|| c =='\n')
Expr=ExprNumInt|...
expr = number
<|>...<|> ("("*> alter spaceOrNewLine expr <*")")
Plain numbers can be preceded by only spaces, whereas a parenthesised expression allows for newlines.
Expected behavior
I would expect the following file to parse:
(
2 )
and produce ExprInt 2.
However, we instead get the error:
This is confusing, as we have changed the definition of whitespace, but so far whitespace trailing "(" has only been consumed using the old definition.
I would expect any trailing whitespace according to the new definition be consumed also.
Description
alter
does not consume leading whitespace according to the new whitespace parser.Reproduction Steps
This issue was originally found in
gigaparsec
, and I do not have scala installed, so this will be in haskell.Assume the lexical description has
whitespaceIsContextDependent = True
, and the default whitespace parser does not consider newlines (\n
) to be whitespace.Then consider this expression parser:
Plain numbers can be preceded by only spaces, whereas a parenthesised expression allows for newlines.
Expected behavior
I would expect the following file to parse:
and produce
ExprInt 2
.However, we instead get the error:
This is confusing, as we have changed the definition of whitespace, but so far whitespace trailing
"("
has only been consumed using the old definition.I would expect any trailing whitespace according to the new definition be consumed also.
Additional context
Parsley Version: Gigaparsec 0.3.0.0
Scala Version: GHC 8.10-9.8
Suggested Fix
The defn of the
alter
combinator,should probably be changed to
wsImpl.rollback(wsImpl.setDuring(whiteSpace(newSpace))(whiteSpace *> within))
or whatever the scala syntax for
*>
is.The text was updated successfully, but these errors were encountered: