diff options
author | Wu Cheng-Han | 2015-07-04 11:31:01 +0800 |
---|---|---|
committer | Wu Cheng-Han | 2015-07-04 11:31:01 +0800 |
commit | 01685c255fda6e13f1cd2980130d2e388d52125c (patch) | |
tree | c329610e7011c0d77c55ef54f371181aeb362d13 /public/vendor/codemirror/mode/pig | |
parent | 1d843c8ac257d512a96cf054ab24e6a3c2f34e26 (diff) |
Updated codemirror to 5.4.0
Diffstat (limited to 'public/vendor/codemirror/mode/pig')
-rwxr-xr-x | public/vendor/codemirror/mode/pig/pig.js | 40 |
1 files changed, 15 insertions, 25 deletions
diff --git a/public/vendor/codemirror/mode/pig/pig.js b/public/vendor/codemirror/mode/pig/pig.js index c74b2cc8..5b567272 100755 --- a/public/vendor/codemirror/mode/pig/pig.js +++ b/public/vendor/codemirror/mode/pig/pig.js @@ -30,12 +30,6 @@ CodeMirror.defineMode("pig", function(_config, parserConfig) { return f(stream, state); } - var type; - function ret(tp, style) { - type = tp; - return style; - } - function tokenComment(stream, state) { var isEnd = false; var ch; @@ -46,7 +40,7 @@ CodeMirror.defineMode("pig", function(_config, parserConfig) { } isEnd = (ch == "*"); } - return ret("comment", "comment"); + return "comment"; } function tokenString(quote) { @@ -60,10 +54,11 @@ CodeMirror.defineMode("pig", function(_config, parserConfig) { } if (end || !(escaped || multiLineStrings)) state.tokenize = tokenBase; - return ret("string", "error"); + return "error"; }; } + function tokenBase(stream, state) { var ch = stream.next(); @@ -72,11 +67,11 @@ CodeMirror.defineMode("pig", function(_config, parserConfig) { return chain(stream, state, tokenString(ch)); // is it one of the special chars else if(/[\[\]{}\(\),;\.]/.test(ch)) - return ret(ch); + return null; // is it a number? else if(/\d/.test(ch)) { stream.eatWhile(/[\w\.]/); - return ret("number", "number"); + return "number"; } // multi line comment or operator else if (ch == "/") { @@ -85,47 +80,42 @@ CodeMirror.defineMode("pig", function(_config, parserConfig) { } else { stream.eatWhile(isOperatorChar); - return ret("operator", "operator"); + return "operator"; } } // single line comment or operator else if (ch=="-") { if(stream.eat("-")){ stream.skipToEnd(); - return ret("comment", "comment"); + return "comment"; } else { stream.eatWhile(isOperatorChar); - return ret("operator", "operator"); + return "operator"; } } // is it an operator else if (isOperatorChar.test(ch)) { stream.eatWhile(isOperatorChar); - return ret("operator", "operator"); + return "operator"; } else { // get the while word stream.eatWhile(/[\w\$_]/); // is it one of the listed keywords? if (keywords && keywords.propertyIsEnumerable(stream.current().toUpperCase())) { - if (stream.eat(")") || stream.eat(".")) { - //keywords can be used as variables like flatten(group), group.$0 etc.. - } - else { - return ("keyword", "keyword"); - } + //keywords can be used as variables like flatten(group), group.$0 etc.. + if (!stream.eat(")") && !stream.eat(".")) + return "keyword"; } // is it one of the builtin functions? if (builtins && builtins.propertyIsEnumerable(stream.current().toUpperCase())) - { - return ("keyword", "variable-2"); - } + return "variable-2"; // is it one of the listed types? if (types && types.propertyIsEnumerable(stream.current().toUpperCase())) - return ("keyword", "variable-3"); + return "variable-3"; // default is a 'variable' - return ret("variable", "pig-word"); + return "variable"; } } |