-
Notifications
You must be signed in to change notification settings - Fork 62
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
Issue in docs #272
Comments
akosthekiss
added a commit
to akosthekiss/grammarinator
that referenced
this issue
Feb 23, 2025
- The example grammar was incorrect, at least for parsing. For ANTLR, character classes are invalid in parser rules, may only be used in lexer rules. Thus, grammar was rewritten to use lexer rules. - In the python examples, indentation was off by one for `quantify` and `charset` methods. Fixed. - The `quantify` methods in the examples used an old API: the number and names of arguments was incorrect, and the methods still acted as generators. So, the `cnt` argument was added, `min` and `max` were renamed to `start` and `stop`, and `return` was used instead of `yield`ing. - Since the `decimal` rule in the grammar got turned into an lexer rule, `Decimal` nodes don't have children anymore. Thus, `charset` methods in the examples have been updated to make decisions based on token length instead of children count. - It got revealed that `charset` methods don't get charsets as lists but as tuples. The documentation of `Model.charset` had to updated and example `charset` methods had to be adapted. - All methods in the `DispatchingModel` subclass example fell into infinite recursion. The use of `super()` in the subclass directed the call to the method defined in `DispatchingModel`, which in turn called back into the subclass (and so on), instead of calling to the method in `DefaultModel`, the parent class of `DispatchingModel` and the grandparent of the subclass. Fixed by using the two-argument version of `super(..., ...)`. Fixes: renatahodovan#272
@0legmax Thanks for reporting this issue. It has also revealed additional problems in the documentation. Got them fixed (hopefully). If you find any other problems (or this problem presists on your side by any chance), please do report them by opening a new issue. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://github.com/renatahodovan/grammarinator/blob/bf348a0bbec239a6c7cbcd01455bb53de484d6fe/docs/guide/models.rst?plain=1#L98C16-L98C37
Here I'm getting infinite recursion.
super()
isDispatchingModel
here, but we should be callingDefaultModel
insteadThe text was updated successfully, but these errors were encountered: