forth_highlight_rules.js 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. /* ***** BEGIN LICENSE BLOCK *****
  2. * Distributed under the BSD license:
  3. *
  4. * Copyright (c) 2012, Ajax.org B.V.
  5. * All rights reserved.
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions are met:
  9. * * Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. * * Redistributions in binary form must reproduce the above copyright
  12. * notice, this list of conditions and the following disclaimer in the
  13. * documentation and/or other materials provided with the distribution.
  14. * * Neither the name of Ajax.org B.V. nor the
  15. * names of its contributors may be used to endorse or promote products
  16. * derived from this software without specific prior written permission.
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  19. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  20. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  21. * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
  22. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  23. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  24. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  25. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  26. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  27. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  28. *
  29. * ***** END LICENSE BLOCK ***** */
  30. /* This file was autogenerated from https://raw.github.com/vze26m98/Forth.tmbundle/master/Syntaxes/Forth.tmLanguage (uuid: ) */
  31. /****************************************************************************************
  32. * IT MIGHT NOT BE PERFECT ...But it's a good start from an existing *.tmlanguage file. *
  33. * fileTypes *
  34. ****************************************************************************************/
  35. define(function(require, exports, module) {
  36. "use strict";
  37. var oop = require("../lib/oop");
  38. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  39. var ForthHighlightRules = function() {
  40. // regexp must not have capturing parentheses. Use (?:) instead.
  41. // regexps are ordered -> the first match is used
  42. this.$rules = { start: [ { include: '#forth' } ],
  43. '#comment':
  44. [ { token: 'comment.line.double-dash.forth',
  45. regex: '(?:^|\\s)--\\s.*$',
  46. comment: 'line comments for iForth' },
  47. { token: 'comment.line.backslash.forth',
  48. regex: '(?:^|\\s)\\\\[\\s\\S]*$',
  49. comment: 'ANSI line comment' },
  50. { token: 'comment.line.backslash-g.forth',
  51. regex: '(?:^|\\s)\\\\[Gg] .*$',
  52. comment: 'gForth line comment' },
  53. { token: 'comment.block.forth',
  54. regex: '(?:^|\\s)\\(\\*(?=\\s|$)',
  55. push:
  56. [ { token: 'comment.block.forth',
  57. regex: '(?:^|\\s)\\*\\)(?=\\s|$)',
  58. next: 'pop' },
  59. { defaultToken: 'comment.block.forth' } ],
  60. comment: 'multiline comments for iForth' },
  61. { token: 'comment.block.documentation.forth',
  62. regex: '\\bDOC\\b',
  63. caseInsensitive: true,
  64. push:
  65. [ { token: 'comment.block.documentation.forth',
  66. regex: '\\bENDDOC\\b',
  67. caseInsensitive: true,
  68. next: 'pop' },
  69. { defaultToken: 'comment.block.documentation.forth' } ],
  70. comment: 'documentation comments for iForth' },
  71. { token: 'comment.line.parentheses.forth',
  72. regex: '(?:^|\\s)\\.?\\( [^)]*\\)',
  73. comment: 'ANSI line comment' } ],
  74. '#constant':
  75. [ { token: 'constant.language.forth',
  76. regex: '(?:^|\\s)(?:TRUE|FALSE|BL|PI|CELL|C/L|R/O|W/O|R/W)(?=\\s|$)',
  77. caseInsensitive: true},
  78. { token: 'constant.numeric.forth',
  79. regex: '(?:^|\\s)[$#%]?[-+]?[0-9]+(?:\\.[0-9]*e-?[0-9]+|\\.?[0-9a-fA-F]*)(?=\\s|$)'},
  80. { token: 'constant.character.forth',
  81. regex: '(?:^|\\s)(?:[&^]\\S|(?:"|\')\\S(?:"|\'))(?=\\s|$)'}],
  82. '#forth':
  83. [ { include: '#constant' },
  84. { include: '#comment' },
  85. { include: '#string' },
  86. { include: '#word' },
  87. { include: '#variable' },
  88. { include: '#storage' },
  89. { include: '#word-def' } ],
  90. '#storage':
  91. [ { token: 'storage.type.forth',
  92. regex: '(?:^|\\s)(?:2CONSTANT|2VARIABLE|ALIAS|CONSTANT|CREATE-INTERPRET/COMPILE[:]?|CREATE|DEFER|FCONSTANT|FIELD|FVARIABLE|USER|VALUE|VARIABLE|VOCABULARY)(?=\\s|$)',
  93. caseInsensitive: true}],
  94. '#string':
  95. [ { token: 'string.quoted.double.forth',
  96. regex: '(ABORT" |BREAK" |\\." |C" |0"|S\\\\?" )([^"]+")',
  97. caseInsensitive: true},
  98. { token: 'string.unquoted.forth',
  99. regex: '(?:INCLUDE|NEEDS|REQUIRE|USE)[ ]\\S+(?=\\s|$)',
  100. caseInsensitive: true}],
  101. '#variable':
  102. [ { token: 'variable.language.forth',
  103. regex: '\\b(?:I|J)\\b',
  104. caseInsensitive: true } ],
  105. '#word':
  106. [ { token: 'keyword.control.immediate.forth',
  107. regex: '(?:^|\\s)\\[(?:\\?DO|\\+LOOP|AGAIN|BEGIN|DEFINED|DO|ELSE|ENDIF|FOR|IF|IFDEF|IFUNDEF|LOOP|NEXT|REPEAT|THEN|UNTIL|WHILE)\\](?=\\s|$)',
  108. caseInsensitive: true},
  109. { token: 'keyword.other.immediate.forth',
  110. regex: '(?:^|\\s)(?:COMPILE-ONLY|IMMEDIATE|IS|RESTRICT|TO|WHAT\'S|])(?=\\s|$)',
  111. caseInsensitive: true},
  112. { token: 'keyword.control.compile-only.forth',
  113. regex: '(?:^|\\s)(?:-DO|\\-LOOP|\\?DO|\\?LEAVE|\\+DO|\\+LOOP|ABORT\\"|AGAIN|AHEAD|BEGIN|CASE|DO|ELSE|ENDCASE|ENDIF|ENDOF|ENDTRY\\-IFERROR|ENDTRY|FOR|IF|IFERROR|LEAVE|LOOP|NEXT|RECOVER|REPEAT|RESTORE|THEN|TRY|U\\-DO|U\\+DO|UNTIL|WHILE)(?=\\s|$)',
  114. caseInsensitive: true},
  115. { token: 'keyword.other.compile-only.forth',
  116. regex: '(?:^|\\s)(?:\\?DUP-0=-IF|\\?DUP-IF|\\)|\\[|\\[\'\\]|\\[CHAR\\]|\\[COMPILE\\]|\\[IS\\]|\\[TO\\]|<COMPILATION|<INTERPRETATION|ASSERT\\(|ASSERT0\\(|ASSERT1\\(|ASSERT2\\(|ASSERT3\\(|COMPILATION>|DEFERS|DOES>|INTERPRETATION>|OF|POSTPONE)(?=\\s|$)',
  117. caseInsensitive: true},
  118. { token: 'keyword.other.non-immediate.forth',
  119. regex: '(?:^|\\s)(?:\'|<IS>|<TO>|CHAR|END-STRUCT|INCLUDE[D]?|LOAD|NEEDS|REQUIRE[D]?|REVISION|SEE|STRUCT|THRU|USE)(?=\\s|$)',
  120. caseInsensitive: true},
  121. { token: 'keyword.other.warning.forth',
  122. regex: '(?:^|\\s)(?:~~|BREAK:|BREAK"|DBG)(?=\\s|$)',
  123. caseInsensitive: true}],
  124. '#word-def':
  125. [ { token:
  126. [ 'keyword.other.compile-only.forth',
  127. 'keyword.other.compile-only.forth',
  128. 'meta.block.forth',
  129. 'entity.name.function.forth' ],
  130. regex: '(:NONAME)|(^:|\\s:)(\\s)(\\S+)(?=\\s|$)',
  131. caseInsensitive: true,
  132. push:
  133. [ { token: 'keyword.other.compile-only.forth',
  134. regex: ';(?:CODE)?',
  135. caseInsensitive: true,
  136. next: 'pop' },
  137. { include: '#constant' },
  138. { include: '#comment' },
  139. { include: '#string' },
  140. { include: '#word' },
  141. { include: '#variable' },
  142. { include: '#storage' },
  143. { defaultToken: 'meta.block.forth' } ] } ] }
  144. this.normalizeRules();
  145. };
  146. ForthHighlightRules.metaData = { fileTypes: [ 'frt', 'fs', 'ldr' ],
  147. foldingStartMarker: '/\\*\\*|\\{\\s*$',
  148. foldingStopMarker: '\\*\\*/|^\\s*\\}',
  149. keyEquivalent: '^~F',
  150. name: 'Forth',
  151. scopeName: 'source.forth' }
  152. oop.inherits(ForthHighlightRules, TextHighlightRules);
  153. exports.ForthHighlightRules = ForthHighlightRules;
  154. });