Projekt

Obecné

Profil

Stáhnout (11.3 KB) Statistiky
| Větev: | Tag: | Revize:
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

    
4
var oop = require("../lib/oop");
5
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
6

    
7
var ForthHighlightRules = function() {
8

    
9
    this.$rules = { start: [ { include: '#forth' } ],
10
      '#comment':
11
       [ { token: 'comment.line.double-dash.forth',
12
           regex: '(?:^|\\s)--\\s.*$',
13
           comment: 'line comments for iForth' },
14
         { token: 'comment.line.backslash.forth',
15
           regex: '(?:^|\\s)\\\\[\\s\\S]*$',
16
           comment: 'ANSI line comment' },
17
         { token: 'comment.line.backslash-g.forth',
18
           regex: '(?:^|\\s)\\\\[Gg] .*$',
19
           comment: 'gForth line comment' },
20
         { token: 'comment.block.forth',
21
           regex: '(?:^|\\s)\\(\\*(?=\\s|$)',
22
           push:
23
            [ { token: 'comment.block.forth',
24
                regex: '(?:^|\\s)\\*\\)(?=\\s|$)',
25
                next: 'pop' },
26
              { defaultToken: 'comment.block.forth' } ],
27
           comment: 'multiline comments for iForth' },
28
         { token: 'comment.block.documentation.forth',
29
           regex: '\\bDOC\\b',
30
           caseInsensitive: true,
31
           push:
32
            [ { token: 'comment.block.documentation.forth',
33
                regex: '\\bENDDOC\\b',
34
                caseInsensitive: true,
35
                next: 'pop' },
36
              { defaultToken: 'comment.block.documentation.forth' } ],
37
           comment: 'documentation comments for iForth' },
38
         { token: 'comment.line.parentheses.forth',
39
           regex: '(?:^|\\s)\\.?\\( [^)]*\\)',
40
           comment: 'ANSI line comment' } ],
41
      '#constant':
42
       [ { token: 'constant.language.forth',
43
           regex: '(?:^|\\s)(?:TRUE|FALSE|BL|PI|CELL|C/L|R/O|W/O|R/W)(?=\\s|$)',
44
           caseInsensitive: true},
45
         { token: 'constant.numeric.forth',
46
           regex: '(?:^|\\s)[$#%]?[-+]?[0-9]+(?:\\.[0-9]*e-?[0-9]+|\\.?[0-9a-fA-F]*)(?=\\s|$)'},
47
         { token: 'constant.character.forth',
48
           regex: '(?:^|\\s)(?:[&^]\\S|(?:"|\')\\S(?:"|\'))(?=\\s|$)'}],
49
      '#forth':
50
       [ { include: '#constant' },
51
         { include: '#comment' },
52
         { include: '#string' },
53
         { include: '#word' },
54
         { include: '#variable' },
55
         { include: '#storage' },
56
         { include: '#word-def' } ],
57
      '#storage':
58
       [ { token: 'storage.type.forth',
59
           regex: '(?:^|\\s)(?:2CONSTANT|2VARIABLE|ALIAS|CONSTANT|CREATE-INTERPRET/COMPILE[:]?|CREATE|DEFER|FCONSTANT|FIELD|FVARIABLE|USER|VALUE|VARIABLE|VOCABULARY)(?=\\s|$)',
60
           caseInsensitive: true}],
61
      '#string':
62
       [ { token: 'string.quoted.double.forth',
63
           regex: '(ABORT" |BREAK" |\\." |C" |0"|S\\\\?" )([^"]+")',
64
           caseInsensitive: true},
65
         { token: 'string.unquoted.forth',
66
           regex: '(?:INCLUDE|NEEDS|REQUIRE|USE)[ ]\\S+(?=\\s|$)',
67
           caseInsensitive: true}],
68
      '#variable':
69
       [ { token: 'variable.language.forth',
70
           regex: '\\b(?:I|J)\\b',
71
           caseInsensitive: true } ],
72
      '#word':
73
       [ { token: 'keyword.control.immediate.forth',
74
           regex: '(?:^|\\s)\\[(?:\\?DO|\\+LOOP|AGAIN|BEGIN|DEFINED|DO|ELSE|ENDIF|FOR|IF|IFDEF|IFUNDEF|LOOP|NEXT|REPEAT|THEN|UNTIL|WHILE)\\](?=\\s|$)',
75
           caseInsensitive: true},
76
         { token: 'keyword.other.immediate.forth',
77
           regex: '(?:^|\\s)(?:COMPILE-ONLY|IMMEDIATE|IS|RESTRICT|TO|WHAT\'S|])(?=\\s|$)',
78
           caseInsensitive: true},
79
         { token: 'keyword.control.compile-only.forth',
80
           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|$)',
81
           caseInsensitive: true},
82
         { token: 'keyword.other.compile-only.forth',
83
           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|$)',
84
           caseInsensitive: true},
85
         { token: 'keyword.other.non-immediate.forth',
86
           regex: '(?:^|\\s)(?:\'|<IS>|<TO>|CHAR|END-STRUCT|INCLUDE[D]?|LOAD|NEEDS|REQUIRE[D]?|REVISION|SEE|STRUCT|THRU|USE)(?=\\s|$)',
87
           caseInsensitive: true},
88
         { token: 'keyword.other.warning.forth',
89
           regex: '(?:^|\\s)(?:~~|BREAK:|BREAK"|DBG)(?=\\s|$)',
90
           caseInsensitive: true}],
91
      '#word-def':
92
       [ { token:
93
            [ 'keyword.other.compile-only.forth',
94
              'keyword.other.compile-only.forth',
95
              'meta.block.forth',
96
              'entity.name.function.forth' ],
97
           regex: '(:NONAME)|(^:|\\s:)(\\s)(\\S+)(?=\\s|$)',
98
           caseInsensitive: true,
99
           push:
100
            [ { token: 'keyword.other.compile-only.forth',
101
                regex: ';(?:CODE)?',
102
                caseInsensitive: true,
103
                next: 'pop' },
104
              { include: '#constant' },
105
              { include: '#comment' },
106
              { include: '#string' },
107
              { include: '#word' },
108
              { include: '#variable' },
109
              { include: '#storage' },
110
              { defaultToken: 'meta.block.forth' } ] } ] };
111
    
112
    this.normalizeRules();
113
};
114

    
115
ForthHighlightRules.metaData = { fileTypes: [ 'frt', 'fs', 'ldr', 'fth', '4th' ],
116
      foldingStartMarker: '/\\*\\*|\\{\\s*$',
117
      foldingStopMarker: '\\*\\*/|^\\s*\\}',
118
      keyEquivalent: '^~F',
119
      name: 'Forth',
120
      scopeName: 'source.forth' };
121

    
122

    
123
oop.inherits(ForthHighlightRules, TextHighlightRules);
124

    
125
exports.ForthHighlightRules = ForthHighlightRules;
126
});
127

    
128
ace.define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module) {
129
"use strict";
130

    
131
var oop = require("../../lib/oop");
132
var Range = require("../../range").Range;
133
var BaseFoldMode = require("./fold_mode").FoldMode;
134

    
135
var FoldMode = exports.FoldMode = function(commentRegex) {
136
    if (commentRegex) {
137
        this.foldingStartMarker = new RegExp(
138
            this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
139
        );
140
        this.foldingStopMarker = new RegExp(
141
            this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
142
        );
143
    }
144
};
145
oop.inherits(FoldMode, BaseFoldMode);
146

    
147
(function() {
148
    
149
    this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
150
    this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
151
    this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/;
152
    this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
153
    this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
154
    this._getFoldWidgetBase = this.getFoldWidget;
155
    this.getFoldWidget = function(session, foldStyle, row) {
156
        var line = session.getLine(row);
157
    
158
        if (this.singleLineBlockCommentRe.test(line)) {
159
            if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
160
                return "";
161
        }
162
    
163
        var fw = this._getFoldWidgetBase(session, foldStyle, row);
164
    
165
        if (!fw && this.startRegionRe.test(line))
166
            return "start"; // lineCommentRegionStart
167
    
168
        return fw;
169
    };
170

    
171
    this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
172
        var line = session.getLine(row);
173
        
174
        if (this.startRegionRe.test(line))
175
            return this.getCommentRegionBlock(session, line, row);
176
        
177
        var match = line.match(this.foldingStartMarker);
178
        if (match) {
179
            var i = match.index;
180

    
181
            if (match[1])
182
                return this.openingBracketBlock(session, match[1], row, i);
183
                
184
            var range = session.getCommentFoldRange(row, i + match[0].length, 1);
185
            
186
            if (range && !range.isMultiLine()) {
187
                if (forceMultiline) {
188
                    range = this.getSectionRange(session, row);
189
                } else if (foldStyle != "all")
190
                    range = null;
191
            }
192
            
193
            return range;
194
        }
195

    
196
        if (foldStyle === "markbegin")
197
            return;
198

    
199
        var match = line.match(this.foldingStopMarker);
200
        if (match) {
201
            var i = match.index + match[0].length;
202

    
203
            if (match[1])
204
                return this.closingBracketBlock(session, match[1], row, i);
205

    
206
            return session.getCommentFoldRange(row, i, -1);
207
        }
208
    };
209
    
210
    this.getSectionRange = function(session, row) {
211
        var line = session.getLine(row);
212
        var startIndent = line.search(/\S/);
213
        var startRow = row;
214
        var startColumn = line.length;
215
        row = row + 1;
216
        var endRow = row;
217
        var maxRow = session.getLength();
218
        while (++row < maxRow) {
219
            line = session.getLine(row);
220
            var indent = line.search(/\S/);
221
            if (indent === -1)
222
                continue;
223
            if  (startIndent > indent)
224
                break;
225
            var subRange = this.getFoldWidgetRange(session, "all", row);
226
            
227
            if (subRange) {
228
                if (subRange.start.row <= startRow) {
229
                    break;
230
                } else if (subRange.isMultiLine()) {
231
                    row = subRange.end.row;
232
                } else if (startIndent == indent) {
233
                    break;
234
                }
235
            }
236
            endRow = row;
237
        }
238
        
239
        return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
240
    };
241
    this.getCommentRegionBlock = function(session, line, row) {
242
        var startColumn = line.search(/\s*$/);
243
        var maxRow = session.getLength();
244
        var startRow = row;
245
        
246
        var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
247
        var depth = 1;
248
        while (++row < maxRow) {
249
            line = session.getLine(row);
250
            var m = re.exec(line);
251
            if (!m) continue;
252
            if (m[1]) depth--;
253
            else depth++;
254

    
255
            if (!depth) break;
256
        }
257

    
258
        var endRow = row;
259
        if (endRow > startRow) {
260
            return new Range(startRow, startColumn, endRow, line.length);
261
        }
262
    };
263

    
264
}).call(FoldMode.prototype);
265

    
266
});
267

    
268
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) {
269
"use strict";
270

    
271
var oop = require("../lib/oop");
272
var TextMode = require("./text").Mode;
273
var ForthHighlightRules = require("./forth_highlight_rules").ForthHighlightRules;
274
var FoldMode = require("./folding/cstyle").FoldMode;
275

    
276
var Mode = function() {
277
    this.HighlightRules = ForthHighlightRules;
278
    this.foldingRules = new FoldMode();
279
    this.$behaviour = this.$defaultBehaviour;
280
};
281
oop.inherits(Mode, TextMode);
282

    
283
(function() {
284
    this.lineCommentStart = "--";
285
    this.blockComment = null;
286
    this.$id = "ace/mode/forth";
287
}).call(Mode.prototype);
288

    
289
exports.Mode = Mode;
290
});                (function() {
291
                    ace.require(["ace/mode/forth"], function(m) {
292
                        if (typeof module == "object" && typeof exports == "object" && module) {
293
                            module.exports = m;
294
                        }
295
                    });
296
                })();
297
            
(69-69/244)