New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AttributeError: 'Unlexer' object has no attribute 'WHEN' #5
Comments
@marcospassos Could you provide the way you've built the grammar and how the tests were generated? I've generated a fuzzer from the example you pasted and it seemed to work fine. The commands I used: grammarinator-process TestLexer.g TestParser.g -o test
grammarinator-generate -l test/TestUnlexer.py -p test/TestUnparser.py -r domain -n1 However, one thing is suspicious: your trace seems to use an unparser named BaseCclUnparser which is not the same as the example. So maybe something is missing from the repro grammar. |
Ok, pretty weird. It looks like the error only happens if you execute the command out of the folder containing the grammars. Try it from the parent folder:
Now, I can generate it running the command inside the dir. However, now I'm getting another error:
|
@marcospassos This is because your grammar is recursive and there is no recursion limit set. You can define it with the |
But it's not even documented in the command line signature. What does this flag do exactly?
About the problem related to the working dir, is it the expected behavior? |
Looks like this flag does not exist in the version that I'm using:
|
Ok, I found it on master (the version installed using pip is not in sync). |
@marcospassos Seems that we are using different versions. The support for recursion limit was added in 85ca911. The |
@marcospassos Yes, pip is only updated when a new version is released. Between two releases the new features are only available in the master. |
I'm having a bad time trying to make it work with our grammar. I've reinstalled everything from scratch, but the latest version (master) throws new errors now:
|
The same errors do not occur in the version installed using pip. |
@marcospassos This is a bug indeed. Thanks! I will fix it. The problem is that EOF is a builtin ANTLR token that should have been handled specially when calculating the distances. |
@renatahodovan thanks! Looking forward try a version that works with our grammar!
As a side note, it's important to allow generating tests on CI servers. |
@marcospassos If I'm right, then 2554246 has fixed the EOF issue and your example should work after updating to the latest master. |
Not yet =(
|
@marcospassos The other question about the working dir. I tried to run the example from different directories, but could not reproduce it. So could you rephrase it please, 'cos I'm not sure I understand the problem. |
Hm... The assertion is weird. Could you give a repro about the failing grammar? |
I'm afraid not. The message is very unclear about the reason it's failing (the grammar has 1000+ lines). On the other hand, I can't publish the grammar because it's a proprietary language. Is there anything else I can do to help you? |
The assert means that the grammar has an alternation with an alternative that has an infinite depth. This could be because of an undefined rule reference or an infinite recursion, for example. One thing you can try is to put a print into the process.py:357 printing the value of the |
Hm... it does not make sense. The last rule it prints is
I can't reach any conclusion about that. This grammar works pretty well in Java, so I don't think it is a problem in the grammar definition (any invalid reference would not compile). Besides this, this issue does not occur in the version available through |
The issue is related to the recursion limit feature which is not part of the pip version, this is why that version works. |
Alright. The issue means, that the minimum distance from the 16. alternative of the |
Okay, I've may found a reproduction case. I try to come up with a solution and will see if that solves your issue too. |
@renatahodovan I don't think the problem is in the |
\o/ |
@marcospassos I think (or hope) that the issue has been eliminated on the current master. Please verify if it solves your problem too. And don't hesitate to send a report if you find further bugs. |
@renatahodovan it worked, thanks! However, I still cannot generate the tests:
Any guess? |
Seems that |
hi @renatahodovan! Sure, although it does not recurse infinitely:
|
@marcospassos I've found a possible reason of the failure. Please try the latest master whether it solves your issue. Otherwise, please open another bug entry, since this one is getting overloaded :) |
@renatahodovan still no success. I've opened the issue #6 to discuss the new issue. |
We're facing the following error when generating our grammar:
Parser:
Lexer:
The text was updated successfully, but these errors were encountered: