| 1 |
ace.define("ace/mode/forth_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 ForthHighlightRules = function () { |
| 6 |
this.$rules = { start: [{ include: '#forth' }], |
| 7 |
'#comment': [{ token: 'comment.line.double-dash.forth', |
| 8 |
regex: '(?:^|\\s)--\\s.*$', |
| 9 |
comment: 'line comments for iForth' }, |
| 10 |
{ token: 'comment.line.backslash.forth', |
| 11 |
regex: '(?:^|\\s)\\\\[\\s\\S]*$', |
| 12 |
comment: 'ANSI line comment' }, |
| 13 |
{ token: 'comment.line.backslash-g.forth', |
| 14 |
regex: '(?:^|\\s)\\\\[Gg] .*$', |
| 15 |
comment: 'gForth line comment' }, |
| 16 |
{ token: 'comment.block.forth', |
| 17 |
regex: '(?:^|\\s)\\(\\*(?=\\s|$)', |
| 18 |
push: [{ token: 'comment.block.forth', |
| 19 |
regex: '(?:^|\\s)\\*\\)(?=\\s|$)', |
| 20 |
next: 'pop' }, |
| 21 |
{ defaultToken: 'comment.block.forth' }], |
| 22 |
comment: 'multiline comments for iForth' }, |
| 23 |
{ token: 'comment.block.documentation.forth', |
| 24 |
regex: '\\bDOC\\b', |
| 25 |
caseInsensitive: true, |
| 26 |
push: [{ token: 'comment.block.documentation.forth', |
| 27 |
regex: '\\bENDDOC\\b', |
| 28 |
caseInsensitive: true, |
| 29 |
next: 'pop' }, |
| 30 |
{ defaultToken: 'comment.block.documentation.forth' }], |
| 31 |
comment: 'documentation comments for iForth' }, |
| 32 |
{ token: 'comment.line.parentheses.forth', |
| 33 |
regex: '(?:^|\\s)\\.?\\( [^)]*\\)', |
| 34 |
comment: 'ANSI line comment' }], |
| 35 |
'#constant': [{ token: 'constant.language.forth', |
| 36 |
regex: '(?:^|\\s)(?:TRUE|FALSE|BL|PI|CELL|C/L|R/O|W/O|R/W)(?=\\s|$)', |
| 37 |
caseInsensitive: true }, |
| 38 |
{ token: 'constant.numeric.forth', |
| 39 |
regex: '(?:^|\\s)[$#%]?[-+]?[0-9]+(?:\\.[0-9]*e-?[0-9]+|\\.?[0-9a-fA-F]*)(?=\\s|$)' }, |
| 40 |
{ token: 'constant.character.forth', |
| 41 |
regex: '(?:^|\\s)(?:[&^]\\S|(?:"|\')\\S(?:"|\'))(?=\\s|$)' }], |
| 42 |
'#forth': [{ include: '#constant' }, |
| 43 |
{ include: '#comment' }, |
| 44 |
{ include: '#string' }, |
| 45 |
{ include: '#word' }, |
| 46 |
{ include: '#variable' }, |
| 47 |
{ include: '#storage' }, |
| 48 |
{ include: '#word-def' }], |
| 49 |
'#storage': [{ token: 'storage.type.forth', |
| 50 |
regex: '(?:^|\\s)(?:2CONSTANT|2VARIABLE|ALIAS|CONSTANT|CREATE-INTERPRET/COMPILE[:]?|CREATE|DEFER|FCONSTANT|FIELD|FVARIABLE|USER|VALUE|VARIABLE|VOCABULARY)(?=\\s|$)', |
| 51 |
caseInsensitive: true }], |
| 52 |
'#string': [{ token: 'string.quoted.double.forth', |
| 53 |
regex: '(ABORT" |BREAK" |\\." |C" |0"|S\\\\?" )([^"]+")', |
| 54 |
caseInsensitive: true }, |
| 55 |
{ token: 'string.unquoted.forth', |
| 56 |
regex: '(?:INCLUDE|NEEDS|REQUIRE|USE)[ ]\\S+(?=\\s|$)', |
| 57 |
caseInsensitive: true }], |
| 58 |
'#variable': [{ token: 'variable.language.forth', |
| 59 |
regex: '\\b(?:I|J)\\b', |
| 60 |
caseInsensitive: true }], |
| 61 |
'#word': [{ token: 'keyword.control.immediate.forth', |
| 62 |
regex: '(?:^|\\s)\\[(?:\\?DO|\\+LOOP|AGAIN|BEGIN|DEFINED|DO|ELSE|ENDIF|FOR|IF|IFDEF|IFUNDEF|LOOP|NEXT|REPEAT|THEN|UNTIL|WHILE)\\](?=\\s|$)', |
| 63 |
caseInsensitive: true }, |
| 64 |
{ token: 'keyword.other.immediate.forth', |
| 65 |
regex: '(?:^|\\s)(?:COMPILE-ONLY|IMMEDIATE|IS|RESTRICT|TO|WHAT\'S|])(?=\\s|$)', |
| 66 |
caseInsensitive: true }, |
| 67 |
{ token: 'keyword.control.compile-only.forth', |
| 68 |
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|$)', |
| 69 |
caseInsensitive: true }, |
| 70 |
{ token: 'keyword.other.compile-only.forth', |
| 71 |
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|$)', |
| 72 |
caseInsensitive: true }, |
| 73 |
{ token: 'keyword.other.non-immediate.forth', |
| 74 |
regex: '(?:^|\\s)(?:\'|<IS>|<TO>|CHAR|END-STRUCT|INCLUDE[D]?|LOAD|NEEDS|REQUIRE[D]?|REVISION|SEE|STRUCT|THRU|USE)(?=\\s|$)', |
| 75 |
caseInsensitive: true }, |
| 76 |
{ token: 'keyword.other.warning.forth', |
| 77 |
regex: '(?:^|\\s)(?:~~|BREAK:|BREAK"|DBG)(?=\\s|$)', |
| 78 |
caseInsensitive: true }], |
| 79 |
'#word-def': [{ token: ['keyword.other.compile-only.forth', |
| 80 |
'keyword.other.compile-only.forth', |
| 81 |
'meta.block.forth', |
| 82 |
'entity.name.function.forth'], |
| 83 |
regex: '(:NONAME)|(^:|\\s:)(\\s)(\\S+)(?=\\s|$)', |
| 84 |
caseInsensitive: true, |
| 85 |
push: [{ token: 'keyword.other.compile-only.forth', |
| 86 |
regex: ';(?:CODE)?', |
| 87 |
caseInsensitive: true, |
| 88 |
next: 'pop' }, |
| 89 |
{ include: '#constant' }, |
| 90 |
{ include: '#comment' }, |
| 91 |
{ include: '#string' }, |
| 92 |
{ include: '#word' }, |
| 93 |
{ include: '#variable' }, |
| 94 |
{ include: '#storage' }, |
| 95 |
{ defaultToken: 'meta.block.forth' }] }] }; |
| 96 |
this.normalizeRules(); |
| 97 |
}; |
| 98 |
ForthHighlightRules.metaData = { fileTypes: ['frt', 'fs', 'ldr', 'fth', '4th'], |
| 99 |
foldingStartMarker: '/\\*\\*|\\{\\s*$', |
| 100 |
foldingStopMarker: '\\*\\*/|^\\s*\\}', |
| 101 |
keyEquivalent: '^~F', |
| 102 |
name: 'Forth', |
| 103 |
scopeName: 'source.forth' }; |
| 104 |
oop.inherits(ForthHighlightRules, TextHighlightRules); |
| 105 |
exports.ForthHighlightRules = ForthHighlightRules; |
| 106 |
|
| 107 |
}); |
| 108 |
|
| 109 |
ace.define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module){"use strict"; |
| 110 |
var oop = require("../../lib/oop"); |
| 111 |
var Range = require("../../range").Range; |
| 112 |
var BaseFoldMode = require("./fold_mode").FoldMode; |
| 113 |
var FoldMode = exports.FoldMode = function (commentRegex) { |
| 114 |
if (commentRegex) { |
| 115 |
this.foldingStartMarker = new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)); |
| 116 |
this.foldingStopMarker = new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)); |
| 117 |
} |
| 118 |
}; |
| 119 |
oop.inherits(FoldMode, BaseFoldMode); |
| 120 |
(function () { |
| 121 |
this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/; |
| 122 |
this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/; |
| 123 |
this.singleLineBlockCommentRe = /^\s*(\/\*).*\*\/\s*$/; |
| 124 |
this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/; |
| 125 |
this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/; |
| 126 |
this._getFoldWidgetBase = this.getFoldWidget; |
| 127 |
this.getFoldWidget = function (session, foldStyle, row) { |
| 128 |
var line = session.getLine(row); |
| 129 |
if (this.singleLineBlockCommentRe.test(line)) { |
| 130 |
if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line)) |
| 131 |
return ""; |
| 132 |
} |
| 133 |
var fw = this._getFoldWidgetBase(session, foldStyle, row); |
| 134 |
if (!fw && this.startRegionRe.test(line)) |
| 135 |
return "start"; |
| 136 |
return fw; |
| 137 |
}; |
| 138 |
this.getFoldWidgetRange = function (session, foldStyle, row, forceMultiline) { |
| 139 |
var line = session.getLine(row); |
| 140 |
if (this.startRegionRe.test(line)) |
| 141 |
return this.getCommentRegionBlock(session, line, row); |
| 142 |
var match = line.match(this.foldingStartMarker); |
| 143 |
if (match) { |
| 144 |
var i = match.index; |
| 145 |
if (match[1]) |
| 146 |
return this.openingBracketBlock(session, match[1], row, i); |
| 147 |
var range = session.getCommentFoldRange(row, i + match[0].length, 1); |
| 148 |
if (range && !range.isMultiLine()) { |
| 149 |
if (forceMultiline) { |
| 150 |
range = this.getSectionRange(session, row); |
| 151 |
} |
| 152 |
else if (foldStyle != "all") |
| 153 |
range = null; |
| 154 |
} |
| 155 |
return range; |
| 156 |
} |
| 157 |
if (foldStyle === "markbegin") |
| 158 |
return; |
| 159 |
var match = line.match(this.foldingStopMarker); |
| 160 |
if (match) { |
| 161 |
var i = match.index + match[0].length; |
| 162 |
if (match[1]) |
| 163 |
return this.closingBracketBlock(session, match[1], row, i); |
| 164 |
return session.getCommentFoldRange(row, i, -1); |
| 165 |
} |
| 166 |
}; |
| 167 |
this.getSectionRange = function (session, row) { |
| 168 |
var line = session.getLine(row); |
| 169 |
var startIndent = line.search(/\S/); |
| 170 |
var startRow = row; |
| 171 |
var startColumn = line.length; |
| 172 |
row = row + 1; |
| 173 |
var endRow = row; |
| 174 |
var maxRow = session.getLength(); |
| 175 |
while (++row < maxRow) { |
| 176 |
line = session.getLine(row); |
| 177 |
var indent = line.search(/\S/); |
| 178 |
if (indent === -1) |
| 179 |
continue; |
| 180 |
if (startIndent > indent) |
| 181 |
break; |
| 182 |
var subRange = this.getFoldWidgetRange(session, "all", row); |
| 183 |
if (subRange) { |
| 184 |
if (subRange.start.row <= startRow) { |
| 185 |
break; |
| 186 |
} |
| 187 |
else if (subRange.isMultiLine()) { |
| 188 |
row = subRange.end.row; |
| 189 |
} |
| 190 |
else if (startIndent == indent) { |
| 191 |
break; |
| 192 |
} |
| 193 |
} |
| 194 |
endRow = row; |
| 195 |
} |
| 196 |
return new Range(startRow, startColumn, endRow, session.getLine(endRow).length); |
| 197 |
}; |
| 198 |
this.getCommentRegionBlock = function (session, line, row) { |
| 199 |
var startColumn = line.search(/\s*$/); |
| 200 |
var maxRow = session.getLength(); |
| 201 |
var startRow = row; |
| 202 |
var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/; |
| 203 |
var depth = 1; |
| 204 |
while (++row < maxRow) { |
| 205 |
line = session.getLine(row); |
| 206 |
var m = re.exec(line); |
| 207 |
if (!m) |
| 208 |
continue; |
| 209 |
if (m[1]) |
| 210 |
depth--; |
| 211 |
else |
| 212 |
depth++; |
| 213 |
if (!depth) |
| 214 |
break; |
| 215 |
} |
| 216 |
var endRow = row; |
| 217 |
if (endRow > startRow) { |
| 218 |
return new Range(startRow, startColumn, endRow, line.length); |
| 219 |
} |
| 220 |
}; |
| 221 |
}).call(FoldMode.prototype); |
| 222 |
|
| 223 |
}); |
| 224 |
|
| 225 |
ace.define("ace/mode/forth",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/forth_highlight_rules","ace/mode/folding/cstyle"], function(require, exports, module){ |
| 226 |
|
| 227 |
|
| 228 |
"use strict"; |
| 229 |
var oop = require("../lib/oop"); |
| 230 |
var TextMode = require("./text").Mode; |
| 231 |
var ForthHighlightRules = require("./forth_highlight_rules").ForthHighlightRules; |
| 232 |
var FoldMode = require("./folding/cstyle").FoldMode; |
| 233 |
var Mode = function () { |
| 234 |
this.HighlightRules = ForthHighlightRules; |
| 235 |
this.foldingRules = new FoldMode(); |
| 236 |
this.$behaviour = this.$defaultBehaviour; |
| 237 |
}; |
| 238 |
oop.inherits(Mode, TextMode); |
| 239 |
(function () { |
| 240 |
this.lineCommentStart = "--"; |
| 241 |
this.blockComment = null; |
| 242 |
this.$id = "ace/mode/forth"; |
| 243 |
}).call(Mode.prototype); |
| 244 |
exports.Mode = Mode; |
| 245 |
|
| 246 |
}); (function() { |
| 247 |
ace.require(["ace/mode/forth"], function(m) { |
| 248 |
if (typeof module == "object" && typeof exports == "object" && module) { |
| 249 |
module.exports = m; |
| 250 |
} |
| 251 |
}); |
| 252 |
})(); |
| 253 |
|