Comments (3)
Hi @bendrissou
Thanks for the report! The generated Python code is incorrect, since the input grammar is not correct either. Grammarinator follows the syntax of ANTLR where terminal rules must not refer to non-terminals. If you generate a parser from the grammar above with ANTLR then you get the following error message:
error(160): /work/dir/json.g4:11:29: reference to parser rule token in lexer rule NUMBER
warning(125): json.g4:8:5: implicit definition of token NUMBER in parser
If you transform token
into a terminal rule (rename it to Token
) then it will work as expected (both with Grammarinator and ANTLR).
You are right though, that it would be helpful to throw an error from grammarinator-process if the input grammar is not correct. I'll think about it how to handle all the possible input errors (w/o explicitly validating it with ANTLR).
from grammarinator.
@bendrissou Did you manage to fix the grammar? Can we close this issue?
from grammarinator.
Yes, I have fixed my grammar. I only wanted to report the bug. Found the bug with my fuzzer.
from grammarinator.
Related Issues (20)
- API usage HOT 2
- unrecognized arguments: -p HOT 1
- Generating alternation at most once HOT 2
- Enforce coverage of a grammar rule HOT 1
- undefined variables HOT 3
- grammarinator-generate fails for the PostgreSQL grammar HOT 3
- Can't get this to work HOT 2
- Half the generated files are empty? HOT 6
- Generated file missing tokens HOT 1
- Invalid words while using NOT HOT 1
- Python keywords as rule name HOT 3
- Error processing grammar ModuleNotFoundError: No module named 'grammarinator.parser.ANTLRv4Lexer' HOT 3
- Wrong indentation in generated Python code HOT 2
- Test case doesn't work anymore HOT 2
- How to get the value of `current` ? HOT 2
- Can't set alt weights HOT 4
- AttributeError: type object 'JSONGenerator' has no attribute '<INVALID>' HOT 1
- ANTLR download fails due to SSLError HOT 2
- Generation seed not working HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from grammarinator.