-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This PR adds the [G-code language](https://reprap.org/wiki/G-code) to Prism and resolves #1571. ### Features - All fields from A-Z ([case sensitive](https://reprap.org/wiki/G-code#Case_sensitivity)) and [checksums](https://reprap.org/wiki/G-code#.2A:_Checksum) (`*`). - [Comments](https://reprap.org/wiki/G-code#Comments) of both the semicolon and parenthesis style. - [Quoted strings](https://reprap.org/wiki/G-code#Quoted_strings). - The colon punctuation of [lists (see the example)](https://reprap.org/wiki/G-code#M584:_Set_drive_mapping).
- Loading branch information
1 parent
225dd3f
commit 2288c25
Showing
12 changed files
with
134 additions
and
3 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
Prism.languages.gcode = { | ||
'comment': /;.*|\B\(.*?\)\B/, | ||
'string': { | ||
pattern: /"(?:""|[^"])*"/, | ||
greedy: true | ||
}, | ||
'keyword': /\b[GM]\d+(?:\.\d+)?\b/, | ||
'property': /\b[A-Z]/, | ||
'checksum': { | ||
pattern: /\*\d+/, | ||
alias: 'punctuation' | ||
}, | ||
// T0:0:0 | ||
'punctuation': /:/ | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<h2>Comments</h2> | ||
<pre><code>; comment | ||
(some more comments) | ||
G28 (even in here) X0 | ||
</code></pre> | ||
|
||
<h2>Quoted strings</h2> | ||
<pre><code>"foo""bar"</code></pre> | ||
|
||
<h2>Full example</h2> | ||
<pre><code>M190 S60 ; Heat bed to 60°C | ||
G21 ; Set units to millimeters | ||
G28 ; Move to Origin (Homing) | ||
G29 ; Auto Bed Leveling | ||
G28 X0 Y0 ; Home X and Y to min endstops | ||
M107 ; Fan off | ||
M109 S200 ; Heat hotend to 200°C | ||
G92 E0 ; Set current extruder position as zero | ||
G1 F200 E15 ; Extrude 15mm filament with 200mm/min | ||
G92 E0 ; Set current extruder position as zero | ||
G1 F500 | ||
</code></pre> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
G28*22 | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["keyword", "G28"], | ||
["checksum", "*22"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for checksums. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
; foo | ||
(Home some axes) | ||
G28 (here come the axes to be homed) X | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["comment", "; foo"], | ||
|
||
["comment", "(Home some axes)"], | ||
|
||
["keyword", "G28"], | ||
["comment", "(here come the axes to be homed)"], | ||
["property", "X"] | ||
|
||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for comments. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
G00 | ||
G200 | ||
G84.1 | ||
|
||
M00 | ||
M123 | ||
M52.4 | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["keyword", "G00"], | ||
["keyword", "G200"], | ||
["keyword", "G84.1"], | ||
|
||
["keyword", "M00"], | ||
["keyword", "M123"], | ||
["keyword", "M52.4"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for G- and M-codes. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
X123 | ||
Y0.2 | ||
Z-3.1415 | ||
E420:420 | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["property", "X"], "123\n", | ||
["property", "Y"], "0.2\n", | ||
["property", "Z"], "-3.1415\n", | ||
["property", "E"], "420", ["punctuation", ":"], "420" | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for all other codes except G- and M-codes. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
M587 S"MYROUTER" P"ABCxyz;"" 123" | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["keyword", "M587"], | ||
|
||
["property", "S"], | ||
["string", "\"MYROUTER\""], | ||
|
||
["property", "P"], | ||
["string", "\"ABCxyz;\"\" 123\""] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for strings. |