My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

G-Code.sublime-syntax 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. %YAML 1.2
  2. ---
  3. #
  4. # G-Code (RepRap, not ISO-6983)
  5. # Author: @thinkyhead
  6. #
  7. # RapRap G-Code is very simple.
  8. #
  9. # TODO: Lines that start with N get a different context, accepting a checksum.
  10. #
  11. name: G-Code (RepRap)
  12. file_extensions:
  13. - [ g, gco, gcode ]
  14. scope: source.gcode
  15. variables:
  16. decimal: '[+-]?\d+(\.\d*)?'
  17. contexts:
  18. prototype:
  19. - match: \s+
  20. - include: mixin_comment
  21. - match: $
  22. pop: true
  23. main:
  24. - meta_scope: line.gcode
  25. - match: '([Nn]\s*(\d+))'
  26. captures:
  27. 1: entity.nword.gcode
  28. 2: constant.numeric.line-number.gcode
  29. - match: ()
  30. set: gcode_command
  31. # G, M, or T command
  32. gcode_command:
  33. - meta_content_scope: ctx.command.gcode
  34. # M20 S2 P/path/to/file/name.gco
  35. - match: ([Mm](20))\s*((S)(2)\s*(P))
  36. captures:
  37. 1: entity.command.gcode markup.bold.gcode
  38. 2: constant.numeric.command.gcode
  39. 3: ctx.params.gcode
  40. 4: keyword.param.gcode
  41. 5: constant.numeric.param.gcode
  42. 6: keyword.param.gcode
  43. set: gcode_string_arg
  44. # M117 or M118 - Commands taking a string
  45. - match: ([Mm]\s*(11[78]))\b
  46. captures:
  47. 1: entity.command.gcode markup.bold.gcode
  48. 2: constant.numeric.command.gcode
  49. set: gcode_string_arg
  50. # Other commands, followed by data
  51. - match: ([GMTgmt]\s*(\d+)((\.)(\d+))?)
  52. captures:
  53. 1: entity.command.gcode markup.bold.gcode
  54. 2: constant.numeric.command.gcode
  55. 4: entity.separator.subcode
  56. 5: constant.numeric.subcode
  57. set: gcode_params
  58. - match: ()
  59. set: syntax_error
  60. # Parameters of a command
  61. gcode_params:
  62. - meta_content_scope: ctx.params.gcode
  63. # M32 [S<pos>] [P<bool>] !/path/file.gco#
  64. - match: \!
  65. scope: punctuation.string.path.open.gcode
  66. push: gcode_path_arg
  67. # asterisk starts a checksum
  68. - match: \*
  69. scope: punctuation.marker.checksum.gcode
  70. set: gcode_checksum
  71. # parameter and single-quoted value
  72. - match: ([A-Za-z])\s*(')
  73. captures:
  74. 1: keyword.param.gcode
  75. 2: punctuation.quote.single.open.gcode
  76. push: gcode_string_arg_quoted_single
  77. # parameter and double-quoted value
  78. - match: ([A-Za-z])\s*(")
  79. captures:
  80. 1: keyword.param.gcode
  81. 2: punctuation.quote.double.open.gcode
  82. push: gcode_string_arg_quoted_double
  83. # parameter and numeric value
  84. - match: ([A-Za-z])\s*({{decimal}})
  85. captures:
  86. 1: keyword.param.gcode
  87. 2: constant.numeric.param.gcode
  88. # parameter with no value
  89. - match: '[A-Za-z]'
  90. scope: keyword.param.gcode
  91. set: gcode_params
  92. - match: ()
  93. set: syntax_error
  94. gcode_string_arg_quoted_single:
  95. - meta_content_scope: string.quoted.single.gcode
  96. - match: ([^'\\]+)
  97. - match: (\\)
  98. scope: punctuation.string.escape.gcode
  99. push: escape_char
  100. - match: (')
  101. scope: punctuation.quote.single.close.gcode
  102. pop: true
  103. - match: ()
  104. set: syntax_error
  105. gcode_string_arg_quoted_double:
  106. - meta_content_scope: string.quoted.double.gcode
  107. - match: ([^"\\]+)
  108. - match: (\\)
  109. scope: punctuation.string.escape.gcode
  110. push: escape_char
  111. - match: (")
  112. scope: punctuation.quote.double.close.gcode
  113. pop: true
  114. - match: ()
  115. set: syntax_error
  116. gcode_string_arg:
  117. - meta_content_scope: ctx.string.gcode
  118. - match: ([^;]+)
  119. scope: string.unquoted.gcode
  120. escape_char:
  121. - meta_scope: string.escape.gcode punctuation.string.escape.gcode
  122. - match: '.'
  123. pop: true
  124. gcode_path_arg:
  125. - meta_content_scope: string.unquoted.path.gcode
  126. - match: (#)
  127. scope: punctuation.string.path.close.gcode
  128. pop: true
  129. gcode_checksum:
  130. - meta_content_scope: constant.numeric.checksum.gcode
  131. - meta_include_prototype: false
  132. - match: \d+
  133. - match: ( *)$
  134. pop: true
  135. - include: mixin_comment
  136. - match: ()
  137. set: syntax_error
  138. # Done interpreting to the end of the line
  139. gcode_line_done:
  140. - match: \s*$
  141. pop: true
  142. # Comments begin with a ';' and finish at the end of the line.
  143. mixin_comment:
  144. - match: ^\s*;
  145. scope: punctuation.comment.line.start
  146. set: gcode_comment
  147. - match: \s*;
  148. scope: punctuation.comment.eol.start
  149. set: gcode_comment
  150. # Comment to end of line.
  151. gcode_comment:
  152. - meta_content_scope: comment.gcode
  153. - match: \s*$
  154. pop: true
  155. # Everything after this point is broken by a syntax error
  156. syntax_error:
  157. - meta_scope: invalid.error.syntax.gcode
  158. - match: .*$
  159. pop: true