Debian Codegraph @

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

raw symbols SCIP
1 ace.define("ace/mode/scheme_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 SchemeHighlightRules = function () {
5 var keywordControl = "case|do|let|loop|if|else|when";
6 var keywordOperator = "eq?|eqv?|equal?|and|or|not|null?";
7 var constantLanguage = "#t|#f";
8 var supportFunctions = "cons|car|cdr|cond|lambda|lambda*|syntax-rules|format|set!|quote|eval|append|list|list?|member?|load";
9 var keywordMapper = this.createKeywordMapper({
10 "keyword.control": keywordControl,
11 "keyword.operator": keywordOperator,
12 "constant.language": constantLanguage,
13 "support.function": supportFunctions
14 }, "identifier", true);
15 this.$rules =
16 {
17 "start": [
18 {
19 token: "comment",
20 regex: ";.*$"
21 },
22 {
23 "token": ["storage.type.function-type.scheme", "text", "entity.name.function.scheme"],
24 "regex": "(?:\\b(?:(define|define-syntax|define-macro))\\b)(\\s+)((?:\\w|\\-|\\!|\\?)*)"
25 },
26 {
27 "token": "punctuation.definition.constant.character.scheme",
28 "regex": "#:\\S+"
29 },
30 {
31 "token": ["punctuation.definition.variable.scheme", "variable.other.global.scheme", "punctuation.definition.variable.scheme"],
32 "regex": "(\\*)(\\S*)(\\*)"
33 },
34 {
35 "token": "constant.numeric", // hex
36 "regex": "#[xXoObB][0-9a-fA-F]+"
37 },
38 {
39 "token": "constant.numeric", // float
40 "regex": "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?"
41 },
42 {
43 "token": keywordMapper,
44 "regex": "[a-zA-Z_#][a-zA-Z0-9_\\-\\?\\!\\*]*"
45 },
46 {
47 "token": "string",
48 "regex": '"(?=.)',
49 "next": "qqstring"
50 }
51 ],
52 "qqstring": [
53 {
54 "token": "constant.character.escape.scheme",
55 "regex": "\\\\."
56 },
57 {
58 "token": "string",
59 "regex": '[^"\\\\]+',
60 "merge": true
61 }, {
62 "token": "string",
63 "regex": "\\\\$",
64 "next": "qqstring",
65 "merge": true
66 }, {
67 "token": "string",
68 "regex": '"|$',
69 "next": "start",
70 "merge": true
71 }
72 ]
73 };
74 };
75 oop.inherits(SchemeHighlightRules, TextHighlightRules);
76 exports.SchemeHighlightRules = SchemeHighlightRules;
77
78 });
79
80 ace.define("ace/mode/matching_parens_outdent",["require","exports","module","ace/range"], function(require, exports, module){"use strict";
81 var Range = require("../range").Range;
82 var MatchingParensOutdent = function () { };
83 (function () {
84 this.checkOutdent = function (line, input) {
85 if (!/^\s+$/.test(line))
86 return false;
87 return /^\s*\)/.test(input);
88 };
89 this.autoOutdent = function (doc, row) {
90 var line = doc.getLine(row);
91 var match = line.match(/^(\s*\))/);
92 if (!match)
93 return 0;
94 var column = match[1].length;
95 var openBracePos = doc.findMatchingBracket({ row: row, column: column });
96 if (!openBracePos || openBracePos.row == row)
97 return 0;
98 var indent = this.$getIndent(doc.getLine(openBracePos.row));
99 doc.replace(new Range(row, 0, row, column - 1), indent);
100 };
101 this.$getIndent = function (line) {
102 var match = line.match(/^(\s+)/);
103 if (match) {
104 return match[1];
105 }
106 return "";
107 };
108 }).call(MatchingParensOutdent.prototype);
109 exports.MatchingParensOutdent = MatchingParensOutdent;
110
111 });
112
113 ace.define("ace/mode/scheme",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/scheme_highlight_rules","ace/mode/matching_parens_outdent"], function(require, exports, module){"use strict";
114 var oop = require("../lib/oop");
115 var TextMode = require("./text").Mode;
116 var SchemeHighlightRules = require("./scheme_highlight_rules").SchemeHighlightRules;
117 var MatchingParensOutdent = require("./matching_parens_outdent").MatchingParensOutdent;
118 var Mode = function () {
119 this.HighlightRules = SchemeHighlightRules;
120 this.$outdent = new MatchingParensOutdent();
121 this.$behaviour = this.$defaultBehaviour;
122 };
123 oop.inherits(Mode, TextMode);
124 (function () {
125 this.lineCommentStart = ";";
126 this.minorIndentFunctions = ["define", "lambda", "define-macro", "define-syntax", "syntax-rules", "define-record-type", "define-structure"];
127 this.$toIndent = function (str) {
128 return str.split('').map(function (ch) {
129 if (/\s/.exec(ch)) {
130 return ch;
131 }
132 else {
133 return ' ';
134 }
135 }).join('');
136 };
137 this.$calculateIndent = function (line, tab) {
138 var baseIndent = this.$getIndent(line);
139 var delta = 0;
140 var isParen, ch;
141 for (var i = line.length - 1; i >= 0; i--) {
142 ch = line[i];
143 if (ch === '(') {
144 delta--;
145 isParen = true;
146 }
147 else if (ch === '(' || ch === '[' || ch === '{') {
148 delta--;
149 isParen = false;
150 }
151 else if (ch === ')' || ch === ']' || ch === '}') {
152 delta++;
153 }
154 if (delta < 0) {
155 break;
156 }
157 }
158 if (delta < 0 && isParen) {
159 i += 1;
160 var iBefore = i;
161 var fn = '';
162 while (true) {
163 ch = line[i];
164 if (ch === ' ' || ch === '\t') {
165 if (this.minorIndentFunctions.indexOf(fn) !== -1) {
166 return this.$toIndent(line.substring(0, iBefore - 1) + tab);
167 }
168 else {
169 return this.$toIndent(line.substring(0, i + 1));
170 }
171 }
172 else if (ch === undefined) {
173 return this.$toIndent(line.substring(0, iBefore - 1) + tab);
174 }
175 fn += line[i];
176 i++;
177 }
178 }
179 else if (delta < 0 && !isParen) {
180 return this.$toIndent(line.substring(0, i + 1));
181 }
182 else if (delta > 0) {
183 baseIndent = baseIndent.substring(0, baseIndent.length - tab.length);
184 return baseIndent;
185 }
186 else {
187 return baseIndent;
188 }
189 };
190 this.getNextLineIndent = function (state, line, tab) {
191 return this.$calculateIndent(line, tab);
192 };
193 this.checkOutdent = function (state, line, input) {
194 return this.$outdent.checkOutdent(line, input);
195 };
196 this.autoOutdent = function (state, doc, row) {
197 this.$outdent.autoOutdent(doc, row);
198 };
199 this.$id = "ace/mode/scheme";
200 }).call(Mode.prototype);
201 exports.Mode = Mode;
202
203 }); (function() {
204 ace.require(["ace/mode/scheme"], function(m) {
205 if (typeof module == "object" && typeof exports == "object" && module) {
206 module.exports = m;
207 }
208 });
209 })();
210