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