|
@@ -10,10 +10,10 @@
|
10
|
10
|
#
|
11
|
11
|
name: G-Code (RepRap)
|
12
|
12
|
file_extensions:
|
13
|
|
- - [ gco, gcode ]
|
|
13
|
+ - [ g, gco, gcode ]
|
14
|
14
|
scope: source.gcode
|
15
|
15
|
variables:
|
16
|
|
- decimal: '[+-]?\d+(\.(\d+)?)?'
|
|
16
|
+ decimal: '[+-]?\d+(\.\d*)?'
|
17
|
17
|
|
18
|
18
|
contexts:
|
19
|
19
|
prototype:
|
|
@@ -25,11 +25,11 @@ contexts:
|
25
|
25
|
pop: true
|
26
|
26
|
|
27
|
27
|
main:
|
28
|
|
- - meta_content_scope: ctx.line.gcode
|
|
28
|
+ - meta_scope: line.gcode
|
29
|
29
|
|
30
|
30
|
- match: '([Nn]\s*(\d+))'
|
31
|
31
|
captures:
|
32
|
|
- 1: ctx.gcode_line_num
|
|
32
|
+ 1: entity.nword.gcode
|
33
|
33
|
2: constant.numeric.line-number.gcode
|
34
|
34
|
|
35
|
35
|
- match: ()
|
|
@@ -40,7 +40,7 @@ contexts:
|
40
|
40
|
- meta_content_scope: ctx.command.gcode
|
41
|
41
|
|
42
|
42
|
# M20 S2 P/path/to/file/name.gco
|
43
|
|
- - match: ([Mm](20))(\s*(S)(2)\s*(P))
|
|
43
|
+ - match: ([Mm](20))\s*((S)(2)\s*(P))
|
44
|
44
|
captures:
|
45
|
45
|
1: entity.command.gcode markup.bold.gcode
|
46
|
46
|
2: constant.numeric.command.gcode
|
|
@@ -50,15 +50,15 @@ contexts:
|
50
|
50
|
6: keyword.param.gcode
|
51
|
51
|
set: gcode_string_arg
|
52
|
52
|
|
53
|
|
- # command followed by data
|
|
53
|
+ # M117 or M118 - Commands taking a string
|
54
|
54
|
- match: ([Mm]\s*(11[78]))\b
|
55
|
55
|
captures:
|
56
|
56
|
1: entity.command.gcode markup.bold.gcode
|
57
|
57
|
2: constant.numeric.command.gcode
|
58
|
58
|
set: gcode_string_arg
|
59
|
59
|
|
60
|
|
- # command followed by data
|
61
|
|
- - match: '([GMTgmt]\s*(\d+)((\.)(\d+))?)'
|
|
60
|
+ # Other commands, followed by data
|
|
61
|
+ - match: ([GMTgmt]\s*(\d+)((\.)(\d+))?)
|
62
|
62
|
captures:
|
63
|
63
|
1: entity.command.gcode markup.bold.gcode
|
64
|
64
|
2: constant.numeric.command.gcode
|
|
@@ -74,16 +74,30 @@ contexts:
|
74
|
74
|
- meta_content_scope: ctx.params.gcode
|
75
|
75
|
|
76
|
76
|
# M32 [S<pos>] [P<bool>] !/path/file.gco#
|
77
|
|
- - match: '!'
|
78
|
|
- scope: entity.string.filename.open
|
|
77
|
+ - match: \!
|
|
78
|
+ scope: punctuation.string.path.open.gcode
|
79
|
79
|
push: gcode_path_arg
|
80
|
80
|
|
81
|
81
|
# asterisk starts a checksum
|
82
|
82
|
- match: \*
|
83
|
|
- scope: entity.checksum.gcode
|
|
83
|
+ scope: punctuation.marker.checksum.gcode
|
84
|
84
|
set: gcode_checksum
|
85
|
85
|
|
86
|
|
- # parameter and value
|
|
86
|
+ # parameter and single-quoted value
|
|
87
|
+ - match: ([A-Za-z])\s*(')
|
|
88
|
+ captures:
|
|
89
|
+ 1: keyword.param.gcode
|
|
90
|
+ 2: punctuation.quote.single.open.gcode
|
|
91
|
+ push: gcode_string_arg_quoted_single
|
|
92
|
+
|
|
93
|
+ # parameter and double-quoted value
|
|
94
|
+ - match: ([A-Za-z])\s*(")
|
|
95
|
+ captures:
|
|
96
|
+ 1: keyword.param.gcode
|
|
97
|
+ 2: punctuation.quote.double.open.gcode
|
|
98
|
+ push: gcode_string_arg_quoted_double
|
|
99
|
+
|
|
100
|
+ # parameter and numeric value
|
87
|
101
|
- match: ([A-Za-z])\s*({{decimal}})
|
88
|
102
|
captures:
|
89
|
103
|
1: keyword.param.gcode
|
|
@@ -97,27 +111,67 @@ contexts:
|
97
|
111
|
- match: ()
|
98
|
112
|
set: syntax_error
|
99
|
113
|
|
|
114
|
+ gcode_string_arg_quoted_single:
|
|
115
|
+ - meta_content_scope: string.quoted.single.gcode
|
|
116
|
+
|
|
117
|
+ - match: ([^'\\]+)
|
|
118
|
+
|
|
119
|
+ - match: (\\)
|
|
120
|
+ scope: punctuation.string.escape.gcode
|
|
121
|
+ push: escape_char
|
|
122
|
+
|
|
123
|
+ - match: (')
|
|
124
|
+ scope: punctuation.quote.single.close.gcode
|
|
125
|
+ pop: true
|
|
126
|
+
|
|
127
|
+ - match: ()
|
|
128
|
+ set: syntax_error
|
|
129
|
+
|
|
130
|
+ gcode_string_arg_quoted_double:
|
|
131
|
+ - meta_content_scope: string.quoted.double.gcode
|
|
132
|
+
|
|
133
|
+ - match: ([^"\\]+)
|
|
134
|
+
|
|
135
|
+ - match: (\\)
|
|
136
|
+ scope: punctuation.string.escape.gcode
|
|
137
|
+ push: escape_char
|
|
138
|
+
|
|
139
|
+ - match: (")
|
|
140
|
+ scope: punctuation.quote.double.close.gcode
|
|
141
|
+ pop: true
|
|
142
|
+
|
|
143
|
+ - match: ()
|
|
144
|
+ set: syntax_error
|
|
145
|
+
|
100
|
146
|
gcode_string_arg:
|
101
|
147
|
- meta_content_scope: ctx.string.gcode
|
102
|
148
|
|
103
|
149
|
- match: ([^;]+)
|
104
|
150
|
scope: string.unquoted.gcode
|
105
|
151
|
|
106
|
|
- gcode_path_arg:
|
107
|
|
- - meta_content_scope: ctx.path.gcode
|
|
152
|
+ escape_char:
|
|
153
|
+ - meta_scope: string.escape.gcode punctuation.string.escape.gcode
|
108
|
154
|
|
109
|
|
- - match: ([^#]+)
|
110
|
|
- scope: string.unquoted.path.gcode
|
|
155
|
+ - match: '.'
|
|
156
|
+ pop: true
|
|
157
|
+
|
|
158
|
+ gcode_path_arg:
|
|
159
|
+ - meta_content_scope: string.unquoted.path.gcode
|
111
|
160
|
|
112
|
161
|
- match: (#)
|
113
|
|
- scope: entity.string.path.close.gcode
|
|
162
|
+ scope: punctuation.string.path.close.gcode
|
114
|
163
|
pop: true
|
115
|
164
|
|
116
|
165
|
gcode_checksum:
|
117
|
|
- - meta_content_scope: ctx.checksum.gcode
|
|
166
|
+ - meta_content_scope: constant.numeric.checksum.gcode
|
|
167
|
+ - meta_include_prototype: false
|
118
|
168
|
|
119
|
169
|
- match: \d+
|
120
|
|
- scope: constant.numeric.checksum.gcode
|
|
170
|
+
|
|
171
|
+ - match: ( *)$
|
|
172
|
+ pop: true
|
|
173
|
+
|
|
174
|
+ - include: mixin_comment
|
121
|
175
|
|
122
|
176
|
- match: ()
|
123
|
177
|
set: syntax_error
|
|
@@ -130,15 +184,15 @@ contexts:
|
130
|
184
|
# Comments begin with a ';' and finish at the end of the line.
|
131
|
185
|
mixin_comment:
|
132
|
186
|
- match: ^\s*;
|
133
|
|
- scope: punctuation.definition.comment.line.start
|
|
187
|
+ scope: punctuation.comment.line.start
|
134
|
188
|
set: gcode_comment
|
135
|
189
|
- match: \s*;
|
136
|
|
- scope: punctuation.definition.comment.eol.start
|
|
190
|
+ scope: punctuation.comment.eol.start
|
137
|
191
|
set: gcode_comment
|
138
|
192
|
|
139
|
193
|
# Comment to end of line.
|
140
|
194
|
gcode_comment:
|
141
|
|
- - meta_scope: comment.gcode
|
|
195
|
+ - meta_content_scope: comment.gcode
|
142
|
196
|
- match: \s*$
|
143
|
197
|
pop: true
|
144
|
198
|
|