From 01685c255fda6e13f1cd2980130d2e388d52125c Mon Sep 17 00:00:00 2001 From: Wu Cheng-Han Date: Sat, 4 Jul 2015 11:31:01 +0800 Subject: Updated codemirror to 5.4.0 --- public/vendor/codemirror/mode/php/php.js | 38 ++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 17 deletions(-) (limited to 'public/vendor/codemirror/mode/php') diff --git a/public/vendor/codemirror/mode/php/php.js b/public/vendor/codemirror/mode/php/php.js index e112d911..0c3f21e5 100755 --- a/public/vendor/codemirror/mode/php/php.js +++ b/public/vendor/codemirror/mode/php/php.js @@ -17,31 +17,31 @@ return obj; } - // Helper for stringWithEscapes - function matchSequence(list, end) { - if (list.length == 0) return stringWithEscapes(end); + // Helper for phpString + function matchSequence(list, end, escapes) { + if (list.length == 0) return phpString(end); return function (stream, state) { var patterns = list[0]; for (var i = 0; i < patterns.length; i++) if (stream.match(patterns[i][0])) { state.tokenize = matchSequence(list.slice(1), end); return patterns[i][1]; } - state.tokenize = stringWithEscapes(end); + state.tokenize = phpString(end, escapes); return "string"; }; } - function stringWithEscapes(closing) { - return function(stream, state) { return stringWithEscapes_(stream, state, closing); }; + function phpString(closing, escapes) { + return function(stream, state) { return phpString_(stream, state, closing, escapes); }; } - function stringWithEscapes_(stream, state, closing) { + function phpString_(stream, state, closing, escapes) { // "Complex" syntax - if (stream.match("${", false) || stream.match("{$", false)) { + if (escapes !== false && stream.match("${", false) || stream.match("{$", false)) { state.tokenize = null; return "string"; } // Simple syntax - if (stream.match(/^\$[a-zA-Z_][a-zA-Z0-9_]*/)) { + if (escapes !== false && stream.match(/^\$[a-zA-Z_][a-zA-Z0-9_]*/)) { // After the variable name there may appear array or object operator. if (stream.match("[", false)) { // Match array operator @@ -51,14 +51,14 @@ [/\$[a-zA-Z_][a-zA-Z0-9_]*/, "variable-2"], [/[\w\$]+/, "variable"]], [["]", null]] - ], closing); + ], closing, escapes); } if (stream.match(/\-\>\w/, false)) { // Match object operator state.tokenize = matchSequence([ [["->", null]], [[/[\w]+/, "variable"]] - ], closing); + ], closing, escapes); } return "variable-2"; } @@ -66,8 +66,9 @@ var escaped = false; // Normal string while (!stream.eol() && - (escaped || (!stream.match("{$", false) && - !stream.match(/^(\$[a-zA-Z_][a-zA-Z0-9_]*|\$\{)/, false)))) { + (escaped || escapes === false || + (!stream.match("{$", false) && + !stream.match(/^(\$[a-zA-Z_][a-zA-Z0-9_]*|\$\{)/, false)))) { if (!escaped && stream.match(closing)) { state.tokenize = null; state.tokStack.pop(); state.tokStack.pop(); @@ -94,6 +95,7 @@ helperType: "php", keywords: keywords(phpKeywords), blockKeywords: keywords("catch do else elseif for foreach if switch try while finally"), + defKeywords: keywords("class function interface namespace trait"), atoms: keywords(phpAtoms), builtin: keywords(phpBuiltin), multiLineStrings: true, @@ -104,11 +106,13 @@ }, "<": function(stream, state) { if (stream.match(/< 0 && !--state.tokStack[state.tokStack.length - 1]) { - state.tokenize = stringWithEscapes(state.tokStack[state.tokStack.length - 2]); + state.tokenize = phpString(state.tokStack[state.tokStack.length - 2]); } return false; } -- cgit v1.2.3