Skip to content

Commit dd61480

Browse files
committed
Update syntax rules.
1 parent 3d7ce85 commit dd61480

File tree

3 files changed

+108
-121
lines changed

3 files changed

+108
-121
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
"private": true,
44
"displayName": "Rhai Language Support",
55
"description": "Highlight and formatter for Rhai",
6-
"publisher": "aster",
6+
"publisher": "rhaiscript",
77
"version": "0.5.0",
88
"icon": "assets/icon.png",
99
"repository": {
1010
"type": "git",
11-
"url": "https://github.com/GalAster/vscode-rhai.git"
11+
"url": "https://github.com/rhaiscript/vscode-rhai.git"
1212
},
1313
"categories": [
1414
"Programming Languages",

syntax/rhai.YAML-tmLanguage

Lines changed: 48 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -38,21 +38,21 @@ repository:
3838
'1': {name: punctuation.definition.comment.line.rhai}
3939
literal:
4040
patterns:
41-
- include: '#keywords'
41+
- include: '#keyword'
4242
- include: '#string'
4343
- include: '#number'
4444
- include: '#symbol'
4545
- include: '#variable'
4646
- include: '#dict'
4747
- include: '#operators'
48-
keywords:
48+
keyword:
4949
patterns:
5050
- match: \b(let|const)\b
5151
name: keyword.control.definition.rhai
5252
- match: \b(fn|Fn)\b
53-
name: keyword.control.definition.function.rhai
54-
- match: \b(import|export|as)\b
55-
name: keyword.control.import.rhai
53+
name: keyword.control.definition.function.rhai storage.type.function.rhai keyword.declaration.function.rhai
54+
- match: \b(import|export|as|private)\b
55+
name: keyword.control.import.rhai keyword.control.export.rhai
5656
- match: \b(if|else)\b
5757
name: keyword.control.conditional.rhai
5858
- match: \b(switch|return|throw|try|catch)\b
@@ -64,16 +64,18 @@ repository:
6464
- match: \b(true|false)\b
6565
name: constant.language.rhai
6666
- match: \b(print|debug|call|curry|eval|type_of|is_def_var|is_def_fn|is_shared)\b
67-
name: keyword.other.rhai
67+
name: keyword.other.rhai support.function.rhai
68+
- match: \b(var|static|begin|end|shared|each|then|goto|exit|unless|match|case|public|protected|new|use|with|module|package|super|thread|spawn|go|await|async|sync|yield|default|void|null|nil)\b
69+
name: invalid.illegal.rhai
6870
operators:
6971
patterns:
7072
- match: (==|!=|<=|>=|<|>)
7173
name: keyword.operator.comparison.rhai
72-
- match: (\+|\-|\*|\/|\*\*|%)
74+
- match: (\+|-|\*|/|\*\*|%)
7375
name: keyword.operator.arithmetic.rhai
74-
- match: (\||&|>>|<<)
76+
- match: (\||&|>>|<<|^)
7577
name: keyword.operator.bitwise.rhai
76-
- match: (=|\+=|\-=|\*=|\/=|\*\*=|%=|\|=|&=|>>=|<<=)
78+
- match: (=|\+=|-=|\*=|/=|\*\*=|%=|\|=|&=|^=|>>=|<<=)
7779
name: keyword.operator.assignment.rhai
7880
- match: (!)
7981
name: keyword.operator.infix.rhai
@@ -82,43 +84,36 @@ repository:
8284
number:
8385
patterns:
8486
- match: (?<!\w)(0x[0-9a-fA-F][_0-9a-fA-F]*)(?!\w)
85-
captures:
86-
'1': {name: constant.numeric.hex.rhai}
87+
name: constant.numeric.hex.rhai
8788
- match: (?<!\w)(0o[0-7][_0-7]*)(?!\w)
88-
captures:
89-
'1': {name: constant.numeric.oct.rhai}
89+
name: constant.numeric.oct.rhai}
9090
- match: (?<!\w)(0b[01][_01]*)(?!\w)
91-
captures:
92-
'1': {name: constant.numeric.bin.rhai}
93-
- match: ([\+\-]?[0-9][_0-9]*(\.([0-9][_0-9]*)?))
94-
captures:
95-
'1': {name: constant.numeric.decimal.rhai}
96-
- match: ([\+\-]?[0-9][_0-9]*(\.[0-9][_0-9]*)?e[\+\-]?[0-9][_0-9]*)
97-
captures:
98-
'1': {name: constant.numeric.decimal.rhai}
99-
- match: ([\+\-]?([0-9][_0-9]*))
100-
captures:
101-
'1': {name: constant.numeric.integer.rhai}
91+
name: constant.numeric.bin.rhai
92+
- match: ([\+-]?[0-9][_0-9]*(\.[0-9][_0-9]*)?e[\+-]?[0-9][_0-9]*)
93+
name: constant.numeric.decimal.rhai
94+
- match: ([\+-]?[0-9][_0-9]*(\.([0-9][_0-9]*)?))
95+
name: constant.numeric.decimal.rhai
96+
- match: ([\+-]?[0-9][_0-9]*)
97+
name: constant.numeric.integer.rhai
10298
string:
10399
patterns:
104100
- name: string.quoted.block.rhai
105101
begin: ('`')
106102
beginCaptures:
107-
'1': {name: punctuation.definition.string.block.rhai}
103+
'1': {name: punctuation.definition.string.begin.rhai}
108104
end: ('`')
109105
endCaptures:
110-
'1': {name: punctuation.definition.string.block.rhai}
111-
- match: (\'[^'\\]*(?:\\.[^'\\]*)*\')
112-
captures:
113-
'1': {name: string.quoted.single.rhai}
106+
'1': {name: punctuation.definition.string.end.rhai}
107+
- match: ('([^'\\]|\\([tnr'\\]|x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8}))')
108+
name: string.quoted.single.rhai
109+
patterns:
110+
- match: \\([tnr'\\]|x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})
111+
name: constant.character.escape.rhai
114112
- match: ("[^"\\]*(?:\\.[^"\\]*)*")
115-
captures:
116-
'1': {name: string.quoted.single.rhai}
113+
name: string.quoted.single.rhai
117114
patterns:
118-
- match: \\([btnfr"\\\n/]|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})
115+
- match: \\([tnr"\\\n]|x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})
119116
name: constant.character.escape.rhai
120-
- match: \\[^btnfr/"\\\n]
121-
name: invalid.illegal.escape.rhai
122117
dict:
123118
patterns:
124119
- begin: (#\{)
@@ -135,30 +130,36 @@ repository:
135130

136131
symbol:
137132
patterns:
138-
- match: (::)
139-
name: punctuation.accessor
140-
- match: (:|=>)
141-
name: punctuation.separator
133+
- match: (\:\:)
134+
name: punctuation.accessor.rhai
135+
- match: (\:|=>|,)
136+
name: punctuation.separator.rhai
142137
- match: (;)
143-
name: punctuation.terminator
138+
name: punctuation.terminator.rhai
139+
- match: (\.)
140+
name: punctuation.accessor.rhai
144141
- match: (\{)
145-
name: punctuation.section.block.begin
142+
name: punctuation.section.block.begin.rhai
146143
- match: (\})
147-
name: punctuation.section.block.end
144+
name: punctuation.section.block.end.rhai
148145
- match: (\()
149-
name: punctuation.section.group.begin
146+
name: punctuation.section.group.begin.rhai
150147
- match: (\))
151-
name: punctuation.section.group.end
148+
name: punctuation.section.group.end.rhai
152149
- match: (\[)
153-
name: punctuation.section.brackets.begin
150+
name: punctuation.section.brackets.begin.rhai
154151
- match: (\])
155-
name: punctuation.section.brackets.end
152+
name: punctuation.section.brackets.end.rhai
153+
- match: (\(\*|\*\)|#!|\+\+|--|\.\.|\.\.\.|~|#|@|$|->|<-|===|!==|\:=|\:\:<)
154+
name: invalid.illegal.rhai
156155

157156
variable:
158157
patterns:
159158
- match: (?<!\w)([A-Z][_0-9A-Z]*)(?!\w)
160-
name: variable.other.constant.rhai
159+
name: entity.name.constant.rhai variable.other.constant.rhai
161160
- match: (?<!\w)([_a-zA-Z][_0-9a-zA-Z]*)(?=\(|\!\()
162-
name: entity.name.function.rhai
161+
name: variable.function
163162
- match: (?<!\w)([_a-zA-Z][_0-9a-zA-Z]*)(?!\w)
164163
name: variable.other.readwrite.rhai
164+
- match: (?<!\w)([_a-zA-Z][_0-9a-zA-Z]*\s*\:\:)+\s*(?=\w)
165+
name: entity.name.namespace.rhai

0 commit comments

Comments
 (0)