55 lines
1.7 KiB
YAML
55 lines
1.7 KiB
YAML
%YAML 1.2
|
|
---
|
|
# NotesCraft's own HCL grammar. Original work written for this project; not copied
|
|
# from any other grammar. Regexes stay linear: no nested quantifiers, so nothing backtracks far.
|
|
# Strings end at their line unless the language allows multi-line ones.
|
|
name: HCL
|
|
file_extensions: [hcl, tf, tfvars, terraform]
|
|
scope: source.hcl
|
|
|
|
contexts:
|
|
main:
|
|
- match: '/\*'
|
|
scope: punctuation.definition.comment.begin
|
|
push: block0
|
|
- match: '#.*'
|
|
scope: comment.line
|
|
- match: '//.*'
|
|
scope: comment.line
|
|
- match: '<<-?(\w+)\n'
|
|
scope: punctuation.definition.string.begin
|
|
push: heredoc
|
|
- match: '\b[A-Za-z_][\w-]*(?=\s*=[^=])'
|
|
scope: meta.mapping.key
|
|
- match: '"'
|
|
scope: punctuation.definition.string.begin
|
|
push: str-dq
|
|
- match: '\b(?:resource|data|variable|output|locals|module|provider|terraform|for|in|if|else|endif|endfor|dynamic|moved|import|check|required_providers|backend|lifecycle|provisioner)\b'
|
|
scope: keyword.control
|
|
- match: '\b(?:true|false|null)\b'
|
|
scope: constant.language
|
|
- match: '\b(?:0[xX][0-9a-fA-F_]+|0[bB][01_]+|\d[\d_]*(?:\.\d[\d_]*)?(?:[eE][+-]?\d+)?)\b'
|
|
scope: constant.numeric
|
|
- match: '\b[A-Za-z_]\w*(?=\s*\()'
|
|
scope: entity.name.function
|
|
- match: '[-+*/%=<>!&|^~?:]+'
|
|
scope: keyword.operator
|
|
block0:
|
|
- meta_scope: comment.block
|
|
- match: '\*/'
|
|
pop: true
|
|
str-dq:
|
|
- meta_scope: string.quoted.double
|
|
- match: '\\.'
|
|
scope: constant.character.escape
|
|
- match: '"'
|
|
scope: punctuation.definition.string.end
|
|
pop: true
|
|
- match: '(?=\n)'
|
|
pop: true
|
|
heredoc:
|
|
- meta_scope: string.unquoted.heredoc
|
|
- match: '^\s*\1\b'
|
|
scope: punctuation.definition.string.end
|
|
pop: true
|