Skip to content

Commit

Permalink
Merge pull request #138 from amplify-education/fix-conditional-grammar
Browse files Browse the repository at this point in the history
support conditional without parentheses inside nested locals
  • Loading branch information
IButskhrikidze authored May 24, 2023
2 parents fa7120a + c4982be commit 48be3a3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion hcl2/hcl2.lark
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ identifier : /[a-zA-Z_][a-zA-Z0-9_-]*/

?expression : expr_term | operation | conditional

conditional : expression "?" new_line_or_comment? expression new_line_or_comment? ":" new_line_or_comment? expression new_line_or_comment?
conditional : expression "?" new_line_or_comment? expression new_line_or_comment? ":" new_line_or_comment? expression

?operation : unary_op | binary_op
!unary_op : ("-" | "!") expr_term
Expand Down
10 changes: 10 additions & 0 deletions test/helpers/terraform-config-json/locals_embedded_condition.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"locals": [
{
"terraform": {
"channels": "${local.running_in_ci ? local.ci_channels : local.local_channels}",
"authentication": []
}
}
]
}
6 changes: 6 additions & 0 deletions test/helpers/terraform-config/locals_embedded_condition.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
locals {
terraform = {
channels = local.running_in_ci ? local.ci_channels : local.local_channels
authentication = []
}
}

0 comments on commit 48be3a3

Please sign in to comment.