Merge pull request #2090 from adamjcook/gcode
Adding G-code (ISO 6983) language mode.
This commit is contained in:
commit
fe9b95f9e2
6 changed files with 184 additions and 0 deletions
31
demo/kitchen-sink/docs/gcode.gcode
Normal file
31
demo/kitchen-sink/docs/gcode.gcode
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
O003 (DIAMOND SQUARE)
|
||||||
|
N2 G54 G90 G49 G80
|
||||||
|
N3 M6 T1 (1.ENDMILL)
|
||||||
|
N4 M3 S1800
|
||||||
|
N5 G0 X-.6 Y2.050
|
||||||
|
N6 G43 H1 Z.1
|
||||||
|
N7 G1 Z-.3 F50.
|
||||||
|
N8 G41 D1 Y1.45
|
||||||
|
N9 G1 X0 F20.
|
||||||
|
N10 G2 J-1.45
|
||||||
|
(CUTTER COMP CANCEL)
|
||||||
|
N11 G1 Z-.2 F50.
|
||||||
|
N12 Y-.990
|
||||||
|
N13 G40
|
||||||
|
N14 G0 X-.6 Y1.590
|
||||||
|
N15 G0 Z.1
|
||||||
|
N16 M5 G49 G28 G91 Z0
|
||||||
|
N17 CALL O9456
|
||||||
|
N18 #500=0.004
|
||||||
|
N19 #503=[#500+#501]
|
||||||
|
N20 VC45=0.0006
|
||||||
|
VS4=0.0007
|
||||||
|
N21 G90 G10 L20 P3 X5.Y4. Z6.567
|
||||||
|
N22 G0 X5000
|
||||||
|
N23 IF [#1 LT 0.370] GOTO 49
|
||||||
|
N24 X-0.678 Y+.990
|
||||||
|
N25 G84.3 X-0.1
|
||||||
|
N26 #4=#5*COS[45]
|
||||||
|
N27 #4=#5*SIN[45]
|
||||||
|
N28 VZOFZ=652.9658
|
||||||
|
%
|
||||||
|
|
@ -70,6 +70,7 @@ var supportedModes = {
|
||||||
EJS: ["ejs"],
|
EJS: ["ejs"],
|
||||||
Forth: ["frt|fs|ldr"],
|
Forth: ["frt|fs|ldr"],
|
||||||
FTL: ["ftl"],
|
FTL: ["ftl"],
|
||||||
|
Gcode: ["gcode"],
|
||||||
Gherkin: ["feature"],
|
Gherkin: ["feature"],
|
||||||
Gitignore: ["^.gitignore"],
|
Gitignore: ["^.gitignore"],
|
||||||
Glsl: ["glsl|frag|vert"],
|
Glsl: ["glsl|frag|vert"],
|
||||||
|
|
|
||||||
51
lib/ace/mode/gcode.js
Normal file
51
lib/ace/mode/gcode.js
Normal file
|
|
@ -0,0 +1,51 @@
|
||||||
|
/* ***** BEGIN LICENSE BLOCK *****
|
||||||
|
* Distributed under the BSD license:
|
||||||
|
*
|
||||||
|
* Copyright (c) 2010, Ajax.org B.V.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of Ajax.org B.V. nor the
|
||||||
|
* names of its contributors may be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
|
||||||
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
|
define(function(require, exports, module) {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var oop = require("../lib/oop");
|
||||||
|
var TextMode = require("./text").Mode;
|
||||||
|
var GcodeHighlightRules = require("./gcode_highlight_rules").GcodeHighlightRules;
|
||||||
|
var Range = require("../range").Range;
|
||||||
|
|
||||||
|
var Mode = function() {
|
||||||
|
this.HighlightRules = GcodeHighlightRules;
|
||||||
|
};
|
||||||
|
oop.inherits(Mode, TextMode);
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
this.$id = "ace/mode/gcode";
|
||||||
|
}).call(Mode.prototype);
|
||||||
|
|
||||||
|
exports.Mode = Mode;
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
94
lib/ace/mode/gcode_highlight_rules.js
Normal file
94
lib/ace/mode/gcode_highlight_rules.js
Normal file
|
|
@ -0,0 +1,94 @@
|
||||||
|
/* ***** BEGIN LICENSE BLOCK *****
|
||||||
|
* Distributed under the BSD license:
|
||||||
|
*
|
||||||
|
* Copyright (c) 2012, Ajax.org B.V.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of Ajax.org B.V. nor the
|
||||||
|
* names of its contributors may be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
|
||||||
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
|
define(function(require, exports, module) {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var oop = require("../lib/oop");
|
||||||
|
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
||||||
|
|
||||||
|
var GcodeHighlightRules = function() {
|
||||||
|
|
||||||
|
var keywords = (
|
||||||
|
"IF|DO|WHILE|ENDWHILE|CALL|ENDIF|SUB|ENDSUB|GOTO|REPEAT|ENDREPEAT|CALL"
|
||||||
|
);
|
||||||
|
|
||||||
|
var builtinConstants = (
|
||||||
|
"PI"
|
||||||
|
);
|
||||||
|
|
||||||
|
var builtinFunctions = (
|
||||||
|
"ATAN|ABS|ACOS|ASIN|SIN|COS|EXP|FIX|FUP|ROUND|LN|TAN"
|
||||||
|
);
|
||||||
|
var keywordMapper = this.createKeywordMapper({
|
||||||
|
"support.function": builtinFunctions,
|
||||||
|
"keyword": keywords,
|
||||||
|
"constant.language": builtinConstants
|
||||||
|
}, "identifier", true);
|
||||||
|
|
||||||
|
this.$rules = {
|
||||||
|
"start" : [ {
|
||||||
|
token : "comment",
|
||||||
|
regex : "\\(.*\\)"
|
||||||
|
}, {
|
||||||
|
token : "comment", // block number
|
||||||
|
regex : "([N])([0-9]+)"
|
||||||
|
}, {
|
||||||
|
token : "string", // " string
|
||||||
|
regex : "([G])([0-9]+\\.?[0-9]?)"
|
||||||
|
}, {
|
||||||
|
token : "string", // ' string
|
||||||
|
regex : "([M])([0-9]+\\.?[0-9]?)"
|
||||||
|
}, {
|
||||||
|
token : "constant.numeric", // float
|
||||||
|
regex : "([-+]?([0-9]*\\.?[0-9]+\\.?))|(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)"
|
||||||
|
}, {
|
||||||
|
token : keywordMapper,
|
||||||
|
regex : "[A-Z]"
|
||||||
|
}, {
|
||||||
|
token : "keyword.operator",
|
||||||
|
regex : "EQ|LT|GT|NE|GE|LE|OR|XOR"
|
||||||
|
}, {
|
||||||
|
token : "paren.lparen",
|
||||||
|
regex : "[\\[]"
|
||||||
|
}, {
|
||||||
|
token : "paren.rparen",
|
||||||
|
regex : "[\\]]"
|
||||||
|
}, {
|
||||||
|
token : "text",
|
||||||
|
regex : "\\s+"
|
||||||
|
} ]
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
oop.inherits(GcodeHighlightRules, TextHighlightRules);
|
||||||
|
|
||||||
|
exports.GcodeHighlightRules = GcodeHighlightRules;
|
||||||
|
});
|
||||||
7
lib/ace/snippets/gcode.js
Normal file
7
lib/ace/snippets/gcode.js
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
define(function(require, exports, module) {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
exports.snippetText = require("../requirejs/text!./gcode.snippets");
|
||||||
|
exports.scope = "gcode";
|
||||||
|
|
||||||
|
});
|
||||||
0
lib/ace/snippets/gcode.snippets
Normal file
0
lib/ace/snippets/gcode.snippets
Normal file
Loading…
Add table
Add a link
Reference in a new issue