|Serializer overzealously inserts parentheses [message #1840774]
||Fri, 23 April 2021 14:04
| Dimo Petroff
Registered: November 2018
I have a left-factored expressions grammar with optional empty parameter lists and parenthesised expressions, but the serializer tends to parenthesise by default even when the parser does not need it.|
The parser is perfectly happy with things like 1 * 1 + 1, however serialising a manually constructed AST representing the same parse result gives me (1 * 1) + 1. This is not incorrect, because the operator precedence is such, but the parentheses are not necessary, so it's not clear to me why the Serializer produces them.
I also have cases where the unnecessary and completely optional (in the grammar) empty parenthesis for an empty argument list of a feature call are serialised, although this is a corner case I'm struggling to reproduce in a minimal example even using my full grammar.
Unfortunately, I've not managed to produce a smaller grammar that expresses the problem yet, but I'm hoping someone has dealt with similar problems and can give some hits about where to look while I'm slowly whittling my actual grammar down to a minimal reproducible example that I can post.
[Updated on: Fri, 23 April 2021 14:07]
Report message to a moderator
Powered by FUDForum
. Page generated in 0.02206 seconds