hcl/extras/grammar/HCLTemplate.tmLanguage
Martin Atkins 1718a963e6 extras: initial TextMate-style grammar for HCL
This is for the core HCL syntax, so it doesn't include any
application-specific keyword highlighting, etc.

The structural, expression, and template languages are separated into
different grammar definitions so that they can be used independently, but
they embed each other as needed to complete the language.

This is just a first pass, really. There are probably some bugs here, and
also some missing features.
2018-07-07 12:36:52 -07:00

172 lines
4.5 KiB
Plaintext
Executable File

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>fileTypes</key>
<array>
<string>tmpl</string>
</array>
<key>name</key>
<string>HCL Template</string>
<key>patterns</key>
<array>
<dict>
<key>begin</key>
<string>[^\$]?(\$\{~?)</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>entity.tag.embedded.start.hcltemplate</string>
</dict>
</dict>
<key>comment</key>
<string>Interpolation Sequences</string>
<key>end</key>
<string>~?}</string>
<key>endCaptures</key>
<dict>
<key>0</key>
<dict>
<key>name</key>
<string>entity.tag.embedded.end.hcltemplate</string>
</dict>
</dict>
<key>name</key>
<string>meta.interp.hcltemplate</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>source.hclexpr</string>
</dict>
</array>
</dict>
<dict>
<key>begin</key>
<string>[^\%]?(\%\{~?)</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>entity.tag.embedded.start.hcltemplate</string>
</dict>
</dict>
<key>comment</key>
<string>Control Sequences</string>
<key>end</key>
<string>~?}</string>
<key>endCaptures</key>
<dict>
<key>0</key>
<dict>
<key>name</key>
<string>entity.tag.embedded.end.hcltemplate</string>
</dict>
</dict>
<key>name</key>
<string>meta.control.hcltemplate</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#templateif</string>
</dict>
<dict>
<key>include</key>
<string>#templatefor</string>
</dict>
<dict>
<key>include</key>
<string>#templatesimplekw</string>
</dict>
</array>
</dict>
</array>
<key>repository</key>
<dict>
<key>templatefor</key>
<dict>
<key>begin</key>
<string>(for)\s*(\w+)\s*(,\s*(\w+)\s*)?(in)</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>keyword.control.hcltemplate</string>
</dict>
<key>2</key>
<dict>
<key>name</key>
<string>variable.other.hcl</string>
</dict>
<key>4</key>
<dict>
<key>name</key>
<string>variable.other.hcl</string>
</dict>
<key>5</key>
<dict>
<key>name</key>
<string>keyword.control.hcltemplate</string>
</dict>
</dict>
<key>end</key>
<string>(?=~?\})</string>
<key>name</key>
<string>meta.templatefor.hcltemplate</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>source.hclexpr</string>
</dict>
</array>
</dict>
<key>templateif</key>
<dict>
<key>begin</key>
<string>(if)\s*</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>keyword.control.hcltemplate</string>
</dict>
</dict>
<key>end</key>
<string>(?=~?\})</string>
<key>name</key>
<string>meta.templateif.hcltemplate</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>source.hclexpr</string>
</dict>
</array>
</dict>
<key>templatesimplekw</key>
<dict>
<key>captures</key>
<dict>
<key>0</key>
<dict>
<key>name</key>
<string>keyword.control.hcl</string>
</dict>
</dict>
<key>match</key>
<string>(else|endif|endfor)</string>
</dict>
</dict>
<key>scopeName</key>
<string>source.hcltemplate</string>
<key>uuid</key>
<string>ac6be18e-d44f-4a73-bd8f-b973fd26df05</string>
</dict>
</plist>