Skip to content

Commit

Permalink
allow if and for_each keywords to be used as identifiers (#168)
Browse files Browse the repository at this point in the history
  • Loading branch information
kkozik-amplify authored Aug 6, 2024
1 parent c52be2d commit 92f2ee2
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 25 deletions.
4 changes: 3 additions & 1 deletion hcl2/hcl2.lark
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ 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_-]*/ | IN | FOR
identifier : /[a-zA-Z_][a-zA-Z0-9_-]*/ | IN | FOR | IF | FOR_EACH
IF : "if"
IN : "in"
FOR : "for"
FOR_EACH : "for_each"

?expression : expr_term | operation | conditional

Expand Down
13 changes: 0 additions & 13 deletions test/helpers/terraform-config-json/resource_in_attribute.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
"resource_name": {
"name": "resource_name",
"attribute": "attribute_value",
"for": "attribute_value2"
"if" : "attribute_value2",
"in" : "attribute_value3",
"for" : "attribute_value4",
"for_each" : "attribute_value5"
}
}
}
Expand Down
5 changes: 0 additions & 5 deletions test/helpers/terraform-config/resource_for_attribute.tf

This file was deleted.

5 changes: 0 additions & 5 deletions test/helpers/terraform-config/resource_in_attribute.tf

This file was deleted.

8 changes: 8 additions & 0 deletions test/helpers/terraform-config/resource_keyword_attribute.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
resource "custom_provider_resource" "resource_name" {
name = "resource_name"
attribute = "attribute_value"
if = "attribute_value2"
in = "attribute_value3"
for = "attribute_value4"
for_each = "attribute_value5"
}

0 comments on commit 92f2ee2

Please sign in to comment.