Browse Source

Extended G-code syntax

- Parenthesized comments
- Multiple E values split by colons (RepRapFirmware)
Scott Lahteine 5 years ago
parent
commit
4e7187b926

+ 21
- 0
buildroot/share/sublime/RepRapTools/G-Code.sublime-syntax View File

97
         2: punctuation.quote.double.open.gcode
97
         2: punctuation.quote.double.open.gcode
98
       push: gcode_string_arg_quoted_double
98
       push: gcode_string_arg_quoted_double
99
 
99
 
100
+    # parameter and list of values
101
+    - match: ([Ee])\s*(({{decimal}}\s*:\s*)+{{decimal}})
102
+      captures:
103
+        1: keyword.param.gcode
104
+        2: constant.numeric.param.gcode
105
+
100
     # parameter and numeric value
106
     # parameter and numeric value
101
     - match: ([A-Za-z])\s*({{decimal}})
107
     - match: ([A-Za-z])\s*({{decimal}})
102
       captures:
108
       captures:
189
     - match: \s*;
195
     - match: \s*;
190
       scope: punctuation.comment.eol.start
196
       scope: punctuation.comment.eol.start
191
       set: gcode_comment
197
       set: gcode_comment
198
+    - match: \s*\(
199
+      scope: punctuation.paren.comment.open
200
+      push: gcode_comment_paren
192
 
201
 
193
   # Comment to end of line.
202
   # Comment to end of line.
194
   gcode_comment:
203
   gcode_comment:
196
     - match: \s*$
205
     - match: \s*$
197
       pop: true
206
       pop: true
198
 
207
 
208
+  gcode_comment_paren:
209
+    - meta_content_scope: paren.comment.gcode
210
+
211
+    - match: '[^)]+'
212
+
213
+    - match: '[)]'
214
+      scope: punctuation.paren.comment.close
215
+      pop: true
216
+
217
+    - match: \s*$
218
+      pop: true
219
+
199
   # Everything after this point is broken by a syntax error
220
   # Everything after this point is broken by a syntax error
200
   syntax_error:
221
   syntax_error:
201
     - meta_scope: invalid.error.syntax.gcode
222
     - meta_scope: invalid.error.syntax.gcode

+ 19
- 1
buildroot/share/sublime/RepRapTools/syntax_test_G-code.gcode View File

9
 ;   ^constant.numeric.param.gcode
9
 ;   ^constant.numeric.param.gcode
10
 ;              ^comment
10
 ;              ^comment
11
 
11
 
12
+T0 (This is a comment) S12
13
+;^entity.command.gcode
14
+;  ^punctuation.paren.comment.open
15
+;   ^paren.comment.gcode
16
+;                    ^punctuation.paren.comment.close
17
+;                      ^keyword.param.gcode
18
+;                       ^constant.numeric.param.gcode
19
+
12
 M20 P'/path/to/macro/macro.g' R12
20
 M20 P'/path/to/macro/macro.g' R12
13
 ;<-entity.command.gcode
21
 ;<-entity.command.gcode
14
 ;^constant.numeric.command.gcode
22
 ;^constant.numeric.command.gcode
16
 ;    ^punctuation.quote.single.open.gcode
24
 ;    ^punctuation.quote.single.open.gcode
17
 ;       ^string.quoted.single.gcode
25
 ;       ^string.quoted.single.gcode
18
 ;                           ^punctuation.quote.single.close.gcode
26
 ;                           ^punctuation.quote.single.close.gcode
27
+;                             ^keyword.param.gcode
28
+;                              ^constant.numeric.param.gcode
19
 
29
 
20
 M117 This is a message   ; and comment
30
 M117 This is a message   ; and comment
21
 ;<-entity.command.gcode
31
 ;<-entity.command.gcode
83
 ;                ^constant.numeric.checksum.gcode
93
 ;                ^constant.numeric.checksum.gcode
84
 ;                  ^invalid.error.syntax.gcode
94
 ;                  ^invalid.error.syntax.gcode
85
 
95
 
86
-N234 M107 *64
96
+N234 M107 *64     
87
 ;              ^-invalid.error.syntax.gcode
97
 ;              ^-invalid.error.syntax.gcode
88
 
98
 
99
+M92 E304.5:304.5:420:420:420:420 ; EOL Comment
100
+;<-entity.command.gcode
101
+;^constant.numeric.command.gcode
102
+;   ^keyword.param.gcode
103
+;    ^constant.numeric.param.gcode
104
+;             ^constant.numeric.param.gcode
105
+;                                ^punctuation.comment.eol.start
106
+;                                 ^comment.gcode

Loading…
Cancel
Save