fix and improvements

This commit is contained in:
csh 2025-06-17 13:12:53 +08:00
parent 211dd22a4d
commit cbcff7d1b4
6 changed files with 112 additions and 71 deletions

View File

@ -49,7 +49,9 @@ f(a, b);
f(a: 1; b: 's'); f(a: 1; b: 's');
// 三元表达式(不应该有冲突) // 类变量声明,三元表达式(不应该有冲突)
a: string;
[weakref]b: MyClass;
a ? b : c; a ? b : c;
a ? b : c ? d : e; a ? b : c ? d : e;
@ -62,4 +64,3 @@ select distinct ["test"] from table where ['a'] = 1 end;
a := array(1, 2); a := array(1, 2);
b := array((1, 2), (3, 4)) b := array((1, 2), (3, 4))

View File

@ -11,47 +11,61 @@ set cpo&vim
syn case ignore syn case ignore
# Keywords # Keywords
syn keyword tslHeader program function procedure nextgroup=tslFuncName skipwhite # 程序结构声明
syn keyword tslBuiltinVar paramcount realparamcount params syn keyword tslProgramStructure program function procedure nextgroup=tslFuncName skipwhite
syn keyword tslBuiltinVar system thisfunction tslassigning syn keyword tslModuleStructure unit uses implementation interface initalization finalization
syn keyword tslBuiltinVar likeeps likeepsrate
syn keyword tslConditional else if # 数据类型
syn keyword tslStatement begin end then syn keyword tslPrimitiveType string integer boolean int64 real array
syn keyword tslStatement this with exit
syn keyword tslStatement weakref autoref namespace # 类型系统和面向对象
syn keyword tslInterface unit uses implementation interface initalization finalization syn keyword tslClassType type class fakeclass new
syn keyword tslRepeat for while do downto step until repeat to syn keyword tslClassModifier override overload virtual property self inherited
syn keyword tslBranch break continue syn keyword tslAccessModifier public protected private published
syn keyword tslConstructor create destroy operator
syn keyword tslReferenceModifier weakref autoref
syn keyword tslPropertyAccessor read write
# 变量和常量修饰符
syn keyword tslVariableModifier external const out var
syn keyword tslScopeModifier global static
# 控制流
syn keyword tslConditional if else then case of
syn keyword tslLoop for while do downto step until repeat to
syn keyword tslBranch break continue goto label exit
syn keyword tslReturn return debugreturn debugrunenv debugrunenvdo syn keyword tslReturn return debugreturn debugrunenv debugrunenvdo
syn keyword tslLabel case of goto label
syn keyword tslOperator write read # 程序块结构
syn keyword tslOperator union minus union2 syn keyword tslBlock begin end with
syn keyword tslShiftOperator ror rol shr shl syn keyword tslNamespace namespace
# 异常处理
syn keyword tslException except raise try finally exceptobject
# 运算符
syn keyword tslLogicOperator and in is not or syn keyword tslLogicOperator and in is not or
syn keyword tslArithmOperator div mod syn keyword tslArithmOperator div mod
syn keyword tslBitwiseOperator ror rol shr shl
syn keyword tslSetOperator union minus union2
# SQL相关关键字
syn keyword tslSqlCommand select vselect sselect update delete mselect
syn keyword tslSqlClause sqlin from where group by order distinct join
syn keyword tslSqlOperator like on set
# 系统相关
syn keyword tslSystemKeyword setuid sudo
syn keyword tslCallingConvention cdecl pascal stdcall safecall fastcall register
# 内置变量
syn keyword tslBuiltinVar paramcount realparamcount params
syn keyword tslBuiltinVar system tslassigning
syn keyword tslBuiltinVar likeeps likeepsrate
# 内置函数
syn keyword tslBuiltinFunction echo mtic mtoc
syn keyword tslException except raise try finally exceptobject # 常量
syn keyword tslBoolean false true syn keyword tslBoolean false true
syn keyword tslNil nil syn keyword tslNull nil
syn keyword tslMathConstant inf nan
syn keyword tslType string integer boolean int64 real array
syn keyword tslBuiltins echo mtic mtoc this
syn keyword tslBuiltins inf nan
syn keyword tslBuiltins external const out var
syn keyword tslSql select vselect sselect update delete mselect
syn keyword tslSqlOperator sqlin from where group by like order
syn keyword tslSqlOperator distinct join on set
syn keyword tslOther setuid sudo
syn keyword tslCallFunc cdecl pascal stdcall safecall fastcall register
syn keyword tslScope global static
syn keyword tslClass type class fakeclass new
syn keyword tslClassModifier override overload virtual property self inherited
syn keyword tslConstruct create destroy operator
syn keyword tslAccess public protected private published
syn keyword tslTodo FIXME NOTE NOTES TODO XXX contained syn keyword tslTodo FIXME NOTE NOTES TODO XXX contained
# Function definitions # Function definitions
@ -73,8 +87,8 @@ syn match tslReturnType ':\s*[^;]*' contained contains=tslColon
syn match tslParamSep '[;,]' contained syn match tslParamSep '[;,]' contained
syn match tslColon ':' contained syn match tslColon ':' contained
syn match tslVarDecl '^\s*\h\w*\s*:=\@!\s*[^;?]*;' contains=tslVarName,tslVarType syn match tslVarDecl '\(?\s*\)\@<!\h\w*\s*:=\@!\s*[^;?]*;' contains=tslVarName,tslVarType
syn match tslVarName '^\s*\h\w*\ze\s*:=\@!' contained syn match tslVarName '\(?\s*\)\@<!\h\w*\ze\s*:=\@!' contained
syn match tslVarType ':=\@!\s*[^;?]*' contained contains=tslColon syn match tslVarType ':=\@!\s*[^;?]*' contained contains=tslColon
# 匹配完整的属性链 # 匹配完整的属性链
@ -132,11 +146,44 @@ syn match tslNumber '\<\d\+\.\%([eE][+-]\=\d\+\)\=[jJ]\=\%(\W\|$\)\@='
syn match tslNumber '\%(^\|\W\)\zs\d*\.\d\+\%([eE][+-]\=\d\+\)\=[jJ]\=\>' syn match tslNumber '\%(^\|\W\)\zs\d*\.\d\+\%([eE][+-]\=\d\+\)\=[jJ]\=\>'
# Highlight links # Highlight links
hi def link tslProgramStructure Statement
hi def link tslModuleStructure Statement
hi def link tslPrimitiveType Type
hi def link tslClassType Statement
hi def link tslClassModifier Identifier
hi def link tslAccessModifier Statement
hi def link tslPropertyAccessor Operator
hi def link tslConstructor Special
hi def link tslVariableModifier StorageClass
hi def link tslScopeModifier StorageClass
hi def link tslReferenceModifier StorageClass
hi def link tslConditional Conditional
hi def link tslLoop Repeat
hi def link tslBranch Conditional
hi def link tslReturn Statement
hi def link tslBlock Statement
hi def link tslNamespace Statement
hi def link tslException Exception
hi def link tslLogicOperator Operator
hi def link tslArithmOperator Operator
hi def link tslBitwiseOperator Operator
hi def link tslSetOperator Operator
hi def link tslSqlCommand Keyword
hi def link tslSqlClause Special
hi def link tslSqlOperator Special
hi def link tslSystemKeyword Special
hi def link tslCallingConvention Special
hi def link tslBuiltinVar Constant
hi def link tslBuiltinFunction Constant
hi def link tslBoolean Boolean
hi def link tslNull Constant
hi def link tslMathConstant Number
# 其他元素的高亮链接保持不变
hi def link tslClassName Type hi def link tslClassName Type
hi def link tslDot Operator hi def link tslDot Operator
hi def link tslPropertyName Special hi def link tslPropertyName Special
hi def link tslHeader Statement
hi def link tslFuncName Function hi def link tslFuncName Function
hi def link tslTypeNameInFunc Type hi def link tslTypeNameInFunc Type
hi def link tslParam Identifier hi def link tslParam Identifier
@ -153,38 +200,14 @@ hi def link tslCallParam Identifier
hi def link tslCallValue Type hi def link tslCallValue Type
hi def link tslCallSep Delimiter hi def link tslCallSep Delimiter
hi def link tslBuiltinVar Constant
hi def link tslConditional Conditional
hi def link tslStatement Statement
hi def link tslInterface Statement
hi def link tslRepeat Repeat
hi def link tslBranch Conditional
hi def link tslReturn Statement
hi def link tslLabel Label
hi def link tslOperator Operator hi def link tslOperator Operator
hi def link tslDelimiter Delimiter hi def link tslDelimiter Delimiter
hi def link tslException Exception
hi def link tslBoolean Boolean
hi def link tslNil Constant
hi def link tslBuiltins Constant
hi def link tslShiftOperator Operator
hi def link tslLogicOperator Operator
hi def link tslArithmOperator Operator
hi def link tslSql Keyword
hi def link tslSqlOperator Special
hi def link tslOther Special
hi def link tslScope StorageClass
hi def link tslClass Statement
hi def link tslClassModifier Identifier
hi def link tslConstruct Special
hi def link tslAccess Statement
hi def link tslTodo Todo hi def link tslTodo Todo
hi def link tslComment Comment hi def link tslComment Comment
hi def link tslString String hi def link tslString String
hi def link tslRawString String hi def link tslRawString String
hi def link tslQuotes String hi def link tslQuotes String
hi def link tslNumber Number hi def link tslNumber Number
hi def link tslType Type
b:current_syntax = "tsl" b:current_syntax = "tsl"

View File

@ -2,6 +2,11 @@
Notable changes to the `TSL` extension will be documented in this file. Notable changes to the `TSL` extension will be documented in this file.
## [1.4.0]: 2025-6-17
- 修复:`[weakref]typename: type;`时,变量和类型高亮失效
- 调整关键字分类
## [1.3.0]: 2025-06-17 ## [1.3.0]: 2025-06-17
- 支持关键字大小写不敏感 - 支持关键字大小写不敏感

View File

@ -1,7 +1,7 @@
{ {
"name": "tsl-devkit", "name": "tsl-devkit",
"displayName": "TSL", "displayName": "TSL",
"version": "1.3.0", "version": "1.4.0",
"description": "TSL syntax highlighter support for VSCode.", "description": "TSL syntax highlighter support for VSCode.",
"publisher": "csh", "publisher": "csh",
"homepage": "https://git.mytsl.cn/csh/tsl-devkit", "homepage": "https://git.mytsl.cn/csh/tsl-devkit",

View File

@ -189,7 +189,7 @@
}, },
"variable-declarations": { "variable-declarations": {
"name": "meta.variable.declaration.tsl", "name": "meta.variable.declaration.tsl",
"match": "^\\s*(\\w+)\\s*(:)(?!=)\\s*([^;?]*)(;)?", "match": "(?<!\\?\\s*)(\\w+)\\s*(:)(?!=)\\s*([^;?]*)(;)?",
"captures": { "captures": {
"1": { "1": {
"name": "variable.other.declaration.tsl" "name": "variable.other.declaration.tsl"
@ -412,6 +412,10 @@
"name": "storage.modifier.access.tsl", "name": "storage.modifier.access.tsl",
"match": "(?i)\\b(public|protected|private|published)\\b" "match": "(?i)\\b(public|protected|private|published)\\b"
}, },
{
"name": "keyword.other.property-accessor.tsl",
"match": "(?i)\\b(read|write)\\b"
},
{ {
"name": "keyword.other.constructor.tsl", "name": "keyword.other.constructor.tsl",
"match": "(?i)\\b(create|destroy|operator)\\b" "match": "(?i)\\b(create|destroy|operator)\\b"
@ -438,7 +442,15 @@
}, },
{ {
"name": "keyword.control.block.tsl", "name": "keyword.control.block.tsl",
"match": "(?i)\\b(begin|end|this|with|weakref|autoref|namespace)\\b" "match": "(?i)\\b(begin|end|with)\\b"
},
{
"name": "storage.modifier.reference.tsl",
"match": "(?i)\\b(weakref|autoref)\\b"
},
{
"name": "keyword.other.namespace.tsl",
"match": "(?i)\\bnamespace\\b"
}, },
{ {
"name": "keyword.control.exception.tsl", "name": "keyword.control.exception.tsl",
@ -460,10 +472,6 @@
"name": "keyword.operator.set.tsl", "name": "keyword.operator.set.tsl",
"match": "(?i)\\b(union|minus|union2)\\b" "match": "(?i)\\b(union|minus|union2)\\b"
}, },
{
"name": "keyword.operator.io.tsl",
"match": "(?i)\\b(write|read)\\b"
},
{ {
"name": "keyword.control.sql.tsl", "name": "keyword.control.sql.tsl",
"match": "(?i)\\b(select|vselect|sselect|update|delete|mselect)\\b" "match": "(?i)\\b(select|vselect|sselect|update|delete|mselect)\\b"
@ -486,16 +494,20 @@
}, },
{ {
"name": "variable.language.builtin.tsl", "name": "variable.language.builtin.tsl",
"match": "(?i)\\b(paramcount|realparamcount|params|system|thisfunction|tslassigning|likeeps|likeepsrate)\\b" "match": "(?i)\\b(paramcount|realparamcount|params|system|tslassigning|likeeps|likeepsrate)\\b"
}, },
{ {
"name": "support.function.builtin.tsl", "name": "support.function.builtin.tsl",
"match": "(?i)\\b(echo|mtic|mtoc|this|inf|nan)\\b" "match": "(?i)\\b(echo|mtic|mtoc)\\b"
}, },
{ {
"name": "constant.language.boolean.tsl", "name": "constant.language.boolean.tsl",
"match": "(?i)\\b(false|true)\\b" "match": "(?i)\\b(false|true)\\b"
}, },
{
"name": "constant.language.math.tsl",
"match": "(?i)\\b(inf|nan)\\b"
},
{ {
"name": "constant.language.null.tsl", "name": "constant.language.null.tsl",
"match": "(?i)\\bnil\\b" "match": "(?i)\\bnil\\b"