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
Currently, error messages always display the farthest that parsing got and the next token as the actual value that stopped parsing. This worked fine until the transformation parser, which can succeed in parsing input and then fail to accept that parsed value. The message the parsing failed on the token after the successful parse is not particularly correct. The error is the parsed token itself, which can be seen in this example:
fromdataclassesimportdataclassfromparsitaimport*@dataclassclassPercent:
number: intdefto_percent(number: int):
ifnot0<=number<=100:
returnfailure("a number between 0 and 100")
else:
returnsuccess(Percent(number))
classTestParsers(TextParsers):
percent= (reg(r"[0-9]+") >int) >=to_percentTestParsers.percent.parse("150").or_die()
This displays the error Expected a number between 0 and 100 but found end of source, when Expected a number between 0 and 100 but found 150 would be more sensible.
To fix this would require that the actual value and farthest point be configurable separately by the parser.
The text was updated successfully, but these errors were encountered:
Currently, error messages always display the farthest that parsing got and the next token as the actual value that stopped parsing. This worked fine until the transformation parser, which can succeed in parsing input and then fail to accept that parsed value. The message the parsing failed on the token after the successful parse is not particularly correct. The error is the parsed token itself, which can be seen in this example:
This displays the error
Expected a number between 0 and 100 but found end of source
, whenExpected a number between 0 and 100 but found 150
would be more sensible.To fix this would require that the actual value and farthest point be configurable separately by the parser.
The text was updated successfully, but these errors were encountered: