From c2805e03c84b6e598556fd06d1ede7aaeea7ce9c Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 6 Mar 2012 16:17:54 -0800 Subject: 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 --- imports/codemirror/mode/rust/rust.js | 51 +++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 15 deletions(-) mode change 100755 => 100644 imports/codemirror/mode/rust/rust.js (limited to 'imports/codemirror/mode/rust/rust.js') diff --git a/imports/codemirror/mode/rust/rust.js b/imports/codemirror/mode/rust/rust.js old mode 100755 new mode 100644 index 5ab964c1..2a5caac2 --- a/imports/codemirror/mode/rust/rust.js +++ b/imports/codemirror/mode/rust/rust.js @@ -4,12 +4,12 @@ CodeMirror.defineMode("rust", function() { "if": "if-style", "while": "if-style", "else": "else-style", "do": "else-style", "ret": "else-style", "fail": "else-style", "break": "atom", "cont": "atom", "const": "let", "resource": "fn", - "let": "let", "fn": "fn", "for": "for", "alt": "alt", "obj": "fn", - "lambda": "fn", "type": "type", "tag": "tag", "mod": "mod", + "let": "let", "fn": "fn", "for": "for", "alt": "alt", "iface": "iface", + "impl": "impl", "type": "type", "enum": "enum", "mod": "mod", "as": "op", "true": "atom", "false": "atom", "assert": "op", "check": "op", "claim": "op", "native": "ignore", "unsafe": "ignore", "import": "else-style", "export": "else-style", "copy": "op", "log": "op", "log_err": "op", - "use": "op", "bind": "op" + "use": "op", "bind": "op", "self": "atom" }; var typeKeywords = function() { var keywords = {"fn": "fn", "block": "fn", "obj": "obj"}; @@ -169,13 +169,18 @@ CodeMirror.defineMode("rust", function() { }; } + function stat_of(comb, tag) { + return cont(pushlex("stat", tag), comb, poplex, block); + } function block(type) { if (type == "}") return cont(); - if (type == "let") return cont(pushlex("stat", "let"), letdef1, poplex, block); - if (type == "fn") return cont(pushlex("stat"), fndef, poplex, block); + if (type == "let") return stat_of(letdef1, "let"); + if (type == "fn") return stat_of(fndef); if (type == "type") return cont(pushlex("stat"), tydef, endstatement, poplex, block); - if (type == "tag") return cont(pushlex("stat"), tagdef, poplex, block); - if (type == "mod") return cont(pushlex("stat"), mod, poplex, block); + if (type == "enum") return stat_of(enumdef); + if (type == "mod") return stat_of(mod); + if (type == "iface") return stat_of(iface); + if (type == "impl") return stat_of(impl); if (type == "open-attr") return cont(pushlex("]"), commasep(expression, "]"), poplex); if (type == "ignore" || type.match(/[\]\);,]/)) return cont(block); return pass(pushlex("stat"), expression, poplex, endstatement, block); @@ -253,11 +258,13 @@ CodeMirror.defineMode("rust", function() { return pass(); } function fndef(type) { + if (content == "@" || content == "~") {cx.marked = "keyword"; return cont(fndef);} if (type == "name") {cx.marked = "def"; return cont(fndef);} if (content == "<") return cont(typarams, fndef); if (type == "{") return pass(expression); if (type == "(") return cont(pushlex(")"), commasep(argdef, ")"), poplex, fndef); if (type == "->") return cont(typecx, rtype, valcx, fndef); + if (type == ";") return cont(); return cont(fndef); } function tydef(type) { @@ -266,27 +273,41 @@ CodeMirror.defineMode("rust", function() { if (content == "=") return cont(typecx, rtype, valcx); return cont(tydef); } - function tagdef(type) { - if (type == "name") {cx.marked = "def"; return cont(tagdef);} - if (content == "<") return cont(typarams, tagdef); + function enumdef(type) { + if (type == "name") {cx.marked = "def"; return cont(enumdef);} + if (content == "<") return cont(typarams, enumdef); if (content == "=") return cont(typecx, rtype, valcx, endstatement); - if (type == "{") return cont(pushlex("}"), typecx, tagblock, valcx, poplex); - return cont(tagdef); + if (type == "{") return cont(pushlex("}"), typecx, enumblock, valcx, poplex); + return cont(enumdef); } - function tagblock(type) { + function enumblock(type) { if (type == "}") return cont(); - if (type == "(") return cont(pushlex(")"), commasep(rtype, ")"), poplex, tagblock); + if (type == "(") return cont(pushlex(")"), commasep(rtype, ")"), poplex, enumblock); if (content.match(/^\w+$/)) cx.marked = "def"; - return cont(tagblock); + return cont(enumblock); } function mod(type) { if (type == "name") {cx.marked = "def"; return cont(mod);} if (type == "{") return cont(pushlex("}"), block, poplex); return pass(); } + function iface(type) { + if (type == "name") {cx.marked = "def"; return cont(iface);} + if (content == "<") return cont(typarams, iface); + if (type == "{") return cont(pushlex("}"), block, poplex); + return pass(); + } + function impl(type) { + if (content == "<") return cont(typarams, impl); + if (content == "of" || content == "for") {cx.marked = "keyword"; return cont(rtype, impl);} + if (type == "name") {cx.marked = "def"; return cont(impl);} + if (type == "{") return cont(pushlex("}"), block, poplex); + return pass(); + } function typarams(type) { if (content == ">") return cont(); if (content == ",") return cont(typarams); + if (content == ":") return cont(rtype, typarams); return pass(rtype, typarams); } function argdef(type) { -- cgit v1.2.3