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 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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. - [ 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_content_scope: ctx.line.gcode
  25. - match: '([Nn]\s*(\d+))'
  26. captures:
  27. 1: ctx.gcode_line_num
  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. # command followed by data
  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. # command 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: entity.string.filename.open
  66. push: gcode_path_arg
  67. # asterisk starts a checksum
  68. - match: \*
  69. scope: entity.checksum.gcode
  70. set: gcode_checksum
  71. # parameter and value
  72. - match: ([A-Za-z])\s*({{decimal}})
  73. captures:
  74. 1: keyword.param.gcode
  75. 2: constant.numeric.param.gcode
  76. # parameter with no value
  77. - match: '[A-Za-z]'
  78. scope: keyword.param.gcode
  79. set: gcode_params
  80. - match: ()
  81. set: syntax_error
  82. gcode_string_arg:
  83. - meta_content_scope: ctx.string.gcode
  84. - match: ([^;]+)
  85. scope: string.unquoted.gcode
  86. gcode_path_arg:
  87. - meta_content_scope: ctx.path.gcode
  88. - match: ([^#]+)
  89. scope: string.unquoted.path.gcode
  90. - match: (#)
  91. scope: entity.string.path.close.gcode
  92. pop: true
  93. gcode_checksum:
  94. - meta_content_scope: ctx.checksum.gcode
  95. - match: \d+
  96. scope: constant.numeric.checksum.gcode
  97. - match: ()
  98. set: syntax_error
  99. # Done interpreting to the end of the line
  100. gcode_line_done:
  101. - match: \s*$
  102. pop: true
  103. # Comments begin with a ';' and finish at the end of the line.
  104. mixin_comment:
  105. - match: ^\s*;
  106. scope: punctuation.definition.comment.line.start
  107. set: gcode_comment
  108. - match: \s*;
  109. scope: punctuation.definition.comment.eol.start
  110. set: gcode_comment
  111. # Comment to end of line.
  112. gcode_comment:
  113. - meta_scope: comment.gcode
  114. - match: \s*$
  115. pop: true
  116. # Everything after this point is broken by a syntax error
  117. syntax_error:
  118. - meta_scope: invalid.error.syntax.gcode
  119. - match: .*$
  120. pop: true