mode-gcode.js 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. ace.define("ace/mode/gcode_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",[], 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. });
  73. (function() {
  74. ace.require(["ace/mode/gcode"], function(m) {
  75. if (typeof module == "object" && typeof exports == "object" && module) {
  76. module.exports = m;
  77. }
  78. });
  79. })();