Skip to content

Commit fda4e21

Browse files
committed
Added syntax for .effect files
1 parent 2b63919 commit fda4e21

File tree

1 file changed

+240
-0
lines changed

1 file changed

+240
-0
lines changed

Effect.sublime-syntax

Lines changed: 240 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,240 @@
1+
%YAML 1.2
2+
---
3+
name: Crackshell Effect
4+
file_extensions:
5+
- effect
6+
scope: text.xml.effect
7+
variables:
8+
valid_expression_functions: '(sin|cos|abs|ceil|floor|exp|log|saturate|sign|sqrt|clamp|lerp|min|max|smoothstep|pow|rand|wpos[xyz]|wposyz|mod|prime)'
9+
valid_types: '(variation)'
10+
contexts:
11+
preprocessor-expression:
12+
- match: '\b[A-Z0-9_]+\b'
13+
scope: entity.name.constant
14+
- match: '(\|\||&&)'
15+
scope: keyword.operator.logical
16+
- match: '"'
17+
scope: punctuation.definition.string.begin
18+
push:
19+
- meta_scope: string.quoted.double
20+
- match: '"'
21+
scope: punctuation.definition.string.end
22+
pop: true
23+
- match: '$'
24+
pop: true
25+
26+
has-preprocessor:
27+
- match: '^\s*(%)'
28+
captures:
29+
1: keyword.control.import
30+
push:
31+
- meta_scope: meta.preprocessor
32+
- match: '//.*'
33+
scope: comment.line
34+
- match: '(?i)(if|else|endif)\b'
35+
scope: support.function
36+
set: preprocessor-expression
37+
- match: '(PROFILE_START|PROFILE_STOP)\b'
38+
scope: support.function
39+
set:
40+
- meta_scope: string.unquoted
41+
- match: '$'
42+
pop: true
43+
- match: '[A-Za-z_][A-Za-z0-9_]+'
44+
scope: keyword.control.import
45+
set: preprocessor-expression
46+
- match: '$'
47+
pop: true
48+
49+
comment:
50+
- match: '<!--'
51+
scope: punctuation.definition.comment.begin
52+
push:
53+
- meta_scope: comment.block
54+
- match: '-->'
55+
scope: punctuation.definition.comment.end
56+
pop: true
57+
- match: '-{2,}'
58+
scope: invalid.illegal.double-hyphen-within-comment
59+
60+
string:
61+
- meta_scope: string.quoted.double
62+
- match: '"'
63+
scope: punctuation.definition.string.end
64+
pop: true
65+
66+
renderable-base-attributes:
67+
- match: '(pos|delay|layer|ulayer)\b'
68+
scope: support.other
69+
push: attribute-value
70+
71+
attributes:
72+
- include: has-preprocessor
73+
- match: '[A-Za-z0-9\-_]+\b'
74+
scope: entity.other.attribute-name
75+
push: attribute-value
76+
- match: '(?=/?>)'
77+
pop: true
78+
79+
attribute-value:
80+
- match: '='
81+
scope: punctuation.separator.key-value
82+
- match: '"'
83+
scope: punctuation.definition.string.begin
84+
push: string
85+
- match: ''
86+
pop: true
87+
88+
expression-attributes:
89+
- include: has-preprocessor
90+
- match: '[A-Za-z0-9\-_]+\b'
91+
scope: entity.other.attribute-name
92+
push: attribute-value-expression
93+
- match: '(?=/?>)'
94+
pop: true
95+
96+
attribute-value-expression:
97+
- match: '='
98+
scope: punctuation.separator.key-value
99+
- match: '"'
100+
scope: punctuation.definition.string.begin
101+
push:
102+
- match: '"'
103+
scope: punctuation.definition.string.end
104+
pop: true
105+
- include: expression
106+
- match: ''
107+
pop: true
108+
109+
expression:
110+
- meta_scope: meta.parens
111+
- match: '\b{{valid_expression_functions}}\b'
112+
scope: support.function
113+
- match: '\b(pi)\b'
114+
scope: support.constant
115+
- match: '\b(true|false)\b'
116+
scope: constant.language
117+
- match: '\b[A-Za-z_][A-Za-z0-9_]*\b'
118+
scope: variable.other
119+
- match: '[+\-*/]'
120+
scope: keyword.operator.arithmetic
121+
- match: '[0-9\.]+'
122+
scope: constant.numeric
123+
- match: ','
124+
scope: punctuation.separator
125+
- match: '\('
126+
scope: punctuation.section.parens.begin
127+
push: expression
128+
- match: '\)'
129+
scope: punctuation.section.parens.end
130+
pop: true
131+
132+
main:
133+
- include: comment
134+
- include: has-preprocessor
135+
- match: '(<)/?$'
136+
captures:
137+
1: invalid.illegal.missing-entity
138+
- match: '<'
139+
scope: punctuation.definition.tag.begin
140+
push:
141+
- meta_scope: meta.tag.xml
142+
143+
- match: '/?>'
144+
scope: punctuation.definition.tag.end
145+
pop: true
146+
- match: '/'
147+
scope: punctuation.definition.tag.begin
148+
149+
- match: '\b(effect)\s*\b'
150+
captures:
151+
1: entity.name.tag storage.type
152+
push:
153+
- match: '(material|looping|layer|wpos-track|bounds)\b'
154+
scope: support.other
155+
push: attribute-value
156+
- include: attributes
157+
158+
- match: '\b(param)\s*\b'
159+
captures:
160+
1: entity.name.tag storage.type
161+
push:
162+
- match: '(name|default)\b'
163+
scope: support.other
164+
push: attribute-value
165+
- include: attributes
166+
167+
- match: '\b(data)\s*\b'
168+
captures:
169+
1: entity.name.tag storage.type
170+
set:
171+
- match: '>'
172+
scope: meta.tag.xml punctuation.definition.tag.end
173+
embed: scope:text.xml.sval
174+
escape: '(</)(data)(>)'
175+
escape_captures:
176+
1: meta.tag.xml punctuation.definition.tag.begin
177+
2: meta.tag.xml storage.type
178+
3: meta.tag.xml punctuation.definition.tag.end
179+
- match: ''
180+
pop: true
181+
182+
- match: '\b(light)\s*\b'
183+
captures:
184+
1: entity.name.tag storage.type
185+
push:
186+
- match: '(start|origin)\b' # NOTE: "pos" used to be available, but has been deprecated, so we don't match it here!
187+
scope: support.other
188+
push: attribute-value
189+
- include: attributes
190+
191+
- match: '\b(sprite)\s*\b'
192+
captures:
193+
1: entity.name.tag storage.type
194+
push:
195+
- match: '(angle|color-[rgba]|(scale|pos)-[xy]|num-sprites)\b'
196+
scope: support.other
197+
push: attribute-value-expression
198+
- match: '(start|texture|material|origin|mask(ed)?|looping|loopback)\b'
199+
scope: support.other
200+
push: attribute-value
201+
- include: attributes
202+
203+
# Note: Child of sprite
204+
- match: '\b(frame)\s*\b'
205+
captures:
206+
1: entity.name.tag storage.type
207+
push:
208+
- match: '[xywh]\b'
209+
scope: support.other
210+
push: attribute-value-expression
211+
- match: '(time)\b'
212+
scope: support.other
213+
push: attribute-value
214+
- include: attributes
215+
216+
- match: '\b(trail)\s*\b'
217+
captures:
218+
1: entity.name.tag storage.type
219+
push:
220+
- match: '(start|texture|material|origin|mask(ed)?)\b'
221+
scope: support.other
222+
push: attribute-value
223+
- include: attributes
224+
225+
# Note: Children of other elements (light, trail)
226+
- match: '\b((pos|uv-[lr])-[xy]|segments|cast-shadows|length|looping|overlay|shadow-cast-pos-[xy]|size|angle|color-[rgba])\s*\b'
227+
captures:
228+
1: entity.name.tag storage.type
229+
push:
230+
- match: '(value)\b'
231+
scope: support.other
232+
push: attribute-value-expression
233+
- include: attributes
234+
235+
- match: '\b{{valid_types}}\b'
236+
scope: entity.name.tag storage.type
237+
- match: '\b[A-Za-z0-9\-_]+\b'
238+
scope: invalid.illegal.unsupported-type
239+
- match: '\s+'
240+
push: attributes

0 commit comments

Comments
 (0)