1
/* ***** BEGIN LICENSE BLOCK *****
 
 
2
 * Distributed under the BSD license:
 
 
4
 * Copyright (c) 2012, Ajax.org B.V.
 
 
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.
 
 
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.
 
 
34
 * ***** END LICENSE BLOCK ***** */
 
 
36
define('ace/mode/pascal', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/pascal_highlight_rules', 'ace/mode/folding/coffee'], function(require, exports, module) {
 
 
39
var oop = require("../lib/oop");
 
 
40
var TextMode = require("./text").Mode;
 
 
41
var Tokenizer = require("../tokenizer").Tokenizer;
 
 
42
var PascalHighlightRules = require("./pascal_highlight_rules").PascalHighlightRules;
 
 
43
var FoldMode = require("./folding/coffee").FoldMode;
 
 
45
var Mode = function() {
 
 
46
    var highlighter = new PascalHighlightRules();
 
 
47
    this.foldingRules = new FoldMode();
 
 
48
    this.$tokenizer = new Tokenizer(highlighter.getRules());
 
 
50
oop.inherits(Mode, TextMode);
 
 
54
    this.lineCommentStart = ["--", "//"];
 
 
56
        {start: "(*", end: "*)"},
 
 
57
        {start: "{", end: "}"}
 
 
60
}).call(Mode.prototype);
 
 
65
define('ace/mode/pascal_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
 
 
68
var oop = require("../lib/oop");
 
 
69
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
 
 
71
var PascalHighlightRules = function() {
 
 
73
    this.$rules = { start: 
 
 
74
       [ { caseInsensitive: true,
 
 
75
           token: 'keyword.control.pascal',
 
 
76
           regex: '\\b(?:(absolute|abstract|all|and|and_then|array|as|asm|attribute|begin|bindable|case|class|const|constructor|destructor|div|do|do|else|end|except|export|exports|external|far|file|finalization|finally|for|forward|goto|if|implementation|import|in|inherited|initialization|interface|interrupt|is|label|library|mod|module|name|near|nil|not|object|of|only|operator|or|or_else|otherwise|packed|pow|private|program|property|protected|public|published|qualified|record|repeat|resident|restricted|segment|set|shl|shr|then|to|try|type|unit|until|uses|value|var|view|virtual|while|with|xor))\\b' },
 
 
77
         { caseInsensitive: true,           
 
 
79
            [ 'variable.pascal', "text",
 
 
80
              'storage.type.prototype.pascal',
 
 
81
              'entity.name.function.prototype.pascal' ],
 
 
82
           regex: '\\b(function|procedure)(\\s+)(\\w+)(\\.\\w+)?(?=(?:\\(.*?\\))?;\\s*(?:attribute|forward|external))' },
 
 
83
         { caseInsensitive: true,
 
 
85
            [ 'variable.pascal', "text",
 
 
86
              'storage.type.function.pascal',
 
 
87
              'entity.name.function.pascal' ],
 
 
88
           regex: '\\b(function|procedure)(\\s+)(\\w+)(\\.\\w+)?' },
 
 
89
         { token: 'constant.numeric.pascal',
 
 
90
           regex: '\\b((0(x|X)[0-9a-fA-F]*)|(([0-9]+\\.?[0-9]*)|(\\.[0-9]+))((e|E)(\\+|-)?[0-9]+)?)(L|l|UL|ul|u|U|F|f|ll|LL|ull|ULL)?\\b' },
 
 
91
         { token: 'punctuation.definition.comment.pascal',
 
 
94
            [ { token: 'comment.line.double-dash.pascal.one',
 
 
97
              { defaultToken: 'comment.line.double-dash.pascal.one' } ] },
 
 
98
         { token: 'punctuation.definition.comment.pascal',
 
 
101
            [ { token: 'comment.line.double-slash.pascal.two',
 
 
104
              { defaultToken: 'comment.line.double-slash.pascal.two' } ] },
 
 
105
         { token: 'punctuation.definition.comment.pascal',
 
 
108
            [ { token: 'punctuation.definition.comment.pascal',
 
 
111
              { defaultToken: 'comment.block.pascal.one' } ] },
 
 
112
         { token: 'punctuation.definition.comment.pascal',
 
 
115
            [ { token: 'punctuation.definition.comment.pascal',
 
 
118
              { defaultToken: 'comment.block.pascal.two' } ] },
 
 
119
         { token: 'punctuation.definition.string.begin.pascal',
 
 
122
            [ { token: 'constant.character.escape.pascal', regex: '\\\\.' },
 
 
123
              { token: 'punctuation.definition.string.end.pascal',
 
 
126
              { defaultToken: 'string.quoted.double.pascal' } ],
 
 
128
         { token: 'punctuation.definition.string.begin.pascal',
 
 
131
            [ { token: 'constant.character.escape.apostrophe.pascal',
 
 
133
              { token: 'punctuation.definition.string.end.pascal',
 
 
136
              { defaultToken: 'string.quoted.single.pascal' } ] },
 
 
137
          { token: 'keyword.operator',
 
 
138
           regex: '[+\\-;,/*%]|:=|=' } ] }
 
 
140
    this.normalizeRules();
 
 
143
oop.inherits(PascalHighlightRules, TextHighlightRules);
 
 
145
exports.PascalHighlightRules = PascalHighlightRules;
 
 
148
define('ace/mode/folding/coffee', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/folding/fold_mode', 'ace/range'], function(require, exports, module) {
 
 
151
var oop = require("../../lib/oop");
 
 
152
var BaseFoldMode = require("./fold_mode").FoldMode;
 
 
153
var Range = require("../../range").Range;
 
 
155
var FoldMode = exports.FoldMode = function() {};
 
 
156
oop.inherits(FoldMode, BaseFoldMode);
 
 
160
    this.getFoldWidgetRange = function(session, foldStyle, row) {
 
 
161
        var range = this.indentationBlock(session, row);
 
 
166
        var line = session.getLine(row);
 
 
167
        var startLevel = line.search(re);
 
 
168
        if (startLevel == -1 || line[startLevel] != "#")
 
 
171
        var startColumn = line.length;
 
 
172
        var maxRow = session.getLength();
 
 
176
        while (++row < maxRow) {
 
 
177
            line = session.getLine(row);
 
 
178
            var level = line.search(re);
 
 
183
            if (line[level] != "#")
 
 
189
        if (endRow > startRow) {
 
 
190
            var endColumn = session.getLine(endRow).length;
 
 
191
            return new Range(startRow, startColumn, endRow, endColumn);
 
 
194
    this.getFoldWidget = function(session, foldStyle, row) {
 
 
195
        var line = session.getLine(row);
 
 
196
        var indent = line.search(/\S/);
 
 
197
        var next = session.getLine(row + 1);
 
 
198
        var prev = session.getLine(row - 1);
 
 
199
        var prevIndent = prev.search(/\S/);
 
 
200
        var nextIndent = next.search(/\S/);
 
 
203
            session.foldWidgets[row - 1] = prevIndent!= -1 && prevIndent < nextIndent ? "start" : "";
 
 
206
        if (prevIndent == -1) {
 
 
207
            if (indent == nextIndent && line[indent] == "#" && next[indent] == "#") {
 
 
208
                session.foldWidgets[row - 1] = "";
 
 
209
                session.foldWidgets[row + 1] = "";
 
 
212
        } else if (prevIndent == indent && line[indent] == "#" && prev[indent] == "#") {
 
 
213
            if (session.getLine(row - 2).search(/\S/) == -1) {
 
 
214
                session.foldWidgets[row - 1] = "start";
 
 
215
                session.foldWidgets[row + 1] = "";
 
 
220
        if (prevIndent!= -1 && prevIndent < indent)
 
 
221
            session.foldWidgets[row - 1] = "start";
 
 
223
            session.foldWidgets[row - 1] = "";
 
 
225
        if (indent < nextIndent)
 
 
231
}).call(FoldMode.prototype);