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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. %YAML 1.2
  2. ---
  3. #
  4. # G-Code (RepRap, not ISO-6983)
  5. #
  6. # RapRap G-Code is very simple.
  7. #
  8. # TODO: Lines that start with N get a different context, accepting a checksum.
  9. #
  10. name: G-Code (RepRap)
  11. file_extensions:
  12. - [ gco, gcode ]
  13. scope: source.gcode
  14. variables:
  15. decimal: '[+-]?\d+(\.(\d+)?)?'
  16. contexts:
  17. prototype:
  18. - match: \s+
  19. - include: mixin_comment
  20. - match: $
  21. pop: true
  22. main:
  23. - meta_content_scope: ctx.line.gcode
  24. - match: '([Nn]\s*(\d+))'
  25. captures:
  26. 1: ctx.gcode_line_num
  27. 2: constant.numeric.line-number.gcode
  28. - match: ()
  29. set: gcode_command
  30. # G, M, or T command
  31. gcode_command:
  32. - meta_content_scope: ctx.command.gcode
  33. # M20 S2 P/path/to/file/name.gco
  34. - match: ([Mm](20))(\s*(S)(2)\s*(P))
  35. captures:
  36. 1: entity.command.gcode markup.bold.gcode
  37. 2: constant.numeric.command.gcode
  38. 3: ctx.params.gcode
  39. 4: keyword.param.gcode
  40. 5: constant.numeric.param.gcode
  41. 6: keyword.param.gcode
  42. set: gcode_string_arg
  43. # command followed by data
  44. - match: ([Mm]\s*(11[78]))\b
  45. captures:
  46. 1: entity.command.gcode markup.bold.gcode
  47. 2: constant.numeric.command.gcode
  48. set: gcode_string_arg
  49. # command followed by data
  50. - match: '([GMTgmt]\s*(\d+)((\.)(\d+))?)'
  51. captures:
  52. 1: entity.command.gcode markup.bold.gcode
  53. 2: constant.numeric.command.gcode
  54. 4: entity.separator.subcode
  55. 5: constant.numeric.subcode
  56. set: gcode_params
  57. - match: ()
  58. set: syntax_error
  59. # Parameters of a command
  60. gcode_params:
  61. - meta_content_scope: ctx.params.gcode
  62. # M32 [S<pos>] [P<bool>] !/path/file.gco#
  63. - match: '!'
  64. scope: entity.string.filename.open
  65. push: gcode_path_arg
  66. # asterisk starts a checksum
  67. - match: \*
  68. scope: entity.checksum.gcode
  69. set: gcode_checksum
  70. # parameter and value
  71. - match: ([A-Za-z])\s*({{decimal}})
  72. captures:
  73. 1: keyword.param.gcode
  74. 2: constant.numeric.param.gcode
  75. # parameter with no value
  76. - match: '[A-Za-z]'
  77. scope: keyword.param.gcode
  78. set: gcode_params
  79. - match: ()
  80. set: syntax_error
  81. gcode_string_arg:
  82. - meta_content_scope: ctx.string.gcode
  83. - match: ([^;]+)
  84. scope: string.unquoted.gcode
  85. gcode_path_arg:
  86. - meta_content_scope: ctx.path.gcode
  87. - match: ([^#]+)
  88. scope: string.unquoted.path.gcode
  89. - match: (#)
  90. scope: entity.string.path.close.gcode
  91. pop: true
  92. gcode_checksum:
  93. - meta_content_scope: ctx.checksum.gcode
  94. - match: \d+
  95. scope: constant.numeric.checksum.gcode
  96. - match: ()
  97. set: syntax_error
  98. # Done interpreting to the end of the line
  99. gcode_line_done:
  100. - match: \s*$
  101. pop: true
  102. # Comments begin with a ';' and finish at the end of the line.
  103. mixin_comment:
  104. - match: ^\s*;
  105. scope: punctuation.definition.comment.line.start
  106. set: gcode_comment
  107. - match: \s*;
  108. scope: punctuation.definition.comment.eol.start
  109. set: gcode_comment
  110. # Comment to end of line.
  111. gcode_comment:
  112. - meta_scope: comment.gcode
  113. - match: \s*$
  114. pop: true
  115. # Everything after this point is broken by a syntax error
  116. syntax_error:
  117. - meta_scope: invalid.error.syntax.gcode
  118. - match: .*$
  119. pop: true