Skip to content

Instantly share code, notes, and snippets.

@breck7
Created October 29, 2019 01:40
Show Gist options
  • Save breck7/d9be31b6c31928b9fc02d45f91c7c91a to your computer and use it in GitHub Desktop.
Save breck7/d9be31b6c31928b9fc02d45f91c7c91a to your computer and use it in GitHub Desktop.
Custom Sublime Syntax Autogenerated from https://jtree.treenotation.org/designer/#standard%20grammar
%YAML 1.2
---
name: grammar
file_extensions: [grammar,gram]
scope: source.grammar
variables:
abstractConstantCell: '[^ ]*'
javascriptSafeAlphaNumericIdentifierCell: '[a-zA-Z0-9_]+'
anyCell: '[^ ]*'
baseNodeTypesCell: '(?:errorNode|blobNode)'
booleanCell: '(?:false|true)'
cellParserCell: '(?:postfix|omnifix|prefix)'
cellPropertyNameCell: '[^ ]*'
cellTypeIdCell: '[a-zA-Z0-9_]+'
constantIdentifierCell: '[a-zA-Z]\w+'
constructorFilePathCell: '[^ ]*'
enumOptionCell: '[^ ]*'
cellExampleCell: '[^ ]*'
extraCell: '[^ ]*'
fileExtensionCell: '[a-zA-Z0-9]+'
floatCell: '\-?[0-9]*\.?[0-9]*'
intCell: '\-?[0-9]+'
javascriptCodeCell: '[^ ]*'
lowercaseCell: '[a-z]+'
nodeTypeIdCell: '[a-zA-Z0-9_]+'
propertyKeywordCell: '[^ ]*'
regexCell: '[^ ]*'
reservedWordCell: '[^ ]*'
scopeNameCell: '(?:punctuation.section.interpolation.begin|punctuation.section.interpolation.end|constant.numeric.integer.hexadecimal|punctuation.definition.generic.begin|punctuation.definition.string.begin|constant.numeric.complex.imaginary|constant.numeric.float.hexadecimal|punctuation.definition.generic.end|punctuation.section.brackets.begin|punctuation.separator.continuation|punctuation.definition.annotation|punctuation.definition.string.end|constant.numeric.integer.decimal|entity.name.function.constructor|punctuation.section.braces.begin|punctuation.section.brackets.end|punctuation.section.parens.begin|constant.numeric.integer.binary|entity.name.function.destructor|punctuation.definition.variable|punctuation.section.block.begin|punctuation.section.group.begin|source.language-suffix.embedded|constant.numeric.float.decimal|constant.numeric.integer.octal|constant.numeric.integer.other|entity.name.class.forward-decl|punctuation.definition.comment|punctuation.definition.keyword|punctuation.section.braces.end|punctuation.section.parens.end|constant.numeric.complex.real|constant.numeric.float.binary|punctuation.section.block.end|punctuation.section.group.end|keyword.declaration.interface|constant.numeric.float.octal|constant.numeric.float.other|entity.other.inherited-class|keyword.declaration.function|comment.block.documentation|entity.other.attribute-name|keyword.control.conditional|keyword.operator.arithmetic|keyword.operator.assignment|constant.other.placeholder|meta.annotation.identifier|meta.annotation.parameters|keyword.declaration.struct|constant.character.escape|meta.function.return-type|keyword.declaration.class|keyword.declaration.trait|keyword.declaration.union|constant.numeric.complex|constant.numeric.integer|keyword.operator.bitwise|keyword.operator.logical|meta.function.parameters|keyword.declaration.type|keyword.declaration.enum|keyword.declaration.impl|variable.other.readwrite|variable.other.constant|constant.numeric.float|keyword.control.import|markup.list.unnumbered|punctuation.terminator|storage.type.interface|entity.name.interface|entity.name.namespace|keyword.operator.word|markup.underline.link|punctuation.separator|storage.type.function|variable.other.member|entity.name.constant|entity.name.function|markup.list.numbered|punctuation.accessor|string.quoted.double|string.quoted.single|string.quoted.triple|entity.name.section|keyword.declaration|storage.type.struct|string.quoted.other|variable.annotation|entity.name.struct|invalid.deprecated|meta.function-call|meta.interpolation|storage.type.class|storage.type.trait|storage.type.union|variable.parameter|constant.language|entity.name.class|entity.name.label|entity.name.trait|entity.name.union|markup.raw.inline|meta.preprocessor|storage.type.enum|storage.type.impl|variable.function|variable.language|constant.numeric|entity.name.enum|entity.name.impl|entity.name.type|keyword.operator|markup.raw.block|markup.underline|storage.modifier|support.constant|support.function|entity.name.tag|invalid.illegal|keyword.control|markup.inserted|meta.annotation|string.unquoted|constant.other|markup.deleted|markup.heading|meta.interface|meta.namespace|meta.paragraph|support.module|variable.other|comment.block|keyword.other|markup.italic|meta.brackets|meta.function|meta.toc-list|string.regexp|support.class|comment.line|markup.other|markup.quote|meta.generic|storage.type|support.type|entity.name|markup.bold|meta.braces|meta.parens|meta.string|meta.struct|punctuation|meta.block|meta.class|meta.group|meta.trait|meta.union|meta.enum|meta.impl|meta.path|meta.type|text.html|constant|meta.tag|text.xml|variable|comment|invalid|keyword|storage|support|entity|markup|source|string|meta|text)'
scriptUrlCell: '[^ ]*'
semanticVersionCell: '[0-9]+\.[0-9]+\.[0-9]+'
stringCell: '[^ ]*'
tagCell: '[^ ]*'
todoCell: '[^ ]*'
toolingDirectiveCell: '[^ ]*'
wordCell: '[a-zA-Z]+'
exampleAnyCell: '[^ ]*'
contexts:
main:
- include: 'grammarNode'
- include: 'closeChildrenNode'
- include: 'indentCharacterNode'
- include: 'catchAllCellDelimiterNode'
- include: 'openChildrenNode'
- include: 'stringTemplateNode'
- include: 'joinChildrenWithNode'
- include: 'booleanNode'
- include: 'floatNode'
- include: 'intNode'
- include: 'stringNode'
- include: 'compilesToNode'
- include: 'extensionsNode'
- include: 'versionNode'
- include: 'abstractNode'
- include: 'baseNodeTypeNode'
- include: 'catchAllCellTypeNode'
- include: 'cellParserNode'
- include: 'catchAllNodeTypeNode'
- include: 'cellsNode'
- include: 'compilerNode'
- include: 'descriptionNode'
- include: 'exampleNode'
- include: 'extendsNodeTypeNode'
- include: 'frequencyNode'
- include: 'inScopeNode'
- include: 'javascriptNode'
- include: 'cruxNode'
- include: 'patternNode'
- include: 'requiredNode'
- include: 'singleNode'
- include: 'tagsNode'
- include: 'catchAllErrorNode'
- include: 'catchAllExampleLineNode'
- include: 'catchAllJavascriptCodeLineNode'
- include: 'catchAllMultilineStringConstantNode'
- include: 'cellTypeDefinitionNode'
- include: 'enumFromCellTypesNode'
- include: 'enumNode'
- include: 'examplesNode'
- include: 'highlightScopeNode'
- include: 'rootFlagNode'
- include: 'nodeTypeDefinitionNode'
- include: 'regexNode'
- include: 'reservedWordsNode'
- include: 'todoNode'
- include: 'toolingNode'
- include: 'extendsCellTypeNode'
'grammarNode':
- match: undefined
scope: source.grammarNode
'closeChildrenNode':
- match: '^ *closeChildren(?: |$)'
scope: constant.language.closeChildrenNode
push:
- match: ({{propertyKeywordCell}})? ?({{anyCell}})?
captures:
1: constant.language.propertyKeywordCell
2: source.anyCell
- match: $
pop: true
'indentCharacterNode':
- match: '^ *indentCharacter(?: |$)'
scope: constant.language.indentCharacterNode
push:
- match: ({{propertyKeywordCell}})? ?({{anyCell}})?
captures:
1: constant.language.propertyKeywordCell
2: source.anyCell
- match: $
pop: true
'catchAllCellDelimiterNode':
- match: '^ *catchAllCellDelimiter(?: |$)'
scope: constant.language.catchAllCellDelimiterNode
push:
- match: ({{propertyKeywordCell}})? ?({{anyCell}})?
captures:
1: constant.language.propertyKeywordCell
2: source.anyCell
- match: $
pop: true
'openChildrenNode':
- match: '^ *openChildren(?: |$)'
scope: constant.language.openChildrenNode
push:
- match: ({{propertyKeywordCell}})? ?({{anyCell}})?
captures:
1: constant.language.propertyKeywordCell
2: source.anyCell
- match: $
pop: true
'stringTemplateNode':
- match: '^ *stringTemplate(?: |$)'
scope: constant.language.stringTemplateNode
push:
- match: ({{propertyKeywordCell}})? ?({{anyCell}})?
captures:
1: constant.language.propertyKeywordCell
2: source.anyCell
- match: $
pop: true
'joinChildrenWithNode':
- match: '^ *joinChildrenWith(?: |$)'
scope: constant.language.joinChildrenWithNode
push:
- match: ({{propertyKeywordCell}})? ?({{anyCell}})?
captures:
1: constant.language.propertyKeywordCell
2: source.anyCell
- match: $
pop: true
'booleanNode':
- match: '^ *boolean(?: |$)'
scope: constant.language.booleanNode
push:
- match: ({{propertyKeywordCell}})? ?({{constantIdentifierCell}})? ?({{booleanCell}})?
captures:
1: constant.language.propertyKeywordCell
2: constant.other.constantIdentifierCell
3: constant.numeric.booleanCell
- match: $
pop: true
'floatNode':
- match: '^ *float(?: |$)'
scope: constant.language.floatNode
push:
- match: ({{propertyKeywordCell}})? ?({{constantIdentifierCell}})? ?({{floatCell}})?
captures:
1: constant.language.propertyKeywordCell
2: constant.other.constantIdentifierCell
3: constant.numeric.floatCell
- match: $
pop: true
'intNode':
- match: '^ *int(?: |$)'
scope: constant.language.intNode
push:
- match: ({{propertyKeywordCell}})? ?({{constantIdentifierCell}})? ?({{intCell}})?
captures:
1: constant.language.propertyKeywordCell
2: constant.other.constantIdentifierCell
3: constant.numeric.intCell
- match: $
pop: true
'stringNode':
- match: '^ *string(?: |$)'
scope: constant.language.stringNode
push:
- match: ({{propertyKeywordCell}})? ?({{constantIdentifierCell}})? ?({{stringCell}})?
captures:
1: constant.language.propertyKeywordCell
2: constant.other.constantIdentifierCell
3: string.stringCell
- match: $
pop: true
'compilesToNode':
- match: '^ *compilesTo(?: |$)'
scope: constant.language.compilesToNode
push:
- match: ({{propertyKeywordCell}})? ?({{fileExtensionCell}})?
captures:
1: constant.language.propertyKeywordCell
2: string.fileExtensionCell
- match: $
pop: true
'extensionsNode':
- match: '^ *extensions(?: |$)'
scope: constant.language.extensionsNode
push:
- match: ({{propertyKeywordCell}})? ?({{fileExtensionCell}})?
captures:
1: constant.language.propertyKeywordCell
2: string.fileExtensionCell
- match: $
pop: true
'versionNode':
- match: '^ *version(?: |$)'
scope: constant.language.versionNode
push:
- match: ({{propertyKeywordCell}})? ?({{semanticVersionCell}})?
captures:
1: constant.language.propertyKeywordCell
2: constant.numeric.semanticVersionCell
- match: $
pop: true
'abstractNode':
- match: '^ *abstract(?: |$)'
scope: constant.language.abstractNode
push:
- match: ({{propertyKeywordCell}})?
captures:
1: constant.language.propertyKeywordCell
- match: $
pop: true
'baseNodeTypeNode':
- match: '^ *baseNodeType(?: |$)'
scope: constant.language.baseNodeTypeNode
push:
- match: ({{propertyKeywordCell}})? ?({{baseNodeTypesCell}})?
captures:
1: constant.language.propertyKeywordCell
2: variable.parameter.baseNodeTypesCell
- match: $
pop: true
'catchAllCellTypeNode':
- match: '^ *catchAllCellType(?: |$)'
scope: constant.language.catchAllCellTypeNode
push:
- match: ({{propertyKeywordCell}})? ?({{cellTypeIdCell}})?
captures:
1: constant.language.propertyKeywordCell
2: storage.cellTypeIdCell
- match: $
pop: true
'cellParserNode':
- match: '^ *cellParser(?: |$)'
scope: constant.language.cellParserNode
push:
- match: ({{propertyKeywordCell}})? ?({{cellParserCell}})?
captures:
1: constant.language.propertyKeywordCell
2: constant.numeric.cellParserCell
- match: $
pop: true
'catchAllNodeTypeNode':
- match: '^ *catchAllNodeType(?: |$)'
scope: constant.language.catchAllNodeTypeNode
push:
- match: ({{propertyKeywordCell}})? ?({{nodeTypeIdCell}})?
captures:
1: constant.language.propertyKeywordCell
2: variable.parameter.nodeTypeIdCell
- match: $
pop: true
'cellsNode':
- match: '^ *cells(?: |$)'
scope: constant.language.cellsNode
push:
- match: ({{propertyKeywordCell}})? ?({{cellTypeIdCell}})?
captures:
1: constant.language.propertyKeywordCell
2: storage.cellTypeIdCell
- match: $
pop: true
'compilerNode':
- match: '^ *compiler(?: |$)'
scope: constant.language.compilerNode
push:
- match: ({{propertyKeywordCell}})?
captures:
1: constant.language.propertyKeywordCell
- match: $
pop: true
'descriptionNode':
- match: '^ *description(?: |$)'
scope: constant.language.descriptionNode
push:
- match: ({{propertyKeywordCell}})? ?({{stringCell}})?
captures:
1: constant.language.propertyKeywordCell
2: string.stringCell
- match: $
pop: true
'exampleNode':
- match: '^ *example(?: |$)'
scope: constant.language.exampleNode
push:
- match: ({{propertyKeywordCell}})? ?({{exampleAnyCell}})?
captures:
1: constant.language.propertyKeywordCell
2: comment.exampleAnyCell
- match: $
pop: true
'extendsNodeTypeNode':
- match: '^ *extends(?: |$)'
scope: constant.language.extendsNodeTypeNode
push:
- match: ({{propertyKeywordCell}})? ?({{nodeTypeIdCell}})?
captures:
1: constant.language.propertyKeywordCell
2: variable.parameter.nodeTypeIdCell
- match: $
pop: true
'frequencyNode':
- match: '^ *frequency(?: |$)'
scope: constant.language.frequencyNode
push:
- match: ({{propertyKeywordCell}})? ?({{floatCell}})?
captures:
1: constant.language.propertyKeywordCell
2: constant.numeric.floatCell
- match: $
pop: true
'inScopeNode':
- match: '^ *inScope(?: |$)'
scope: constant.language.inScopeNode
push:
- match: ({{propertyKeywordCell}})? ?({{nodeTypeIdCell}})?
captures:
1: constant.language.propertyKeywordCell
2: variable.parameter.nodeTypeIdCell
- match: $
pop: true
'javascriptNode':
- match: '^ *javascript(?: |$)'
scope: constant.language.javascriptNode
push:
- match: ({{propertyKeywordCell}})?
captures:
1: constant.language.propertyKeywordCell
- match: $
pop: true
'cruxNode':
- match: '^ *crux(?: |$)'
scope: constant.language.cruxNode
push:
- match: ({{propertyKeywordCell}})? ?({{stringCell}})?
captures:
1: constant.language.propertyKeywordCell
2: string.stringCell
- match: $
pop: true
'patternNode':
- match: '^ *pattern(?: |$)'
scope: constant.language.patternNode
push:
- match: ({{propertyKeywordCell}})? ?({{regexCell}})?
captures:
1: constant.language.propertyKeywordCell
2: string.regexp.regexCell
- match: $
pop: true
'requiredNode':
- match: '^ *required(?: |$)'
scope: constant.language.requiredNode
push:
- match: ({{propertyKeywordCell}})?
captures:
1: constant.language.propertyKeywordCell
- match: $
pop: true
'singleNode':
- match: '^ *single(?: |$)'
scope: constant.language.singleNode
push:
- match: ({{propertyKeywordCell}})?
captures:
1: constant.language.propertyKeywordCell
- match: $
pop: true
'tagsNode':
- match: '^ *tags(?: |$)'
scope: constant.language.tagsNode
push:
- match: ({{propertyKeywordCell}})? ?({{tagCell}})?
captures:
1: constant.language.propertyKeywordCell
2: string.tagCell
- match: $
pop: true
'catchAllErrorNode':
- match: undefined
scope: source.catchAllErrorNode
'catchAllExampleLineNode':
- match: undefined
scope: comment.catchAllExampleLineNode
push:
- match: ({{exampleAnyCell}})? ?({{exampleAnyCell}})?
captures:
1: comment.exampleAnyCell
2: comment.exampleAnyCell
- match: $
pop: true
'catchAllJavascriptCodeLineNode':
- match: undefined
scope: source.catchAllJavascriptCodeLineNode
push:
- match: ({{javascriptCodeCell}})?
captures:
1: source.javascriptCodeCell
- match: $
pop: true
'catchAllMultilineStringConstantNode':
- match: undefined
scope: string.catchAllMultilineStringConstantNode
push:
- match: ({{stringCell}})? ?({{stringCell}})?
captures:
1: string.stringCell
2: string.stringCell
- match: $
pop: true
'cellTypeDefinitionNode':
- match: '^[a-zA-Z0-9_]+Cell$'
scope: storage.cellTypeDefinitionNode
push:
- match: ({{cellTypeIdCell}})?
captures:
1: storage.cellTypeIdCell
- match: $
pop: true
'enumFromCellTypesNode':
- match: '^ *enumFromCellTypes(?: |$)'
scope: variable.parameter.enumFromCellTypesNode
push:
- match: ({{cellPropertyNameCell}})? ?({{cellTypeIdCell}})?
captures:
1: variable.parameter.cellPropertyNameCell
2: storage.cellTypeIdCell
- match: $
pop: true
'enumNode':
- match: '^ *enum(?: |$)'
scope: variable.parameter.enumNode
push:
- match: ({{cellPropertyNameCell}})? ?({{enumOptionCell}})?
captures:
1: variable.parameter.cellPropertyNameCell
2: string.enumOptionCell
- match: $
pop: true
'examplesNode':
- match: '^ *examples(?: |$)'
scope: variable.parameter.examplesNode
push:
- match: ({{cellPropertyNameCell}})? ?({{cellExampleCell}})?
captures:
1: variable.parameter.cellPropertyNameCell
2: string.cellExampleCell
- match: $
pop: true
'highlightScopeNode':
- match: '^ *highlightScope(?: |$)'
scope: constant.language.highlightScopeNode
push:
- match: ({{propertyKeywordCell}})? ?({{scopeNameCell}})?
captures:
1: constant.language.propertyKeywordCell
2: string.scopeNameCell
- match: $
pop: true
'rootFlagNode':
- match: '^ *root(?: |$)'
scope: constant.language.rootFlagNode
push:
- match: ({{propertyKeywordCell}})?
captures:
1: constant.language.propertyKeywordCell
- match: $
pop: true
'nodeTypeDefinitionNode':
- match: '^[a-zA-Z0-9_]+Node$'
scope: variable.parameter.nodeTypeDefinitionNode
push:
- match: ({{nodeTypeIdCell}})?
captures:
1: variable.parameter.nodeTypeIdCell
- match: $
pop: true
'regexNode':
- match: '^ *regex(?: |$)'
scope: variable.parameter.regexNode
push:
- match: ({{cellPropertyNameCell}})? ?({{regexCell}})?
captures:
1: variable.parameter.cellPropertyNameCell
2: string.regexp.regexCell
- match: $
pop: true
'reservedWordsNode':
- match: '^ *reservedWords(?: |$)'
scope: variable.parameter.reservedWordsNode
push:
- match: ({{cellPropertyNameCell}})? ?({{reservedWordCell}})?
captures:
1: variable.parameter.cellPropertyNameCell
2: string.reservedWordCell
- match: $
pop: true
'todoNode':
- match: '^ *todo(?: |$)'
scope: comment.todoNode
push:
- match: ({{todoCell}})? ?({{todoCell}})?
captures:
1: comment.todoCell
2: comment.todoCell
- match: $
pop: true
'toolingNode':
- match: '^ *tooling(?: |$)'
scope: comment.toolingNode
push:
- match: ({{toolingDirectiveCell}})? ?({{toolingDirectiveCell}})?
captures:
1: comment.toolingDirectiveCell
2: comment.toolingDirectiveCell
- match: $
pop: true
'extendsCellTypeNode':
- match: '^ *extends(?: |$)'
scope: constant.language.extendsCellTypeNode
push:
- match: ({{propertyKeywordCell}})? ?({{cellTypeIdCell}})?
captures:
1: constant.language.propertyKeywordCell
2: storage.cellTypeIdCell
- match: $
pop: true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment