Community
Participate
Working Groups
I have been plagued for a while with getting "the required loop (...)+ at xxx" did not match any input, and have now figured out what I did in my (b3) grammar to trigger this. With this grammar (where everything in the unordered group is optional): BeeModel returns build::BeeModel hidden(WS, SL_COMMENT, ML_COMMENT) : {build::BeeModel} (imports += Import)* ( (functions += Function) * & (concerns += Concern_Named) * & (propertySets += PropertySet_Named) * & (buildUnits += BuildUnit) * & (providers += TopLevelUnitProvider) ? & (repositories += Repository) * & (defaultProperties = PropertySetDefault) ? )? ; If there is anything wrong while parsing the 'Function' rule - say it was given the faulty "function two : 1 + ;" b3 expression I get the "(...)+" error message and it marks the keyword "function". This is really bad when the function has many expressions and deep nesting. If I however change the grammar to: BeeModel returns build::BeeModel hidden(WS, SL_COMMENT, ML_COMMENT) : {build::BeeModel} (imports += Import) //* ( (functions += Function) //* | (concerns += Concern_Named) //* | (propertySets += PropertySet_Named) //* | (buildUnits += BuildUnit) //* | (providers += TopLevelUnitProvider) //? | (repositories += Repository) //* | (defaultProperties = PropertySetDefault) //? )* ; I get the correct error marker on the last '+' sign, and a meaningful error message. (There are issues with this grammar, as two of the assignments will cause dangling instances as input may overwrite). The former grammar is also what I really want - I want the various statements to be grouped (i.e. all functions should be in one group), but the groups can be in any order. When input is correct, it correctly parses it this way. This issue basically makes it impossible for me to use unordered groups.
Assumingung the following model: |function someFun() { Integer x = 1+ } and | as current parser offset (a): The parser will try to simulate a function (backtracking == true) and fail at the + sign (b). Afterwards, it will decide that there is no alternative to be choosen at the offset (a) and mark the token with an error. However, the actual error is at offset (b). If the body becomes more complex, it is hard to see why the parser failed with the given input.
Since I did not find a way to fix this in SR1, I'll reschedule this one for Indigo.
I hope that Antlr 3.2 allows to fix this issue. Added dependency to bug 326811
Can someone verify if this has been fixed in the meantime?