Community
Participate
Working Groups
I'm using version 0.1.106.v201004212015 of the LPG IDE, and wanted to use the automatic source code formatter by pressing Cmd+Shift+F (Control+Shift+F I guess on Windows). But it messed up the grammar badly, as it functionally changed the grammar rules: it removed necessary spaces from the language, and the left hand sides of the rules are added to the right hand side of the rule. E.g. TextualModel ::= NamespaceDeclarationOpt ImportDeclarationsOpt ModelElementDefinitions become TextualModel::=TextualModel NamespaceDeclarationOpt ImportDeclarationsOpt ModelElementDefinitions The problems are twofold: 1) By removing some necessary whitespaces (e.g. before ::= or | characters) special symbols are considered as parts of the terminal/non-terminal symbols's name instead of grammar features. 2) By adding the left hand terminal to the right hand the grammar becomes unusable, as no sane replacements can be made by the parser. I suggest either removing the autoformat option completely from the LPG grammar, or fixing these errors, as these are a real pain to fix. Thanks.
And it also removes anything between $-s in the grammar - thus unhiding non-terminals and removing list definitions.
Hi there, thanks for the bug report! The error of repeating the non-terminal on the rule RHS should be trivial to fix. Can you tell me where necessary spaces got deleted? [Honestly, it's been ages since I used auto-format on LPG, or for that matter, on pretty much anything, including Java. I never seem to like what it produces enough to keep...]
I could identify two scenarios where this causes errors originally: one was at the '::=' symbol (but that could be related to the left hand side duplication). The other was at '|' symbols on the right hand side of rules, where if it was written after the previous symbol, the parser considered the '|' as a part of the symbol name - but I couldn't reproduce this using the already cleaned up grammar (I manually fixed the previously messed up grammar).
I fixed the repeating the LHS non-terminal on the rule RHS. The fix is in head of SVN trunk. I'll look at the problem with $'s next.
I've fixed the problem with loss of macros, and a few other unfortunate bits of breakage. There still seems to be a problem with the %Recover segment - the AST produced doesn't seem to record the symbols, for some reason. Still looking into that.