Debian Codegraph @

extensions/CodeEditor/modules/lib/ace/mode-perl.js

raw symbols SCIP
1 ace.define("ace/mode/perl_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module){"use strict";
2 var oop = require("../lib/oop");
3 var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
4 var PerlHighlightRules = function () {
5 var keywords = ("base|constant|continue|else|elsif|for|foreach|format|goto|if|last|local|my|next|" +
6 "no|package|parent|redo|require|scalar|sub|unless|until|while|use|vars");
7 var buildinConstants = ("ARGV|ENV|INC|SIG");
8 var builtinFunctions = ("getprotobynumber|getprotobyname|getservbyname|gethostbyaddr|" +
9 "gethostbyname|getservbyport|getnetbyaddr|getnetbyname|getsockname|" +
10 "getpeername|setpriority|getprotoent|setprotoent|getpriority|" +
11 "endprotoent|getservent|setservent|endservent|sethostent|socketpair|" +
12 "getsockopt|gethostent|endhostent|setsockopt|setnetent|quotemeta|" +
13 "localtime|prototype|getnetent|endnetent|rewinddir|wantarray|getpwuid|" +
14 "closedir|getlogin|readlink|endgrent|getgrgid|getgrnam|shmwrite|" +
15 "shutdown|readline|endpwent|setgrent|readpipe|formline|truncate|" +
16 "dbmclose|syswrite|setpwent|getpwnam|getgrent|getpwent|ucfirst|sysread|" +
17 "setpgrp|shmread|sysseek|sysopen|telldir|defined|opendir|connect|" +
18 "lcfirst|getppid|binmode|syscall|sprintf|getpgrp|readdir|seekdir|" +
19 "waitpid|reverse|unshift|symlink|dbmopen|semget|msgrcv|rename|listen|" +
20 "chroot|msgsnd|shmctl|accept|unpack|exists|fileno|shmget|system|" +
21 "unlink|printf|gmtime|msgctl|semctl|values|rindex|substr|splice|" +
22 "length|msgget|select|socket|return|caller|delete|alarm|ioctl|index|" +
23 "undef|lstat|times|srand|chown|fcntl|close|write|umask|rmdir|study|" +
24 "sleep|chomp|untie|print|utime|mkdir|atan2|split|crypt|flock|chmod|" +
25 "BEGIN|bless|chdir|semop|shift|reset|link|stat|chop|grep|fork|dump|" +
26 "join|open|tell|pipe|exit|glob|warn|each|bind|sort|pack|eval|push|" +
27 "keys|getc|kill|seek|sqrt|send|wait|rand|tied|read|time|exec|recv|" +
28 "eof|chr|int|ord|exp|pos|pop|sin|log|abs|oct|hex|tie|cos|vec|END|ref|" +
29 "map|die|uc|lc|do");
30 var keywordMapper = this.createKeywordMapper({
31 "keyword": keywords,
32 "constant.language": buildinConstants,
33 "support.function": builtinFunctions
34 }, "identifier");
35 this.$rules = {
36 "start": [
37 {
38 token: "comment.doc",
39 regex: "^=(?:begin|item)\\b",
40 next: "block_comment"
41 }, {
42 token: "string.regexp",
43 regex: "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)"
44 }, {
45 token: "string", // single line
46 regex: '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
47 }, {
48 token: "string", // multi line string start
49 regex: '["].*\\\\$',
50 next: "qqstring"
51 }, {
52 token: "string", // single line
53 regex: "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
54 }, {
55 token: "string", // multi line string start
56 regex: "['].*\\\\$",
57 next: "qstring"
58 }, {
59 token: "constant.numeric", // hex
60 regex: "0x[0-9a-fA-F]+\\b"
61 }, {
62 token: "constant.numeric", // float
63 regex: "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
64 }, {
65 token: keywordMapper,
66 regex: "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
67 }, {
68 token: "keyword.operator",
69 regex: "%#|\\$#|\\.\\.\\.|\\|\\|=|>>=|<<=|<=>|&&=|=>|!~|\\^=|&=|\\|=|\\.=|x=|%=|\\/=|\\*=|\\-=|\\+=|=~|\\*\\*|\\-\\-|\\.\\.|\\|\\||&&|\\+\\+|\\->|!=|==|>=|<=|>>|<<|,|=|\\?\\:|\\^|\\||x|%|\\/|\\*|<|&|\\\\|~|!|>|\\.|\\-|\\+|\\-C|\\-b|\\-S|\\-u|\\-t|\\-p|\\-l|\\-d|\\-f|\\-g|\\-s|\\-z|\\-k|\\-e|\\-O|\\-T|\\-B|\\-M|\\-A|\\-X|\\-W|\\-c|\\-R|\\-o|\\-x|\\-w|\\-r|\\b(?:and|cmp|eq|ge|gt|le|lt|ne|not|or|xor)"
70 }, {
71 token: "comment",
72 regex: "#.*$"
73 }, {
74 token: "lparen",
75 regex: "[[({]"
76 }, {
77 token: "rparen",
78 regex: "[\\])}]"
79 }, {
80 token: "text",
81 regex: "\\s+"
82 }
83 ],
84 "qqstring": [
85 {
86 token: "string",
87 regex: '(?:(?:\\\\.)|(?:[^"\\\\]))*?"',
88 next: "start"
89 }, {
90 token: "string",
91 regex: '.+'
92 }
93 ],
94 "qstring": [
95 {
96 token: "string",
97 regex: "(?:(?:\\\\.)|(?:[^'\\\\]))*?'",
98 next: "start"
99 }, {
100 token: "string",
101 regex: '.+'
102 }
103 ],
104 "block_comment": [
105 {
106 token: "comment.doc",
107 regex: "^=cut\\b",
108 next: "start"
109 },
110 {
111 defaultToken: "comment.doc"
112 }
113 ]
114 };
115 };
116 oop.inherits(PerlHighlightRules, TextHighlightRules);
117 exports.PerlHighlightRules = PerlHighlightRules;
118
119 });
120
121 ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module){"use strict";
122 var Range = require("../range").Range;
123 var MatchingBraceOutdent = function () { };
124 (function () {
125 this.checkOutdent = function (line, input) {
126 if (!/^\s+$/.test(line))
127 return false;
128 return /^\s*\}/.test(input);
129 };
130 this.autoOutdent = function (doc, row) {
131 var line = doc.getLine(row);
132 var match = line.match(/^(\s*\})/);
133 if (!match)
134 return 0;
135 var column = match[1].length;
136 var openBracePos = doc.findMatchingBracket({ row: row, column: column });
137 if (!openBracePos || openBracePos.row == row)
138 return 0;
139 var indent = this.$getIndent(doc.getLine(openBracePos.row));
140 doc.replace(new Range(row, 0, row, column - 1), indent);
141 };
142 this.$getIndent = function (line) {
143 return line.match(/^\s*/)[0];
144 };
145 }).call(MatchingBraceOutdent.prototype);
146 exports.MatchingBraceOutdent = MatchingBraceOutdent;
147
148 });
149
150 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";
151 var oop = require("../../lib/oop");
152 var Range = require("../../range").Range;
153 var BaseFoldMode = require("./fold_mode").FoldMode;
154 var FoldMode = exports.FoldMode = function (commentRegex) {
155 if (commentRegex) {
156 this.foldingStartMarker = new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start));
157 this.foldingStopMarker = new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end));
158 }
159 };
160 oop.inherits(FoldMode, BaseFoldMode);
161 (function () {
162 this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
163 this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
164 this.singleLineBlockCommentRe = /^\s*(\/\*).*\*\/\s*$/;
165 this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
166 this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
167 this._getFoldWidgetBase = this.getFoldWidget;
168 this.getFoldWidget = function (session, foldStyle, row) {
169 var line = session.getLine(row);
170 if (this.singleLineBlockCommentRe.test(line)) {
171 if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
172 return "";
173 }
174 var fw = this._getFoldWidgetBase(session, foldStyle, row);
175 if (!fw && this.startRegionRe.test(line))
176 return "start"; // lineCommentRegionStart
177 return fw;
178 };
179 this.getFoldWidgetRange = function (session, foldStyle, row, forceMultiline) {
180 var line = session.getLine(row);
181 if (this.startRegionRe.test(line))
182 return this.getCommentRegionBlock(session, line, row);
183 var match = line.match(this.foldingStartMarker);
184 if (match) {
185 var i = match.index;
186 if (match[1])
187 return this.openingBracketBlock(session, match[1], row, i);
188 var range = session.getCommentFoldRange(row, i + match[0].length, 1);
189 if (range && !range.isMultiLine()) {
190 if (forceMultiline) {
191 range = this.getSectionRange(session, row);
192 }
193 else if (foldStyle != "all")
194 range = null;
195 }
196 return range;
197 }
198 if (foldStyle === "markbegin")
199 return;
200 var match = line.match(this.foldingStopMarker);
201 if (match) {
202 var i = match.index + match[0].length;
203 if (match[1])
204 return this.closingBracketBlock(session, match[1], row, i);
205 return session.getCommentFoldRange(row, i, -1);
206 }
207 };
208 this.getSectionRange = function (session, row) {
209 var line = session.getLine(row);
210 var startIndent = line.search(/\S/);
211 var startRow = row;
212 var startColumn = line.length;
213 row = row + 1;
214 var endRow = row;
215 var maxRow = session.getLength();
216 while (++row < maxRow) {
217 line = session.getLine(row);
218 var indent = line.search(/\S/);
219 if (indent === -1)
220 continue;
221 if (startIndent > indent)
222 break;
223 var subRange = this.getFoldWidgetRange(session, "all", row);
224 if (subRange) {
225 if (subRange.start.row <= startRow) {
226 break;
227 }
228 else if (subRange.isMultiLine()) {
229 row = subRange.end.row;
230 }
231 else if (startIndent == indent) {
232 break;
233 }
234 }
235 endRow = row;
236 }
237 return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
238 };
239 this.getCommentRegionBlock = function (session, line, row) {
240 var startColumn = line.search(/\s*$/);
241 var maxRow = session.getLength();
242 var startRow = row;
243 var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
244 var depth = 1;
245 while (++row < maxRow) {
246 line = session.getLine(row);
247 var m = re.exec(line);
248 if (!m)
249 continue;
250 if (m[1])
251 depth--;
252 else
253 depth++;
254 if (!depth)
255 break;
256 }
257 var endRow = row;
258 if (endRow > startRow) {
259 return new Range(startRow, startColumn, endRow, line.length);
260 }
261 };
262 }).call(FoldMode.prototype);
263
264 });
265
266 ace.define("ace/mode/perl",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/perl_highlight_rules","ace/mode/matching_brace_outdent","ace/mode/folding/cstyle"], function(require, exports, module){"use strict";
267 var oop = require("../lib/oop");
268 var TextMode = require("./text").Mode;
269 var PerlHighlightRules = require("./perl_highlight_rules").PerlHighlightRules;
270 var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
271 var CStyleFoldMode = require("./folding/cstyle").FoldMode;
272 var Mode = function () {
273 this.HighlightRules = PerlHighlightRules;
274 this.$outdent = new MatchingBraceOutdent();
275 this.foldingRules = new CStyleFoldMode({ start: "^=(begin|item)\\b", end: "^=(cut)\\b" });
276 this.$behaviour = this.$defaultBehaviour;
277 };
278 oop.inherits(Mode, TextMode);
279 (function () {
280 this.lineCommentStart = "#";
281 this.blockComment = [
282 { start: "=begin", end: "=cut", lineStartOnly: true },
283 { start: "=item", end: "=cut", lineStartOnly: true }
284 ];
285 this.getNextLineIndent = function (state, line, tab) {
286 var indent = this.$getIndent(line);
287 var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
288 var tokens = tokenizedLine.tokens;
289 if (tokens.length && tokens[tokens.length - 1].type == "comment") {
290 return indent;
291 }
292 if (state == "start") {
293 var match = line.match(/^.*[\{\(\[:]\s*$/);
294 if (match) {
295 indent += tab;
296 }
297 }
298 return indent;
299 };
300 this.checkOutdent = function (state, line, input) {
301 return this.$outdent.checkOutdent(line, input);
302 };
303 this.autoOutdent = function (state, doc, row) {
304 this.$outdent.autoOutdent(doc, row);
305 };
306 this.$id = "ace/mode/perl";
307 this.snippetFileId = "ace/snippets/perl";
308 }).call(Mode.prototype);
309 exports.Mode = Mode;
310
311 }); (function() {
312 ace.require(["ace/mode/perl"], function(m) {
313 if (typeof module == "object" && typeof exports == "object" && module) {
314 module.exports = m;
315 }
316 });
317 })();
318