-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPiranha.sublime-syntax
184 lines (154 loc) · 4.91 KB
/
Piranha.sublime-syntax
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
%YAML 1.2
---
name: Piranha
file_extensions:
- mr
scope: source.piranha
contexts:
main:
# Decorators
- match: '\bnode\b'
scope: keyword.control.node.piranha
- match: '\b(as|public|private|module|inline|auto)\b'
scope: storage.modifier.piranha
- match: '\b(input|output|modify|toggle)\b'
scope: entity.other.attribute-name.piranha
- match: '\balias\b'
scope: keyword.control.alias.piranha
- match: '\bimport\b'
scope: keyword.control.import.piranha
- match: '\b(true|false)\b'
scope: constant.language.piranha
- match: '@[a-zA-Z_][a-zA-Z_0-9]*\s*:'
scope: entity.name.function.decorator.piranha
push:
- meta_scope: meta.decorator.piranha
- match: '\n'
pop: true
- include: strings
# Node definition and instance patterns
- match: '\bnode\b\s+([a-zA-Z_][a-zA-Z0-9_]*)\s*\{'
captures:
1: storage.type.piranha
2: entity.name.class.piranha
push: node_block
# Node with tag
- match: '\bnode\b\s+([a-zA-Z_][a-zA-Z0-9_]*)\s*=>\s*([a-zA-Z_][a-zA-Z0-9_]*)\s*\{'
captures:
1: storage.type.piranha
2: entity.name.class.piranha
3: entity.name.tag.piranha
push: node_block
# Node instance call patterns
- match: '([a-zA-Z_][a-zA-Z_0-9]*)\s*\('
scope: entity.name.function.piranha
push:
- match: '\)'
pop: true
- include: attribute_specification
- match: '([a-zA-Z_][a-zA-Z_0-9]*)\s+([a-zA-Z_][a-zA-Z_0-9]*)\s*\('
captures:
1: entity.name.class.piranha
2: entity.name.function.piranha
push:
- match: '\)'
pop: true
- include: attribute_specification
# Global keywords and modifiers
# - match: '\bnode\b'
# scope: keyword.control.node.piranha
# Strings
- match: '"'
scope: punctuation.definition.string.begin.piranha
push: double_quoted_string
# Numbers (decimal and hexadecimal)
- match: '\b0x[0-9a-fA-F]+\b'
scope: constant.numeric.hex.piranha
- match: '\b\d+(\.\d+)?\b'
scope: constant.numeric.piranha
# Comments
- match: '//'
scope: punctuation.definition.comment.piranha
push: line_comment
- match: '/\*'
scope: punctuation.definition.comment.block.piranha
push: block_comment
# Block for handling nodes
node_block:
- meta_scope: meta.block.node.piranha
- match: '\}'
pop: true
- include: attributes
- include: node_instance
- include: comments
- include: decorators
# Double quoted strings and escape sequences
double_quoted_string:
- meta_scope: string.quoted.double.piranha
- match: '\\\\.'
scope: constant.character.escape.piranha
- match: '"'
scope: punctuation.definition.string.end.piranha
pop: true
# Line comments
line_comment:
- meta_scope: comment.line.double-slash.piranha
- match: $
pop: true
# Block comments
block_comment:
- meta_scope: comment.block.piranha
- match: '\*/'
pop: true
#Attribute specification within nodes
attribute_specification:
- match: '([a-zA-Z_][a-zA-Z_0-9]*)\s*:'
scope: entity.other.attribute-name.piranha
- match: '\b(node|output|alias|input|public|private|as)\b'
scope: invalid.illegal.piranha
- include: main
# Handling attributes inside nodes
attributes:
- match: '(input|output|modify|toggle)(\s+[a-zA-Z_][a-zA-Z_0-9]*)\s*\['
captures:
1: storage.modifier.piranha
2: entity.other.attribute-name.piranha
push:
- meta_scope: meta.attribute.piranha
- match: '\]'
pop: true
- match: '(.*?)\s*::\s*([a-zA-Z_][a-zA-Z_0-9]*)'
captures:
1: entity.meta.piranha
2: entity.name.class.piranha
- include: main
- match: '(input|output|modify|toggle)\s+[a-zA-Z_][a-zA-Z_0-9]*'
captures:
1: storage.modifier.piranha
2: entity.other.attribute-name.piranha
- include: main
# Node instance handling
node_instance:
- match: '([a-zA-Z_][a-zA-Z_0-9]*)\s*\('
scope: entity.meta.piranha
push:
- match: '\)'
pop: true
- include: attribute_specification
- match: '([a-zA-Z_][a-zA-Z_0-9]*)\s+([a-zA-Z_][a-zA-Z_0-9]*)\s*\('
captures:
1: entity.name.class.piranha
2: entity.name.function.piranha
push:
- match: '\)'
pop: true
- include: attribute_specification
# Decorators for nodes and attributes
decorators:
- match: '@[a-zA-Z_][a-zA-Z_0-9]*\s*:'
scope: entity.name.function.decorator.piranha
push:
- meta_scope: meta.decorator.piranha
- match: '\n'
pop: true
- include: strings