Skip to content
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

Error in processor.py when processing PartiQL grammars #212

Closed
miryung opened this issue Feb 6, 2024 · 2 comments
Closed

Error in processor.py when processing PartiQL grammars #212

miryung opened this issue Feb 6, 2024 · 2 comments

Comments

@miryung
Copy link

miryung commented Feb 6, 2024

I am trying to process PartiQL ANLTR grammar located here: https://partiql.org/syntax/antlr.html

I attached g4 grammars with txt extension (to allow upload). I checked that these grammars do not have syntax errors and are able to parse input files correctly.
PartiQL.g4.txt
PartiQLTokens.g4.txt

miryung@bcd074185726 ANTLRGrammar % grammarinator-process --no-actions -o PartiQL-example/fuzzer PartiQL.g4 PartiQLTokens.g4
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.11/bin/grammarinator-process", line 8, in
sys.exit(execute())
^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/grammarinator/process.py", line 67, in execute
ProcessorTool(args.language, args.out).process(args.grammar, options=options, default_rule=args.rule, encoding=args.encoding, errors=args.encoding_errors, lib_dir=args.lib, actions=args.actions, pep8=args.pep8)
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/grammarinator/tool/processor.py", line 444, in process
self._analyze_graph(graph)
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/grammarinator/tool/processor.py", line 906, in _analyze_graph
for out_v in graph.vertices[v].out_neighbours:
~~~~~~~~~~~~~~^^^
KeyError: None

@renatahodovan
Copy link
Owner

Hi @miryung !

Thanks for the report. The problem with the provided grammar is that it consists of a combined grammar (PartiQL.g4) and a lexer grammar (PartiQLTokens.g4), instead of using either a pair of parser & lexer grammars or a single combined grammar as described in the ANTLR docs.

ANTLR will generate a single parser only from your combined grammar since it doesn't contain any lexer rules and a lexer from your lexer grammar. So, those two can work together as a parser-lexer pair. However, this is a bit of an edge case. It should be safer to define PartiQL.g4 explicitly as a parser grammar. Not to mention that Grammarinator does not support this edge case.

However, by adding the parser keyword to the first grammar definition line of PartiQL.g4 (making it parser grammar PartiQL;), Grammarinator can also handle the two grammar files.

Please, tell me if it worked for you!

@miryung
Copy link
Author

miryung commented Feb 16, 2024

It worked for me. Thanks Renata.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants