aboutsummaryrefslogtreecommitdiff
path: root/imports/codemirror/mode/rust/rust.js
diff options
context:
space:
mode:
authorEric Guzman2012-03-12 15:33:04 -0700
committerEric Guzman2012-03-12 15:33:04 -0700
commit7e3161153b87b891875ac65368a19aed12909fa3 (patch)
treeb80f48d711a9729fc39dbbdff28c4f0620e7302d /imports/codemirror/mode/rust/rust.js
parent7a28932ba8a7517bbaaabe1f5edf678416aafc9c (diff)
parent69d90467865a1384725b2301901be2180c5a841f (diff)
downloadninja-7e3161153b87b891875ac65368a19aed12909fa3.tar.gz
Merge branch 'refs/heads/master' into CSSPanelUpdates
Conflicts: js/panels/PanelContainer/PanelContainer.reel/PanelContainer.js
Diffstat (limited to 'imports/codemirror/mode/rust/rust.js')
-rw-r--r--[-rwxr-xr-x]imports/codemirror/mode/rust/rust.js51
1 files changed, 36 insertions, 15 deletions
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) {