From 4e7187b926e06c371812154ca51f7ed3b321c010 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 11 May 2019 17:45:10 -0500 Subject: [PATCH] Extended G-code syntax - Parenthesized comments - Multiple E values split by colons (RepRapFirmware) --- .../sublime/RepRapTools/G-Code.sublime-syntax | 21 +++++++++++++++++++ .../RepRapTools/syntax_test_G-code.gcode | 20 +++++++++++++++++- 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/buildroot/share/sublime/RepRapTools/G-Code.sublime-syntax b/buildroot/share/sublime/RepRapTools/G-Code.sublime-syntax index 59be5721f2..d1571e3ad8 100644 --- a/buildroot/share/sublime/RepRapTools/G-Code.sublime-syntax +++ b/buildroot/share/sublime/RepRapTools/G-Code.sublime-syntax @@ -97,6 +97,12 @@ contexts: 2: punctuation.quote.double.open.gcode push: gcode_string_arg_quoted_double + # parameter and list of values + - match: ([Ee])\s*(({{decimal}}\s*:\s*)+{{decimal}}) + captures: + 1: keyword.param.gcode + 2: constant.numeric.param.gcode + # parameter and numeric value - match: ([A-Za-z])\s*({{decimal}}) captures: @@ -189,6 +195,9 @@ contexts: - match: \s*; scope: punctuation.comment.eol.start set: gcode_comment + - match: \s*\( + scope: punctuation.paren.comment.open + push: gcode_comment_paren # Comment to end of line. gcode_comment: @@ -196,6 +205,18 @@ contexts: - match: \s*$ pop: true + gcode_comment_paren: + - meta_content_scope: paren.comment.gcode + + - match: '[^)]+' + + - match: '[)]' + scope: punctuation.paren.comment.close + pop: true + + - match: \s*$ + pop: true + # Everything after this point is broken by a syntax error syntax_error: - meta_scope: invalid.error.syntax.gcode diff --git a/buildroot/share/sublime/RepRapTools/syntax_test_G-code.gcode b/buildroot/share/sublime/RepRapTools/syntax_test_G-code.gcode index c47701bd55..2d3a4738eb 100644 --- a/buildroot/share/sublime/RepRapTools/syntax_test_G-code.gcode +++ b/buildroot/share/sublime/RepRapTools/syntax_test_G-code.gcode @@ -9,6 +9,14 @@ G1 X100 Y100 ; Move to 100,100 ; ^constant.numeric.param.gcode ; ^comment +T0 (This is a comment) S12 +;^entity.command.gcode +; ^punctuation.paren.comment.open +; ^paren.comment.gcode +; ^punctuation.paren.comment.close +; ^keyword.param.gcode +; ^constant.numeric.param.gcode + M20 P'/path/to/macro/macro.g' R12 ;<-entity.command.gcode ;^constant.numeric.command.gcode @@ -16,6 +24,8 @@ M20 P'/path/to/macro/macro.g' R12 ; ^punctuation.quote.single.open.gcode ; ^string.quoted.single.gcode ; ^punctuation.quote.single.close.gcode +; ^keyword.param.gcode +; ^constant.numeric.param.gcode M117 This is a message ; and comment ;<-entity.command.gcode @@ -83,6 +93,14 @@ N234 G1 X-5 Y+2 *64 error ; ^constant.numeric.checksum.gcode ; ^invalid.error.syntax.gcode -N234 M107 *64 +N234 M107 *64 ; ^-invalid.error.syntax.gcode +M92 E304.5:304.5:420:420:420:420 ; EOL Comment +;<-entity.command.gcode +;^constant.numeric.command.gcode +; ^keyword.param.gcode +; ^constant.numeric.param.gcode +; ^constant.numeric.param.gcode +; ^punctuation.comment.eol.start +; ^comment.gcode