Skip to content

Commit

Permalink
fix: Add support for attributes named "in". (#164)
Browse files Browse the repository at this point in the history
Special thanks to @jqcorreia for the grammar lesson and debugging.
  • Loading branch information
elisiariocouto authored Jun 25, 2024
1 parent 124a429 commit 98d401c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
5 changes: 3 additions & 2 deletions hcl2/hcl2.lark
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ block : identifier (identifier | STRING_LIT)* new_line_or_comment? "{" body "}"
new_line_and_or_comma: new_line_or_comment | "," | "," new_line_or_comment
new_line_or_comment: ( /\n/ | /#.*\n/ | /\/\/.*\n/ )+

identifier : /[a-zA-Z_][a-zA-Z0-9_-]*/
identifier : /[a-zA-Z_][a-zA-Z0-9_-]*/ | IN
IN : "in"

?expression : expr_term | operation | conditional

Expand All @@ -27,7 +28,7 @@ expr_term : "(" new_line_or_comment? expression new_line_or_comment? ")"
| index_expr_term
| get_attr_expr_term
| identifier
| provider_function_call
| provider_function_call
| heredoc_template
| heredoc_template_trim
| attr_splat_expr_term
Expand Down
13 changes: 13 additions & 0 deletions test/helpers/terraform-config-json/resource_in_attribute.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"resource": [
{
"custom_provider_resource": {
"resource_name": {
"name": "resource_name",
"attribute": "attribute_value",
"in": "attribute_value2"
}
}
}
]
}
5 changes: 5 additions & 0 deletions test/helpers/terraform-config/resource_in_attribute.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
resource "custom_provider_resource" "resource_name" {
name = "resource_name"
attribute = "attribute_value"
in = "attribute_value2"
}

0 comments on commit 98d401c

Please sign in to comment.