We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hi,
I've found an issue when parsing key words:
main.tf
variable "if" { description = "this is fine" } variable "object" { description = "this fails" type = object({ if = string in = string for = string action = string }) }
main.py
import hcl2 with open('main.tf', 'r') as file: dict = hcl2.load(file) print(dict)
python main.py Traceback (most recent call last): File "/Users/josh/.local/share/virtualenvs/empty-locals-s2Z1l-Fh/lib/python3.9/site-packages/lark/parsers/lalr_parser.py", line 59, in get_action return states[state][token.type] KeyError: 'IF' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/Users/josh/github/bridgecrew.io/replication-cases/variable-named-if/main.py", line 3, in <module> dict = hcl2.load(file) File "/Users/josh/.local/share/virtualenvs/empty-locals-s2Z1l-Fh/lib/python3.9/site-packages/hcl2/api.py", line 9, in load return loads(file.read()) File "/Users/josh/.local/share/virtualenvs/empty-locals-s2Z1l-Fh/lib/python3.9/site-packages/hcl2/api.py", line 18, in loads return hcl2.parse(text + "\n") File "/Users/josh/.local/share/virtualenvs/empty-locals-s2Z1l-Fh/lib/python3.9/site-packages/lark/lark.py", line 464, in parse return self.parser.parse(text, start=start) File "/Users/josh/.local/share/virtualenvs/empty-locals-s2Z1l-Fh/lib/python3.9/site-packages/lark/parser_frontends.py", line 115, in parse return self._parse(token_stream, start) File "/Users/josh/.local/share/virtualenvs/empty-locals-s2Z1l-Fh/lib/python3.9/site-packages/lark/parser_frontends.py", line 63, in _parse return self.parser.parse(input, start, *args) File "/Users/josh/.local/share/virtualenvs/empty-locals-s2Z1l-Fh/lib/python3.9/site-packages/lark/parsers/lalr_parser.py", line 35, in parse return self.parser.parse(*args) File "/Users/josh/.local/share/virtualenvs/empty-locals-s2Z1l-Fh/lib/python3.9/site-packages/lark/parsers/lalr_parser.py", line 88, in parse action, arg = get_action(token) File "/Users/josh/.local/share/virtualenvs/empty-locals-s2Z1l-Fh/lib/python3.9/site-packages/lark/parsers/lalr_parser.py", line 66, in get_action raise UnexpectedToken(token, expected, state=state, puppet=puppet) lark.exceptions.UnexpectedToken: Unexpected token Token('IF', 'if') at line 9, column 5. Expected one of: * __ANON_11 * TRUE * LPAR * LSQB * __ANON_3 * MINUS * STRING_LIT * __ANON_10 * RBRACE * NULL * DECIMAL * BANG * LBRACE * FOR * FALSE
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Hi,
I've found an issue when parsing key words:
main.tf
main.py
The text was updated successfully, but these errors were encountered: