315 lines
11 KiB
JSON
315 lines
11 KiB
JSON
{
|
|
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
|
|
"name": "Gram",
|
|
"scopeName": "source.gram",
|
|
"patterns": [
|
|
{ "include": "#frontmatter" },
|
|
{ "include": "#comments" },
|
|
{ "include": "#use-directive" },
|
|
{ "include": "#sections" },
|
|
{ "include": "#actions" },
|
|
{ "include": "#elements" }
|
|
],
|
|
"repository": {
|
|
"use-directive": {
|
|
"patterns": [
|
|
{ "include": "#use-directive-block" },
|
|
{ "include": "#use-directive-single" }
|
|
]
|
|
},
|
|
"use-directive-block": {
|
|
"begin": "^(@use)\\s+(\"[^\"\\n]*\")\\s+(as)\\s+(\\{)",
|
|
"beginCaptures": {
|
|
"1": { "name": "keyword.control.import.gram" },
|
|
"2": { "name": "string.quoted.double.gram" },
|
|
"3": { "name": "keyword.control.import.gram" },
|
|
"4": { "name": "punctuation.section.embedded.begin.gram" }
|
|
},
|
|
"end": "(\\})(?:\\s*(~\\{[^\\}]+\\}))?",
|
|
"endCaptures": {
|
|
"1": { "name": "punctuation.section.embedded.end.gram" },
|
|
"2": { "name": "entity.name.tag.retro.gram" }
|
|
},
|
|
"name": "meta.import.bindings.gram",
|
|
"patterns": [
|
|
{ "match": ",", "name": "punctuation.separator.comma.gram" },
|
|
{ "match": "\\bas\\b", "name": "keyword.control.import.gram" },
|
|
{ "include": "#references" }
|
|
]
|
|
},
|
|
"use-directive-single": {
|
|
"match": "^(@use)\\s+(\"[^\"\\n]*\")\\s+(as)\\s+(&\\w+(?:\\s+\\w+)*\\{\\}|&[^\\s]+)(?:\\s*(~\\{[^\\}]+\\}))?",
|
|
"captures": {
|
|
"1": { "name": "keyword.control.import.gram" },
|
|
"2": { "name": "string.quoted.double.gram" },
|
|
"3": { "name": "keyword.control.import.gram" },
|
|
"4": {
|
|
"name": "meta.import.bindings.gram",
|
|
"patterns": [{ "include": "#references" }]
|
|
},
|
|
"5": { "name": "entity.name.tag.retro.gram" }
|
|
}
|
|
},
|
|
"frontmatter": {
|
|
"begin": "^---$",
|
|
"end": "^---$",
|
|
"name": "meta.embedded.block.frontmatter",
|
|
"patterns": [{ "include": "source.yaml" }]
|
|
},
|
|
"comments": {
|
|
"patterns": [
|
|
{
|
|
"name": "comment.line.double-slash.gram",
|
|
"match": "//.*$"
|
|
},
|
|
{
|
|
"name": "comment.block.gram",
|
|
"begin": "/\\*",
|
|
"end": "\\*/"
|
|
}
|
|
]
|
|
},
|
|
"sections": {
|
|
"match": "^(##)\\s+((?:(?!->&|~\\{).)*?)(?:\\s*(~\\{[^\\}]+\\}))?(?:\\s*(->&)\\s*([^\\{\\s]+(?:\\s+[^\\{\\s]+)*))?(?:\\s*(~\\{[^\\}]+\\}))?",
|
|
"captures": {
|
|
"1": { "name": "markup.heading.marker.gram" },
|
|
"2": { "name": "entity.name.section.gram" },
|
|
"3": { "name": "entity.name.tag.retro.gram" },
|
|
"4": { "name": "keyword.operator.arrow.gram" },
|
|
"5": { "name": "entity.name.tag.intermediate.gram" },
|
|
"6": { "name": "entity.name.tag.retro.gram" }
|
|
}
|
|
},
|
|
"actions": {
|
|
"match": "^\\s*(\\[)([^\\]]+)(\\])",
|
|
"captures": {
|
|
"1": { "name": "punctuation.definition.tag.begin.gram" },
|
|
"2": { "name": "entity.name.function.action.gram" },
|
|
"3": { "name": "punctuation.definition.tag.end.gram" }
|
|
}
|
|
},
|
|
"elements": {
|
|
"patterns": [
|
|
{ "include": "#ingredients" },
|
|
{ "include": "#cookware" },
|
|
{ "include": "#timers" },
|
|
{ "include": "#temperatures" },
|
|
{ "include": "#references" },
|
|
{ "include": "#composites" },
|
|
{ "include": "#intermediate-decl" }
|
|
]
|
|
},
|
|
"ingredients": {
|
|
"patterns": [
|
|
{
|
|
"name": "meta.ingredient.gram",
|
|
"begin": "(@)([-?&*=]*)([^\\{\\[@#~^&:<]+?)(?:(:)([\\w\\s]+))?(\\{)",
|
|
"beginCaptures": {
|
|
"1": { "name": "keyword.control.ingredient.gram" },
|
|
"2": { "name": "storage.modifier.gram" },
|
|
"3": { "name": "entity.name.type.ingredient.gram" },
|
|
"4": { "name": "keyword.operator.alias.gram" },
|
|
"5": { "name": "string.other.alias.gram" },
|
|
"6": { "name": "punctuation.section.embedded.begin.gram" }
|
|
},
|
|
"end": "(\\})(?:\\(([^)]+)\\))?",
|
|
"endCaptures": {
|
|
"1": { "name": "punctuation.section.embedded.end.gram" },
|
|
"2": { "name": "string.other.preparation.gram" }
|
|
},
|
|
"patterns": [
|
|
{ "include": "#quantity-content" }
|
|
]
|
|
},
|
|
{
|
|
"name": "meta.ingredient.bare.gram",
|
|
"match": "(@)([-?&*=]*)([^\\s\\{\\[@#~^&:<]+)(?:(:)([\\w]+))?(?:\\(([^)]+)\\))?",
|
|
"captures": {
|
|
"1": { "name": "keyword.control.ingredient.gram" },
|
|
"2": { "name": "storage.modifier.gram" },
|
|
"3": { "name": "entity.name.type.ingredient.gram" },
|
|
"4": { "name": "keyword.operator.alias.gram" },
|
|
"5": { "name": "string.other.alias.gram" },
|
|
"6": { "name": "string.other.preparation.gram" }
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"cookware": {
|
|
"patterns": [
|
|
{
|
|
"name": "meta.cookware.gram",
|
|
"begin": "(#)([-?&*=]*)([^\\{\\[@#~^&:<]+?)(?:(:)([\\w\\s]+))?(\\{)",
|
|
"beginCaptures": {
|
|
"1": { "name": "keyword.control.cookware.gram" },
|
|
"2": { "name": "storage.modifier.gram" },
|
|
"3": { "name": "support.class.cookware.gram" },
|
|
"4": { "name": "keyword.operator.alias.gram" },
|
|
"5": { "name": "string.other.alias.gram" },
|
|
"6": { "name": "punctuation.section.embedded.begin.gram" }
|
|
},
|
|
"end": "(\\})(?:\\(([^)]+)\\))?",
|
|
"endCaptures": {
|
|
"1": { "name": "punctuation.section.embedded.end.gram" },
|
|
"2": { "name": "string.other.preparation.gram" }
|
|
},
|
|
"patterns": [
|
|
{ "include": "#quantity-content" }
|
|
]
|
|
},
|
|
{
|
|
"name": "meta.cookware.bare.gram",
|
|
"match": "(#)([-?&*=]*)([^\\s\\{\\[@#~^&:<]+)(?:(:)([\\w]+))?(?:\\(([^)]+)\\))?",
|
|
"captures": {
|
|
"1": { "name": "keyword.control.cookware.gram" },
|
|
"2": { "name": "storage.modifier.gram" },
|
|
"3": { "name": "support.class.cookware.gram" },
|
|
"4": { "name": "keyword.operator.alias.gram" },
|
|
"5": { "name": "string.other.alias.gram" },
|
|
"6": { "name": "string.other.preparation.gram" }
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"timers": {
|
|
"name": "meta.timer.gram",
|
|
"begin": "(~)(_)?([\\w\\s]+)?(\\{)",
|
|
"beginCaptures": {
|
|
"1": { "name": "keyword.control.timer.gram" },
|
|
"2": { "name": "storage.modifier.gram" },
|
|
"3": { "name": "support.type.timer.gram" },
|
|
"4": { "name": "punctuation.section.embedded.begin.gram" }
|
|
},
|
|
"end": "(\\})",
|
|
"endCaptures": {
|
|
"1": { "name": "punctuation.section.embedded.end.gram" }
|
|
},
|
|
"patterns": [ { "include": "#quantity-content" } ]
|
|
},
|
|
"temperatures": {
|
|
"name": "meta.temperature.gram",
|
|
"begin": "(\\^)([\\w\\s]+)?(\\{)",
|
|
"beginCaptures": {
|
|
"1": { "name": "keyword.control.temperature.gram" },
|
|
"2": { "name": "constant.numeric.temperature.gram" },
|
|
"3": { "name": "punctuation.section.embedded.begin.gram" }
|
|
},
|
|
"end": "(\\})",
|
|
"endCaptures": {
|
|
"1": { "name": "punctuation.section.embedded.end.gram" }
|
|
},
|
|
"patterns": [ { "include": "#temperature-content" } ]
|
|
},
|
|
"references": {
|
|
"patterns": [
|
|
{
|
|
"name": "meta.reference.usage.gram",
|
|
"begin": "(&)(\\w+(?:\\s+\\w+)*)(\\{)",
|
|
"beginCaptures": {
|
|
"1": { "name": "keyword.control.reference.gram" },
|
|
"2": { "name": "entity.name.tag.reference.gram" },
|
|
"3": { "name": "punctuation.section.embedded.begin.gram" }
|
|
},
|
|
"end": "(\\})",
|
|
"endCaptures": {
|
|
"1": { "name": "punctuation.section.embedded.end.gram" }
|
|
},
|
|
"patterns": [ { "include": "#quantity-content" } ]
|
|
},
|
|
{
|
|
"name": "meta.reference.usage.bare.gram",
|
|
"match": "(&)([^\\s\\{\\[@#~^&:<,\\}]+)",
|
|
"captures": {
|
|
"1": { "name": "keyword.control.reference.gram" },
|
|
"2": { "name": "entity.name.tag.reference.gram" }
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"composites": {
|
|
"patterns": [
|
|
{
|
|
"name": "meta.composite.gram",
|
|
"begin": "(<@)([^\\{\\[@#~^&:<]+?)(\\{)",
|
|
"beginCaptures": {
|
|
"1": { "name": "keyword.control.ingredient.gram" },
|
|
"2": { "name": "entity.name.type.ingredient.gram" },
|
|
"3": { "name": "punctuation.section.embedded.begin.gram" }
|
|
},
|
|
"end": "(\\})",
|
|
"endCaptures": {
|
|
"1": { "name": "punctuation.section.embedded.end.gram" }
|
|
},
|
|
"patterns": [ { "include": "#quantity-content" } ]
|
|
},
|
|
{
|
|
"name": "meta.composite.bare.gram",
|
|
"match": "(<@)([^\\s\\{\\[@#~^&:<]+)",
|
|
"captures": {
|
|
"1": { "name": "keyword.control.ingredient.gram" },
|
|
"2": { "name": "entity.name.type.ingredient.gram" }
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"intermediate-decl": {
|
|
"match": "(->&)\\s*([^\\{\\s@#~^&]+(?:\\s+[^\\{\\s@#~^&]+)*)(?:\\{\\})?",
|
|
"captures": {
|
|
"1": { "name": "keyword.operator.arrow.gram" },
|
|
"2": { "name": "entity.name.tag.intermediate.gram" }
|
|
}
|
|
},
|
|
"temperature-content": {
|
|
"patterns": [
|
|
{
|
|
"comment": "Numeric value + a recognized unit (C/F, °C/°F, case-insensitive) — matches the compiler's own whitelist.",
|
|
"match": "(\\d+(?:\\.\\d+)?(?:/\\d+(?:\\.\\d+)?)?)\\s*(°?[CFcf])\\b",
|
|
"captures": {
|
|
"1": { "name": "constant.numeric.gram" },
|
|
"2": { "name": "keyword.other.unit.gram" }
|
|
}
|
|
},
|
|
{
|
|
"comment": "Numeric value + anything else — same INVALID_UNIT case the compiler warns on.",
|
|
"match": "(\\d+(?:\\.\\d+)?(?:/\\d+(?:\\.\\d+)?)?)\\s*([^\\d\\}]+)",
|
|
"captures": {
|
|
"1": { "name": "constant.numeric.gram" },
|
|
"2": { "name": "invalid.illegal.unit.gram" }
|
|
}
|
|
},
|
|
{
|
|
"match": "\\d+(?:\\.\\d+)?(?:/\\d+(?:\\.\\d+)?)?",
|
|
"name": "constant.numeric.gram"
|
|
},
|
|
{
|
|
"comment": "No leading digit — a semantic/qualitative temperature (e.g. 'medium heat'), not a unit.",
|
|
"match": "[^\\d\\}]+",
|
|
"name": "string.unquoted.descriptor.gram"
|
|
}
|
|
]
|
|
},
|
|
"quantity-content": {
|
|
"patterns": [
|
|
{
|
|
"match": "\\d+(?:\\.\\d+)?(?:/\\d+(?:\\.\\d+)?)?",
|
|
"name": "constant.numeric.gram"
|
|
},
|
|
{
|
|
"match": "(%)",
|
|
"name": "keyword.operator.percent.gram"
|
|
},
|
|
{
|
|
"match": "(@&|&|@)([^\\}]+)",
|
|
"captures": {
|
|
"1": { "name": "keyword.control.reference.gram" },
|
|
"2": { "name": "entity.name.tag.reference.gram" }
|
|
}
|
|
},
|
|
{
|
|
"match": "[^\\d%@&\\}]+",
|
|
"name": "keyword.other.unit.gram"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
}
|