tm-lang/sehn.tmLanguage.yaml

195 lines
5.1 KiB
YAML

# =====================================
# Meta
name: SEHN
uuid: 06947fd2-ab1f-4518-8f45-cc76b0294e5f
scopeName: source.sehn
fileTypes:
- sehn
# =====================================
# Folding
# Matches the start of a dict, list or textlist as
# long as the end does not follow on the same line, ignoring
# whitespace and one optional comma OR if the start character
# is at the end of the line.
foldingStartMarker: '^\s*[{\[\`](?!.*[}\]\`],?\s*$)|[{\[\`]\s*$'
# Matches the end of a dict, list or textlist as
# long as it is not preceeded by anything other
# than whitespace.
foldingStopMarker: '^\s*[}\]\`]'
# =====================================
# Root patterns
patterns:
- include: '#value'
# =====================================
# Common patterns
repository:
value:
patterns:
- include: '#bool'
- include: '#real'
- include: '#text'
- include: '#text-list'
- include: '#list'
- include: '#dict'
- include: '#tag'
- include: '#kind'
- include: '#comment'
- include: '#illegal'
# =====================================
bool:
name: constant.language.boolean.sehn
match: '\b(?:true|false)\b'
# =====================================
real:
name: constant.numeric.sehn
match: '\-?(?:(?:([0-9]+)(\.)([0-9]+))|(?:([1-9][0-9]*)(e)(-?)([1-9][0-9]+))|(?:([1-9][0-9]+)))'
# =====================================
text:
name: string.quoted.double.sehn
begin: '"'
end: '"'
beginCaptures:
0:
name: punctuation.definition.string.begin.sehn
endCaptures:
0:
name: punctuation.definition.string.end.sehn
patterns:
- include: '#text-content'
text-content:
patterns:
- name: constant.character.escape.sehn
match: '\\(?:["\\/bfnrt]|u[0-9a-fA-F]{4})'
- name: invalid.illegal.unrecognized-string-escape.sehn
match: '\\.'
text-list:
name: meta.structure.stringlist
begin: '\`'
end: '\`'
beginCaptures:
0:
name: punctuation.definition.stringlist.begin.sehn
endCaptures:
0:
name: punctuation.definition.stringlist.end.sehn
patterns:
- include: '#text'
- include: '#comment'
- include: '#illegal'
# =====================================
dict:
name: meta.structure.dictionary.sehn
begin: '\{'
end: '\}'
beginCaptures:
0:
name: punctuation.definition.dictionary.begin.sehn
endCaptures:
0:
name: punctuation.definition.dictionary.end.sehn
patterns:
- include: '#dict-key'
- include: '#comment'
- include: '#dict-val'
- name: invalid.illegal.expected-dictionary-separator.sehn
match: '[^\s\}]'
dict-key:
name: string.sehn support.type.property-name.sehn
begin: '"'
end: '"'
beginCaptures:
0:
name: punctuation.support.type.property-name.begin.sehn
endCaptures:
0:
name: punctuation.support.type.property-name.end.sehn
patterns:
- include: '#text-content'
dict-val:
name: meta.structure.dictionary.value.sehn
begin: ':'
end: '(,)|(?=\})'
beginCaptures:
0:
name: punctuation.separator.dictionary.key-value.sehn
endCaptures:
1:
name: punctuation.separator.dictionary.pair.sehn
patterns:
- include: '#value'
- name": invalid.illegal.expected-dictionary-separator.sehn
match": '[^\\s,]'
# =====================================
list:
name: meta.structure.list.sehn
begin: '\['
end: '\]'
beginCaptures:
0:
name: punctuation.definition.list.begin.sehn
endCaptures:
0:
name: punctuation.definition.list.end.sehn
patterns:
- name: punctuation.separator.list.sehn
match: ','
- include: '#value'
- name: invalid.illegal.expected-list-separator.sehn
match: '[^\s\]]'
# =====================================
tag:
name: meta.structure.tag
begin: '(?:(\b(?:[a-z](?:[a-zA-Z0-9]*\/?[a-zA-Z0-9]+)+)\b)|(\b(?:[A-Z](?:[a-zA-Z0-9]*\/?[a-zA-Z0-9]+)+)\b))(\()'
end: '(\))'
beginCaptures:
1:
name: storage.type.tag.standard.sehn
2:
name: storage.type.tag.application.sehn
3:
name: punctuation.definition.tag.begin.sehn
endCaptures:
0:
name: punctuation.definition.tag.end.sehn
patterns:
- include: '#value'
# =====================================
kind:
patterns:
- name: storage.type.base.sehn
match: '\b(?:none|bool|real|text|dict|list|kind)\b'
- name: storage.type.extension.standard.sehn
match: '\b(?:[a-z](?:[a-zA-Z0-9]*\/?[a-zA-Z0-9]+)+)\b'
- name: storage.type.extension.application.sehn
match: '\b(?:[A-Z](?:[a-zA-Z0-9]*\/?[a-zA-Z0-9]+)+)\b'
# =====================================
comment:
name: comment.line.sehn
match: '#.*'
illegal:
name: invalid.illegal.sehn
match: '[^\s]'