1 Star 0 Fork 0

zxxLang/ZxxSublime

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Zxx.sublime-syntax 8.99 KB
一键复制 编辑 原始数据 按行查看 历史
achun 提交于 2018-12-06 17:01 +08:00 . update
%YAML 1.2
---
# http://www.sublimetext.com/docs/3/syntax.html
# http://www.sublimetext.com/docs/3/scope_naming.html
name: zxx
file_extensions:
- zxx
first_line_match: ^#!\s*/.*\bzx(\d(\.\d)?)?\b
scope: source.zxx
variables:
identifier: '(?:[a-zA-Z]|\p{L})(?:-?(?:[a-zA-Z0-9]|\p{L}))*'
path: \x27[A-Za-z](?:[-./]?[A-Za-z0-9])*\x27
support_types: \b(?:any|b(?:ool|yte)|string|fn|rune|regex|f(?:32|64|128|loat)|u?int|[us](?:8|16|32|64|128)|time|error)(?=[^-])\b
overloading: '(?:>>>|<<|>>|[<>=!]=?|[~&|^+*/%-]|\.\.|\*\*|\[x\])'
contexts:
main:
- include: use
- include: pub-const
- include: pub-fn
- include: pub-type
- match: .*$
scope: comment.line.zxx
patterns:
- include: pop
- include: comment
- include: operator
- include: builtin
- include: literals
- include: brackets
- include: function-type
- include: local-function
- match: \b(extends|switch|case|struct|traits|out|echo|defer|if|for|else|elif|break|continue|try|throw|catch|yield)(?=[^-])\b
scope: keyword.control.zxx
- match: ({{identifier}})
scope: variable.other.zxx
pop:
- match: ^(?=[^\s])
pop: true
comment:
- match: \;
scope: punctuation.definition.comment.zxx
push:
- meta_scope: comment.line.zxx
- match: $
pop: true
- match: ^(\x20\x20)+;;.*$
scope: punctuation.definition.comment.begin.zxx
push:
- meta_scope: comment.block.zxx
- match: ^(\x20\x20)+;;.*$
scope: punctuation.definition.comment.end.zxx
pop: true
use:
- match: ^use\b
scope: storage.type.zxx
push:
- meta_scope: meta.namespace.zxx
# - include: pop
- include: comment
- include: patterns
pub-fn:
- match: ^((?:pub |extern )?fn)[ ]+(?:({{identifier}})([@.]))?(?:({{identifier}})|({{overloading}}))
captures:
1: storage.type.zxx
2: entity.name.type.zxx
3: punctuation.definition.zxx
4: entity.name.function.zxx
5: keyword.operator.zxx
push:
- meta_scope: meta.function.zxx
- include: patterns
pub-type:
- match: ^((?:pub )?(type|enum|trait))\s+({{identifier}})
captures:
1: storage.type.zxx
3: entity.name.type.zxx
push:
- meta_scope: meta.type.zxx
- include: patterns
pub-const:
- match: ^((?:pub )?const)\b(?:\x20+(@)((?:{{identifier}}\.)?(?:{{identifier}})))?
captures:
1: storage.type.zxx
2: punctuation.definition.zxx
3: variable.other.zxx
push:
- meta_scope: meta.constant.zxx
- include: patterns
parameter:
- match: \b(out|yield)[ ]+
scope: keyword.control.zxx
- match: \,
scope: punctuation.separator.zxx
- match: (;.*)?$
captures:
1: comment.line.zxx
- include: normal-type
- match: (?=\))
pop: true
parameters:
- match: \]
scope: punctuation.definition.parameter.end.zxx
pop: true
- include: parameter
function-type:
- match: \b(fn)[ ]*(\[)
captures:
1: storage.type.zxx
2: punctuation.definition.parameter.begin.zxx
push: parameters
local-function:
- match: \b(fn)[ ]+({{identifier}})[ ]*(\[)
captures:
1: storage.type.zxx
2: entity.name.function.zxx
3: punctuation.definition.parameter.begin.zxx
push: parameters
normal-type:
- include: compound-types
- include: function-type
- match: (?:({{support_types}})|(?:({{identifier}})(\.))?({{identifier}}))(?:\x20+({{identifier}}))?
captures:
1: support.type.zxx
3: punctuation.accessor.zxx
5: variable.parameter.zxx
brackets:
- match: \[
scope: punctuation.section.brackets.begin.zxx
- match: \]
scope: punctuation.section.brackets.end.zxx
- match: \(
scope: punctuation.section.group.begin.zxx
- match: \)
scope: punctuation.section.group.end.zxx
- match: \{
scope: punctuation.section.braces.begin.zxx
- match: \}
scope: punctuation.section.braces.end.zxx
operator:
- match: \.\.\.
scope: keyword.operator.spread.zxx
- match: \.\.
scope: keyword.operator.yielder.zxx
- match: \!|\?
scope: keyword.optional.zxx
- match: \.
scope: punctuation.accessor.zxx
- match: ((?:[-+*/&|^%:]|\*\*|<<|>>>|>>)?=)
scope: keyword.operator.assignment.zxx
- match: (\*{1,2}|[-+/%])
scope: keyword.operator.arithmetic.zxx
- match: (<<|>>>|>>|[&^|~])
scope: keyword.operator.bitwise.zxx
- match: ([<>]=?)
scope: keyword.operator.logical.zxx
- match: \,
scope: punctuation.separator.zxx
- match: \b(of)\b(?=[^-])
scope: keyword.control.zxx
- match: \b(is|not(in)?|un|and|or|in)\b(?=[^-])
scope: keyword.operator.word.zxx
builtin:
- match: _
scope: keyword.other.zxx
- match: \b(true|false|null|NaN|Infinity)\b(?=[^-]|$)
scope: keyword.other.constant.zxx
- match: \b(typeof|copy)\b(?=[^-]|$)
scope: support.function.zxx
- match: \b(this|super|iota)\b(?=[^-]|$)
scope: variable.language.zxx
- match: ({{support_types}})
scope: support.type.zxx
# time:
# - match: ((\d{4}(-?(0[1-9]|1[0-2])(-?(0[1-9]|[12][0-9]|3[01]))?)?)?((DST|T)?(\d\d(:?\d\d){0,2})?)?(\.\d{1,9})?(LSC)?(Z|[-+]\d\d(:?\d\d)?)?)
# scope: constant.other.time.zxx
literals:
- match: \b(\d+\.\d+\.\d+(-(\d+\.\d+\.\d+)?)?)\b
scope: constant.version.zxx
- match: \b0x[0-9a-fA-F](-?[0-9a-fA-F])*\b
scope: constant.numeric.integer.zxx
- match: \b0b[01](-?[01])*\b
scope: constant.numeric.integer.zxx
- match: \b(\d(-?\d)*\.\d(-?\d)*)(?:[eE][-+]?\d(-?\d)*)?\b
scope: constant.numeric.floating-point.zxx
- match: \b0f[0-9a-fA-F](-?[0-9a-fA-F])*\b
scope: constant.numeric.floating-point.zxx
- match: \b(\d(-?\d)*([eE][-+]?\d(-?\d)*)?)\b
scope: constant.numeric.integer.zxx
- match: \".?\"
scope: constant.other.rune.zxx
- match: (\$)[a-zA-Z0-9`~!@#$%^&*()_+={}\[\]|\\:;'"<>,.?/-]+
captures:
0: variable.other.zxx
1: punctuation.definition.variable.zxx
- match: \'
scope: punctuation.definition.string.begin.zxx
push:
- meta_scope: string.quoted.single.zxx
- match: \'
scope: punctuation.definition.string.end.zxx
pop: true
- match: ^[^ ]+
scope: invalid.illegal.missing-indentation.zxx
- include: escaped_char
- match: \`
scope: punctuation.definition.string.begin.zxx
push:
- meta_scope: string.template.zxx
- match: \`
scope: punctuation.definition.string.end.zxx
pop: true
- match: '{{'
scope: punctuation.definition.template-expression.begin.zxx
push:
- meta_scope: meta.template.expression.zxx
- match: '}}'
scope: punctuation.definition.template-expression.end.zxx
pop: true
- include: patterns
- match: ^$
- match: ^[^ ]+
scope: invalid.illegal.missing-indentation.zxx
- match: \\
scope: punctuation.definition.string.begin.zxx
push:
- meta_scope: string.regexp.zxx
- match: \\[pP]([A-Z]|\{[\d0-9]+\})
scope: constant.character.unicode-class.zxx
- match: \\.
scope: constant.character.escape.zxx
- match: \/
scope: punctuation.definition.string.end.zxx
pop: true
escaped_char:
- match: ^(\x20{2})+
scope: punctuation.indentation.zxx
- match: (\\x[0-9A-Fa-f]{2})|(\\")|(\\')|(\\\\)|(\\\/)|(\\b)|(\\f)|(\\n)|(\\r)|(\\t)
captures:
1: constant.character.escape.hex.zxx
2: constant.character.escape.double-quote.zxx
3: constant.character.escape.single-quote.zxx
4: constant.character.escape.reverse-solidus.zxx
5: constant.character.escape.solidus.zxx
6: constant.character.escape.backspace.zxx
7: constant.character.escape.formfeed.zxx
8: constant.character.escape.linefeed.zxx
9: constant.character.escape.carriage-return.zxx
10: constant.character.escape.horizontal-tab.zxx
- match: (\\u\{[0-9A-Fa-f]{1,6}\})|(\\u[0-9A-Fa-f]{4})
scope: constant.character.escape.unicode.zxx
- match: (\\[\x21-\x7E])
scope: constant.character.escape.visible.zxx
compound-types:
- match: \[
scope: punctuation.section.brackets.begin.zxx
push:
- match: (\])(?:\x20+({{identifier}}))?
captures:
1: punctuation.section.brackets.end.zxx
2: variable.parameter.zxx
pop: true
- match: \b(0x[0-9a-fA-F]+|\d+)\b
scope: constant.numeric.integer.zxx
- include: normal-type
- match: \{
scope: punctuation.section.braces.begin.zxx
push:
- match: (\})(?:\x20+({{identifier}}))?
captures:
1: punctuation.section.braces.end.zxx
2: variable.parameter.zxx
pop: true
- include: normal-type
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ZxxLang/ZxxSublime.git
git@gitee.com:ZxxLang/ZxxSublime.git
ZxxLang
ZxxSublime
ZxxSublime
master

搜索帮助