hcl/extras/grammar/HCLExpression.json-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

212 lines
4.4 KiB
JSON
Executable File

{
"fileTypes": [],
"name": "HCL Expression",
"patterns": [
{
"begin": "#|//",
"captures": {
"0": {
"name": "punctuation.definition.comment.hcl"
}
},
"comment": "Comments",
"end": "$\\n?",
"name": "comment.line.hcl"
},
{
"begin": "/\\*",
"captures": {
"0": {
"name": "punctuation.definition.comment.hcl"
}
},
"comment": "Block comments",
"end": "\\*/",
"name": "comment.block.hcl"
},
{
"comment": "Language constants (true, false, null)",
"match": "\\b(true|false|null)\\b",
"name": "constant.language.hcl"
},
{
"comment": "Numbers",
"match": "\\b([0-9]+)(.[0-9]+)?([eE][0-9]+)?\\b",
"name": "constant.numeric.hcl"
},
{
"begin": "([-\\w]+)(\\()",
"beginCaptures": {
"1": {
"name": "keyword.other.function.inline.hcl"
},
"2": {
"name": "keyword.other.section.begin.hcl"
}
},
"comment": "Function Calls",
"end": "(\\))",
"endCaptures": {
"1": {
"name": "keyword.other.section.end.hcl"
}
},
"patterns": [
{
"include": "$self"
}
]
},
{
"captures": {
"0": {
"name": "variable.other.hcl"
}
},
"comment": "Variables and Attribute Names",
"match": "[-\\w]+"
},
{
"begin": "(?\u003e\\s*\u003c\u003c(\\w+))",
"beginCaptures": {
"0": {
"name": "punctuation.definition.string.begin.hcl"
},
"1": {
"name": "keyword.operator.heredoc.hcl"
}
},
"comment": "Heredoc Templates",
"end": "^\\s*\\1$",
"endCaptures": {
"0": {
"name": "punctuation.definition.string.end.hcl keyword.operator.heredoc.hcl"
}
},
"patterns": [
{
"include": "source.hcltemplate"
}
]
},
{
"begin": "\\\"",
"beginCaptures": {
"0": {
"name": "string.hcl punctuation.definition.string.begin.hcl"
}
},
"comment": "String Templates",
"end": "\\\"",
"endCaptures": {
"0": {
"name": "string.hcl punctuation.definition.string.end.hcl"
}
},
"patterns": [
{
"include": "source.hcltemplate"
},
{
"match": "(^\"|$\\{|%\\{)+",
"name": "string.quoted.double.hcl"
}
]
},
{
"captures": {
"0": {
"name": "keyword.operator.hcl"
}
},
"comment": "Operators",
"match": "(!=|==|\u003e=|\u003c=|\u0026\u0026|\\|\\||[-+*/%\u003c\u003e!?:])"
},
{
"begin": "\\(",
"beginCaptures": {
"0": {
"name": "meta.brace.round.hcl"
}
},
"comment": "Parentheses",
"end": "\\)",
"endCaptures": {
"0": {
"name": "meta.brace.round.hcl"
}
},
"patterns": [
{
"include": "$self"
}
]
},
{
"begin": "\\[",
"beginCaptures": {
"0": {
"name": "meta.brace.square.hcl"
}
},
"comment": "Tuple Constructor",
"end": "\\]",
"endCaptures": {
"0": {
"name": "meta.brace.square.hcl"
}
},
"patterns": [
{
"captures": {
"0": {
"name": "keyword.control.hcl"
}
},
"match": "(for|in)"
},
{
"include": "$self"
}
]
},
{
"begin": "\\{",
"beginCaptures": {
"0": {
"name": "meta.brace.curly.hcl"
}
},
"comment": "Object Constructor",
"end": "\\}",
"endCaptures": {
"0": {
"name": "meta.brace.curly.hcl"
}
},
"patterns": [
{
"captures": {
"0": {
"name": "keyword.control.hcl"
}
},
"match": "(for|in)"
},
{
"captures": {
"0": {
"name": "keyword.operator.hcl"
}
},
"match": "(=\u003e|\\.\\.\\.)"
},
{
"include": "$self"
}
]
}
],
"scopeName": "source.hclexpr",
"uuid": "6c358551-0381-4128-9ea3-277b21943b5c"
}