Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion hcl2/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def strip_line_comment(line: str) -> tuple[str, str, str] | tuple[str, None, Non
class Hcl2:
"""Wrapper class for Lark"""

lark_parser = Lark(grammar=LARK_GRAMMAR, parser="lalr", propagate_positions=True, cache=True)
lark_parser = Lark(grammar=LARK_GRAMMAR, parser="lalr", propagate_positions=True, cache=True, regex=True)

def parse(self, text: str) -> dict[str, list[dict[str, Any]]]:
"""Parses a HCL file and returns a dict"""
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
# http://docs.python.org/2/distutils/setupscript.html#relationships-between-distributions-and-packages
lark>=1.0.0
importlib-resources>=2.0.0,<7.0.0; python_version < '3.9'
regex==2024.9.11
9 changes: 9 additions & 0 deletions test/helpers/terraform-config/bad_regex.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
resource "aws_glue_connection" "example" {
name = "example-connection"
connection_properties = {
startswith(each.value.connection_properties[x], "$${abcded:"


variable "connection_properties" {

}
2 changes: 1 addition & 1 deletion test/unit/test_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def _load_test_files(self):
hcl2.load(hcl2_file)
self.fail("Should throw parsing error for file")
except Exception as err:
if not str(err).startswith('Line has unclosed quote marks'):
if not str(err).startswith('Line has unclosed quote marks') and not str(err).startswith('No terminal matches'):
self.fail(f'Got an unexpected error, {err}')
else:
with open(file_path, 'r', encoding='utf8') as hcl2_file, \
Expand Down
Loading