Просмотр исходного кода

Extended G-code syntax

- Parenthesized comments
- Multiple E values split by colons (RepRapFirmware)
Scott Lahteine 5 лет назад
Родитель
Сommit
4e7187b926

+ 21
- 0
buildroot/share/sublime/RepRapTools/G-Code.sublime-syntax Просмотреть файл

@@ -97,6 +97,12 @@ contexts:
97 97
         2: punctuation.quote.double.open.gcode
98 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 106
     # parameter and numeric value
101 107
     - match: ([A-Za-z])\s*({{decimal}})
102 108
       captures:
@@ -189,6 +195,9 @@ contexts:
189 195
     - match: \s*;
190 196
       scope: punctuation.comment.eol.start
191 197
       set: gcode_comment
198
+    - match: \s*\(
199
+      scope: punctuation.paren.comment.open
200
+      push: gcode_comment_paren
192 201
 
193 202
   # Comment to end of line.
194 203
   gcode_comment:
@@ -196,6 +205,18 @@ contexts:
196 205
     - match: \s*$
197 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 220
   # Everything after this point is broken by a syntax error
200 221
   syntax_error:
201 222
     - meta_scope: invalid.error.syntax.gcode

+ 19
- 1
buildroot/share/sublime/RepRapTools/syntax_test_G-code.gcode Просмотреть файл

@@ -9,6 +9,14 @@ G1 X100 Y100 ; Move to 100,100
9 9
 ;   ^constant.numeric.param.gcode
10 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 20
 M20 P'/path/to/macro/macro.g' R12
13 21
 ;<-entity.command.gcode
14 22
 ;^constant.numeric.command.gcode
@@ -16,6 +24,8 @@ M20 P'/path/to/macro/macro.g' R12
16 24
 ;    ^punctuation.quote.single.open.gcode
17 25
 ;       ^string.quoted.single.gcode
18 26
 ;                           ^punctuation.quote.single.close.gcode
27
+;                             ^keyword.param.gcode
28
+;                              ^constant.numeric.param.gcode
19 29
 
20 30
 M117 This is a message   ; and comment
21 31
 ;<-entity.command.gcode
@@ -83,6 +93,14 @@ N234 G1 X-5 Y+2 *64 error
83 93
 ;                ^constant.numeric.checksum.gcode
84 94
 ;                  ^invalid.error.syntax.gcode
85 95
 
86
-N234 M107 *64
96
+N234 M107 *64     
87 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

Загрузка…
Отмена
Сохранить