Community
Participate
Working Groups
Build Identifier: 20110218-0911 I try to migrate a backtracking grammar to xtext2 from the zipped update-site tmf-xtext-Update-2.0.0RC1.zip. When i invoke the parser rule in AbstractContentAssistParser.getFollowElements(AbstractInternalContentAssistParser, AbstractElement, String[], int) on the input "package a { public class Aa { var name:String|; } }" eclipse freezes (| is the caret position). The input is valid and is parsed without errors by the runtime parser. The freeze is due to a endless loop: 1. parser.rule__ITypeDirective__Alternatives tries to predict a dfa. 2. fails to predict with a NoViableAltException. 3. recovers the error, stack and input and starts again at 1. without any side effects. Instead i would expect that the content assist parser simply fails or even better correctly predicts the follow elements. Reproducible: Always Steps to Reproduce: The grammar is huge but i can try to reduce it to a small reproducible example when needed.
A reproducable example would be very helpful.
Created attachment 196688 [details] failing test project 1. extract the zip. 2. add the .antlr-generator-3.2.0.jar and a com.ibm.icu_3.4.4.1.jar to the org.xtext.example.mydsl project. 3. launch org.xtext.example.mydsl/GenerateMyDsl.mwe2.launch 4. launch org.xtext.example.mydsl.tests/org.xtext.example.mydsl.tests.launch 5. notice freeze 6. edit MxDsl.xtext so MyAttributes is only parsed when a token is matched: MyAttributes: (attributes+=MyAttribute)+; MyField: attr=MyAttributes? 'var' LT* bindings+=MyBinding (LT* ',' LT* bindings+=MyBinding)* VirtualSemi; 7. generate and test again and notice success so it seems that rules the might not match any tokens make it fail?
i changed my main grammar and it seems to work. but i think xtext should analyze this situation and warn the user not to use rules that might not consume any tokens. otherwise empty rules can be handy for ast construction. i use them to help with default behavior for declaration attributes and as placeholders for empty entries in array literals. xtext is great. thanks
Pushed to master. Please note that the production parser may get stuck, too. E.g. the following input models will lead to infinite loops: package a { public class Aa { package a { public class Aa { var package a { public class Aa { var } package a { public class Aa { var Name }
(In reply to comment #4) > Please note that the production parser may get stuck, too. see bug 360892
Closing all bugs that were set to RESOLVED before Neon.0