aboutsummaryrefslogtreecommitdiff
path: root/imports/codemirror/mode/rust
diff options
context:
space:
mode:
authorValerio Virgillito2012-03-06 16:17:54 -0800
committerValerio Virgillito2012-03-06 16:17:54 -0800
commitc2805e03c84b6e598556fd06d1ede7aaeea7ce9c (patch)
treeb033421762f5e0fedbc8700bfc1f175c7c5cabcf /imports/codemirror/mode/rust
parent1cd89d4d06e3a8f2c221628b19cf26a2c69f5d3f (diff)
downloadninja-c2805e03c84b6e598556fd06d1ede7aaeea7ce9c.tar.gz
Squashed commit FileIO-Build-Candidate into Master
Fixing issues with HTML and CSS URLs. Adjusted RegEx logic. Also code a mirror update and undo/redo changes were merged into this request. Signed-off-by: Valerio Virgillito <valerio@motorola.com>
Diffstat (limited to 'imports/codemirror/mode/rust')
-rw-r--r--[-rwxr-xr-x]imports/codemirror/mode/rust/index.html6
-rw-r--r--[-rwxr-xr-x]imports/codemirror/mode/rust/rust.js51
2 files changed, 39 insertions, 18 deletions
diff --git a/imports/codemirror/mode/rust/index.html b/imports/codemirror/mode/rust/index.html
index a84c61e5..3b811e35 100755..100644
--- a/imports/codemirror/mode/rust/index.html
+++ b/imports/codemirror/mode/rust/index.html
@@ -15,9 +15,9 @@
15// Demo code. 15// Demo code.
16 16
17type foo<T> = int; 17type foo<T> = int;
18tag bar { 18enum bar {
19 some(int, foo<float>); 19 some(int, foo<float>),
20 none; 20 none
21} 21}
22 22
23fn check_crate(x: int) { 23fn check_crate(x: int) {
diff --git a/imports/codemirror/mode/rust/rust.js b/imports/codemirror/mode/rust/rust.js
index 5ab964c1..2a5caac2 100755..100644
--- a/imports/codemirror/mode/rust/rust.js
+++ b/imports/codemirror/mode/rust/rust.js
@@ -4,12 +4,12 @@ CodeMirror.defineMode("rust", function() {
4 "if": "if-style", "while": "if-style", "else": "else-style", 4 "if": "if-style", "while": "if-style", "else": "else-style",
5 "do": "else-style", "ret": "else-style", "fail": "else-style", 5 "do": "else-style", "ret": "else-style", "fail": "else-style",
6 "break": "atom", "cont": "atom", "const": "let", "resource": "fn", 6 "break": "atom", "cont": "atom", "const": "let", "resource": "fn",
7 "let": "let", "fn": "fn", "for": "for", "alt": "alt", "obj": "fn", 7 "let": "let", "fn": "fn", "for": "for", "alt": "alt", "iface": "iface",
8 "lambda": "fn", "type": "type", "tag": "tag", "mod": "mod", 8 "impl": "impl", "type": "type", "enum": "enum", "mod": "mod",
9 "as": "op", "true": "atom", "false": "atom", "assert": "op", "check": "op", 9 "as": "op", "true": "atom", "false": "atom", "assert": "op", "check": "op",
10 "claim": "op", "native": "ignore", "unsafe": "ignore", "import": "else-style", 10 "claim": "op", "native": "ignore", "unsafe": "ignore", "import": "else-style",
11 "export": "else-style", "copy": "op", "log": "op", "log_err": "op", 11 "export": "else-style", "copy": "op", "log": "op", "log_err": "op",
12 "use": "op", "bind": "op" 12 "use": "op", "bind": "op", "self": "atom"
13 }; 13 };
14 var typeKeywords = function() { 14 var typeKeywords = function() {
15 var keywords = {"fn": "fn", "block": "fn", "obj": "obj"}; 15 var keywords = {"fn": "fn", "block": "fn", "obj": "obj"};
@@ -169,13 +169,18 @@ CodeMirror.defineMode("rust", function() {
169 }; 169 };
170 } 170 }
171 171
172 function stat_of(comb, tag) {
173 return cont(pushlex("stat", tag), comb, poplex, block);
174 }
172 function block(type) { 175 function block(type) {
173 if (type == "}") return cont(); 176 if (type == "}") return cont();
174 if (type == "let") return cont(pushlex("stat", "let"), letdef1, poplex, block); 177 if (type == "let") return stat_of(letdef1, "let");
175 if (type == "fn") return cont(pushlex("stat"), fndef, poplex, block); 178 if (type == "fn") return stat_of(fndef);
176 if (type == "type") return cont(pushlex("stat"), tydef, endstatement, poplex, block); 179 if (type == "type") return cont(pushlex("stat"), tydef, endstatement, poplex, block);
177 if (type == "tag") return cont(pushlex("stat"), tagdef, poplex, block); 180 if (type == "enum") return stat_of(enumdef);
178 if (type == "mod") return cont(pushlex("stat"), mod, poplex, block); 181 if (type == "mod") return stat_of(mod);
182 if (type == "iface") return stat_of(iface);
183 if (type == "impl") return stat_of(impl);
179 if (type == "open-attr") return cont(pushlex("]"), commasep(expression, "]"), poplex); 184 if (type == "open-attr") return cont(pushlex("]"), commasep(expression, "]"), poplex);
180 if (type == "ignore" || type.match(/[\]\);,]/)) return cont(block); 185 if (type == "ignore" || type.match(/[\]\);,]/)) return cont(block);
181 return pass(pushlex("stat"), expression, poplex, endstatement, block); 186 return pass(pushlex("stat"), expression, poplex, endstatement, block);
@@ -253,11 +258,13 @@ CodeMirror.defineMode("rust", function() {
253 return pass(); 258 return pass();
254 } 259 }
255 function fndef(type) { 260 function fndef(type) {
261 if (content == "@" || content == "~") {cx.marked = "keyword"; return cont(fndef);}
256 if (type == "name") {cx.marked = "def"; return cont(fndef);} 262 if (type == "name") {cx.marked = "def"; return cont(fndef);}
257 if (content == "<") return cont(typarams, fndef); 263 if (content == "<") return cont(typarams, fndef);
258 if (type == "{") return pass(expression); 264 if (type == "{") return pass(expression);
259 if (type == "(") return cont(pushlex(")"), commasep(argdef, ")"), poplex, fndef); 265 if (type == "(") return cont(pushlex(")"), commasep(argdef, ")"), poplex, fndef);
260 if (type == "->") return cont(typecx, rtype, valcx, fndef); 266 if (type == "->") return cont(typecx, rtype, valcx, fndef);
267 if (type == ";") return cont();
261 return cont(fndef); 268 return cont(fndef);
262 } 269 }
263 function tydef(type) { 270 function tydef(type) {
@@ -266,27 +273,41 @@ CodeMirror.defineMode("rust", function() {
266 if (content == "=") return cont(typecx, rtype, valcx); 273 if (content == "=") return cont(typecx, rtype, valcx);
267 return cont(tydef); 274 return cont(tydef);
268 } 275 }
269 function tagdef(type) { 276 function enumdef(type) {
270 if (type == "name") {cx.marked = "def"; return cont(tagdef);} 277 if (type == "name") {cx.marked = "def"; return cont(enumdef);}
271 if (content == "<") return cont(typarams, tagdef); 278 if (content == "<") return cont(typarams, enumdef);
272 if (content == "=") return cont(typecx, rtype, valcx, endstatement); 279 if (content == "=") return cont(typecx, rtype, valcx, endstatement);
273 if (type == "{") return cont(pushlex("}"), typecx, tagblock, valcx, poplex); 280 if (type == "{") return cont(pushlex("}"), typecx, enumblock, valcx, poplex);
274 return cont(tagdef); 281 return cont(enumdef);
275 } 282 }
276 function tagblock(type) { 283 function enumblock(type) {
277 if (type == "}") return cont(); 284 if (type == "}") return cont();
278 if (type == "(") return cont(pushlex(")"), commasep(rtype, ")"), poplex, tagblock); 285 if (type == "(") return cont(pushlex(")"), commasep(rtype, ")"), poplex, enumblock);
279 if (content.match(/^\w+$/)) cx.marked = "def"; 286 if (content.match(/^\w+$/)) cx.marked = "def";
280 return cont(tagblock); 287 return cont(enumblock);
281 } 288 }
282 function mod(type) { 289 function mod(type) {
283 if (type == "name") {cx.marked = "def"; return cont(mod);} 290 if (type == "name") {cx.marked = "def"; return cont(mod);}
284 if (type == "{") return cont(pushlex("}"), block, poplex); 291 if (type == "{") return cont(pushlex("}"), block, poplex);
285 return pass(); 292 return pass();
286 } 293 }
294 function iface(type) {
295 if (type == "name") {cx.marked = "def"; return cont(iface);}
296 if (content == "<") return cont(typarams, iface);
297 if (type == "{") return cont(pushlex("}"), block, poplex);
298 return pass();
299 }
300 function impl(type) {
301 if (content == "<") return cont(typarams, impl);
302 if (content == "of" || content == "for") {cx.marked = "keyword"; return cont(rtype, impl);}
303 if (type == "name") {cx.marked = "def"; return cont(impl);}
304 if (type == "{") return cont(pushlex("}"), block, poplex);
305 return pass();
306 }
287 function typarams(type) { 307 function typarams(type) {
288 if (content == ">") return cont(); 308 if (content == ">") return cont();
289 if (content == ",") return cont(typarams); 309 if (content == ",") return cont(typarams);
310 if (content == ":") return cont(rtype, typarams);
290 return pass(rtype, typarams); 311 return pass(rtype, typarams);
291 } 312 }
292 function argdef(type) { 313 function argdef(type) {