Open ornariece opened 3 years ago
Well, match_examples
succeeds (e.g. not fails), but does not produce the correct result.
A workaround that is not quite good, but at least doesn't crash is to use use_accepts=False
, but I am looking into a fix.
Ok, this is major: When you have that kind of Transformer, the exception can't even be displayed correctly, it only shows <exception str() failed>
.
Does this branch work: https://github.com/MegaIng/lark/tree/fix-accepts
If it works, this was surprisingly little effort.
works for me!
match_examples
, at some pointhttps://github.com/lark-parser/lark/blob/2335aa63e183c9182d6f8554b0d2d3714fd2286b/lark/exceptions.py#L110
creates a Token, whose value is set to an empty string:
https://github.com/lark-parser/lark/blob/2335aa63e183c9182d6f8554b0d2d3714fd2286b/lark/parsers/lalr_interactive_parser.py#L88
the problem is, this empty string might not be a valid input for whatever transformer method the user defined. in my case, i have a method that uses
Decimal
fromdecimal
, and trying to pass an empty string to it results in adecimal.InvalidOperation
being raised. that exception isn't caught by the except statementhttps://github.com/lark-parser/lark/blob/2335aa63e183c9182d6f8554b0d2d3714fd2286b/lark/parsers/lalr_interactive_parser.py#L89
and
match_examples
fails because of that. with a broaderexcept
statement (sayexcept Exception:
),mach_examples
succeeds