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

AttributeError: type object 'JSONGenerator' has no attribute '<INVALID>' #80

Closed
bendrissou opened this issue Mar 2, 2023 · 1 comment · Fixed by #82
Closed

AttributeError: type object 'JSONGenerator' has no attribute '<INVALID>' #80

bendrissou opened this issue Mar 2, 2023 · 1 comment · Fixed by #82

Comments

@bendrissou
Copy link

bendrissou commented Mar 2, 2023

I was trying to generate json files using the --population option and the antlr json grammar. The grt files have been prepared with no problem. But I get an error when I run the following command:

grammarinator-generate JSONGenerator.JSONGenerator -r json -o tests/test_%d.json -d 20 -n 1 --population ../seeds/grts --no-generate --sys-path .

The error output:

Test generation failed.
Traceback (most recent call last):
  File "/home/bachir/.local/lib/python3.8/site-packages/grammarinator/generate.py", line 119, in create_new_test
    tree = generator(self.rule, self.max_depth)
  File "/home/bachir/.local/lib/python3.8/site-packages/grammarinator/generate.py", line 197, in recombine
    options = self.default_selector(node for rule_name in common_types for node in tree_1.node_dict[rule_name])
  File "/home/bachir/.local/lib/python3.8/site-packages/grammarinator/generate.py", line 213, in default_selector
    return [node for node in iterable if node.name is not None and node.parent is not None and node.name != 'EOF' and node.level + min_depth(node) < self.max_depth]
  File "/home/bachir/.local/lib/python3.8/site-packages/grammarinator/generate.py", line 213, in <listcomp>
    return [node for node in iterable if node.name is not None and node.parent is not None and node.name != 'EOF' and node.level + min_depth(node) < self.max_depth]
  File "/home/bachir/.local/lib/python3.8/site-packages/grammarinator/generate.py", line 211, in min_depth
    return getattr(getattr(self.generator_cls, node.name), 'min_depth', 0)
AttributeError: type object 'JSONGenerator' has no attribute '<INVALID>'

The error does not occur if option --population is omitted. In addition, the seed inputs have been successfully parsed into grt files. The error occurs with any provided grt file.

Any idea what could be the cause of this?

renatahodovan added a commit that referenced this issue Mar 3, 2023
Inline tokens are named as `<INVALID>` by ANTLR. When such a node
was chosen to be mutated then Grammarinator tried to regenerate
them according to a rule definition called `<INVALID>` which did
not exist, of course. The patch disables the mutation of such nodes
since inline tokens are constants, hence mutating them would not
have any importance either.

Fixes #80.
renatahodovan added a commit that referenced this issue Mar 3, 2023
Inline tokens are named as `<INVALID>` by ANTLR. When such a node
was chosen to be mutated then Grammarinator tried to regenerate
them according to a rule definition called `<INVALID>` which did
not exist, of course. The patch disables the mutation of such nodes
since inline tokens are constants, hence mutating them would not
have any importance either.

Fixes #80.
akosthekiss pushed a commit that referenced this issue Mar 3, 2023
Inline tokens are named as `<INVALID>` by ANTLR. When such a node
was chosen to be mutated then Grammarinator tried to regenerate
them according to a rule definition called `<INVALID>` which did
not exist, of course. The patch disables the mutation of such nodes
since inline tokens are constants, hence mutating them would not
have any importance either.

Fixes #80.
@renatahodovan
Copy link
Owner

@bendrissou Thanks for the report! Hopefully it is fixed now.

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

Successfully merging a pull request may close this issue.

2 participants