Terraform.tmLanguage icon indicating copy to clipboard operation
Terraform.tmLanguage copied to clipboard

Parsing of heredoc identifier broken?

Open rchl opened this issue 4 years ago • 0 comments
trafficstars

This heredoc template expression breaks parsing:

<<__EOF__
aaa
__EOF__

It looks like because the identifier used here (__EOF__) starts with an underscore and that is deemed invalid.

I've tried to understand what characters are allowed in identifiers but going down the rabbit hole almost exploded my brain when trying to understand the unicode spec stuff.

HCL syntax spec says [1]:

The heredoc template expression type is introduced by either << or <<-, followed by an identifier.

and "identifier" is defined as [2]:

Identifiers name entities such as blocks, attributes and expression variables. Identifiers are interpreted as per UAX #31 Section 2. Identifier = ID_Start (ID_Continue | '-')*;

Where the UAX link points to a spec where I completely lost comprehension.

So the question is, can the identifier start with an underscore? Terraform actually works just fine with it so I guess yes.

[1] https://github.com/hashicorp/hcl/blob/hcl2/hclsyntax/spec.md#template-expressions [2] https://github.com/hashicorp/hcl/blob/hcl2/hclsyntax/spec.md#identifiers

rchl avatar Dec 11 '20 11:12 rchl