Support 'quotedTemplate' in addition to 'StrLit' in block labels.
- Dominant language
- Go
- Stars
- 5.8k
- Forks
- 657
- Avg merge
- 20h 36m
- Merged PRs (30d)
- 6
Description
Currently, block label can be either identifier or string literal. I kind of want to support following pattern in a DSL I'm working on
```hcl
template {
repeat = 10
vars {
prefix = "Hello"
}
generate {
object "${vars.prefix}-${repeat}" {
}
}
}
```
But the HCL spec explicitly only allows strings or literals as object keys.
Lifting the `quotedTemplate` from just subpattern of TemplateExpr into a rule that could be used as block label would greatly extend the usability, and reduce the need for patterns like `for_each` in terraform.
TL;DR: In [Syntax spec](https://github.com/hashicorp/hcl/blob/main/hclsyntax/spec.md#expressions):
Replace
```ebnf
Block = Identifier (StringLit|Identifier)* "{" Newline Body "}" Newline;
```
with:
```ebnf
Block = Identifier (StringLit|Identifier|QuotedTemplate)* "{" Newline Body "}" Newline;
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with hclsyntax/spec.md at the Block grammar and review the parser entry points for Block, StringLit, Identifier, and quotedTemplate. Determine the compatibility and parsing implications of allowing quotedTemplate as a block label; done means the syntax is specified and the existing label forms continue to work alongside interpolated labels.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100