mode-gcode.js 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. ace.define("ace/mode/gcode_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) {
  2. "use strict";
  3. var oop = require("../lib/oop");
  4. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  5. var GcodeHighlightRules = function() {
  6. var keywords = (
  7. "IF|DO|WHILE|ENDWHILE|CALL|ENDIF|SUB|ENDSUB|GOTO|REPEAT|ENDREPEAT|CALL"
  8. );
  9. var builtinConstants = (
  10. "PI"
  11. );
  12. var builtinFunctions = (
  13. "ATAN|ABS|ACOS|ASIN|SIN|COS|EXP|FIX|FUP|ROUND|LN|TAN"
  14. );
  15. var keywordMapper = this.createKeywordMapper({
  16. "support.function": builtinFunctions,
  17. "keyword": keywords,
  18. "constant.language": builtinConstants
  19. }, "identifier", true);
  20. this.$rules = {
  21. "start" : [ {
  22. token : "comment",
  23. regex : "\\(.*\\)"
  24. }, {
  25. token : "comment", // block number
  26. regex : "([N])([0-9]+)"
  27. }, {
  28. token : "string", // " string
  29. regex : "([G])([0-9]+\\.?[0-9]?)"
  30. }, {
  31. token : "string", // ' string
  32. regex : "([M])([0-9]+\\.?[0-9]?)"
  33. }, {
  34. token : "constant.numeric", // float
  35. regex : "([-+]?([0-9]*\\.?[0-9]+\\.?))|(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)"
  36. }, {
  37. token : keywordMapper,
  38. regex : "[A-Z]"
  39. }, {
  40. token : "keyword.operator",
  41. regex : "EQ|LT|GT|NE|GE|LE|OR|XOR"
  42. }, {
  43. token : "paren.lparen",
  44. regex : "[\\[]"
  45. }, {
  46. token : "paren.rparen",
  47. regex : "[\\]]"
  48. }, {
  49. token : "text",
  50. regex : "\\s+"
  51. } ]
  52. };
  53. };
  54. oop.inherits(GcodeHighlightRules, TextHighlightRules);
  55. exports.GcodeHighlightRules = GcodeHighlightRules;
  56. });
  57. ace.define("ace/mode/gcode",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/gcode_highlight_rules","ace/range"], function(require, exports, module) {
  58. "use strict";
  59. var oop = require("../lib/oop");
  60. var TextMode = require("./text").Mode;
  61. var GcodeHighlightRules = require("./gcode_highlight_rules").GcodeHighlightRules;
  62. var Range = require("../range").Range;
  63. var Mode = function() {
  64. this.HighlightRules = GcodeHighlightRules;
  65. this.$behaviour = this.$defaultBehaviour;
  66. };
  67. oop.inherits(Mode, TextMode);
  68. (function() {
  69. this.$id = "ace/mode/gcode";
  70. }).call(Mode.prototype);
  71. exports.Mode = Mode;
  72. });