diff --git a/gulliver/js/codemirrorOld/LICENSE b/gulliver/js/codemirrorOld/LICENSE new file mode 100644 index 000000000..aab5d221f --- /dev/null +++ b/gulliver/js/codemirrorOld/LICENSE @@ -0,0 +1,23 @@ + Copyright (c) 2007-2010 Marijn Haverbeke + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any + damages arising from the use of this software. + + Permission is granted to anyone to use this software for any + purpose, including commercial applications, and to alter it and + redistribute it freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product + documentation would be appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must + not be misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source + distribution. + + Marijn Haverbeke + marijnh@gmail.com diff --git a/gulliver/js/codemirrorOld/contrib/csharp/css/csharpcolors.css b/gulliver/js/codemirrorOld/contrib/csharp/css/csharpcolors.css new file mode 100644 index 000000000..234f1ad00 --- /dev/null +++ b/gulliver/js/codemirrorOld/contrib/csharp/css/csharpcolors.css @@ -0,0 +1,60 @@ +html { + cursor: text; +} + +.editbox { + margin: .4em; + padding: 0; + font-family: monospace; + font-size: 10pt; + color: black; +} + +pre.code, .editbox { + color: #666666; +} + +.editbox p { + margin: 0; +} + +span.csharp-punctuation { + color: green; +} + +span.csharp-operator { + color: purple; +} + +span.csharp-keyword { + color: blue; +} + +span.csharp-atom { + color: brown; +} + +span.csharp-variable { + color: black; +} + +span.csharp-variabledef { + color: #0000FF; +} + +span.csharp-localvariable { + color: #004499; +} + +span.csharp-property { + color: black; +} + +span.csharp-comment { + color: green; +} + +span.csharp-string { + color: red; +} + diff --git a/gulliver/js/codemirrorOld/contrib/csharp/index.html b/gulliver/js/codemirrorOld/contrib/csharp/index.html new file mode 100644 index 000000000..8aab8a59d --- /dev/null +++ b/gulliver/js/codemirrorOld/contrib/csharp/index.html @@ -0,0 +1,61 @@ + + + + CodeMirror: C# demonstration + + + + +

Demonstration of CodeMirror's C# highlighter.

+ +

Written by Boris Gaber and Christopher Buchino (license).

+ +
+ +
+ + + + + diff --git a/gulliver/js/codemirrorOld/contrib/csharp/js/parsecsharp.js b/gulliver/js/codemirrorOld/contrib/csharp/js/parsecsharp.js new file mode 100644 index 000000000..214571199 --- /dev/null +++ b/gulliver/js/codemirrorOld/contrib/csharp/js/parsecsharp.js @@ -0,0 +1,329 @@ +/* Parse function for JavaScript. Makes use of the tokenizer from + * tokenizecsharp.js. Note that your parsers do not have to be + * this complicated -- if you don't want to recognize local variables, + * in many languages it is enough to just look for braces, semicolons, + * parentheses, etc, and know when you are inside a string or comment. + * + * See manual.html for more info about the parser interface. + */ + +var JSParser = Editor.Parser = (function() { + // Token types that can be considered to be atoms. + var atomicTypes = {"atom": true, "number": true, "variable": true, "string": true, "regexp": true}; + // Setting that can be used to have JSON data indent properly. + var json = false; + // Constructor for the lexical context objects. + function CSharpLexical(indented, column, type, align, prev, info) { + // indentation at start of this line + this.indented = indented; + // column at which this scope was opened + this.column = column; + // type of scope ('vardef', 'stat' (statement), 'form' (special form), '[', '{', or '(') + this.type = type; + // '[', '{', or '(' blocks that have any text after their opening + // character are said to be 'aligned' -- any lines below are + // indented all the way to the opening character. + if (align != null) + this.align = align; + // Parent scope, if any. + this.prev = prev; + this.info = info; + } + + // CSharp indentation rules. + function indentCSharp(lexical) { + return function(firstChars) { + var firstChar = firstChars && firstChars.charAt(0), type = lexical.type; + var closing = firstChar == type; + if (type == "vardef") + return lexical.indented + 4; + else if (type == "form" && firstChar == "{") + return lexical.indented; + else if (type == "stat" || type == "form") + return lexical.indented + indentUnit; + else if (lexical.info == "switch" && !closing) + return lexical.indented + (/^(?:case|default)\b/.test(firstChars) ? indentUnit : 2 * indentUnit); + else if (lexical.align) + return lexical.column - (closing ? 1 : 0); + else + return lexical.indented + (closing ? 0 : indentUnit); + }; + } + + // The parser-iterator-producing function itself. + function parseCSharp(input, basecolumn) { + // Wrap the input in a token stream + var tokens = tokenizeCSharp(input); + // The parser state. cc is a stack of actions that have to be + // performed to finish the current statement. For example we might + // know that we still need to find a closing parenthesis and a + // semicolon. Actions at the end of the stack go first. It is + // initialized with an infinitely looping action that consumes + // whole statements. + var cc = [statements]; + // The lexical scope, used mostly for indentation. + var lexical = new CSharpLexical((basecolumn || 0) - indentUnit, 0, "block", false); + // Current column, and the indentation at the start of the current + // line. Used to create lexical scope objects. + var column = 0; + var indented = 0; + // Variables which are used by the mark, cont, and pass functions + // below to communicate with the driver loop in the 'next' + // function. + var consume, marked; + + // The iterator object. + var parser = {next: next, copy: copy}; + + function next(){ + // Start by performing any 'lexical' actions (adjusting the + // lexical variable), or the operations below will be working + // with the wrong lexical state. + while(cc[cc.length - 1].lex) + cc.pop()(); + + // Fetch a token. + var token = tokens.next(); + + // Adjust column and indented. + if (token.type == "whitespace" && column == 0) + indented = token.value.length; + column += token.value.length; + if (token.content == "\n"){ + indented = column = 0; + // If the lexical scope's align property is still undefined at + // the end of the line, it is an un-aligned scope. + if (!("align" in lexical)) + lexical.align = false; + // Newline tokens get an indentation function associated with + // them. + token.indentation = indentCSharp(lexical); + } + // No more processing for meaningless tokens. + if (token.type == "whitespace" || token.type == "comment") + return token; + // When a meaningful token is found and the lexical scope's + // align is undefined, it is an aligned scope. + if (!("align" in lexical)) + lexical.align = true; + + // Execute actions until one 'consumes' the token and we can + // return it. + while(true) { + consume = marked = false; + // Take and execute the topmost action. + cc.pop()(token.type, token.content); + if (consume){ + // Marked is used to change the style of the current token. + if (marked) + token.style = marked; + return token; + } + } + } + + // This makes a copy of the parser state. It stores all the + // stateful variables in a closure, and returns a function that + // will restore them when called with a new input stream. Note + // that the cc array has to be copied, because it is contantly + // being modified. Lexical objects are not mutated, and context + // objects are not mutated in a harmful way, so they can be shared + // between runs of the parser. + function copy(){ + var _lexical = lexical, _cc = cc.concat([]), _tokenState = tokens.state; + + return function copyParser(input){ + lexical = _lexical; + cc = _cc.concat([]); // copies the array + column = indented = 0; + tokens = tokenizeCSharp(input, _tokenState); + return parser; + }; + } + + // Helper function for pushing a number of actions onto the cc + // stack in reverse order. + function push(fs){ + for (var i = fs.length - 1; i >= 0; i--) + cc.push(fs[i]); + } + // cont and pass are used by the action functions to add other + // actions to the stack. cont will cause the current token to be + // consumed, pass will leave it for the next action. + function cont(){ + push(arguments); + consume = true; + } + function pass(){ + push(arguments); + consume = false; + } + // Used to change the style of the current token. + function mark(style){ + marked = style; + } + + // Push a new lexical context of the given type. + function pushlex(type, info) { + var result = function(){ + lexical = new CSharpLexical(indented, column, type, null, lexical, info) + }; + result.lex = true; + return result; + } + // Pop off the current lexical context. + function poplex(){ + lexical = lexical.prev; + } + poplex.lex = true; + // The 'lex' flag on these actions is used by the 'next' function + // to know they can (and have to) be ran before moving on to the + // next token. + + // Creates an action that discards tokens until it finds one of + // the given type. + function expect(wanted){ + return function expecting(type){ + if (type == wanted) cont(); + else cont(arguments.callee); + }; + } + + // Looks for a statement, and then calls itself. + function statements(type){ + return pass(statement, statements); + } + // Dispatches various types of statements based on the type of the + // current token. + function statement(type){ + if (type == "var") cont(pushlex("vardef"), vardef1, expect(";"), poplex); + else if (type == "keyword a") cont(pushlex("form"), expression, statement, poplex); + else if (type == "keyword b") cont(pushlex("form"), statement, poplex); + else if (type == "{" && json) cont(pushlex("}"), commasep(objprop, "}"), poplex); + else if (type == "{") cont(pushlex("}"), block, poplex); + else if (type == "function") cont(functiondef); + else if (type == "for") cont(pushlex("form"), expect("("), pushlex(")"), forspec1, expect(")"), poplex, statement, poplex); + else if (type == "variable") cont(pushlex("stat"), maybelabel); + else if (type == "switch") cont(pushlex("form"), expression, pushlex("}", "switch"), expect("{"), block, poplex, poplex); + else if (type == "case") cont(expression, expect(":")); + else if (type == "default") cont(expect(":")); + else if (type == "catch") cont(pushlex("form"), expect("("), funarg, expect(")"), statement, poplex); + + else if (type == "class") cont(classdef); + else if (type == "keyword d") cont(statement); + + else pass(pushlex("stat"), expression, expect(";"), poplex); + } + // Dispatch expression types. + function expression(type){ + if (atomicTypes.hasOwnProperty(type)) cont(maybeoperator); + else if (type == "function") cont(functiondef); + else if (type == "keyword c") cont(expression); + else if (type == "(") cont(pushlex(")"), expression, expect(")"), poplex, maybeoperator); + else if (type == "operator") cont(expression); + else if (type == "[") cont(pushlex("]"), commasep(expression, "]"), poplex, maybeoperator); + else if (type == "{") cont(pushlex("}"), commasep(objprop, "}"), poplex, maybeoperator); + } + // Called for places where operators, function calls, or + // subscripts are valid. Will skip on to the next action if none + // is found. + function maybeoperator(type){ + if (type == "operator") cont(expression); + else if (type == "(") cont(pushlex(")"), expression, commasep(expression, ")"), poplex, maybeoperator); + else if (type == ".") cont(property, maybeoperator); + else if (type == "[") cont(pushlex("]"), expression, expect("]"), poplex, maybeoperator); + } + // When a statement starts with a variable name, it might be a + // label. If no colon follows, it's a regular statement. + function maybelabel(type){ + if (type == ":") cont(poplex, statement); + else if (type == "(") cont(commasep(funarg, ")"), poplex, statement); // method definition + else if (type == "{") cont(poplex, pushlex("}"), block, poplex); // property definition + else pass(maybeoperator, expect(";"), poplex); + } + // Property names need to have their style adjusted -- the + // tokenizer thinks they are variables. + function property(type){ + if (type == "variable") {mark("csharp-property"); cont();} + } + // This parses a property and its value in an object literal. + function objprop(type){ + if (type == "variable") mark("csharp-property"); + if (atomicTypes.hasOwnProperty(type)) cont(expect(":"), expression); + } + // Parses a comma-separated list of the things that are recognized + // by the 'what' argument. + function commasep(what, end){ + function proceed(type) { + if (type == ",") cont(what, proceed); + else if (type == end) cont(); + else cont(expect(end)); + }; + return function commaSeparated(type) { + if (type == end) cont(); + else pass(what, proceed); + }; + } + // Look for statements until a closing brace is found. + function block(type){ + if (type == "}") cont(); + else pass(statement, block); + } + // Variable definitions are split into two actions -- 1 looks for + // a name or the end of the definition, 2 looks for an '=' sign or + // a comma. + function vardef1(type, value){ + if (type == "variable"){cont(vardef2);} + else cont(); + } + function vardef2(type, value){ + if (value == "=") cont(expression, vardef2); + else if (type == ",") cont(vardef1); + } + // For loops. + function forspec1(type){ + if (type == "var") cont(vardef1, forspec2); + else if (type == "keyword d") cont(vardef1, forspec2); + else if (type == ";") pass(forspec2); + else if (type == "variable") cont(formaybein); + else pass(forspec2); + } + function formaybein(type, value){ + if (value == "in") cont(expression); + else cont(maybeoperator, forspec2); + } + function forspec2(type, value){ + if (type == ";") cont(forspec3); + else if (value == "in") cont(expression); + else cont(expression, expect(";"), forspec3); + } + function forspec3(type) { + if (type == ")") pass(); + else cont(expression); + } + // A function definition creates a new context, and the variables + // in its argument list have to be added to this context. + function functiondef(type, value){ + if (type == "variable") cont(functiondef); + else if (type == "(") cont(commasep(funarg, ")"), statement); + } + function funarg(type, value){ + if (type == "variable"){cont();} + } + + function classdef(type) { + if (type == "variable") cont(classdef, statement); + else if (type == ":") cont(classdef, statement); + } + + return parser; + } + + return { + make: parseCSharp, + electricChars: "{}:", + configure: function(obj) { + if (obj.json != null) json = obj.json; + } + }; +})(); diff --git a/gulliver/js/codemirrorOld/contrib/csharp/js/tokenizecsharp.js b/gulliver/js/codemirrorOld/contrib/csharp/js/tokenizecsharp.js new file mode 100644 index 000000000..5d89e2615 --- /dev/null +++ b/gulliver/js/codemirrorOld/contrib/csharp/js/tokenizecsharp.js @@ -0,0 +1,196 @@ +/* Tokenizer for CSharp code */ + +var tokenizeCSharp = (function() { + // Advance the stream until the given character (not preceded by a + // backslash) is encountered, or the end of the line is reached. + function nextUntilUnescaped(source, end) { + var escaped = false; + var next; + while (!source.endOfLine()) { + var next = source.next(); + if (next == end && !escaped) + return false; + escaped = !escaped && next == "\\"; + } + return escaped; + } + + // A map of JavaScript's keywords. The a/b/c keyword distinction is + // very rough, but it gives the parser enough information to parse + // correct code correctly (we don't care that much how we parse + // incorrect code). The style information included in these objects + // is used by the highlighter to pick the correct CSS style for a + // token. + var keywords = function(){ + function result(type, style){ + return {type: type, style: "csharp-" + style}; + } + // keywords that take a parenthised expression, and then a + // statement (if) + var keywordA = result("keyword a", "keyword"); + // keywords that take just a statement (else) + var keywordB = result("keyword b", "keyword"); + // keywords that optionally take an expression, and form a + // statement (return) + var keywordC = result("keyword c", "keyword"); + var operator = result("operator", "keyword"); + var atom = result("atom", "atom"); + // just a keyword with no indentation implications + var keywordD = result("keyword d", "keyword"); + + return { + "if": keywordA, "while": keywordA, "with": keywordA, + "else": keywordB, "do": keywordB, "try": keywordB, "finally": keywordB, + "return": keywordC, "break": keywordC, "continue": keywordC, "new": keywordC, "delete": keywordC, "throw": keywordC, + "in": operator, "typeof": operator, "instanceof": operator, + "var": result("var", "keyword"), "function": result("function", "keyword"), "catch": result("catch", "keyword"), + "for": result("for", "keyword"), "switch": result("switch", "keyword"), + "case": result("case", "keyword"), "default": result("default", "keyword"), + "true": atom, "false": atom, "null": atom, + + "class": result("class", "keyword"), "namespace": result("class", "keyword"), + + "public": keywordD, "private": keywordD, "protected": keywordD, "internal": keywordD, + "extern": keywordD, "override": keywordD, "virtual": keywordD, "abstract": keywordD, + "static": keywordD, "out": keywordD, "ref": keywordD, "const": keywordD, + + "foreach": result("for", "keyword"), "using": keywordC, + + "int": keywordD, "double": keywordD, "long": keywordD, "bool": keywordD, "char": keywordD, + "void": keywordD, "string": keywordD, "byte": keywordD, "sbyte": keywordD, "decimal": keywordD, + "float": keywordD, "uint": keywordD, "ulong": keywordD, "object": keywordD, + "short": keywordD, "ushort": keywordD, + + "get": keywordD, "set": keywordD, "value": keywordD + }; + }(); + + // Some helper regexps + var isOperatorChar = /[+\-*&%=<>!?|]/; + var isHexDigit = /[0-9A-Fa-f]/; + var isWordChar = /[\w\$_]/; + + // Wrapper around jsToken that helps maintain parser state (whether + // we are inside of a multi-line comment and whether the next token + // could be a regular expression). + function jsTokenState(inside, regexp) { + return function(source, setState) { + var newInside = inside; + var type = jsToken(inside, regexp, source, function(c) {newInside = c;}); + var newRegexp = type.type == "operator" || type.type == "keyword c" || type.type.match(/^[\[{}\(,;:]$/); + if (newRegexp != regexp || newInside != inside) + setState(jsTokenState(newInside, newRegexp)); + return type; + }; + } + + // The token reader, inteded to be used by the tokenizer from + // tokenize.js (through jsTokenState). Advances the source stream + // over a token, and returns an object containing the type and style + // of that token. + function jsToken(inside, regexp, source, setInside) { + function readHexNumber(){ + source.next(); // skip the 'x' + source.nextWhileMatches(isHexDigit); + return {type: "number", style: "csharp-atom"}; + } + + function readNumber() { + source.nextWhileMatches(/[0-9]/); + if (source.equals(".")){ + source.next(); + source.nextWhileMatches(/[0-9]/); + } + if (source.equals("e") || source.equals("E")){ + source.next(); + if (source.equals("-")) + source.next(); + source.nextWhileMatches(/[0-9]/); + } + return {type: "number", style: "csharp-atom"}; + } + // Read a word, look it up in keywords. If not found, it is a + // variable, otherwise it is a keyword of the type found. + function readWord() { + source.nextWhileMatches(isWordChar); + var word = source.get(); + var known = keywords.hasOwnProperty(word) && keywords.propertyIsEnumerable(word) && keywords[word]; + return known ? {type: known.type, style: known.style, content: word} : + {type: "variable", style: "csharp-variable", content: word}; + } + function readRegexp() { + nextUntilUnescaped(source, "/"); + source.nextWhileMatches(/[gi]/); + return {type: "regexp", style: "csharp-string"}; + } + // Mutli-line comments are tricky. We want to return the newlines + // embedded in them as regular newline tokens, and then continue + // returning a comment token for every line of the comment. So + // some state has to be saved (inside) to indicate whether we are + // inside a /* */ sequence. + function readMultilineComment(start){ + var newInside = "/*"; + var maybeEnd = (start == "*"); + while (true) { + if (source.endOfLine()) + break; + var next = source.next(); + if (next == "/" && maybeEnd){ + newInside = null; + break; + } + maybeEnd = (next == "*"); + } + setInside(newInside); + return {type: "comment", style: "csharp-comment"}; + } + function readOperator() { + source.nextWhileMatches(isOperatorChar); + return {type: "operator", style: "csharp-operator"}; + } + function readString(quote) { + var endBackSlash = nextUntilUnescaped(source, quote); + setInside(endBackSlash ? quote : null); + return {type: "string", style: "csharp-string"}; + } + + // Fetch the next token. Dispatches on first character in the + // stream, or first two characters when the first is a slash. + if (inside == "\"" || inside == "'") + return readString(inside); + var ch = source.next(); + if (inside == "/*") + return readMultilineComment(ch); + else if (ch == "\"" || ch == "'") + return readString(ch); + // with punctuation, the type of the token is the symbol itself + else if (/[\[\]{}\(\),;\:\.]/.test(ch)) + return {type: ch, style: "csharp-punctuation"}; + else if (ch == "0" && (source.equals("x") || source.equals("X"))) + return readHexNumber(); + else if (/[0-9]/.test(ch)) + return readNumber(); + else if (ch == "/"){ + if (source.equals("*")) + { source.next(); return readMultilineComment(ch); } + else if (source.equals("/")) + { nextUntilUnescaped(source, null); return {type: "comment", style: "csharp-comment"};} + else if (regexp) + return readRegexp(); + else + return readOperator(); + } + else if (ch == "#") { // treat c# regions like comments + nextUntilUnescaped(source, null); return {type: "comment", style: "csharp-comment"}; + } + else if (isOperatorChar.test(ch)) + return readOperator(); + else + return readWord(); + } + + // The external interface to the tokenizer. + return function(source, startState) { + return tokenizer(source, startState || jsTokenState(false, true)); + }; +})(); diff --git a/gulliver/js/codemirrorOld/contrib/freemarker/LICENSE b/gulliver/js/codemirrorOld/contrib/freemarker/LICENSE new file mode 100644 index 000000000..fbbb800fd --- /dev/null +++ b/gulliver/js/codemirrorOld/contrib/freemarker/LICENSE @@ -0,0 +1,24 @@ +Copyright (c) 2010, Keybroker AB +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of Keybroker AB nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL Keybroker AB BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/gulliver/js/codemirrorOld/contrib/freemarker/css/freemarkercolors.css b/gulliver/js/codemirrorOld/contrib/freemarker/css/freemarkercolors.css new file mode 100644 index 000000000..9e7a8f3d8 --- /dev/null +++ b/gulliver/js/codemirrorOld/contrib/freemarker/css/freemarkercolors.css @@ -0,0 +1,63 @@ +html { + cursor: text; +} + +.editbox { + margin: .4em; + padding: 0; + font-family: monospace; + font-size: 12px; + font-size-adjust: none; + font-style: normal; + font-variant: normal; + font-weight: normal; + line-height: normal; + color: black; +} + +pre.code, .editbox { + color: black; +} + +.editbox p { + margin: 0; +} + +span.freemarker-comment { + color: #BB9977; +} + +span.freemarker-generic { +} + +span.freemarker-boundary { + color: darkblue; +} + +span.freemarker-directive { + color: darkblue; +} + +span.freemarker-identifier { + color: purple; +} + +span.freemarker-builtin { + color: gray; +} + +span.freemarker-punctuation { + color: blue; +} + +span.freemarker-string { + color: darkGreen; +} + +span.freemarker-number { + color: blue; +} + +span.freemarker-error { + color: #F00 !important; +} diff --git a/gulliver/js/codemirrorOld/contrib/freemarker/index.html b/gulliver/js/codemirrorOld/contrib/freemarker/index.html new file mode 100644 index 000000000..4ca705f25 --- /dev/null +++ b/gulliver/js/codemirrorOld/contrib/freemarker/index.html @@ -0,0 +1,75 @@ + + + + + CodeMirror: Freemarker demonstration + + + + + +

This page demonstrates CodeMirror's +Freemarker parser. Written by Magnus Ljung, released under a BSD-style license.

+ +
+ +
+ + + + diff --git a/gulliver/js/codemirrorOld/contrib/freemarker/js/parsefreemarker.js b/gulliver/js/codemirrorOld/contrib/freemarker/js/parsefreemarker.js new file mode 100644 index 000000000..562e06287 --- /dev/null +++ b/gulliver/js/codemirrorOld/contrib/freemarker/js/parsefreemarker.js @@ -0,0 +1,380 @@ +var FreemarkerParser = Editor.Parser = (function() { + var autoSelfClosers = {"else": true, "elseif": true}; + + // Simple stateful tokenizer for Freemarker documents. Returns a + // MochiKit-style iterator, with a state property that contains a + // function encapsulating the current state. See tokenize.js. + var tokenizeFreemarker = (function() { + function inText(source, setState) { + var ch = source.next(); + if (ch == "<") { + if (source.equals("!")) { + source.next(); + if (source.lookAhead("--", true)) { + setState(inBlock("freemarker-comment", "-->")); + return null; + } else { + return "freemarker-text"; + } + } else { + source.nextWhileMatches(/[\#\@\/]/); + setState(inFreemarker(">")); + return "freemarker-boundary"; + } + } + else if (ch == "[") { + if(source.matches(/[\#\@]/)) { + setState(pendingFreemarker(source.peek(), "]", false)); + return "freemarker-boundary"; + } else if(source.matches(/\//)) { + setState(pendingFreemarkerEnd("]")); + return "freemarker-boundary"; + } else { + return "freemarker-text"; + } + } + else if (ch == "$") { + if(source.matches(/[\{\w]/)) { + setState(pendingFreemarker("{", "}", true)); + return "freemarker-boundary"; + } else { + return "freemarker-text"; + } + } + else { + source.nextWhileMatches(/[^\$<\n]/); + return "freemarker-text"; + } + } + + function pendingFreemarker(startChar, endChar, nextCanBeIdentifier) { + return function(source, setState) { + var ch = source.next(); + if(ch == startChar) { + setState(inFreemarker(endChar)); + return "freemarker-boundary"; + } else if(nextCanBeIdentifier) { + source.nextWhileMatches(/\w/); + setState(inText); + return "freemarker-identifier"; + } else { + setState(inText); + return null; + } + } + } + + function pendingFreemarkerEnd(endChar) { + return function(source, setState) { + var ch = source.next(); + if(ch == "/") { + setState(pendingFreemarker(source.peek(), endChar, false)); + return "freemarker-boundary"; + } else { + setState(inText); + return null; + } + } + } + + function inFreemarker(terminator) { + return function(source, setState) { + var ch = source.next(); + if (ch == terminator) { + setState(inText); + return "freemarker-boundary"; + } else if (/[?\/]/.test(ch) && source.equals(terminator)) { + source.next(); + setState(inText); + return "freemarker-boundary"; + } else if(/[?!]/.test(ch)) { + if(ch == "?") { + if(source.peek() == "?") { + source.next(); + } else { + setState(inBuiltIn(inFreemarker(terminator))); + } + } + return "freemarker-punctuation"; + } else if(/[()+\/\-*%=]/.test(ch)) { + return "freemarker-punctuation"; + } else if (/[0-9]/.test(ch)) { + source.nextWhileMatches(/[0-9]+\.?[0-9]* /); + return "freemarker-number"; + } else if (/\w/.test(ch)) { + source.nextWhileMatches(/\w/); + return "freemarker-identifier"; + } else if(/[\'\"]/.test(ch)) { + setState(inString(ch, inFreemarker(terminator))); + return "freemarker-string"; + } else { + source.nextWhileMatches(/[^\s\u00a0<>\"\'\}?!\/]/); + return "freemarker-generic"; + } + }; + } + + function inBuiltIn(nextState) { + return function(source, setState) { + var ch = source.peek(); + if(/[a-zA-Z_]/.test(ch)) { + source.next(); + source.nextWhileMatches(/[a-zA-Z_0-9]+/); + setState(nextState); + return "freemarker-builtin"; + } else { + setState(nextState); + } + }; + } + + function inString(quote, nextState) { + return function(source, setState) { + while (!source.endOfLine()) { + if (source.next() == quote) { + setState(nextState); + break; + } + } + return "freemarker-string"; + }; + } + + function inBlock(style, terminator) { + return function(source, setState) { + while (!source.endOfLine()) { + if (source.lookAhead(terminator, true)) { + setState(inText); + break; + } + source.next(); + } + return style; + }; + } + + return function(source, startState) { + return tokenizer(source, startState || inText); + }; + })(); + + // The parser. The structure of this function largely follows that of + // parseXML in parsexml.js + function parseFreemarker(source) { + var tokens = tokenizeFreemarker(source), token; + var cc = [base]; + var tokenNr = 0, indented = 0; + var currentTag = null, context = null; + var consume; + + function push(fs) { + for (var i = fs.length - 1; i >= 0; i--) + cc.push(fs[i]); + } + function cont() { + push(arguments); + consume = true; + } + function pass() { + push(arguments); + consume = false; + } + + function markErr() { + token.style += " freemarker-error"; + } + + function expect(text) { + return function(style, content) { + if (content == text) cont(); + else {markErr(); cont(arguments.callee);} + }; + } + + function pushContext(tagname, startOfLine) { + context = {prev: context, name: tagname, indent: indented, startOfLine: startOfLine}; + } + + function popContext() { + context = context.prev; + } + + function computeIndentation(baseContext) { + return function(nextChars, current, direction, firstToken) { + var context = baseContext; + + nextChars = getThreeTokens(firstToken); + + if ((context && /^<\/\#/.test(nextChars)) || + (context && /^\[\/\#/.test(nextChars))) { + context = context.prev; + } + + while (context && !context.startOfLine) { + context = context.prev; + } + + if (context) { + if(/^<\#else/.test(nextChars) || + /^\[\#else/.test(nextChars)) { + return context.indent; + } + return context.indent + indentUnit; + } else { + return 0; + } + }; + } + + function getThreeTokens(firstToken) { + var secondToken = firstToken ? firstToken.nextSibling : null; + var thirdToken = secondToken ? secondToken.nextSibling : null; + + var nextChars = (firstToken && firstToken.currentText) ? firstToken.currentText : ""; + if(secondToken && secondToken.currentText) { + nextChars = nextChars + secondToken.currentText; + if(thirdToken && thirdToken.currentText) { + nextChars = nextChars + thirdToken.currentText; + } + } + + return nextChars; + } + + function base() { + return pass(element, base); + } + + var harmlessTokens = { "freemarker-text": true, "freemarker-comment": true }; + + function element(style, content) { + if (content == "<#") { + cont(tagname, notEndTag, endtag("/>", ">", tokenNr == 1)); + } else if (content == "")); + } else if(content == "[" && style == "freemarker-boundary") { + cont(hashOrCloseHash); + } else { + cont(); + } + } + + function hashOrCloseHash(style, content) { + if(content == "#") { + cont(tagname, notHashEndTag, endtag("/]", "]", tokenNr == 2)); + } else if(content == "/") { + cont(closeHash); + } else { + markErr(); + } + } + + function closeHash(style, content) { + if(content == "#") { + cont(closetagname, expect("]")); + } else { + markErr(); + } + } + + + function tagname(style, content) { + if (style == "freemarker-identifier") { + currentTag = content.toLowerCase(); + token.style = "freemarker-directive"; + cont(); + } else { + currentTag = null; + pass(); + } + } + + function closetagname(style, content) { + if (style == "freemarker-identifier") { + token.style = "freemarker-directive"; + if (context && content.toLowerCase() == context.name) { + popContext(); + } else { + markErr(); + } + } + cont(); + } + + function notEndTag(style, content) { + if (content == "/>" || content == ">") { + pass(); + } else { + cont(notEndTag); + } + } + + function notHashEndTag(style, content) { + if (content == "/]" || content == "]") { + pass(); + } else { + cont(notHashEndTag); + } + } + + function endtag(closeTagPattern, endTagPattern, startOfLine) { + return function(style, content) { + if (content == closeTagPattern || (content == endTagPattern && autoSelfClosers.hasOwnProperty(currentTag))) { + cont(); + } else if (content == endTagPattern) { + pushContext(currentTag, startOfLine); + cont(); + } else { + markErr(); + cont(arguments.callee); + } + }; + } + + + return { + indentation: function() { return indented; }, + + next: function() { + token = tokens.next(); + if (token.style == "whitespace" && tokenNr == 0) + indented = token.value.length; + else + tokenNr++; + if (token.content == "\n") { + indented = tokenNr = 0; + token.indentation = computeIndentation(context); + } + + if (token.style == "whitespace" || token.type == "freemarker-comment") + return token; + + while(true) { + consume = false; + cc.pop()(token.style, token.content); + if (consume) { + return token; + } + } + }, + + copy: function(){ + var _cc = cc.concat([]), _tokenState = tokens.state, _context = context; + var parser = this; + + return function(input){ + cc = _cc.concat([]); + tokenNr = indented = 0; + context = _context; + tokens = tokenizeFreemarker(input, _tokenState); + return parser; + }; + } + }; + } + + return { + make: parseFreemarker, + electricChars: ">" + }; + })(); diff --git a/gulliver/js/codemirrorOld/contrib/groovy/index.html b/gulliver/js/codemirrorOld/contrib/groovy/index.html new file mode 100644 index 000000000..68e900c6c --- /dev/null +++ b/gulliver/js/codemirrorOld/contrib/groovy/index.html @@ -0,0 +1,57 @@ + + + + CodeMirror: Groovy demonstration + + + + +

Demonstration of CodeMirror's Groovy highlighter.

+ +

Created by eXo Platform SAS (license).

+ +

Note that the files for this parser aren't included in the CodeMirror repository, but have to fetched from svn.exoplatform.org:

+ + + +
+ +
+ + + + + diff --git a/gulliver/js/codemirrorOld/contrib/java/LICENSE b/gulliver/js/codemirrorOld/contrib/java/LICENSE new file mode 100644 index 000000000..ba4282470 --- /dev/null +++ b/gulliver/js/codemirrorOld/contrib/java/LICENSE @@ -0,0 +1,20 @@ + Copyright (c) 2010 Patrick Wied + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any + damages arising from the use of this software. + + Permission is granted to anyone to use this software for any + purpose, including commercial applications, and to alter it and + redistribute it freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product + documentation would be appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must + not be misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source + distribution. diff --git a/gulliver/js/codemirrorOld/contrib/java/css/javacolors.css b/gulliver/js/codemirrorOld/contrib/java/css/javacolors.css new file mode 100644 index 000000000..64ea0ea74 --- /dev/null +++ b/gulliver/js/codemirrorOld/contrib/java/css/javacolors.css @@ -0,0 +1,64 @@ + +html { + cursor: text; +} + +.editbox { + margin: .4em; + padding: 0; + font-family: monospace; + font-size: 10pt; + color: black; +} + +pre.code, .editbox { + color: #666666; +} + +.editbox p { + margin: 0; +} + +span.java-punctuation { + color: black; +} + +span.java-operator { + color: purple; +} + +span.java-keyword { + color: #7f0055; + font-weight:bold; +} + +span.java-atom { + color: brown; +} + +span.java-variable { + color: black; +} + + +span.java-property { + color: black; +} + +span.java-comment { + color: green; +} + +span.javadoc-comment { + color: #3e5797; + font-weight:bold; +} + +span.java-string { + color: blue; +} + +span.java-annotation{ + color: gray; +} + diff --git a/gulliver/js/codemirrorOld/contrib/java/index.html b/gulliver/js/codemirrorOld/contrib/java/index.html new file mode 100644 index 000000000..b60d6a615 --- /dev/null +++ b/gulliver/js/codemirrorOld/contrib/java/index.html @@ -0,0 +1,66 @@ + + + + + Demonstration of CodeMirrors Java highlighter written by Patrick Wied + + + + +

Demonstration of CodeMirror's Java highlighter.

+ +

Written by Patrick Wied.

+ +
+ +
+ + + diff --git a/gulliver/js/codemirrorOld/contrib/java/js/parsejava.js b/gulliver/js/codemirrorOld/contrib/java/js/parsejava.js new file mode 100644 index 000000000..1b104db4b --- /dev/null +++ b/gulliver/js/codemirrorOld/contrib/java/js/parsejava.js @@ -0,0 +1,285 @@ +/** + * Java parser for codemirror + * + * @author Patrick Wied + */ + +var JavaParser = Editor.Parser = (function() { + // Token types that can be considered to be atoms. + var atomicTypes = {"atom": true, "number": true, "string": true, "regexp": true}; + // Setting that can be used to have JSON data indent properly. + var json = false; + // Constructor for the lexical context objects. + function JavaLexical(indented, column, type, align, prev, info) { + // indentation at start of this line + this.indented = indented; + // column at which this scope was opened + this.column = column; + // type of scope ( 'stat' (statement), 'form' (special form), '[', '{', or '(') + this.type = type; + // '[', '{', or '(' blocks that have any text after their opening + // character are said to be 'aligned' -- any lines below are + // indented all the way to the opening character. + if (align != null) + this.align = align; + // Parent scope, if any. + this.prev = prev; + this.info = info; + } + + // java indentation rules. + function indentJava(lexical) { + return function(firstChars) { + var firstChar = firstChars && firstChars.charAt(0), type = lexical.type; + var closing = firstChar == type; + if (type == "form" && firstChar == "{") + return lexical.indented; + else if (type == "stat" || type == "form") + return lexical.indented + indentUnit; + else if (lexical.info == "switch" && !closing) + return lexical.indented + (/^(?:case|default)\b/.test(firstChars) ? indentUnit : 2 * indentUnit); + else if (lexical.align) + return lexical.column - (closing ? 1 : 0); + else + return lexical.indented + (closing ? 0 : indentUnit); + }; + } + + // The parser-iterator-producing function itself. + function parseJava(input, basecolumn) { + // Wrap the input in a token stream + var tokens = tokenizeJava(input); + // The parser state. cc is a stack of actions that have to be + // performed to finish the current statement. For example we might + // know that we still need to find a closing parenthesis and a + // semicolon. Actions at the end of the stack go first. It is + // initialized with an infinitely looping action that consumes + // whole statements. + var cc = [statements]; + // The lexical scope, used mostly for indentation. + var lexical = new JavaLexical(basecolumn || 0, 0, "block", false); + // Current column, and the indentation at the start of the current + // line. Used to create lexical scope objects. + var column = 0; + var indented = 0; + // Variables which are used by the mark, cont, and pass functions + // below to communicate with the driver loop in the 'next' + // function. + var consume, marked; + + // The iterator object. + var parser = {next: next, copy: copy}; + + function next(){ + // Start by performing any 'lexical' actions (adjusting the + // lexical variable), or the operations below will be working + // with the wrong lexical state. + while(cc[cc.length - 1].lex) + cc.pop()(); + + // Fetch a token. + var token = tokens.next(); + + // Adjust column and indented. + if (token.type == "whitespace" && column == 0) + indented = token.value.length; + column += token.value.length; + if (token.content == "\n"){ + indented = column = 0; + // If the lexical scope's align property is still undefined at + // the end of the line, it is an un-aligned scope. + if (!("align" in lexical)) + lexical.align = false; + // Newline tokens get an indentation function associated with + // them. + token.indentation = indentJava(lexical); + + } + // No more processing for meaningless tokens. + if (token.type == "whitespace" || token.type == "comment" || token.type == "javadoc" || token.type == "annotation") + return token; + + // When a meaningful token is found and the lexical scope's + // align is undefined, it is an aligned scope. + if (!("align" in lexical)) + lexical.align = true; + + // Execute actions until one 'consumes' the token and we can + // return it. + while(true) { + consume = marked = false; + // Take and execute the topmost action. + cc.pop()(token.type, token.content); + if (consume){ + // Marked is used to change the style of the current token. + if (marked) + token.style = marked; + return token; + } + } + } + + // This makes a copy of the parser state. It stores all the + // stateful variables in a closure, and returns a function that + // will restore them when called with a new input stream. Note + // that the cc array has to be copied, because it is contantly + // being modified. Lexical objects are not mutated, and context + // objects are not mutated in a harmful way, so they can be shared + // between runs of the parser. + function copy(){ + var _lexical = lexical, _cc = cc.concat([]), _tokenState = tokens.state; + + return function copyParser(input){ + lexical = _lexical; + cc = _cc.concat([]); // copies the array + column = indented = 0; + tokens = tokenizeJava(input, _tokenState); + return parser; + }; + } + + // Helper function for pushing a number of actions onto the cc + // stack in reverse order. + function push(fs){ + for (var i = fs.length - 1; i >= 0; i--) + cc.push(fs[i]); + } + // cont and pass are used by the action functions to add other + // actions to the stack. cont will cause the current token to be + // consumed, pass will leave it for the next action. + function cont(){ + push(arguments); + consume = true; + } + function pass(){ + push(arguments); + consume = false; + } + // Used to change the style of the current token. + function mark(style){ + marked = style; + } + + // Push a new lexical context of the given type. + function pushlex(type, info) { + var result = function(){ + lexical = new JavaLexical(indented, column, type, null, lexical, info) + }; + result.lex = true; + return result; + } + // Pop off the current lexical context. + function poplex(){ + lexical = lexical.prev; + } + poplex.lex = true; + // The 'lex' flag on these actions is used by the 'next' function + // to know they can (and have to) be ran before moving on to the + // next token. + + // Creates an action that discards tokens until it finds one of + // the given type. + function expect(wanted){ + return function expecting(type){ + if (type == wanted) cont(); + else cont(arguments.callee); + }; + } + + // Looks for a statement, and then calls itself. + function statements(type){ + return pass(statement, statements); + } + // Dispatches various types of statements based on the type of the + // current token. + function statement(type){ + if (type == "keyword a") cont(pushlex("form"), expression, statement, poplex); + else if (type == "keyword b") cont(pushlex("form"), statement, poplex); + else if (type == "{") cont(pushlex("}"), block, poplex); + else if (type == "for") cont(pushlex("form"), expect("("), pushlex(")"), forspec1, expect(")"), poplex, statement, poplex); + else if (type == "variable") cont(pushlex("stat"), maybelabel); + else if (type == "switch") cont(pushlex("form"), expression, pushlex("}", "switch"), expect("{"), block, poplex, poplex); + else if (type == "case") cont(expression, expect(":")); + else if (type == "default") cont(expect(":")); + else if (type == "catch") cont(pushlex("form"), expect("("), function(){}, expect(")"), statement, poplex); + else if (type == "class") cont(); + else if (type == "interface") cont(); + else if (type == "keyword c") cont(statement); + else pass(pushlex("stat"), expression, expect(";"), poplex); + } + // Dispatch expression types. + function expression(type){ + if (atomicTypes.hasOwnProperty(type)) cont(maybeoperator); + //else if (type == "function") cont(functiondef); + else if (type == "keyword c") cont(expression); + else if (type == "(") cont(pushlex(")"), expression, expect(")"), poplex, maybeoperator); + else if (type == "operator") cont(expression); + else if (type == "[") cont(pushlex("]"), commasep(expression, "]"), poplex, maybeoperator); + } + // Called for places where operators, function calls, or + // subscripts are valid. Will skip on to the next action if none + // is found. + function maybeoperator(type){ + if (type == "operator") cont(expression); + else if (type == "(") cont(pushlex(")"), expression, commasep(expression, ")"), poplex, maybeoperator); + else if (type == "[") cont(pushlex("]"), expression, expect("]"), poplex, maybeoperator); + } + // When a statement starts with a variable name, it might be a + // label. If no colon follows, it's a regular statement. + + function maybelabel(type){ + if (type == "(") cont(commasep(function(){}, ")"), poplex, statement); // method definition + else if (type == "{") cont(poplex, pushlex("}"), block, poplex); // property definition + else pass(maybeoperator, expect(";"), poplex); + } + + // Parses a comma-separated list of the things that are recognized + // by the 'what' argument. + function commasep(what, end){ + function proceed(type) { + if (type == ",") cont(what, proceed); + else if (type == end) cont(); + else cont(expect(end)); + }; + return function commaSeparated(type) { + if (type == end) cont(); + else pass(what, proceed); + }; + } + // Look for statements until a closing brace is found. + function block(type){ + if (type == "}") cont(); + else pass(statement, block); + } + + // For loops. + + function forspec1(type){ + if (type == ";") pass(forspec2); + else pass(forspec2); + } + function formaybein(type, value){ + if (value == "in") cont(expression); + else cont(maybeoperator, forspec2); + } + function forspec2(type, value){ + if (type == ";") cont(forspec3); + else if (value == "in") cont(expression); + else cont(expression, expect(";"), forspec3); + } + function forspec3(type) { + if (type == ")") pass(); + else cont(expression); + } + + return parser; + } + + return { + make: parseJava, + electricChars: "{}:", + configure: function(obj) { + if (obj.json != null) json = obj.json; + } + }; +})(); diff --git a/gulliver/js/codemirrorOld/contrib/java/js/tokenizejava.js b/gulliver/js/codemirrorOld/contrib/java/js/tokenizejava.js new file mode 100644 index 000000000..1b58901ad --- /dev/null +++ b/gulliver/js/codemirrorOld/contrib/java/js/tokenizejava.js @@ -0,0 +1,222 @@ +/** + * Java tokenizer for codemirror + * + * @author Patrick Wied + * @version 2010-10-07 + */ +var tokenizeJava = (function() { + // Advance the stream until the given character (not preceded by a + // backslash) is encountered, or the end of the line is reached. + function nextUntilUnescaped(source, end) { + var escaped = false; + var next; + while (!source.endOfLine()) { + var next = source.next(); + if (next == end && !escaped) + return false; + escaped = !escaped && next == "\\"; + } + return escaped; + } + + // A map of Java's keywords. The a/b/c keyword distinction is + // very rough, but it gives the parser enough information to parse + // correct code correctly (we don't care that much how we parse + // incorrect code). The style information included in these objects + // is used by the highlighter to pick the correct CSS style for a + // token. + var keywords = function(){ + function result(type, style){ + return {type: type, style: "java-" + style}; + } + // keywords that take a parenthised expression, and then a + // statement (if) + var keywordA = result("keyword a", "keyword"); + // keywords that take just a statement (else) + var keywordB = result("keyword b", "keyword"); + // keywords that optionally take an expression, and form a + // statement (return) + var keywordC = result("keyword c", "keyword"); + var operator = result("operator", "keyword"); + var atom = result("atom", "atom"); + + return { + "if": keywordA, "while": keywordA, "with": keywordA, + "else": keywordB, "do": keywordB, "try": keywordB, "finally": keywordB, + "return": keywordC, "break": keywordC, "continue": keywordC, "new": keywordC, "throw": keywordC, "throws": keywordB, + "in": operator, "typeof": operator, "instanceof": operator, + "catch": result("catch", "keyword"), "for": result("for", "keyword"), "switch": result("switch", "keyword"), + "case": result("case", "keyword"), "default": result("default", "keyword"), + "true": atom, "false": atom, "null": atom, + + "class": result("class", "keyword"), "interface": result("interface", "keyword"), "package": keywordC, "import": keywordC, + "implements": keywordC, "extends": keywordC, "super": keywordC, + + "public": keywordC, "private": keywordC, "protected": keywordC, "transient": keywordC, "this": keywordC, + "static": keywordC, "final": keywordC, "const": keywordC, "abstract": keywordC, "static": keywordC, + + "int": keywordC, "double": keywordC, "long": keywordC, "boolean": keywordC, "char": keywordC, + "void": keywordC, "byte": keywordC, "float": keywordC, "short": keywordC + }; + }(); + + // Some helper regexps + var isOperatorChar = /[+\-*&%=<>!?|]/; + var isHexDigit = /[0-9A-Fa-f]/; + var isWordChar = /[\w\$_]/; + // Wrapper around javaToken that helps maintain parser state (whether + // we are inside of a multi-line comment and whether the next token + // could be a regular expression). + function javaTokenState(inside, regexp) { + return function(source, setState) { + var newInside = inside; + var type = javaToken(inside, regexp, source, function(c) {newInside = c;}); + var newRegexp = type.type == "operator" || type.type == "keyword c" || type.type.match(/^[\[{}\(,;:]$/); + if (newRegexp != regexp || newInside != inside) + setState(javaTokenState(newInside, newRegexp)); + return type; + }; + } + + // The token reader, inteded to be used by the tokenizer from + // tokenize.js (through jsTokenState). Advances the source stream + // over a token, and returns an object containing the type and style + // of that token. + function javaToken(inside, regexp, source, setInside) { + function readHexNumber(){ + source.next(); // skip the 'x' + source.nextWhileMatches(isHexDigit); + return {type: "number", style: "java-atom"}; + } + + function readNumber() { + source.nextWhileMatches(/[0-9]/); + if (source.equals(".")){ + source.next(); + source.nextWhileMatches(/[0-9]/); + } + if (source.equals("e") || source.equals("E")){ + source.next(); + if (source.equals("-")) + source.next(); + source.nextWhileMatches(/[0-9]/); + } + return {type: "number", style: "java-atom"}; + } + // Read a word, look it up in keywords. If not found, it is a + // variable, otherwise it is a keyword of the type found. + function readWord() { + source.nextWhileMatches(isWordChar); + var word = source.get(); + var known = keywords.hasOwnProperty(word) && keywords.propertyIsEnumerable(word) && keywords[word]; + return known ? {type: known.type, style: known.style, content: word} : + {type: "variable", style: "java-variable", content: word}; + } + function readRegexp() { + nextUntilUnescaped(source, "/"); + source.nextWhileMatches(/[gi]/); + return {type: "regexp", style: "java-string"}; + } + // Mutli-line comments are tricky. We want to return the newlines + // embedded in them as regular newline tokens, and then continue + // returning a comment token for every line of the comment. So + // some state has to be saved (inside) to indicate whether we are + // inside a /* */ sequence. + function readMultilineComment(start){ + var newInside = "/*"; + var maybeEnd = (start == "*"); + while (true) { + if (source.endOfLine()) + break; + var next = source.next(); + if (next == "/" && maybeEnd){ + newInside = null; + break; + } + maybeEnd = (next == "*"); + } + setInside(newInside); + return {type: "comment", style: "java-comment"}; + } + + // for reading javadoc + function readJavaDocComment(start){ + var newInside = "/**"; + var maybeEnd = (start == "*"); + while (true) { + if (source.endOfLine()) + break; + var next = source.next(); + if (next == "/" && maybeEnd){ + newInside = null; + break; + } + maybeEnd = (next == "*"); + } + setInside(newInside); + return {type: "javadoc", style: "javadoc-comment"}; + } + // for reading annotations (word based) + function readAnnotation(){ + source.nextWhileMatches(isWordChar); + var word = source.get(); + return {type: "annotation", style: "java-annotation", content:word}; + } + + function readOperator() { + source.nextWhileMatches(isOperatorChar); + return {type: "operator", style: "java-operator"}; + } + function readString(quote) { + var endBackSlash = nextUntilUnescaped(source, quote); + setInside(endBackSlash ? quote : null); + return {type: "string", style: "java-string"}; + } + + // Fetch the next token. Dispatches on first character in the + // stream, or first two characters when the first is a slash. + if (inside == "\"" || inside == "'") + return readString(inside); + var ch = source.next(); + if (inside == "/*") + return readMultilineComment(ch); + else if(inside == "/**") + return readJavaDocComment(ch); + else if (ch == "\"" || ch == "'") + return readString(ch); + // with punctuation, the type of the token is the symbol itself + else if (/[\[\]{}\(\),;\:\.]/.test(ch)) + return {type: ch, style: "java-punctuation"}; + else if (ch == "0" && (source.equals("x") || source.equals("X"))) + return readHexNumber(); + else if (/[0-9]/.test(ch)) + return readNumber(); + else if (ch == "@"){ + return readAnnotation(); + }else if (ch == "/"){ + if (source.equals("*")){ + source.next(); + + if(source.equals("*")) + return readJavaDocComment(ch); + + return readMultilineComment(ch); + } + else if (source.equals("/")) + { nextUntilUnescaped(source, null); return {type: "comment", style: "java-comment"};} + else if (regexp) + return readRegexp(); + else + return readOperator(); + } + else if (isOperatorChar.test(ch)) + return readOperator(); + else + return readWord(); + } + + // The external interface to the tokenizer. + return function(source, startState) { + return tokenizer(source, startState || javaTokenState(false, true)); + }; +})(); diff --git a/gulliver/js/codemirrorOld/contrib/lua/LICENSE b/gulliver/js/codemirrorOld/contrib/lua/LICENSE new file mode 100644 index 000000000..5b867cd52 --- /dev/null +++ b/gulliver/js/codemirrorOld/contrib/lua/LICENSE @@ -0,0 +1,32 @@ +Copyright (c) 2009, Franciszek Wawrzak +All rights reserved. + +This software is provided for use in connection with the +CodeMirror suite of modules and utilities, hosted and maintained +at http://codemirror.net/. + +Redistribution and use of this software in source and binary forms, +with or without modification, are permitted provided that the +following conditions are met: + +* Redistributions of source code must retain the above + copyright notice, this list of conditions and the + following disclaimer. + +* Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the + following disclaimer in the documentation and/or other + materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. diff --git a/gulliver/js/codemirrorOld/contrib/lua/css/luacolors.css b/gulliver/js/codemirrorOld/contrib/lua/css/luacolors.css new file mode 100644 index 000000000..e9015296f --- /dev/null +++ b/gulliver/js/codemirrorOld/contrib/lua/css/luacolors.css @@ -0,0 +1,63 @@ +html { + cursor: text; +} + +.editbox { + margin: .4em; + padding: 0; + font-family: monospace; + font-size: 10pt; + color: black; +} + +pre.code, .editbox { + color: #666666; +} + +.editbox p { + margin: 0; +} + +span.lua-comment { + color: #BB9977; +} + +span.lua-keyword { + font-weight: bold; + color: blue; +} + +span.lua-string { + color: #AA2222; +} + +span.lua-stdfunc { + font-weight: bold; + color: #077; +} +span.lua-customfunc { + font-weight: bold; + color: #0AA; +} + + +span.lua-identifier { + color: black; +} + +span.lua-number { + color: #3A3; +} + +span.lua-token { + color: #151; +} + +span.lua-error { + color: #FFF; + background-color: #F00; +} + + + + diff --git a/gulliver/js/codemirrorOld/contrib/lua/index.html b/gulliver/js/codemirrorOld/contrib/lua/index.html new file mode 100644 index 000000000..2192f020c --- /dev/null +++ b/gulliver/js/codemirrorOld/contrib/lua/index.html @@ -0,0 +1,68 @@ + + + + CodeMirror: Lua demonstration + + + +

This page demonstrates CodeMirror's +Lua parser. Written by Franciszek +Wawrzak, released under a BSD-style license.

+ +
+ +
+ + + + diff --git a/gulliver/js/codemirrorOld/contrib/lua/js/parselua.js b/gulliver/js/codemirrorOld/contrib/lua/js/parselua.js new file mode 100644 index 000000000..5d508b2cd --- /dev/null +++ b/gulliver/js/codemirrorOld/contrib/lua/js/parselua.js @@ -0,0 +1,254 @@ +/* + Simple parser for LUA + Written for Lua 5.1, based on parsecss and other parsers. + features: highlights keywords, strings, comments (no leveling supported! ("[==[")),tokens, basic indenting + + to make this parser highlight your special functions pass table with this functions names to parserConfig argument of creator, + + parserConfig: ["myfunction1","myfunction2"], + */ + + +function findFirstRegexp(words) { + return new RegExp("^(?:" + words.join("|") + ")", "i"); +} + +function matchRegexp(words) { + return new RegExp("^(?:" + words.join("|") + ")$", "i"); +} + + + +var luaCustomFunctions= matchRegexp([]); + +function configureLUA(parserConfig){ + if(parserConfig) + luaCustomFunctions= matchRegexp(parserConfig); +} + + +//long list of standard functions from lua manual +var luaStdFunctions = matchRegexp([ +"_G","_VERSION","assert","collectgarbage","dofile","error","getfenv","getmetatable","ipairs","load","loadfile","loadstring","module","next","pairs","pcall","print","rawequal","rawget","rawset","require","select","setfenv","setmetatable","tonumber","tostring","type","unpack","xpcall", + +"coroutine.create","coroutine.resume","coroutine.running","coroutine.status","coroutine.wrap","coroutine.yield", + +"debug.debug","debug.getfenv","debug.gethook","debug.getinfo","debug.getlocal","debug.getmetatable","debug.getregistry","debug.getupvalue","debug.setfenv","debug.sethook","debug.setlocal","debug.setmetatable","debug.setupvalue","debug.traceback", + +"close","flush","lines","read","seek","setvbuf","write", + +"io.close","io.flush","io.input","io.lines","io.open","io.output","io.popen","io.read","io.stderr","io.stdin","io.stdout","io.tmpfile","io.type","io.write", + +"math.abs","math.acos","math.asin","math.atan","math.atan2","math.ceil","math.cos","math.cosh","math.deg","math.exp","math.floor","math.fmod","math.frexp","math.huge","math.ldexp","math.log","math.log10","math.max","math.min","math.modf","math.pi","math.pow","math.rad","math.random","math.randomseed","math.sin","math.sinh","math.sqrt","math.tan","math.tanh", + +"os.clock","os.date","os.difftime","os.execute","os.exit","os.getenv","os.remove","os.rename","os.setlocale","os.time","os.tmpname", + +"package.cpath","package.loaded","package.loaders","package.loadlib","package.path","package.preload","package.seeall", + +"string.byte","string.char","string.dump","string.find","string.format","string.gmatch","string.gsub","string.len","string.lower","string.match","string.rep","string.reverse","string.sub","string.upper", + +"table.concat","table.insert","table.maxn","table.remove","table.sort" +]); + + + + var luaKeywords = matchRegexp(["and","break","elseif","false","nil","not","or","return", + "true","function", "end", "if", "then", "else", "do", + "while", "repeat", "until", "for", "in", "local" ]); + + var luaIndentKeys = matchRegexp(["function", "if","repeat","for","while", "[\(]", "{"]); + var luaUnindentKeys = matchRegexp(["end", "until", "[\)]", "}"]); + + var luaUnindentKeys2 = findFirstRegexp(["end", "until", "[\)]", "}"]); + var luaMiddleKeys = findFirstRegexp(["else","elseif"]); + + + +var LUAParser = Editor.Parser = (function() { + var tokenizeLUA = (function() { + function normal(source, setState) { + var ch = source.next(); + + if (ch == "-" && source.equals("-")) { + source.next(); + setState(inSLComment); + return null; + } + else if (ch == "\"" || ch == "'") { + setState(inString(ch)); + return null; + } + if (ch == "[" && (source.equals("[") || source.equals("="))) { + var level = 0; + while(source.equals("=")){ + level ++; + source.next(); + } + if(! source.equals("[") ) + return "lua-error"; + setState(inMLSomething(level,"lua-string")); + return null; + } + + else if (ch == "=") { + if (source.equals("=")) + source.next(); + return "lua-token"; + } + + else if (ch == ".") { + if (source.equals(".")) + source.next(); + if (source.equals(".")) + source.next(); + return "lua-token"; + } + + else if (ch == "+" || ch == "-" || ch == "*" || ch == "/" || ch == "%" || ch == "^" || ch == "#" ) { + return "lua-token"; + } + else if (ch == ">" || ch == "<" || ch == "(" || ch == ")" || ch == "{" || ch == "}" || ch == "[" ) { + return "lua-token"; + } + else if (ch == "]" || ch == ";" || ch == ":" || ch == ",") { + return "lua-token"; + } + else if (source.equals("=") && (ch == "~" || ch == "<" || ch == ">")) { + source.next(); + return "lua-token"; + } + + else if (/\d/.test(ch)) { + source.nextWhileMatches(/[\w.%]/); + return "lua-number"; + } + else { + source.nextWhileMatches(/[\w\\\-_.]/); + return "lua-identifier"; + } + } + +function inSLComment(source, setState) { + var start = true; + var count=0; + while (!source.endOfLine()) { + var ch = source.next(); + var level = 0; + if ((ch =="[") && start){ + while(source.equals("=")){ + source.next(); + level++; + } + if (source.equals("[")){ + setState(inMLSomething(level,"lua-comment")); + return null; + } + } + start = false; + } + setState(normal); + return "lua-comment"; + + } + + function inMLSomething(level,what) { + //wat sholud be "lua-string" or "lua-comment", level is the number of "=" in opening mark. + return function(source, setState){ + var dashes = 0; + while (!source.endOfLine()) { + var ch = source.next(); + if (dashes == level+1 && ch == "]" ) { + setState(normal); + break; + } + if (dashes == 0) + dashes = (ch == "]") ? 1:0; + else + dashes = (ch == "=") ? dashes + 1 : 0; + } + return what; + } + } + + + function inString(quote) { + return function(source, setState) { + var escaped = false; + while (!source.endOfLine()) { + var ch = source.next(); + if (ch == quote && !escaped) + break; + escaped = !escaped && ch == "\\"; + } + if (!escaped) + setState(normal); + return "lua-string"; + }; + } + + return function(source, startState) { + return tokenizer(source, startState || normal); + }; + })(); + + function indentLUA(indentDepth, base) { + return function(nextChars) { + + var closing = (luaUnindentKeys2.test(nextChars) || luaMiddleKeys.test(nextChars)); + + + return base + ( indentUnit * (indentDepth - (closing?1:0)) ); + }; + } + + +function parseLUA(source,basecolumn) { + basecolumn = basecolumn || 0; + + var tokens = tokenizeLUA(source); + var indentDepth = 0; + + var iter = { + next: function() { + var token = tokens.next(), style = token.style, content = token.content; + + + + if (style == "lua-identifier" && luaKeywords.test(content)){ + token.style = "lua-keyword"; + } + if (style == "lua-identifier" && luaStdFunctions.test(content)){ + token.style = "lua-stdfunc"; + } + if (style == "lua-identifier" && luaCustomFunctions.test(content)){ + token.style = "lua-customfunc"; + } + + if (luaIndentKeys.test(content)) + indentDepth++; + else if (luaUnindentKeys.test(content)) + indentDepth--; + + + if (content == "\n") + token.indentation = indentLUA( indentDepth, basecolumn); + + return token; + }, + + copy: function() { + var _tokenState = tokens.state, _indentDepth = indentDepth; + return function(source) { + tokens = tokenizeLUA(source, _tokenState); + + indentDepth = _indentDepth; + return iter; + }; + } + }; + return iter; + } + + return {make: parseLUA, configure:configureLUA, electricChars: "delf})"}; //en[d] els[e] unti[l] elsei[f] // this should be taken from Keys keywords +})(); + diff --git a/gulliver/js/codemirrorOld/contrib/ometa/LICENSE b/gulliver/js/codemirrorOld/contrib/ometa/LICENSE new file mode 100644 index 000000000..44ceed6c3 --- /dev/null +++ b/gulliver/js/codemirrorOld/contrib/ometa/LICENSE @@ -0,0 +1,23 @@ + Copyright (c) 2007-2009 Marijn Haverbeke + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any + damages arising from the use of this software. + + Permission is granted to anyone to use this software for any + purpose, including commercial applications, and to alter it and + redistribute it freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product + documentation would be appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must + not be misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source + distribution. + + Marijn Haverbeke + marijnh at gmail diff --git a/gulliver/js/codemirrorOld/contrib/ometa/css/ometacolors.css b/gulliver/js/codemirrorOld/contrib/ometa/css/ometacolors.css new file mode 100644 index 000000000..f797b45b2 --- /dev/null +++ b/gulliver/js/codemirrorOld/contrib/ometa/css/ometacolors.css @@ -0,0 +1,63 @@ +html { + cursor: text; +} + +.editbox { + margin: .4em; + padding: 0; + font-family: monospace; + font-size: 10pt; + color: black; +} + +pre.code, .editbox { + color: #666666; +} + +.editbox p { + margin: 0; +} + +span.js-punctuation { + color: #666666; +} + +span.js-operator { + color: #E1570F; +} + +span.js-keyword { + color: #770088; +} + +span.js-atom { + color: #228811; +} + +span.js-variable { + color: black; +} + +span.js-variabledef { + color: #0000FF; +} + +span.js-localvariable { + color: #004499; +} + +span.js-property { + color: black; +} + +span.js-comment { + color: #AA7700; +} + +span.js-string { + color: #AA2222; +} + +span.ometa-binding { + color: #FF0000; +} diff --git a/gulliver/js/codemirrorOld/contrib/ometa/index.html b/gulliver/js/codemirrorOld/contrib/ometa/index.html new file mode 100644 index 000000000..5569cb520 --- /dev/null +++ b/gulliver/js/codemirrorOld/contrib/ometa/index.html @@ -0,0 +1,77 @@ + + + + CodeMirror: OmetaJS demonstration + + + + +

This page demonstrates CodeMirror's OmetaJS parser.

+ +

Adapted from the official Javascript parser by Eric KEDJI + <eric.kedji@gmail.com>.

+ +
+ +
+ + + + + diff --git a/gulliver/js/codemirrorOld/contrib/ometa/js/parseometa.js b/gulliver/js/codemirrorOld/contrib/ometa/js/parseometa.js new file mode 100644 index 000000000..efb715e94 --- /dev/null +++ b/gulliver/js/codemirrorOld/contrib/ometa/js/parseometa.js @@ -0,0 +1,364 @@ +/* Parse function for JavaScript. Makes use of the tokenizer from + * tokenizejavascript.js. Note that your parsers do not have to be + * this complicated -- if you don't want to recognize local variables, + * in many languages it is enough to just look for braces, semicolons, + * parentheses, etc, and know when you are inside a string or comment. + * + * See manual.html for more info about the parser interface. + */ + +var JSParser = Editor.Parser = (function() { + // Token types that can be considered to be atoms. + var atomicTypes = {"atom": true, "number": true, "variable": true, "string": true, "regexp": true}; + // Setting that can be used to have JSON data indent properly. + var json = false; + // Constructor for the lexical context objects. + function JSLexical(indented, column, type, align, prev, info) { + // indentation at start of this line + this.indented = indented; + // column at which this scope was opened + this.column = column; + // type of scope ('vardef', 'stat' (statement), 'form' (special form), '[', '{', or '(') + this.type = type; + // '[', '{', or '(' blocks that have any text after their opening + // character are said to be 'aligned' -- any lines below are + // indented all the way to the opening character. + if (align != null) + this.align = align; + // Parent scope, if any. + this.prev = prev; + this.info = info; + } + + // My favourite JavaScript indentation rules. + function indentJS(lexical) { + return function(firstChars) { + var firstChar = firstChars && firstChars.charAt(0), type = lexical.type; + var closing = firstChar == type; + if (type == "vardef") + return lexical.indented + 4; + else if (type == "form" && firstChar == "{") + return lexical.indented; + else if (type == "stat" || type == "form") + return lexical.indented + indentUnit; + else if (lexical.info == "switch" && !closing) + return lexical.indented + (/^(?:case|default)\b/.test(firstChars) ? indentUnit : 2 * indentUnit); + else if (lexical.align) + return lexical.column - (closing ? 1 : 0); + else + return lexical.indented + (closing ? 0 : indentUnit); + }; + } + + // The parser-iterator-producing function itself. + function parseJS(input, basecolumn) { + // Wrap the input in a token stream + var tokens = tokenizeJavaScript(input); + // The parser state. cc is a stack of actions that have to be + // performed to finish the current statement. For example we might + // know that we still need to find a closing parenthesis and a + // semicolon. Actions at the end of the stack go first. It is + // initialized with an infinitely looping action that consumes + // whole statements. + var cc = [json ? expressions : statements]; + // Context contains information about the current local scope, the + // variables defined in that, and the scopes above it. + var context = null; + // The lexical scope, used mostly for indentation. + var lexical = new JSLexical((basecolumn || 0) - indentUnit, 0, "block", false); + // Current column, and the indentation at the start of the current + // line. Used to create lexical scope objects. + var column = 0; + var indented = 0; + // Variables which are used by the mark, cont, and pass functions + // below to communicate with the driver loop in the 'next' + // function. + var consume, marked; + + // The iterator object. + var parser = {next: next, copy: copy}; + + function next(){ + // Start by performing any 'lexical' actions (adjusting the + // lexical variable), or the operations below will be working + // with the wrong lexical state. + while(cc[cc.length - 1].lex) + cc.pop()(); + + // Fetch a token. + var token = tokens.next(); + + // Adjust column and indented. + if (token.type == "whitespace" && column == 0) + indented = token.value.length; + column += token.value.length; + if (token.content == "\n"){ + indented = column = 0; + // If the lexical scope's align property is still undefined at + // the end of the line, it is an un-aligned scope. + if (!("align" in lexical)) + lexical.align = false; + // Newline tokens get an indentation function associated with + // them. + token.indentation = indentJS(lexical); + // special handling for multiline strings: keep everything in the first + // column, as spaces at the start of a multiline string are significant + if (lexical.info == "multilineString") { + lexical.align = false; + token.indentation = function () { return 0; }; + } + } + // No more processing for meaningless tokens. + if (token.type == "whitespace" || token.type == "comment") + return token; + // Take note when a multiline string is found, so as to + // correctly handle indentation at the end of the line + // (see above, line 95) + if (token.type == "multilineString") + lexical.info = 'multilineString'; + // When a meaningful token is found and the lexical scope's + // align is undefined, it is an aligned scope. + if (!("align" in lexical)) + lexical.align = true; + + // Execute actions until one 'consumes' the token and we can + // return it. + while(true) { + consume = marked = false; + // Take and execute the topmost action. + cc.pop()(token.type, token.content); + if (consume){ + // Marked is used to change the style of the current token. + if (marked) + token.style = marked; + // Here we differentiate between local and global variables. + else if (token.type == "variable" && inScope(token.content)) + token.style = "js-localvariable"; + return token; + } + } + } + + // This makes a copy of the parser state. It stores all the + // stateful variables in a closure, and returns a function that + // will restore them when called with a new input stream. Note + // that the cc array has to be copied, because it is contantly + // being modified. Lexical objects are not mutated, and context + // objects are not mutated in a harmful way, so they can be shared + // between runs of the parser. + function copy(){ + var _context = context, _lexical = lexical, _cc = cc.concat([]), _tokenState = tokens.state; + + return function copyParser(input){ + context = _context; + lexical = _lexical; + cc = _cc.concat([]); // copies the array + column = indented = 0; + tokens = tokenizeJavaScript(input, _tokenState); + return parser; + }; + } + + // Helper function for pushing a number of actions onto the cc + // stack in reverse order. + function push(fs){ + for (var i = fs.length - 1; i >= 0; i--) + cc.push(fs[i]); + } + // cont and pass are used by the action functions to add other + // actions to the stack. cont will cause the current token to be + // consumed, pass will leave it for the next action. + function cont(){ + push(arguments); + consume = true; + } + function pass(){ + push(arguments); + consume = false; + } + // Used to change the style of the current token. + function mark(style){ + marked = style; + } + + // Push a new scope. Will automatically link the current scope. + function pushcontext(){ + context = {prev: context, vars: {"this": true, "arguments": true}}; + } + // Pop off the current scope. + function popcontext(){ + context = context.prev; + } + // Register a variable in the current scope. + function register(varname){ + if (context){ + mark("js-variabledef"); + context.vars[varname] = true; + } + } + // Check whether a variable is defined in the current scope. + function inScope(varname){ + var cursor = context; + while (cursor) { + if (cursor.vars[varname]) + return true; + cursor = cursor.prev; + } + return false; + } + + // Push a new lexical context of the given type. + function pushlex(type, info) { + var result = function(){ + lexical = new JSLexical(indented, column, type, null, lexical, info) + }; + result.lex = true; + return result; + } + // Pop off the current lexical context. + function poplex(){ + lexical = lexical.prev; + } + poplex.lex = true; + // The 'lex' flag on these actions is used by the 'next' function + // to know they can (and have to) be ran before moving on to the + // next token. + + // Creates an action that discards tokens until it finds one of + // the given type. + function expect(wanted){ + return function expecting(type){ + if (type == wanted) cont(); + else cont(arguments.callee); + }; + } + + // Looks for a statement, and then calls itself. + function statements(type){ + return pass(statement, statements); + } + function expressions(type){ + return pass(expression, expressions); + } + // Dispatches various types of statements based on the type of the + // current token. + function statement(type){ + if (type == "var") cont(pushlex("vardef"), vardef1, expect(";"), poplex); + else if (type == "keyword a") cont(pushlex("form"), expression, statement, poplex); + else if (type == "keyword b") cont(pushlex("form"), statement, poplex); + else if (type == "{") cont(pushlex("}"), block, poplex); + else if (type == "function") cont(functiondef); + else if (type == "for") cont(pushlex("form"), expect("("), pushlex(")"), forspec1, expect(")"), poplex, statement, poplex); + else if (type == "variable") cont(pushlex("stat"), maybelabel); + else if (type == "switch") cont(pushlex("form"), expression, pushlex("}", "switch"), expect("{"), block, poplex, poplex); + else if (type == "case") cont(expression, expect(":")); + else if (type == "default") cont(expect(":")); + else if (type == "catch") cont(pushlex("form"), pushcontext, expect("("), funarg, expect(")"), statement, poplex, popcontext); + else pass(pushlex("stat"), expression, expect(";"), poplex); + } + // Dispatch expression types. + function expression(type){ + if (atomicTypes.hasOwnProperty(type)) cont(maybeoperator); + else if (type == "function") cont(functiondef); + else if (type == "keyword c") cont(expression); + else if (type == "(") cont(pushlex(")"), expression, expect(")"), poplex, maybeoperator); + else if (type == "operator") cont(expression); + else if (type == "[") cont(pushlex("]"), commasep(expression, "]"), poplex, maybeoperator); + else if (type == "{") cont(pushlex("}"), commasep(objprop, "}"), poplex, maybeoperator); + else cont(); + } + // Called for places where operators, function calls, or + // subscripts are valid. Will skip on to the next action if none + // is found. + function maybeoperator(type){ + if (type == "operator") cont(expression); + else if (type == "(") cont(pushlex(")"), commasep(expression, ")"), poplex, maybeoperator); + else if (type == ".") cont(property, maybeoperator); + else if (type == "[") cont(pushlex("]"), expression, expect("]"), poplex, maybeoperator); + } + // When a statement starts with a variable name, it might be a + // label. If no colon follows, it's a regular statement. + function maybelabel(type){ + if (type == ":") cont(poplex, statement); + else pass(maybeoperator, expect(";"), poplex); + } + // Property names need to have their style adjusted -- the + // tokenizer thinks they are variables. + function property(type){ + if (type == "variable") {mark("js-property"); cont();} + } + // This parses a property and its value in an object literal. + function objprop(type){ + if (type == "variable") mark("js-property"); + if (atomicTypes.hasOwnProperty(type)) cont(expect(":"), expression); + } + // Parses a comma-separated list of the things that are recognized + // by the 'what' argument. + function commasep(what, end){ + function proceed(type) { + if (type == ",") cont(what, proceed); + else if (type == end) cont(); + else cont(expect(end)); + } + return function commaSeparated(type) { + if (type == end) cont(); + else pass(what, proceed); + }; + } + // Look for statements until a closing brace is found. + function block(type){ + if (type == "}") cont(); + else pass(statement, block); + } + // Variable definitions are split into two actions -- 1 looks for + // a name or the end of the definition, 2 looks for an '=' sign or + // a comma. + function vardef1(type, value){ + if (type == "variable"){register(value); cont(vardef2);} + else cont(); + } + function vardef2(type, value){ + if (value == "=") cont(expression, vardef2); + else if (type == ",") cont(vardef1); + } + // For loops. + function forspec1(type){ + if (type == "var") cont(vardef1, forspec2); + else if (type == ";") pass(forspec2); + else if (type == "variable") cont(formaybein); + else pass(forspec2); + } + function formaybein(type, value){ + if (value == "in") cont(expression); + else cont(maybeoperator, forspec2); + } + function forspec2(type, value){ + if (type == ";") cont(forspec3); + else if (value == "in") cont(expression); + else cont(expression, expect(";"), forspec3); + } + function forspec3(type) { + if (type == ")") pass(); + else cont(expression); + } + // A function definition creates a new context, and the variables + // in its argument list have to be added to this context. + function functiondef(type, value){ + if (type == "variable"){register(value); cont(functiondef);} + else if (type == "(") cont(pushcontext, commasep(funarg, ")"), statement, popcontext); + } + function funarg(type, value){ + if (type == "variable"){register(value); cont();} + } + + return parser; + } + + return { + make: parseJS, + electricChars: "{}:", + configure: function(obj) { + if (obj.json != null) json = obj.json; + } + }; +})(); diff --git a/gulliver/js/codemirrorOld/contrib/ometa/js/tokenizeometa.js b/gulliver/js/codemirrorOld/contrib/ometa/js/tokenizeometa.js new file mode 100644 index 000000000..430206ca5 --- /dev/null +++ b/gulliver/js/codemirrorOld/contrib/ometa/js/tokenizeometa.js @@ -0,0 +1,209 @@ +/* Tokenizer for JavaScript code */ + +var tokenizeJavaScript = (function() { + // Advance the stream until the given character (not preceded by a + // backslash) is encountered, or the end of the line is reached. + function nextUntilUnescaped(source, end) { + var escaped = false; + while (!source.endOfLine()) { + var next = source.next(); + if (next == end && !escaped) + return false; + escaped = !escaped && next == "\\"; + } + return escaped; + } + + // A map of JavaScript's keywords. The a/b/c keyword distinction is + // very rough, but it gives the parser enough information to parse + // correct code correctly (we don't care that much how we parse + // incorrect code). The style information included in these objects + // is used by the highlighter to pick the correct CSS style for a + // token. + var keywords = function(){ + function result(type, style){ + return {type: type, style: "js-" + style}; + } + // keywords that take a parenthised expression, and then a + // statement (if) + var keywordA = result("keyword a", "keyword"); + // keywords that take just a statement (else) + var keywordB = result("keyword b", "keyword"); + // keywords that optionally take an expression, and form a + // statement (return) + var keywordC = result("keyword c", "keyword"); + var operator = result("operator", "keyword"); + var atom = result("atom", "atom"); + return { + "if": keywordA, "while": keywordA, "with": keywordA, + "else": keywordB, "do": keywordB, "try": keywordB, "finally": keywordB, + "return": keywordC, "break": keywordC, "continue": keywordC, "new": keywordC, "delete": keywordC, "throw": keywordC, + "in": operator, "typeof": operator, "instanceof": operator, + "var": result("var", "keyword"), "function": result("function", "keyword"), "catch": result("catch", "keyword"), + "for": result("for", "keyword"), "switch": result("switch", "keyword"), + "case": result("case", "keyword"), "default": result("default", "keyword"), + "true": atom, "false": atom, "null": atom, "undefined": atom, "NaN": atom, "Infinity": atom, + "ometa": keywordB + }; + }(); + + // Some helper regexps + var isOperatorChar = /[+\-*&%=<>!?|~]/; + var isHexDigit = /[0-9A-Fa-f]/; + var isWordChar = /[\w\$_]/; + + // Wrapper around jsToken that helps maintain parser state (whether + // we are inside of a multi-line comment and whether the next token + // could be a regular expression). + function jsTokenState(inside, regexp) { + return function(source, setState) { + var newInside = inside; + var type = jsToken(inside, regexp, source, function(c) {newInside = c;}); + var newRegexp = type.type == "operator" || type.type == "keyword c" || type.type.match(/^[\[{}\(,;:]$/); + if (newRegexp != regexp || newInside != inside) + setState(jsTokenState(newInside, newRegexp)); + return type; + }; + } + + // The token reader, intended to be used by the tokenizer from + // tokenize.js (through jsTokenState). Advances the source stream + // over a token, and returns an object containing the type and style + // of that token. + function jsToken(inside, regexp, source, setInside) { + function readHexNumber(){ + source.next(); // skip the 'x' + source.nextWhileMatches(isHexDigit); + return {type: "number", style: "js-atom"}; + } + + function readNumber() { + source.nextWhileMatches(/[0-9]/); + if (source.equals(".")){ + source.next(); + source.nextWhileMatches(/[0-9]/); + } + if (source.equals("e") || source.equals("E")){ + source.next(); + if (source.equals("-")) + source.next(); + source.nextWhileMatches(/[0-9]/); + } + return {type: "number", style: "js-atom"}; + } + // Read a word, look it up in keywords. If not found, it is a + // variable, otherwise it is a keyword of the type found. + function readWord() { + source.nextWhileMatches(isWordChar); + var word = source.get(); + var known = keywords.hasOwnProperty(word) && keywords.propertyIsEnumerable(word) && keywords[word]; + return known ? {type: known.type, style: known.style, content: word} : + {type: "variable", style: "js-variable", content: word}; + } + function readRegexp() { + nextUntilUnescaped(source, "/"); + source.nextWhileMatches(/[gi]/); + return {type: "regexp", style: "js-string"}; + } + // Mutli-line comments are tricky. We want to return the newlines + // embedded in them as regular newline tokens, and then continue + // returning a comment token for every line of the comment. So + // some state has to be saved (inside) to indicate whether we are + // inside a /* */ sequence. + function readMultilineComment(start){ + var newInside = "/*"; + var maybeEnd = (start == "*"); + while (true) { + if (source.endOfLine()) + break; + var next = source.next(); + if (next == "/" && maybeEnd){ + newInside = null; + break; + } + maybeEnd = (next == "*"); + } + setInside(newInside); + return {type: "comment", style: "js-comment"}; + } + function readMultilineString(start, quotes) { + var newInside = quotes; + var quote = quotes.charAt(0); + var maybeEnd = (start == quote); + while (true) { + if (source.endOfLine()) + break; + var next = source.next(); + if (next == quote && source.peek() == quote && maybeEnd) { + source.next(); + newInside = null; + break; + } + maybeEnd = (next == quote); + } + setInside(newInside); + return {type: "multilineString", style: "js-string"}; + } + function readOperator() { + source.nextWhileMatches(isOperatorChar); + return {type: "operator", style: "js-operator"}; + } + function readString(quote) { + var endBackSlash = nextUntilUnescaped(source, quote); + setInside(endBackSlash ? quote : null); + return {type: "string", style: "js-string"}; + } + function readOmetaIdentifierString() { + source.nextWhileMatches(isWordChar); + return {type: "string", style: "js-string"}; + } + function readOmetaBinding() { + source.nextWhileMatches(isWordChar); + return {type: "variable", style: "ometa-binding"}; + } + + // Fetch the next token. Dispatches on first character in the + // stream, or first two characters when the first is a slash. + if (inside == "\"" || inside == "'") + return readString(inside); + var ch = source.next(); + if (inside == "/*") + return readMultilineComment(ch); + if (inside == '"""' || inside == "'''") + return readMultilineString(ch, inside); + if (ch == '"' && source.lookAhead('""', true) || ch == "'" && source.lookAhead("''", true)) + return readMultilineString('-', ch+ch+ch); // work as far as '-' is not '"' nor "'" + else if (ch == "\"" || ch == "'") + return readString(ch); + else if (ch == "`" || ch == "#" ) + return readOmetaIdentifierString(); + else if (ch == ':' && isWordChar.test(source.peek())) + return readOmetaBinding(); + // with punctuation, the type of the token is the symbol itself + else if (/[\[\]{}\(\),;\:\.]/.test(ch)) + return {type: ch, style: "js-punctuation"}; + else if (ch == "0" && (source.equals("x") || source.equals("X"))) + return readHexNumber(); + else if (/[0-9]/.test(ch)) + return readNumber(); + else if (ch == "/"){ + if (source.equals("*")) + { source.next(); return readMultilineComment(ch); } + else if (source.equals("/")) + { nextUntilUnescaped(source, null); return {type: "comment", style: "js-comment"};} + else if (regexp) + return readRegexp(); + else + return readOperator(); + } + else if (isOperatorChar.test(ch)) + return readOperator(); + else + return readWord(); + } + + // The external interface to the tokenizer. + return function(source, startState) { + return tokenizer(source, startState || jsTokenState(false, true)); + }; +})(); diff --git a/gulliver/js/codemirrorOld/contrib/php/LICENSE b/gulliver/js/codemirrorOld/contrib/php/LICENSE new file mode 100644 index 000000000..32f48cad0 --- /dev/null +++ b/gulliver/js/codemirrorOld/contrib/php/LICENSE @@ -0,0 +1,37 @@ +Copyright (c) 2008-2009, Yahoo! Inc. +All rights reserved. + +This software is provided for use in connection with the +CodeMirror suite of modules and utilities, hosted and maintained +at http://codemirror.net/. + +Redistribution and use of this software in source and binary forms, +with or without modification, are permitted provided that the +following conditions are met: + +* Redistributions of source code must retain the above + copyright notice, this list of conditions and the + following disclaimer. + +* Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the + following disclaimer in the documentation and/or other + materials provided with the distribution. + +* Neither the name of Yahoo! Inc. nor the names of its + contributors may be used to endorse or promote products + derived from this software without specific prior + written permission of Yahoo! Inc. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. diff --git a/gulliver/js/codemirrorOld/contrib/php/index.html b/gulliver/js/codemirrorOld/contrib/php/index.html new file mode 100644 index 000000000..46b5eacc8 --- /dev/null +++ b/gulliver/js/codemirrorOld/contrib/php/index.html @@ -0,0 +1,310 @@ + + + + + + + CodeMirror: PHP+HTML+JavaScript+CSS mixed-mode demonstration + + + + +

This is a complex demonstration of the PHP+HTML+JavaScript+CSS mixed-mode + syntax highlight capabilities of CodeMirror. + <?php ... ?> tags use the PHP parser, <script> tags use the JavaScript + parser, and <style> tags use the CSS parser. The rest of the content is + parsed using the XML parser in HTML mode.

+ +

Features of the PHP parser: +

+ +
+ +
+ + + + + + diff --git a/gulliver/js/codemirrorOld/contrib/php/js/parsephp.js b/gulliver/js/codemirrorOld/contrib/php/js/parsephp.js new file mode 100644 index 000000000..7d0ad1f3b --- /dev/null +++ b/gulliver/js/codemirrorOld/contrib/php/js/parsephp.js @@ -0,0 +1,419 @@ +/* +Copyright (c) 2008-2009 Yahoo! Inc. All rights reserved. +The copyrights embodied in the content of this file are licensed by +Yahoo! Inc. under the BSD (revised) open source license + +@author Dan Vlad Dascalescu + + +Parse function for PHP. Makes use of the tokenizer from tokenizephp.js. +Based on parsejavascript.js by Marijn Haverbeke. + + +Features: + + special "deprecated" style for PHP4 keywords like 'var' + + support for PHP 5.3 keywords: 'namespace', 'use' + + 911 predefined constants, 1301 predefined functions, 105 predeclared classes + from a typical PHP installation in a LAMP environment + + new feature: syntax error flagging, thus enabling strict parsing of: + + function definitions with explicitly or implicitly typed arguments and default values + + modifiers (public, static etc.) applied to method and member definitions + + foreach(array_expression as $key [=> $value]) loops + + differentiation between single-quoted strings and double-quoted interpolating strings + +*/ + + +// add the Array.indexOf method for JS engines that don't support it (e.g. IE) +// code from https://developer.mozilla.org/En/Core_JavaScript_1.5_Reference/Global_Objects/Array/IndexOf +if (!Array.prototype.indexOf) +{ + Array.prototype.indexOf = function(elt /*, from*/) + { + var len = this.length; + + var from = Number(arguments[1]) || 0; + from = (from < 0) + ? Math.ceil(from) + : Math.floor(from); + if (from < 0) + from += len; + + for (; from < len; from++) + { + if (from in this && + this[from] === elt) + return from; + } + return -1; + }; +} + + +var PHPParser = Editor.Parser = (function() { + // Token types that can be considered to be atoms, part of operator expressions + var atomicTypes = { + "atom": true, "number": true, "variable": true, "string": true + }; + // Constructor for the lexical context objects. + function PHPLexical(indented, column, type, align, prev, info) { + // indentation at start of this line + this.indented = indented; + // column at which this scope was opened + this.column = column; + // type of scope ('stat' (statement), 'form' (special form), '[', '{', or '(') + this.type = type; + // '[', '{', or '(' blocks that have any text after their opening + // character are said to be 'aligned' -- any lines below are + // indented all the way to the opening character. + if (align != null) + this.align = align; + // Parent scope, if any. + this.prev = prev; + this.info = info; + } + + // PHP indentation rules + function indentPHP(lexical) { + return function(firstChars) { + var firstChar = firstChars && firstChars.charAt(0), type = lexical.type; + var closing = firstChar == type; + if (type == "form" && firstChar == "{") + return lexical.indented; + else if (type == "stat" || type == "form") + return lexical.indented + indentUnit; + else if (lexical.info == "switch" && !closing) + return lexical.indented + (/^(?:case|default)\b/.test(firstChars) ? indentUnit : 2 * indentUnit); + else if (lexical.align) + return lexical.column - (closing ? 1 : 0); + else + return lexical.indented + (closing ? 0 : indentUnit); + }; + } + + // The parser-iterator-producing function itself. + function parsePHP(input, basecolumn) { + // Wrap the input in a token stream + var tokens = tokenizePHP(input); + // The parser state. cc is a stack of actions that have to be + // performed to finish the current statement. For example we might + // know that we still need to find a closing parenthesis and a + // semicolon. Actions at the end of the stack go first. It is + // initialized with an infinitely looping action that consumes + // whole statements. + var cc = [statements]; + // The lexical scope, used mostly for indentation. + var lexical = new PHPLexical((basecolumn || 0) - indentUnit, 0, "block", false); + // Current column, and the indentation at the start of the current + // line. Used to create lexical scope objects. + var column = 0; + var indented = 0; + // Variables which are used by the mark, cont, and pass functions + // below to communicate with the driver loop in the 'next' function. + var consume, marked; + + // The iterator object. + var parser = {next: next, copy: copy}; + + // parsing is accomplished by calling next() repeatedly + function next(){ + // Start by performing any 'lexical' actions (adjusting the + // lexical variable), or the operations below will be working + // with the wrong lexical state. + while(cc[cc.length - 1].lex) + cc.pop()(); + + // Fetch the next token. + var token = tokens.next(); + + // Adjust column and indented. + if (token.type == "whitespace" && column == 0) + indented = token.value.length; + column += token.value.length; + if (token.content == "\n"){ + indented = column = 0; + // If the lexical scope's align property is still undefined at + // the end of the line, it is an un-aligned scope. + if (!("align" in lexical)) + lexical.align = false; + // Newline tokens get an indentation function associated with + // them. + token.indentation = indentPHP(lexical); + } + // No more processing for meaningless tokens. + if (token.type == "whitespace" || token.type == "comment" + || token.type == "string_not_terminated" ) + return token; + // When a meaningful token is found and the lexical scope's + // align is undefined, it is an aligned scope. + if (!("align" in lexical)) + lexical.align = true; + + // Execute actions until one 'consumes' the token and we can + // return it. 'marked' is used to change the style of the current token. + while(true) { + consume = marked = false; + // Take and execute the topmost action. + var action = cc.pop(); + action(token); + + if (consume){ + if (marked) + token.style = marked; + // Here we differentiate between local and global variables. + return token; + } + } + return 1; // Firebug workaround for http://code.google.com/p/fbug/issues/detail?id=1239#c1 + } + + // This makes a copy of the parser state. It stores all the + // stateful variables in a closure, and returns a function that + // will restore them when called with a new input stream. Note + // that the cc array has to be copied, because it is contantly + // being modified. Lexical objects are not mutated, so they can + // be shared between runs of the parser. + function copy(){ + var _lexical = lexical, _cc = cc.concat([]), _tokenState = tokens.state; + + return function copyParser(input){ + lexical = _lexical; + cc = _cc.concat([]); // copies the array + column = indented = 0; + tokens = tokenizePHP(input, _tokenState); + return parser; + }; + } + + // Helper function for pushing a number of actions onto the cc + // stack in reverse order. + function push(fs){ + for (var i = fs.length - 1; i >= 0; i--) + cc.push(fs[i]); + } + // cont and pass are used by the action functions to add other + // actions to the stack. cont will cause the current token to be + // consumed, pass will leave it for the next action. + function cont(){ + push(arguments); + consume = true; + } + function pass(){ + push(arguments); + consume = false; + } + // Used to change the style of the current token. + function mark(style){ + marked = style; + } + // Add a lyer of style to the current token, for example syntax-error + function mark_add(style){ + marked = marked + ' ' + style; + } + + // Push a new lexical context of the given type. + function pushlex(type, info) { + var result = function pushlexing() { + lexical = new PHPLexical(indented, column, type, null, lexical, info) + }; + result.lex = true; + return result; + } + // Pop off the current lexical context. + function poplex(){ + if (lexical.prev) + lexical = lexical.prev; + } + poplex.lex = true; + // The 'lex' flag on these actions is used by the 'next' function + // to know they can (and have to) be ran before moving on to the + // next token. + + // Creates an action that discards tokens until it finds one of + // the given type. This will ignore (and recover from) syntax errors. + function expect(wanted){ + return function expecting(token){ + if (token.type == wanted) cont(); // consume the token + else { + cont(arguments.callee); // continue expecting() - call itself + } + }; + } + + // Require a specific token type, or one of the tokens passed in the 'wanted' array + // Used to detect blatant syntax errors. 'execute' is used to pass extra code + // to be executed if the token is matched. For example, a '(' match could + // 'execute' a cont( compasep(funcarg), require(")") ) + function require(wanted, execute){ + return function requiring(token){ + var ok; + var type = token.type; + if (typeof(wanted) == "string") + ok = (type == wanted) -1; + else + ok = wanted.indexOf(type); + if (ok >= 0) { + if (execute && typeof(execute[ok]) == "function") pass(execute[ok]); + else cont(); + } + else { + if (!marked) mark(token.style); + mark_add("syntax-error"); + cont(arguments.callee); + } + }; + } + + // Looks for a statement, and then calls itself. + function statements(token){ + return pass(statement, statements); + } + // Dispatches various types of statements based on the type of the current token. + function statement(token){ + var type = token.type; + if (type == "keyword a") cont(pushlex("form"), expression, altsyntax, statement, poplex); + else if (type == "keyword b") cont(pushlex("form"), altsyntax, statement, poplex); + else if (type == "{") cont(pushlex("}"), block, poplex); + else if (type == "function") funcdef(); + // technically, "class implode {...}" is correct, but we'll flag that as an error because it overrides a predefined function + else if (type == "class") classdef(); + else if (type == "foreach") cont(pushlex("form"), require("("), pushlex(")"), expression, require("as"), require("variable"), /* => $value */ expect(")"), altsyntax, poplex, statement, poplex); + else if (type == "for") cont(pushlex("form"), require("("), pushlex(")"), expression, require(";"), expression, require(";"), expression, require(")"), altsyntax, poplex, statement, poplex); + // public final function foo(), protected static $bar; + else if (type == "modifier") cont(require(["modifier", "variable", "function", "abstract"], + [null, commasep(require("variable")), funcdef, absfun])); + else if (type == "abstract") abs(); + else if (type == "switch") cont(pushlex("form"), require("("), expression, require(")"), pushlex("}", "switch"), require([":", "{"]), block, poplex, poplex); + else if (type == "case") cont(expression, require(":")); + else if (type == "default") cont(require(":")); + else if (type == "catch") cont(pushlex("form"), require("("), require("t_string"), require("variable"), require(")"), statement, poplex); + else if (type == "const") cont(require("t_string")); // 'const static x=5' is a syntax error + // technically, "namespace implode {...}" is correct, but we'll flag that as an error because it overrides a predefined function + else if (type == "namespace") cont(namespacedef, require(";")); + // $variables may be followed by operators, () for variable function calls, or [] subscripts + else pass(pushlex("stat"), expression, require(";"), poplex); + } + // Dispatch expression types. + function expression(token){ + var type = token.type; + if (atomicTypes.hasOwnProperty(type)) cont(maybeoperator); + else if (type == "<<<") cont(require("string"), maybeoperator); // heredoc/nowdoc + else if (type == "t_string") cont(maybe_double_colon, maybeoperator); + else if (type == "keyword c" || type == "operator") cont(expression); + // lambda + else if (type == "function") lambdadef(); + // function call or parenthesized expression: $a = ($b + 1) * 2; + else if (type == "(") cont(pushlex(")"), commasep(expression), require(")"), poplex, maybeoperator); + } + // Called for places where operators, function calls, or subscripts are + // valid. Will skip on to the next action if none is found. + function maybeoperator(token){ + var type = token.type; + if (type == "operator") { + if (token.content == "?") cont(expression, require(":"), expression); // ternary operator + else cont(expression); + } + else if (type == "(") cont(pushlex(")"), expression, commasep(expression), require(")"), poplex, maybeoperator /* $varfunc() + 3 */); + else if (type == "[") cont(pushlex("]"), expression, require("]"), maybeoperator /* for multidimensional arrays, or $func[$i]() */, poplex); + } + // A regular use of the double colon to specify a class, as in self::func() or myclass::$var; + // Differs from `namespace` or `use` in that only one class can be the parent; chains (A::B::$var) are a syntax error. + function maybe_double_colon(token) { + if (token.type == "t_double_colon") + // A::$var, A::func(), A::const + cont(require(["t_string", "variable"]), maybeoperator); + else { + // a t_string wasn't followed by ::, such as in a function call: foo() + pass(expression) + } + } + // the declaration or definition of a function + function funcdef() { + cont(require("t_string"), require("("), pushlex(")"), commasep(funcarg), require(")"), poplex, block); + } + // the declaration or definition of a lambda + function lambdadef() { + cont(require("("), pushlex(")"), commasep(funcarg), require(")"), maybe_lambda_use, poplex, require("{"), pushlex("}"), block, poplex); + } + // optional lambda 'use' statement + function maybe_lambda_use(token) { + if(token.type == "namespace") { + cont(require('('), commasep(funcarg), require(')')); + } + else { + pass(expression); + } + } + // the definition of a class + function classdef() { + cont(require("t_string"), expect("{"), pushlex("}"), block, poplex); + } + // either funcdef if the current token is "function", or the keyword "function" + funcdef + function absfun(token) { + if(token.type == "function") funcdef(); + else cont(require(["function"], [funcdef])); + } + // the abstract class or function (with optional modifier) + function abs(token) { + cont(require(["modifier", "function", "class"], [absfun, funcdef, classdef])); + } + // Parses a comma-separated list of the things that are recognized + // by the 'what' argument. + function commasep(what){ + function proceed(token) { + if (token.type == ",") cont(what, proceed); + } + return function commaSeparated() { + pass(what, proceed); + }; + } + // Look for statements until a closing brace is found. + function block(token) { + if (token.type == "}") cont(); + else pass(statement, block); + } + function empty_parens_if_array(token) { + if(token.content == "array") + cont(require("("), require(")")); + } + function maybedefaultparameter(token){ + if (token.content == "=") cont(require(["t_string", "string", "number", "atom"], [empty_parens_if_array, null, null])); + } + function var_or_reference(token) { + if(token.type == "variable") cont(maybedefaultparameter); + else if(token.content == "&") cont(require("variable"), maybedefaultparameter); + } + // support for default arguments: http://us.php.net/manual/en/functions.arguments.php#functions.arguments.default + function funcarg(token){ + // function foo(myclass $obj) {...} or function foo(myclass &objref) {...} + if (token.type == "t_string") cont(var_or_reference); + // function foo($var) {...} or function foo(&$ref) {...} + else var_or_reference(token); + } + + // A namespace definition or use + function maybe_double_colon_def(token) { + if (token.type == "t_double_colon") + cont(namespacedef); + } + function namespacedef(token) { + pass(require("t_string"), maybe_double_colon_def); + } + + function altsyntax(token){ + if(token.content==':') + cont(altsyntaxBlock,poplex); + } + + function altsyntaxBlock(token){ + if (token.type == "altsyntaxend") cont(require(';')); + else pass(statement, altsyntaxBlock); + } + + + return parser; + } + + return {make: parsePHP, electricChars: "{}:"}; + +})(); diff --git a/gulliver/js/codemirrorOld/contrib/php/js/parsephphtmlmixed.js b/gulliver/js/codemirrorOld/contrib/php/js/parsephphtmlmixed.js new file mode 100644 index 000000000..fa189c18c --- /dev/null +++ b/gulliver/js/codemirrorOld/contrib/php/js/parsephphtmlmixed.js @@ -0,0 +1,116 @@ +/* +Copyright (c) 2008-2009 Yahoo! Inc. All rights reserved. +The copyrights embodied in the content of this file are licensed by +Yahoo! Inc. under the BSD (revised) open source license + +@author Dan Vlad Dascalescu + +Based on parsehtmlmixed.js by Marijn Haverbeke. +*/ + +var PHPHTMLMixedParser = Editor.Parser = (function() { + var processingInstructions = [""); + break; + } + } + else if (token.style == "xml-attribute" && token.content == "\"php\"" && inTag == "script" && lastAtt == "language") + inTag = "script/php"; + // "xml-processing" tokens are ignored, because they should be handled by a specific local parser + else if (token.content == ">") { + if (inTag == "script/php") + iter.next = local(PHPParser, ""); + else if (inTag == "script") + iter.next = local(JSParser, " + + +Tokenizer for PHP code + +References: + + http://php.net/manual/en/reserved.php + + http://php.net/tokens + + get_defined_constants(), get_defined_functions(), get_declared_classes() + executed on a realistic (not vanilla) PHP installation with typical LAMP modules. + Specifically, the PHP bundled with the Uniform Web Server (www.uniformserver.com). + +*/ + + +// add the forEach method for JS engines that don't support it (e.g. IE) +// code from https://developer.mozilla.org/En/Core_JavaScript_1.5_Reference:Objects:Array:forEach +if (!Array.prototype.forEach) +{ + Array.prototype.forEach = function(fun /*, thisp*/) + { + var len = this.length; + if (typeof fun != "function") + throw new TypeError(); + + var thisp = arguments[1]; + for (var i = 0; i < len; i++) + { + if (i in this) + fun.call(thisp, this[i], i, this); + } + }; +} + + +var tokenizePHP = (function() { + /* A map of PHP's reserved words (keywords, predefined classes, functions and + constants. Each token has a type ('keyword', 'operator' etc.) and a style. + The style corresponds to the CSS span class in phpcolors.css. + + Keywords can be of three types: + a - takes an expression and forms a statement - e.g. if + b - takes just a statement - e.g. else + c - takes an optinoal expression, but no statement - e.g. return + This distinction gives the parser enough information to parse + correct code correctly (we don't care that much how we parse + incorrect code). + + Reference: http://us.php.net/manual/en/reserved.php + */ + var keywords = function(){ + function token(type, style){ + return {type: type, style: style}; + } + var result = {}; + + // for each(var element in ["...", "..."]) can pick up elements added to + // Array.prototype, so we'll use the loop structure below. See also + // http://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Statements/for_each...in + + // keywords that take an expression and form a statement + ["if", "elseif", "while", "declare"].forEach(function(element, index, array) { + result[element] = token("keyword a", "php-keyword"); + }); + + // keywords that take just a statement + ["do", "else", "try" ].forEach(function(element, index, array) { + result[element] = token("keyword b", "php-keyword"); + }); + + // keywords that take an optional expression, but no statement + ["return", "break", "continue", // the expression is optional + "new", "clone", "throw" // the expression is mandatory + ].forEach(function(element, index, array) { + result[element] = token("keyword c", "php-keyword"); + }); + + ["__CLASS__", "__DIR__", "__FILE__", "__FUNCTION__", "__METHOD__", "__NAMESPACE__"].forEach(function(element, index, array) { + result[element] = token("atom", "php-compile-time-constant"); + }); + + ["true", "false", "null"].forEach(function(element, index, array) { + result[element] = token("atom", "php-atom"); + }); + + ["and", "or", "xor", "instanceof"].forEach(function(element, index, array) { + result[element] = token("operator", "php-keyword php-operator"); + }); + + ["class", "interface"].forEach(function(element, index, array) { + result[element] = token("class", "php-keyword"); + }); + ["namespace", "use", "extends", "implements"].forEach(function(element, index, array) { + result[element] = token("namespace", "php-keyword"); + }); + + // reserved "language constructs"... http://php.net/manual/en/reserved.php + [ "die", "echo", "empty", "exit", "eval", "include", "include_once", "isset", + "list", "require", "require_once", "return", "print", "unset", + "array" // a keyword rather, but mandates a parenthesized parameter list + ].forEach(function(element, index, array) { + result[element] = token("t_string", "php-reserved-language-construct"); + }); + + result["switch"] = token("switch", "php-keyword"); + result["case"] = token("case", "php-keyword"); + result["default"] = token("default", "php-keyword"); + result["catch"] = token("catch", "php-keyword"); + result["function"] = token("function", "php-keyword"); + + // http://php.net/manual/en/control-structures.alternative-syntax.php must be followed by a ':' + ["endif", "endwhile", "endfor", "endforeach", "endswitch", "enddeclare"].forEach(function(element, index, array) { + result[element] = token("altsyntaxend", "php-keyword"); + }); + + result["const"] = token("const", "php-keyword"); + + ["final", "private", "protected", "public", "global", "static"].forEach(function(element, index, array) { + result[element] = token("modifier", "php-keyword"); + }); + result["var"] = token("modifier", "php-keyword deprecated"); + result["abstract"] = token("abstract", "php-keyword"); + + result["foreach"] = token("foreach", "php-keyword"); + result["as"] = token("as", "php-keyword"); + result["for"] = token("for", "php-keyword"); + + // PHP built-in functions - output of get_defined_functions()["internal"] + [ "zend_version", "func_num_args", "func_get_arg", "func_get_args", "strlen", + "strcmp", "strncmp", "strcasecmp", "strncasecmp", "each", "error_reporting", + "define", "defined", "get_class", "get_parent_class", "method_exists", + "property_exists", "class_exists", "interface_exists", "function_exists", + "get_included_files", "get_required_files", "is_subclass_of", "is_a", + "get_class_vars", "get_object_vars", "get_class_methods", "trigger_error", + "user_error", "set_error_handler", "restore_error_handler", + "set_exception_handler", "restore_exception_handler", "get_declared_classes", + "get_declared_interfaces", "get_defined_functions", "get_defined_vars", + "create_function", "get_resource_type", "get_loaded_extensions", + "extension_loaded", "get_extension_funcs", "get_defined_constants", + "debug_backtrace", "debug_print_backtrace", "bcadd", "bcsub", "bcmul", "bcdiv", + "bcmod", "bcpow", "bcsqrt", "bcscale", "bccomp", "bcpowmod", "jdtogregorian", + "gregoriantojd", "jdtojulian", "juliantojd", "jdtojewish", "jewishtojd", + "jdtofrench", "frenchtojd", "jddayofweek", "jdmonthname", "easter_date", + "easter_days", "unixtojd", "jdtounix", "cal_to_jd", "cal_from_jd", + "cal_days_in_month", "cal_info", "variant_set", "variant_add", "variant_cat", + "variant_sub", "variant_mul", "variant_and", "variant_div", "variant_eqv", + "variant_idiv", "variant_imp", "variant_mod", "variant_or", "variant_pow", + "variant_xor", "variant_abs", "variant_fix", "variant_int", "variant_neg", + "variant_not", "variant_round", "variant_cmp", "variant_date_to_timestamp", + "variant_date_from_timestamp", "variant_get_type", "variant_set_type", + "variant_cast", "com_create_guid", "com_event_sink", "com_print_typeinfo", + "com_message_pump", "com_load_typelib", "com_get_active_object", "ctype_alnum", + "ctype_alpha", "ctype_cntrl", "ctype_digit", "ctype_lower", "ctype_graph", + "ctype_print", "ctype_punct", "ctype_space", "ctype_upper", "ctype_xdigit", + "strtotime", "date", "idate", "gmdate", "mktime", "gmmktime", "checkdate", + "strftime", "gmstrftime", "time", "localtime", "getdate", "date_create", + "date_parse", "date_format", "date_modify", "date_timezone_get", + "date_timezone_set", "date_offset_get", "date_time_set", "date_date_set", + "date_isodate_set", "timezone_open", "timezone_name_get", + "timezone_name_from_abbr", "timezone_offset_get", "timezone_transitions_get", + "timezone_identifiers_list", "timezone_abbreviations_list", + "date_default_timezone_set", "date_default_timezone_get", "date_sunrise", + "date_sunset", "date_sun_info", "filter_input", "filter_var", + "filter_input_array", "filter_var_array", "filter_list", "filter_has_var", + "filter_id", "ftp_connect", "ftp_login", "ftp_pwd", "ftp_cdup", "ftp_chdir", + "ftp_exec", "ftp_raw", "ftp_mkdir", "ftp_rmdir", "ftp_chmod", "ftp_alloc", + "ftp_nlist", "ftp_rawlist", "ftp_systype", "ftp_pasv", "ftp_get", "ftp_fget", + "ftp_put", "ftp_fput", "ftp_size", "ftp_mdtm", "ftp_rename", "ftp_delete", + "ftp_site", "ftp_close", "ftp_set_option", "ftp_get_option", "ftp_nb_fget", + "ftp_nb_get", "ftp_nb_continue", "ftp_nb_put", "ftp_nb_fput", "ftp_quit", + "hash", "hash_file", "hash_hmac", "hash_hmac_file", "hash_init", "hash_update", + "hash_update_stream", "hash_update_file", "hash_final", "hash_algos", "iconv", + "ob_iconv_handler", "iconv_get_encoding", "iconv_set_encoding", "iconv_strlen", + "iconv_substr", "iconv_strpos", "iconv_strrpos", "iconv_mime_encode", + "iconv_mime_decode", "iconv_mime_decode_headers", "json_encode", "json_decode", + "odbc_autocommit", "odbc_binmode", "odbc_close", "odbc_close_all", + "odbc_columns", "odbc_commit", "odbc_connect", "odbc_cursor", + "odbc_data_source", "odbc_execute", "odbc_error", "odbc_errormsg", "odbc_exec", + "odbc_fetch_array", "odbc_fetch_object", "odbc_fetch_row", "odbc_fetch_into", + "odbc_field_len", "odbc_field_scale", "odbc_field_name", "odbc_field_type", + "odbc_field_num", "odbc_free_result", "odbc_gettypeinfo", "odbc_longreadlen", + "odbc_next_result", "odbc_num_fields", "odbc_num_rows", "odbc_pconnect", + "odbc_prepare", "odbc_result", "odbc_result_all", "odbc_rollback", + "odbc_setoption", "odbc_specialcolumns", "odbc_statistics", "odbc_tables", + "odbc_primarykeys", "odbc_columnprivileges", "odbc_tableprivileges", + "odbc_foreignkeys", "odbc_procedures", "odbc_procedurecolumns", "odbc_do", + "odbc_field_precision", "preg_match", "preg_match_all", "preg_replace", + "preg_replace_callback", "preg_split", "preg_quote", "preg_grep", + "preg_last_error", "session_name", "session_module_name", "session_save_path", + "session_id", "session_regenerate_id", "session_decode", "session_register", + "session_unregister", "session_is_registered", "session_encode", + "session_start", "session_destroy", "session_unset", + "session_set_save_handler", "session_cache_limiter", "session_cache_expire", + "session_set_cookie_params", "session_get_cookie_params", + "session_write_close", "session_commit", "spl_classes", "spl_autoload", + "spl_autoload_extensions", "spl_autoload_register", "spl_autoload_unregister", + "spl_autoload_functions", "spl_autoload_call", "class_parents", + "class_implements", "spl_object_hash", "iterator_to_array", "iterator_count", + "iterator_apply", "constant", "bin2hex", "sleep", "usleep", "flush", + "wordwrap", "htmlspecialchars", "htmlentities", "html_entity_decode", + "htmlspecialchars_decode", "get_html_translation_table", "sha1", "sha1_file", + "md5", "md5_file", "crc32", "iptcparse", "iptcembed", "getimagesize", + "image_type_to_mime_type", "image_type_to_extension", "phpinfo", "phpversion", + "phpcredits", "php_logo_guid", "php_real_logo_guid", "php_egg_logo_guid", + "zend_logo_guid", "php_sapi_name", "php_uname", "php_ini_scanned_files", + "strnatcmp", "strnatcasecmp", "substr_count", "strspn", "strcspn", "strtok", + "strtoupper", "strtolower", "strpos", "stripos", "strrpos", "strripos", + "strrev", "hebrev", "hebrevc", "nl2br", "basename", "dirname", "pathinfo", + "stripslashes", "stripcslashes", "strstr", "stristr", "strrchr", "str_shuffle", + "str_word_count", "str_split", "strpbrk", "substr_compare", "strcoll", + "substr", "substr_replace", "quotemeta", "ucfirst", "ucwords", "strtr", + "addslashes", "addcslashes", "rtrim", "str_replace", "str_ireplace", + "str_repeat", "count_chars", "chunk_split", "trim", "ltrim", "strip_tags", + "similar_text", "explode", "implode", "setlocale", "localeconv", "soundex", + "levenshtein", "chr", "ord", "parse_str", "str_pad", "chop", "strchr", + "sprintf", "printf", "vprintf", "vsprintf", "fprintf", "vfprintf", "sscanf", + "fscanf", "parse_url", "urlencode", "urldecode", "rawurlencode", + "rawurldecode", "http_build_query", "unlink", "exec", "system", + "escapeshellcmd", "escapeshellarg", "passthru", "shell_exec", "proc_open", + "proc_close", "proc_terminate", "proc_get_status", "rand", "srand", + "getrandmax", "mt_rand", "mt_srand", "mt_getrandmax", "getservbyname", + "getservbyport", "getprotobyname", "getprotobynumber", "getmyuid", "getmygid", + "getmypid", "getmyinode", "getlastmod", "base64_decode", "base64_encode", + "convert_uuencode", "convert_uudecode", "abs", "ceil", "floor", "round", "sin", + "cos", "tan", "asin", "acos", "atan", "atan2", "sinh", "cosh", "tanh", "pi", + "is_finite", "is_nan", "is_infinite", "pow", "exp", "log", "log10", "sqrt", + "hypot", "deg2rad", "rad2deg", "bindec", "hexdec", "octdec", "decbin", + "decoct", "dechex", "base_convert", "number_format", "fmod", "ip2long", + "long2ip", "getenv", "putenv", "microtime", "gettimeofday", "uniqid", + "quoted_printable_decode", "convert_cyr_string", "get_current_user", + "set_time_limit", "get_cfg_var", "magic_quotes_runtime", + "set_magic_quotes_runtime", "get_magic_quotes_gpc", "get_magic_quotes_runtime", + "import_request_variables", "error_log", "error_get_last", "call_user_func", + "call_user_func_array", "call_user_method", "call_user_method_array", + "serialize", "unserialize", "var_dump", "var_export", "debug_zval_dump", + "print_r", "memory_get_usage", "memory_get_peak_usage", + "register_shutdown_function", "register_tick_function", + "unregister_tick_function", "highlight_file", "show_source", + "highlight_string", "php_strip_whitespace", "ini_get", "ini_get_all", + "ini_set", "ini_alter", "ini_restore", "get_include_path", "set_include_path", + "restore_include_path", "setcookie", "setrawcookie", "header", "headers_sent", + "headers_list", "connection_aborted", "connection_status", "ignore_user_abort", + "parse_ini_file", "is_uploaded_file", "move_uploaded_file", "gethostbyaddr", + "gethostbyname", "gethostbynamel", "intval", "floatval", "doubleval", "strval", + "gettype", "settype", "is_null", "is_resource", "is_bool", "is_long", + "is_float", "is_int", "is_integer", "is_double", "is_real", "is_numeric", + "is_string", "is_array", "is_object", "is_scalar", "is_callable", "ereg", + "ereg_replace", "eregi", "eregi_replace", "split", "spliti", "join", + "sql_regcase", "dl", "pclose", "popen", "readfile", "rewind", "rmdir", "umask", + "fclose", "feof", "fgetc", "fgets", "fgetss", "fread", "fopen", "fpassthru", + "ftruncate", "fstat", "fseek", "ftell", "fflush", "fwrite", "fputs", "mkdir", + "rename", "copy", "tempnam", "tmpfile", "file", "file_get_contents", + "file_put_contents", "stream_select", "stream_context_create", + "stream_context_set_params", "stream_context_set_option", + "stream_context_get_options", "stream_context_get_default", + "stream_filter_prepend", "stream_filter_append", "stream_filter_remove", + "stream_socket_client", "stream_socket_server", "stream_socket_accept", + "stream_socket_get_name", "stream_socket_recvfrom", "stream_socket_sendto", + "stream_socket_enable_crypto", "stream_socket_shutdown", + "stream_copy_to_stream", "stream_get_contents", "fgetcsv", "fputcsv", "flock", + "get_meta_tags", "stream_set_write_buffer", "set_file_buffer", + "set_socket_blocking", "stream_set_blocking", "socket_set_blocking", + "stream_get_meta_data", "stream_get_line", "stream_wrapper_register", + "stream_register_wrapper", "stream_wrapper_unregister", + "stream_wrapper_restore", "stream_get_wrappers", "stream_get_transports", + "get_headers", "stream_set_timeout", "socket_set_timeout", "socket_get_status", + "realpath", "fsockopen", "pfsockopen", "pack", "unpack", "get_browser", + "crypt", "opendir", "closedir", "chdir", "getcwd", "rewinddir", "readdir", + "dir", "scandir", "glob", "fileatime", "filectime", "filegroup", "fileinode", + "filemtime", "fileowner", "fileperms", "filesize", "filetype", "file_exists", + "is_writable", "is_writeable", "is_readable", "is_executable", "is_file", + "is_dir", "is_link", "stat", "lstat", "chown", "chgrp", "chmod", "touch", + "clearstatcache", "disk_total_space", "disk_free_space", "diskfreespace", + "mail", "ezmlm_hash", "openlog", "syslog", "closelog", + "define_syslog_variables", "lcg_value", "metaphone", "ob_start", "ob_flush", + "ob_clean", "ob_end_flush", "ob_end_clean", "ob_get_flush", "ob_get_clean", + "ob_get_length", "ob_get_level", "ob_get_status", "ob_get_contents", + "ob_implicit_flush", "ob_list_handlers", "ksort", "krsort", "natsort", + "natcasesort", "asort", "arsort", "sort", "rsort", "usort", "uasort", "uksort", + "shuffle", "array_walk", "array_walk_recursive", "count", "end", "prev", + "next", "reset", "current", "key", "min", "max", "in_array", "array_search", + "extract", "compact", "array_fill", "array_fill_keys", "range", + "array_multisort", "array_push", "array_pop", "array_shift", "array_unshift", + "array_splice", "array_slice", "array_merge", "array_merge_recursive", + "array_keys", "array_values", "array_count_values", "array_reverse", + "array_reduce", "array_pad", "array_flip", "array_change_key_case", + "array_rand", "array_unique", "array_intersect", "array_intersect_key", + "array_intersect_ukey", "array_uintersect", "array_intersect_assoc", + "array_uintersect_assoc", "array_intersect_uassoc", "array_uintersect_uassoc", + "array_diff", "array_diff_key", "array_diff_ukey", "array_udiff", + "array_diff_assoc", "array_udiff_assoc", "array_diff_uassoc", + "array_udiff_uassoc", "array_sum", "array_product", "array_filter", + "array_map", "array_chunk", "array_combine", "array_key_exists", "pos", + "sizeof", "key_exists", "assert", "assert_options", "version_compare", + "str_rot13", "stream_get_filters", "stream_filter_register", + "stream_bucket_make_writeable", "stream_bucket_prepend", + "stream_bucket_append", "stream_bucket_new", "output_add_rewrite_var", + "output_reset_rewrite_vars", "sys_get_temp_dir", "token_get_all", "token_name", + "readgzfile", "gzrewind", "gzclose", "gzeof", "gzgetc", "gzgets", "gzgetss", + "gzread", "gzopen", "gzpassthru", "gzseek", "gztell", "gzwrite", "gzputs", + "gzfile", "gzcompress", "gzuncompress", "gzdeflate", "gzinflate", "gzencode", + "ob_gzhandler", "zlib_get_coding_type", "libxml_set_streams_context", + "libxml_use_internal_errors", "libxml_get_last_error", "libxml_clear_errors", + "libxml_get_errors", "dom_import_simplexml", "simplexml_load_file", + "simplexml_load_string", "simplexml_import_dom", "wddx_serialize_value", + "wddx_serialize_vars", "wddx_packet_start", "wddx_packet_end", "wddx_add_vars", + "wddx_deserialize", "xml_parser_create", "xml_parser_create_ns", + "xml_set_object", "xml_set_element_handler", "xml_set_character_data_handler", + "xml_set_processing_instruction_handler", "xml_set_default_handler", + "xml_set_unparsed_entity_decl_handler", "xml_set_notation_decl_handler", + "xml_set_external_entity_ref_handler", "xml_set_start_namespace_decl_handler", + "xml_set_end_namespace_decl_handler", "xml_parse", "xml_parse_into_struct", + "xml_get_error_code", "xml_error_string", "xml_get_current_line_number", + "xml_get_current_column_number", "xml_get_current_byte_index", + "xml_parser_free", "xml_parser_set_option", "xml_parser_get_option", + "utf8_encode", "utf8_decode", "xmlwriter_open_uri", "xmlwriter_open_memory", + "xmlwriter_set_indent", "xmlwriter_set_indent_string", + "xmlwriter_start_comment", "xmlwriter_end_comment", + "xmlwriter_start_attribute", "xmlwriter_end_attribute", + "xmlwriter_write_attribute", "xmlwriter_start_attribute_ns", + "xmlwriter_write_attribute_ns", "xmlwriter_start_element", + "xmlwriter_end_element", "xmlwriter_full_end_element", + "xmlwriter_start_element_ns", "xmlwriter_write_element", + "xmlwriter_write_element_ns", "xmlwriter_start_pi", "xmlwriter_end_pi", + "xmlwriter_write_pi", "xmlwriter_start_cdata", "xmlwriter_end_cdata", + "xmlwriter_write_cdata", "xmlwriter_text", "xmlwriter_write_raw", + "xmlwriter_start_document", "xmlwriter_end_document", + "xmlwriter_write_comment", "xmlwriter_start_dtd", "xmlwriter_end_dtd", + "xmlwriter_write_dtd", "xmlwriter_start_dtd_element", + "xmlwriter_end_dtd_element", "xmlwriter_write_dtd_element", + "xmlwriter_start_dtd_attlist", "xmlwriter_end_dtd_attlist", + "xmlwriter_write_dtd_attlist", "xmlwriter_start_dtd_entity", + "xmlwriter_end_dtd_entity", "xmlwriter_write_dtd_entity", + "xmlwriter_output_memory", "xmlwriter_flush", "gd_info", "imagearc", + "imageellipse", "imagechar", "imagecharup", "imagecolorat", + "imagecolorallocate", "imagepalettecopy", "imagecreatefromstring", + "imagecolorclosest", "imagecolordeallocate", "imagecolorresolve", + "imagecolorexact", "imagecolorset", "imagecolortransparent", + "imagecolorstotal", "imagecolorsforindex", "imagecopy", "imagecopymerge", + "imagecopymergegray", "imagecopyresized", "imagecreate", + "imagecreatetruecolor", "imageistruecolor", "imagetruecolortopalette", + "imagesetthickness", "imagefilledarc", "imagefilledellipse", + "imagealphablending", "imagesavealpha", "imagecolorallocatealpha", + "imagecolorresolvealpha", "imagecolorclosestalpha", "imagecolorexactalpha", + "imagecopyresampled", "imagegrabwindow", "imagegrabscreen", "imagerotate", + "imageantialias", "imagesettile", "imagesetbrush", "imagesetstyle", + "imagecreatefrompng", "imagecreatefromgif", "imagecreatefromjpeg", + "imagecreatefromwbmp", "imagecreatefromxbm", "imagecreatefromgd", + "imagecreatefromgd2", "imagecreatefromgd2part", "imagepng", "imagegif", + "imagejpeg", "imagewbmp", "imagegd", "imagegd2", "imagedestroy", + "imagegammacorrect", "imagefill", "imagefilledpolygon", "imagefilledrectangle", + "imagefilltoborder", "imagefontwidth", "imagefontheight", "imageinterlace", + "imageline", "imageloadfont", "imagepolygon", "imagerectangle", + "imagesetpixel", "imagestring", "imagestringup", "imagesx", "imagesy", + "imagedashedline", "imagettfbbox", "imagettftext", "imageftbbox", + "imagefttext", "imagepsloadfont", "imagepsfreefont", "imagepsencodefont", + "imagepsextendfont", "imagepsslantfont", "imagepstext", "imagepsbbox", + "imagetypes", "jpeg2wbmp", "png2wbmp", "image2wbmp", "imagelayereffect", + "imagecolormatch", "imagexbm", "imagefilter", "imageconvolution", + "mb_convert_case", "mb_strtoupper", "mb_strtolower", "mb_language", + "mb_internal_encoding", "mb_http_input", "mb_http_output", "mb_detect_order", + "mb_substitute_character", "mb_parse_str", "mb_output_handler", + "mb_preferred_mime_name", "mb_strlen", "mb_strpos", "mb_strrpos", "mb_stripos", + "mb_strripos", "mb_strstr", "mb_strrchr", "mb_stristr", "mb_strrichr", + "mb_substr_count", "mb_substr", "mb_strcut", "mb_strwidth", "mb_strimwidth", + "mb_convert_encoding", "mb_detect_encoding", "mb_list_encodings", + "mb_convert_kana", "mb_encode_mimeheader", "mb_decode_mimeheader", + "mb_convert_variables", "mb_encode_numericentity", "mb_decode_numericentity", + "mb_send_mail", "mb_get_info", "mb_check_encoding", "mb_regex_encoding", + "mb_regex_set_options", "mb_ereg", "mb_eregi", "mb_ereg_replace", + "mb_eregi_replace", "mb_split", "mb_ereg_match", "mb_ereg_search", + "mb_ereg_search_pos", "mb_ereg_search_regs", "mb_ereg_search_init", + "mb_ereg_search_getregs", "mb_ereg_search_getpos", "mb_ereg_search_setpos", + "mbregex_encoding", "mbereg", "mberegi", "mbereg_replace", "mberegi_replace", + "mbsplit", "mbereg_match", "mbereg_search", "mbereg_search_pos", + "mbereg_search_regs", "mbereg_search_init", "mbereg_search_getregs", + "mbereg_search_getpos", "mbereg_search_setpos", "mysql_connect", + "mysql_pconnect", "mysql_close", "mysql_select_db", "mysql_query", + "mysql_unbuffered_query", "mysql_db_query", "mysql_list_dbs", + "mysql_list_tables", "mysql_list_fields", "mysql_list_processes", + "mysql_error", "mysql_errno", "mysql_affected_rows", "mysql_insert_id", + "mysql_result", "mysql_num_rows", "mysql_num_fields", "mysql_fetch_row", + "mysql_fetch_array", "mysql_fetch_assoc", "mysql_fetch_object", + "mysql_data_seek", "mysql_fetch_lengths", "mysql_fetch_field", + "mysql_field_seek", "mysql_free_result", "mysql_field_name", + "mysql_field_table", "mysql_field_len", "mysql_field_type", + "mysql_field_flags", "mysql_escape_string", "mysql_real_escape_string", + "mysql_stat", "mysql_thread_id", "mysql_client_encoding", "mysql_ping", + "mysql_get_client_info", "mysql_get_host_info", "mysql_get_proto_info", + "mysql_get_server_info", "mysql_info", "mysql_set_charset", "mysql", + "mysql_fieldname", "mysql_fieldtable", "mysql_fieldlen", "mysql_fieldtype", + "mysql_fieldflags", "mysql_selectdb", "mysql_freeresult", "mysql_numfields", + "mysql_numrows", "mysql_listdbs", "mysql_listtables", "mysql_listfields", + "mysql_db_name", "mysql_dbname", "mysql_tablename", "mysql_table_name", + "mysqli_affected_rows", "mysqli_autocommit", "mysqli_change_user", + "mysqli_character_set_name", "mysqli_close", "mysqli_commit", "mysqli_connect", + "mysqli_connect_errno", "mysqli_connect_error", "mysqli_data_seek", + "mysqli_debug", "mysqli_disable_reads_from_master", "mysqli_disable_rpl_parse", + "mysqli_dump_debug_info", "mysqli_enable_reads_from_master", + "mysqli_enable_rpl_parse", "mysqli_embedded_server_end", + "mysqli_embedded_server_start", "mysqli_errno", "mysqli_error", + "mysqli_stmt_execute", "mysqli_execute", "mysqli_fetch_field", + "mysqli_fetch_fields", "mysqli_fetch_field_direct", "mysqli_fetch_lengths", + "mysqli_fetch_array", "mysqli_fetch_assoc", "mysqli_fetch_object", + "mysqli_fetch_row", "mysqli_field_count", "mysqli_field_seek", + "mysqli_field_tell", "mysqli_free_result", "mysqli_get_charset", + "mysqli_get_client_info", "mysqli_get_client_version", "mysqli_get_host_info", + "mysqli_get_proto_info", "mysqli_get_server_info", "mysqli_get_server_version", + "mysqli_get_warnings", "mysqli_init", "mysqli_info", "mysqli_insert_id", + "mysqli_kill", "mysqli_set_local_infile_default", + "mysqli_set_local_infile_handler", "mysqli_master_query", + "mysqli_more_results", "mysqli_multi_query", "mysqli_next_result", + "mysqli_num_fields", "mysqli_num_rows", "mysqli_options", "mysqli_ping", + "mysqli_prepare", "mysqli_report", "mysqli_query", "mysqli_real_connect", + "mysqli_real_escape_string", "mysqli_real_query", "mysqli_rollback", + "mysqli_rpl_parse_enabled", "mysqli_rpl_probe", "mysqli_rpl_query_type", + "mysqli_select_db", "mysqli_set_charset", "mysqli_stmt_attr_get", + "mysqli_stmt_attr_set", "mysqli_stmt_field_count", "mysqli_stmt_init", + "mysqli_stmt_prepare", "mysqli_stmt_result_metadata", + "mysqli_stmt_send_long_data", "mysqli_stmt_bind_param", + "mysqli_stmt_bind_result", "mysqli_stmt_fetch", "mysqli_stmt_free_result", + "mysqli_stmt_get_warnings", "mysqli_stmt_insert_id", "mysqli_stmt_reset", + "mysqli_stmt_param_count", "mysqli_send_query", "mysqli_slave_query", + "mysqli_sqlstate", "mysqli_ssl_set", "mysqli_stat", + "mysqli_stmt_affected_rows", "mysqli_stmt_close", "mysqli_stmt_data_seek", + "mysqli_stmt_errno", "mysqli_stmt_error", "mysqli_stmt_num_rows", + "mysqli_stmt_sqlstate", "mysqli_store_result", "mysqli_stmt_store_result", + "mysqli_thread_id", "mysqli_thread_safe", "mysqli_use_result", + "mysqli_warning_count", "mysqli_bind_param", "mysqli_bind_result", + "mysqli_client_encoding", "mysqli_escape_string", "mysqli_fetch", + "mysqli_param_count", "mysqli_get_metadata", "mysqli_send_long_data", + "mysqli_set_opt", "pdo_drivers", "socket_select", "socket_create", + "socket_create_listen", "socket_accept", "socket_set_nonblock", + "socket_set_block", "socket_listen", "socket_close", "socket_write", + "socket_read", "socket_getsockname", "socket_getpeername", "socket_connect", + "socket_strerror", "socket_bind", "socket_recv", "socket_send", + "socket_recvfrom", "socket_sendto", "socket_get_option", "socket_set_option", + "socket_shutdown", "socket_last_error", "socket_clear_error", "socket_getopt", + "socket_setopt", "eaccelerator_put", "eaccelerator_get", "eaccelerator_rm", + "eaccelerator_gc", "eaccelerator_lock", "eaccelerator_unlock", + "eaccelerator_caching", "eaccelerator_optimizer", "eaccelerator_clear", + "eaccelerator_clean", "eaccelerator_info", "eaccelerator_purge", + "eaccelerator_cached_scripts", "eaccelerator_removed_scripts", + "eaccelerator_list_keys", "eaccelerator_encode", "eaccelerator_load", + "_eaccelerator_loader_file", "_eaccelerator_loader_line", + "eaccelerator_set_session_handlers", "_eaccelerator_output_handler", + "eaccelerator_cache_page", "eaccelerator_rm_page", "eaccelerator_cache_output", + "eaccelerator_cache_result", "xdebug_get_stack_depth", + "xdebug_get_function_stack", "xdebug_print_function_stack", + "xdebug_get_declared_vars", "xdebug_call_class", "xdebug_call_function", + "xdebug_call_file", "xdebug_call_line", "xdebug_var_dump", "xdebug_debug_zval", + "xdebug_debug_zval_stdout", "xdebug_enable", "xdebug_disable", + "xdebug_is_enabled", "xdebug_break", "xdebug_start_trace", "xdebug_stop_trace", + "xdebug_get_tracefile_name", "xdebug_get_profiler_filename", + "xdebug_dump_aggr_profiling_data", "xdebug_clear_aggr_profiling_data", + "xdebug_memory_usage", "xdebug_peak_memory_usage", "xdebug_time_index", + "xdebug_start_error_collection", "xdebug_stop_error_collection", + "xdebug_get_collected_errors", "xdebug_start_code_coverage", + "xdebug_stop_code_coverage", "xdebug_get_code_coverage", + "xdebug_get_function_count", "xdebug_dump_superglobals", + "_", /* alias for gettext()*/ + "get_called_class","class_alias","gc_collect_cycles","gc_enabled","gc_enable", + "gc_disable","date_create_from_format","date_parse_from_format", + "date_get_last_errors","date_add","date_sub","date_diff","date_timestamp_set", + "date_timestamp_get","timezone_location_get","timezone_version_get", + "date_interval_create_from_date_string","date_interval_format", + "libxml_disable_entity_loader","openssl_pkey_free","openssl_pkey_new", + "openssl_pkey_export","openssl_pkey_export_to_file","openssl_pkey_get_private", + "openssl_pkey_get_public","openssl_pkey_get_details","openssl_free_key", + "openssl_get_privatekey","openssl_get_publickey","openssl_x509_read", + "openssl_x509_free","openssl_x509_parse","openssl_x509_checkpurpose", + "openssl_x509_check_private_key","openssl_x509_export","openssl_x509_export_to_file", + "openssl_pkcs12_export","openssl_pkcs12_export_to_file","openssl_pkcs12_read", + "openssl_csr_new","openssl_csr_export","openssl_csr_export_to_file", + "openssl_csr_sign","openssl_csr_get_subject","openssl_csr_get_public_key", + "openssl_digest","openssl_encrypt","openssl_decrypt","openssl_cipher_iv_length", + "openssl_sign","openssl_verify","openssl_seal","openssl_open","openssl_pkcs7_verify", + "openssl_pkcs7_decrypt","openssl_pkcs7_sign","openssl_pkcs7_encrypt", + "openssl_private_encrypt","openssl_private_decrypt","openssl_public_encrypt", + "openssl_public_decrypt","openssl_get_md_methods","openssl_get_cipher_methods", + "openssl_dh_compute_key","openssl_random_pseudo_bytes","openssl_error_string", + "preg_filter","bzopen","bzread","bzwrite","bzflush","bzclose","bzerrno", + "bzerrstr","bzerror","bzcompress","bzdecompress","curl_init","curl_copy_handle", + "curl_version","curl_setopt","curl_setopt_array","curl_exec","curl_getinfo", + "curl_error","curl_errno","curl_close","curl_multi_init","curl_multi_add_handle", + "curl_multi_remove_handle","curl_multi_select","curl_multi_exec","curl_multi_getcontent", + "curl_multi_info_read","curl_multi_close","exif_read_data","read_exif_data", + "exif_tagname","exif_thumbnail","exif_imagetype","ftp_ssl_connect", + "imagecolorclosesthwb","imagecreatefromxpm","textdomain","gettext","dgettext", + "dcgettext","bindtextdomain","ngettext","dngettext","dcngettext", + "bind_textdomain_codeset","hash_copy","imap_open","imap_reopen","imap_close", + "imap_num_msg","imap_num_recent","imap_headers","imap_headerinfo", + "imap_rfc822_parse_headers","imap_rfc822_write_address","imap_rfc822_parse_adrlist", + "imap_body","imap_bodystruct","imap_fetchbody","imap_savebody","imap_fetchheader", + "imap_fetchstructure","imap_gc","imap_expunge","imap_delete","imap_undelete", + "imap_check","imap_listscan","imap_mail_copy","imap_mail_move","imap_mail_compose", + "imap_createmailbox","imap_renamemailbox","imap_deletemailbox","imap_subscribe", + "imap_unsubscribe","imap_append","imap_ping","imap_base64","imap_qprint","imap_8bit", + "imap_binary","imap_utf8","imap_status","imap_mailboxmsginfo","imap_setflag_full", + "imap_clearflag_full","imap_sort","imap_uid","imap_msgno","imap_list","imap_lsub", + "imap_fetch_overview","imap_alerts","imap_errors","imap_last_error","imap_search", + "imap_utf7_decode","imap_utf7_encode","imap_mime_header_decode","imap_thread", + "imap_timeout","imap_get_quota","imap_get_quotaroot","imap_set_quota","imap_setacl", + "imap_getacl","imap_mail","imap_header","imap_listmailbox","imap_getmailboxes", + "imap_scanmailbox","imap_listsubscribed","imap_getsubscribed","imap_fetchtext", + "imap_scan","imap_create","imap_rename","json_last_error","mb_encoding_aliases", + "mcrypt_ecb","mcrypt_cbc","mcrypt_cfb","mcrypt_ofb","mcrypt_get_key_size", + "mcrypt_get_block_size","mcrypt_get_cipher_name","mcrypt_create_iv","mcrypt_list_algorithms", + "mcrypt_list_modes","mcrypt_get_iv_size","mcrypt_encrypt","mcrypt_decrypt", + "mcrypt_module_open","mcrypt_generic_init","mcrypt_generic","mdecrypt_generic", + "mcrypt_generic_end","mcrypt_generic_deinit","mcrypt_enc_self_test", + "mcrypt_enc_is_block_algorithm_mode","mcrypt_enc_is_block_algorithm", + "mcrypt_enc_is_block_mode","mcrypt_enc_get_block_size","mcrypt_enc_get_key_size", + "mcrypt_enc_get_supported_key_sizes","mcrypt_enc_get_iv_size", + "mcrypt_enc_get_algorithms_name","mcrypt_enc_get_modes_name","mcrypt_module_self_test", + "mcrypt_module_is_block_algorithm_mode","mcrypt_module_is_block_algorithm", + "mcrypt_module_is_block_mode","mcrypt_module_get_algo_block_size", + "mcrypt_module_get_algo_key_size","mcrypt_module_get_supported_key_sizes", + "mcrypt_module_close","mysqli_refresh","posix_kill","posix_getpid","posix_getppid", + "posix_getuid","posix_setuid","posix_geteuid","posix_seteuid","posix_getgid", + "posix_setgid","posix_getegid","posix_setegid","posix_getgroups","posix_getlogin", + "posix_getpgrp","posix_setsid","posix_setpgid","posix_getpgid","posix_getsid", + "posix_uname","posix_times","posix_ctermid","posix_ttyname","posix_isatty", + "posix_getcwd","posix_mkfifo","posix_mknod","posix_access","posix_getgrnam", + "posix_getgrgid","posix_getpwnam","posix_getpwuid","posix_getrlimit", + "posix_get_last_error","posix_errno","posix_strerror","posix_initgroups", + "pspell_new","pspell_new_personal","pspell_new_config","pspell_check", + "pspell_suggest","pspell_store_replacement","pspell_add_to_personal", + "pspell_add_to_session","pspell_clear_session","pspell_save_wordlist", + "pspell_config_create","pspell_config_runtogether","pspell_config_mode", + "pspell_config_ignore","pspell_config_personal","pspell_config_dict_dir", + "pspell_config_data_dir","pspell_config_repl","pspell_config_save_repl", + "snmpget","snmpgetnext","snmpwalk","snmprealwalk","snmpwalkoid", + "snmp_get_quick_print","snmp_set_quick_print","snmp_set_enum_print", + "snmp_set_oid_output_format","snmp_set_oid_numeric_print","snmpset", + "snmp2_get","snmp2_getnext","snmp2_walk","snmp2_real_walk","snmp2_set", + "snmp3_get","snmp3_getnext","snmp3_walk","snmp3_real_walk","snmp3_set", + "snmp_set_valueretrieval","snmp_get_valueretrieval","snmp_read_mib", + "use_soap_error_handler","is_soap_fault","socket_create_pair","time_nanosleep", + "time_sleep_until","strptime","php_ini_loaded_file","money_format","lcfirst", + "nl_langinfo","str_getcsv","readlink","linkinfo","symlink","link","proc_nice", + "atanh","asinh","acosh","expm1","log1p","inet_ntop","inet_pton","getopt", + "sys_getloadavg","getrusage","quoted_printable_encode","forward_static_call", + "forward_static_call_array","header_remove","parse_ini_string","gethostname", + "dns_check_record","checkdnsrr","dns_get_mx","getmxrr","dns_get_record", + "stream_context_get_params","stream_context_set_default","stream_socket_pair", + "stream_supports_lock","stream_set_read_buffer","stream_resolve_include_path", + "stream_is_local","fnmatch","chroot","lchown","lchgrp","realpath_cache_size", + "realpath_cache_get","array_replace","array_replace_recursive","ftok","xmlrpc_encode", + "xmlrpc_decode","xmlrpc_decode_request","xmlrpc_encode_request","xmlrpc_get_type", + "xmlrpc_set_type","xmlrpc_is_fault","xmlrpc_server_create","xmlrpc_server_destroy", + "xmlrpc_server_register_method","xmlrpc_server_call_method", + "xmlrpc_parse_method_descriptions","xmlrpc_server_add_introspection_data", + "xmlrpc_server_register_introspection_callback","zip_open","zip_close", + "zip_read","zip_entry_open","zip_entry_close","zip_entry_read","zip_entry_filesize", + "zip_entry_name","zip_entry_compressedsize","zip_entry_compressionmethod", + "svn_checkout","svn_cat","svn_ls","svn_log","svn_auth_set_parameter", + "svn_auth_get_parameter","svn_client_version","svn_config_ensure","svn_diff", + "svn_cleanup","svn_revert","svn_resolved","svn_commit","svn_lock","svn_unlock", + "svn_add","svn_status","svn_update","svn_import","svn_info","svn_export", + "svn_copy","svn_switch","svn_blame","svn_delete","svn_mkdir","svn_move", + "svn_proplist","svn_propget","svn_repos_create","svn_repos_recover", + "svn_repos_hotcopy","svn_repos_open","svn_repos_fs", + "svn_repos_fs_begin_txn_for_commit","svn_repos_fs_commit_txn", + "svn_fs_revision_root","svn_fs_check_path","svn_fs_revision_prop", + "svn_fs_dir_entries","svn_fs_node_created_rev","svn_fs_youngest_rev", + "svn_fs_file_contents","svn_fs_file_length","svn_fs_txn_root","svn_fs_make_file", + "svn_fs_make_dir","svn_fs_apply_text","svn_fs_copy","svn_fs_delete", + "svn_fs_begin_txn2","svn_fs_is_dir","svn_fs_is_file","svn_fs_node_prop", + "svn_fs_change_node_prop","svn_fs_contents_changed","svn_fs_props_changed", + "svn_fs_abort_txn","sqlite_open","sqlite_popen","sqlite_close","sqlite_query", + "sqlite_exec","sqlite_array_query","sqlite_single_query","sqlite_fetch_array", + "sqlite_fetch_object","sqlite_fetch_single","sqlite_fetch_string", + "sqlite_fetch_all","sqlite_current","sqlite_column","sqlite_libversion", + "sqlite_libencoding","sqlite_changes","sqlite_last_insert_rowid", + "sqlite_num_rows","sqlite_num_fields","sqlite_field_name","sqlite_seek", + "sqlite_rewind","sqlite_next","sqlite_prev","sqlite_valid","sqlite_has_more", + "sqlite_has_prev","sqlite_escape_string","sqlite_busy_timeout","sqlite_last_error", + "sqlite_error_string","sqlite_unbuffered_query","sqlite_create_aggregate", + "sqlite_create_function","sqlite_factory","sqlite_udf_encode_binary", + "sqlite_udf_decode_binary","sqlite_fetch_column_types" + ].forEach(function(element, index, array) { + result[element] = token("t_string", "php-predefined-function"); + }); + + // output of get_defined_constants(). Differs significantly from http://php.net/manual/en/reserved.constants.php + [ "E_ERROR", "E_RECOVERABLE_ERROR", "E_WARNING", "E_PARSE", "E_NOTICE", + "E_STRICT", "E_CORE_ERROR", "E_CORE_WARNING", "E_COMPILE_ERROR", + "E_COMPILE_WARNING", "E_USER_ERROR", "E_USER_WARNING", "E_USER_NOTICE", + "E_ALL", "TRUE", "FALSE", "NULL", "ZEND_THREAD_SAFE", "PHP_VERSION", "PHP_OS", + "PHP_SAPI", "DEFAULT_INCLUDE_PATH", "PEAR_INSTALL_DIR", "PEAR_EXTENSION_DIR", + "PHP_EXTENSION_DIR", "PHP_PREFIX", "PHP_BINDIR", "PHP_LIBDIR", "PHP_DATADIR", + "PHP_SYSCONFDIR", "PHP_LOCALSTATEDIR", "PHP_CONFIG_FILE_PATH", + "PHP_CONFIG_FILE_SCAN_DIR", "PHP_SHLIB_SUFFIX", "PHP_EOL", "PHP_EOL", + "PHP_INT_MAX", "PHP_INT_SIZE", "PHP_OUTPUT_HANDLER_START", + "PHP_OUTPUT_HANDLER_CONT", "PHP_OUTPUT_HANDLER_END", "UPLOAD_ERR_OK", + "UPLOAD_ERR_INI_SIZE", "UPLOAD_ERR_FORM_SIZE", "UPLOAD_ERR_PARTIAL", + "UPLOAD_ERR_NO_FILE", "UPLOAD_ERR_NO_TMP_DIR", "UPLOAD_ERR_CANT_WRITE", + "UPLOAD_ERR_EXTENSION", "CAL_GREGORIAN", "CAL_JULIAN", "CAL_JEWISH", + "CAL_FRENCH", "CAL_NUM_CALS", "CAL_DOW_DAYNO", "CAL_DOW_SHORT", "CAL_DOW_LONG", + "CAL_MONTH_GREGORIAN_SHORT", "CAL_MONTH_GREGORIAN_LONG", + "CAL_MONTH_JULIAN_SHORT", "CAL_MONTH_JULIAN_LONG", "CAL_MONTH_JEWISH", + "CAL_MONTH_FRENCH", "CAL_EASTER_DEFAULT", "CAL_EASTER_ROMAN", + "CAL_EASTER_ALWAYS_GREGORIAN", "CAL_EASTER_ALWAYS_JULIAN", + "CAL_JEWISH_ADD_ALAFIM_GERESH", "CAL_JEWISH_ADD_ALAFIM", + "CAL_JEWISH_ADD_GERESHAYIM", "CLSCTX_INPROC_SERVER", "CLSCTX_INPROC_HANDLER", + "CLSCTX_LOCAL_SERVER", "CLSCTX_REMOTE_SERVER", "CLSCTX_SERVER", "CLSCTX_ALL", + "VT_NULL", "VT_EMPTY", "VT_UI1", "VT_I1", "VT_UI2", "VT_I2", "VT_UI4", "VT_I4", + "VT_R4", "VT_R8", "VT_BOOL", "VT_ERROR", "VT_CY", "VT_DATE", "VT_BSTR", + "VT_DECIMAL", "VT_UNKNOWN", "VT_DISPATCH", "VT_VARIANT", "VT_INT", "VT_UINT", + "VT_ARRAY", "VT_BYREF", "CP_ACP", "CP_MACCP", "CP_OEMCP", "CP_UTF7", "CP_UTF8", + "CP_SYMBOL", "CP_THREAD_ACP", "VARCMP_LT", "VARCMP_EQ", "VARCMP_GT", + "VARCMP_NULL", "NORM_IGNORECASE", "NORM_IGNORENONSPACE", "NORM_IGNORESYMBOLS", + "NORM_IGNOREWIDTH", "NORM_IGNOREKANATYPE", "DISP_E_DIVBYZERO", + "DISP_E_OVERFLOW", "DISP_E_BADINDEX", "MK_E_UNAVAILABLE", "INPUT_POST", + "INPUT_GET", "INPUT_COOKIE", "INPUT_ENV", "INPUT_SERVER", "INPUT_SESSION", + "INPUT_REQUEST", "FILTER_FLAG_NONE", "FILTER_REQUIRE_SCALAR", + "FILTER_REQUIRE_ARRAY", "FILTER_FORCE_ARRAY", "FILTER_NULL_ON_FAILURE", + "FILTER_VALIDATE_INT", "FILTER_VALIDATE_BOOLEAN", "FILTER_VALIDATE_FLOAT", + "FILTER_VALIDATE_REGEXP", "FILTER_VALIDATE_URL", "FILTER_VALIDATE_EMAIL", + "FILTER_VALIDATE_IP", "FILTER_DEFAULT", "FILTER_UNSAFE_RAW", + "FILTER_SANITIZE_STRING", "FILTER_SANITIZE_STRIPPED", + "FILTER_SANITIZE_ENCODED", "FILTER_SANITIZE_SPECIAL_CHARS", + "FILTER_SANITIZE_EMAIL", "FILTER_SANITIZE_URL", "FILTER_SANITIZE_NUMBER_INT", + "FILTER_SANITIZE_NUMBER_FLOAT", "FILTER_SANITIZE_MAGIC_QUOTES", + "FILTER_CALLBACK", "FILTER_FLAG_ALLOW_OCTAL", "FILTER_FLAG_ALLOW_HEX", + "FILTER_FLAG_STRIP_LOW", "FILTER_FLAG_STRIP_HIGH", "FILTER_FLAG_ENCODE_LOW", + "FILTER_FLAG_ENCODE_HIGH", "FILTER_FLAG_ENCODE_AMP", + "FILTER_FLAG_NO_ENCODE_QUOTES", "FILTER_FLAG_EMPTY_STRING_NULL", + "FILTER_FLAG_ALLOW_FRACTION", "FILTER_FLAG_ALLOW_THOUSAND", + "FILTER_FLAG_ALLOW_SCIENTIFIC", "FILTER_FLAG_SCHEME_REQUIRED", + "FILTER_FLAG_HOST_REQUIRED", "FILTER_FLAG_PATH_REQUIRED", + "FILTER_FLAG_QUERY_REQUIRED", "FILTER_FLAG_IPV4", "FILTER_FLAG_IPV6", + "FILTER_FLAG_NO_RES_RANGE", "FILTER_FLAG_NO_PRIV_RANGE", "FTP_ASCII", + "FTP_TEXT", "FTP_BINARY", "FTP_IMAGE", "FTP_AUTORESUME", "FTP_TIMEOUT_SEC", + "FTP_AUTOSEEK", "FTP_FAILED", "FTP_FINISHED", "FTP_MOREDATA", "HASH_HMAC", + "ICONV_IMPL", "ICONV_VERSION", "ICONV_MIME_DECODE_STRICT", + "ICONV_MIME_DECODE_CONTINUE_ON_ERROR", "ODBC_TYPE", "ODBC_BINMODE_PASSTHRU", + "ODBC_BINMODE_RETURN", "ODBC_BINMODE_CONVERT", "SQL_ODBC_CURSORS", + "SQL_CUR_USE_DRIVER", "SQL_CUR_USE_IF_NEEDED", "SQL_CUR_USE_ODBC", + "SQL_CONCURRENCY", "SQL_CONCUR_READ_ONLY", "SQL_CONCUR_LOCK", + "SQL_CONCUR_ROWVER", "SQL_CONCUR_VALUES", "SQL_CURSOR_TYPE", + "SQL_CURSOR_FORWARD_ONLY", "SQL_CURSOR_KEYSET_DRIVEN", "SQL_CURSOR_DYNAMIC", + "SQL_CURSOR_STATIC", "SQL_KEYSET_SIZE", "SQL_FETCH_FIRST", "SQL_FETCH_NEXT", + "SQL_CHAR", "SQL_VARCHAR", "SQL_LONGVARCHAR", "SQL_DECIMAL", "SQL_NUMERIC", + "SQL_BIT", "SQL_TINYINT", "SQL_SMALLINT", "SQL_INTEGER", "SQL_BIGINT", + "SQL_REAL", "SQL_FLOAT", "SQL_DOUBLE", "SQL_BINARY", "SQL_VARBINARY", + "SQL_LONGVARBINARY", "SQL_DATE", "SQL_TIME", "SQL_TIMESTAMP", + "PREG_PATTERN_ORDER", "PREG_SET_ORDER", "PREG_OFFSET_CAPTURE", + "PREG_SPLIT_NO_EMPTY", "PREG_SPLIT_DELIM_CAPTURE", "PREG_SPLIT_OFFSET_CAPTURE", + "PREG_GREP_INVERT", "PREG_NO_ERROR", "PREG_INTERNAL_ERROR", + "PREG_BACKTRACK_LIMIT_ERROR", "PREG_RECURSION_LIMIT_ERROR", + "PREG_BAD_UTF8_ERROR", "DATE_ATOM", "DATE_COOKIE", "DATE_ISO8601", + "DATE_RFC822", "DATE_RFC850", "DATE_RFC1036", "DATE_RFC1123", "DATE_RFC2822", + "DATE_RFC3339", "DATE_RSS", "DATE_W3C", "SUNFUNCS_RET_TIMESTAMP", + "SUNFUNCS_RET_STRING", "SUNFUNCS_RET_DOUBLE", "LIBXML_VERSION", + "LIBXML_DOTTED_VERSION", "LIBXML_NOENT", "LIBXML_DTDLOAD", "LIBXML_DTDATTR", + "LIBXML_DTDVALID", "LIBXML_NOERROR", "LIBXML_NOWARNING", "LIBXML_NOBLANKS", + "LIBXML_XINCLUDE", "LIBXML_NSCLEAN", "LIBXML_NOCDATA", "LIBXML_NONET", + "LIBXML_COMPACT", "LIBXML_NOXMLDECL", "LIBXML_NOEMPTYTAG", "LIBXML_ERR_NONE", + "LIBXML_ERR_WARNING", "LIBXML_ERR_ERROR", "LIBXML_ERR_FATAL", + "CONNECTION_ABORTED", "CONNECTION_NORMAL", "CONNECTION_TIMEOUT", "INI_USER", + "INI_PERDIR", "INI_SYSTEM", "INI_ALL", "PHP_URL_SCHEME", "PHP_URL_HOST", + "PHP_URL_PORT", "PHP_URL_USER", "PHP_URL_PASS", "PHP_URL_PATH", + "PHP_URL_QUERY", "PHP_URL_FRAGMENT", "M_E", "M_LOG2E", "M_LOG10E", "M_LN2", + "M_LN10", "M_PI", "M_PI_2", "M_PI_4", "M_1_PI", "M_2_PI", "M_SQRTPI", + "M_2_SQRTPI", "M_LNPI", "M_EULER", "M_SQRT2", "M_SQRT1_2", "M_SQRT3", "INF", + "NAN", "INFO_GENERAL", "INFO_CREDITS", "INFO_CONFIGURATION", "INFO_MODULES", + "INFO_ENVIRONMENT", "INFO_VARIABLES", "INFO_LICENSE", "INFO_ALL", + "CREDITS_GROUP", "CREDITS_GENERAL", "CREDITS_SAPI", "CREDITS_MODULES", + "CREDITS_DOCS", "CREDITS_FULLPAGE", "CREDITS_QA", "CREDITS_ALL", + "HTML_SPECIALCHARS", "HTML_ENTITIES", "ENT_COMPAT", "ENT_QUOTES", + "ENT_NOQUOTES", "STR_PAD_LEFT", "STR_PAD_RIGHT", "STR_PAD_BOTH", + "PATHINFO_DIRNAME", "PATHINFO_BASENAME", "PATHINFO_EXTENSION", + "PATHINFO_FILENAME", "CHAR_MAX", "LC_CTYPE", "LC_NUMERIC", "LC_TIME", + "LC_COLLATE", "LC_MONETARY", "LC_ALL", "SEEK_SET", "SEEK_CUR", "SEEK_END", + "LOCK_SH", "LOCK_EX", "LOCK_UN", "LOCK_NB", "STREAM_NOTIFY_CONNECT", + "STREAM_NOTIFY_AUTH_REQUIRED", "STREAM_NOTIFY_AUTH_RESULT", + "STREAM_NOTIFY_MIME_TYPE_IS", "STREAM_NOTIFY_FILE_SIZE_IS", + "STREAM_NOTIFY_REDIRECTED", "STREAM_NOTIFY_PROGRESS", "STREAM_NOTIFY_FAILURE", + "STREAM_NOTIFY_COMPLETED", "STREAM_NOTIFY_RESOLVE", + "STREAM_NOTIFY_SEVERITY_INFO", "STREAM_NOTIFY_SEVERITY_WARN", + "STREAM_NOTIFY_SEVERITY_ERR", "STREAM_FILTER_READ", "STREAM_FILTER_WRITE", + "STREAM_FILTER_ALL", "STREAM_CLIENT_PERSISTENT", "STREAM_CLIENT_ASYNC_CONNECT", + "STREAM_CLIENT_CONNECT", "STREAM_CRYPTO_METHOD_SSLv2_CLIENT", + "STREAM_CRYPTO_METHOD_SSLv3_CLIENT", "STREAM_CRYPTO_METHOD_SSLv23_CLIENT", + "STREAM_CRYPTO_METHOD_TLS_CLIENT", "STREAM_CRYPTO_METHOD_SSLv2_SERVER", + "STREAM_CRYPTO_METHOD_SSLv3_SERVER", "STREAM_CRYPTO_METHOD_SSLv23_SERVER", + "STREAM_CRYPTO_METHOD_TLS_SERVER", "STREAM_SHUT_RD", "STREAM_SHUT_WR", + "STREAM_SHUT_RDWR", "STREAM_PF_INET", "STREAM_PF_INET6", "STREAM_PF_UNIX", + "STREAM_IPPROTO_IP", "STREAM_IPPROTO_TCP", "STREAM_IPPROTO_UDP", + "STREAM_IPPROTO_ICMP", "STREAM_IPPROTO_RAW", "STREAM_SOCK_STREAM", + "STREAM_SOCK_DGRAM", "STREAM_SOCK_RAW", "STREAM_SOCK_SEQPACKET", + "STREAM_SOCK_RDM", "STREAM_PEEK", "STREAM_OOB", "STREAM_SERVER_BIND", + "STREAM_SERVER_LISTEN", "FILE_USE_INCLUDE_PATH", "FILE_IGNORE_NEW_LINES", + "FILE_SKIP_EMPTY_LINES", "FILE_APPEND", "FILE_NO_DEFAULT_CONTEXT", + "PSFS_PASS_ON", "PSFS_FEED_ME", "PSFS_ERR_FATAL", "PSFS_FLAG_NORMAL", + "PSFS_FLAG_FLUSH_INC", "PSFS_FLAG_FLUSH_CLOSE", "CRYPT_SALT_LENGTH", + "CRYPT_STD_DES", "CRYPT_EXT_DES", "CRYPT_MD5", "CRYPT_BLOWFISH", + "DIRECTORY_SEPARATOR", "PATH_SEPARATOR", "GLOB_BRACE", "GLOB_MARK", + "GLOB_NOSORT", "GLOB_NOCHECK", "GLOB_NOESCAPE", "GLOB_ERR", "GLOB_ONLYDIR", + "LOG_EMERG", "LOG_ALERT", "LOG_CRIT", "LOG_ERR", "LOG_WARNING", "LOG_NOTICE", + "LOG_INFO", "LOG_DEBUG", "LOG_KERN", "LOG_USER", "LOG_MAIL", "LOG_DAEMON", + "LOG_AUTH", "LOG_SYSLOG", "LOG_LPR", "LOG_NEWS", "LOG_UUCP", "LOG_CRON", + "LOG_AUTHPRIV", "LOG_PID", "LOG_CONS", "LOG_ODELAY", "LOG_NDELAY", + "LOG_NOWAIT", "LOG_PERROR", "EXTR_OVERWRITE", "EXTR_SKIP", "EXTR_PREFIX_SAME", + "EXTR_PREFIX_ALL", "EXTR_PREFIX_INVALID", "EXTR_PREFIX_IF_EXISTS", + "EXTR_IF_EXISTS", "EXTR_REFS", "SORT_ASC", "SORT_DESC", "SORT_REGULAR", + "SORT_NUMERIC", "SORT_STRING", "SORT_LOCALE_STRING", "CASE_LOWER", + "CASE_UPPER", "COUNT_NORMAL", "COUNT_RECURSIVE", "ASSERT_ACTIVE", + "ASSERT_CALLBACK", "ASSERT_BAIL", "ASSERT_WARNING", "ASSERT_QUIET_EVAL", + "STREAM_USE_PATH", "STREAM_IGNORE_URL", "STREAM_ENFORCE_SAFE_MODE", + "STREAM_REPORT_ERRORS", "STREAM_MUST_SEEK", "STREAM_URL_STAT_LINK", + "STREAM_URL_STAT_QUIET", "STREAM_MKDIR_RECURSIVE", "IMAGETYPE_GIF", + "IMAGETYPE_JPEG", "IMAGETYPE_PNG", "IMAGETYPE_SWF", "IMAGETYPE_PSD", + "IMAGETYPE_BMP", "IMAGETYPE_TIFF_II", "IMAGETYPE_TIFF_MM", "IMAGETYPE_JPC", + "IMAGETYPE_JP2", "IMAGETYPE_JPX", "IMAGETYPE_JB2", "IMAGETYPE_SWC", + "IMAGETYPE_IFF", "IMAGETYPE_WBMP", "IMAGETYPE_JPEG2000", "IMAGETYPE_XBM", + "T_INCLUDE", "T_INCLUDE_ONCE", "T_EVAL", "T_REQUIRE", "T_REQUIRE_ONCE", + "T_LOGICAL_OR", "T_LOGICAL_XOR", "T_LOGICAL_AND", "T_PRINT", "T_PLUS_EQUAL", + "T_MINUS_EQUAL", "T_MUL_EQUAL", "T_DIV_EQUAL", "T_CONCAT_EQUAL", "T_MOD_EQUAL", + "T_AND_EQUAL", "T_OR_EQUAL", "T_XOR_EQUAL", "T_SL_EQUAL", "T_SR_EQUAL", + "T_BOOLEAN_OR", "T_BOOLEAN_AND", "T_IS_EQUAL", "T_IS_NOT_EQUAL", + "T_IS_IDENTICAL", "T_IS_NOT_IDENTICAL", "T_IS_SMALLER_OR_EQUAL", + "T_IS_GREATER_OR_EQUAL", "T_SL", "T_SR", "T_INC", "T_DEC", "T_INT_CAST", + "T_DOUBLE_CAST", "T_STRING_CAST", "T_ARRAY_CAST", "T_OBJECT_CAST", + "T_BOOL_CAST", "T_UNSET_CAST", "T_NEW", "T_EXIT", "T_IF", "T_ELSEIF", "T_ELSE", + "T_ENDIF", "T_LNUMBER", "T_DNUMBER", "T_STRING", "T_STRING_VARNAME", + "T_VARIABLE", "T_NUM_STRING", "T_INLINE_HTML", "T_CHARACTER", + "T_BAD_CHARACTER", "T_ENCAPSED_AND_WHITESPACE", "T_CONSTANT_ENCAPSED_STRING", + "T_ECHO", "T_DO", "T_WHILE", "T_ENDWHILE", "T_FOR", "T_ENDFOR", "T_FOREACH", + "T_ENDFOREACH", "T_DECLARE", "T_ENDDECLARE", "T_AS", "T_SWITCH", "T_ENDSWITCH", + "T_CASE", "T_DEFAULT", "T_BREAK", "T_CONTINUE", "T_FUNCTION", "T_CONST", + "T_RETURN", "T_USE", "T_GLOBAL", "T_STATIC", "T_VAR", "T_UNSET", "T_ISSET", + "T_EMPTY", "T_CLASS", "T_EXTENDS", "T_INTERFACE", "T_IMPLEMENTS", + "T_OBJECT_OPERATOR", "T_DOUBLE_ARROW", "T_LIST", "T_ARRAY", "T_CLASS_C", + "T_FUNC_C", "T_METHOD_C", "T_LINE", "T_FILE", "T_COMMENT", "T_DOC_COMMENT", + "T_OPEN_TAG", "T_OPEN_TAG_WITH_ECHO", "T_CLOSE_TAG", "T_WHITESPACE", + "T_START_HEREDOC", "T_END_HEREDOC", "T_DOLLAR_OPEN_CURLY_BRACES", + "T_CURLY_OPEN", "T_PAAMAYIM_NEKUDOTAYIM", "T_DOUBLE_COLON", "T_ABSTRACT", + "T_CATCH", "T_FINAL", "T_INSTANCEOF", "T_PRIVATE", "T_PROTECTED", "T_PUBLIC", + "T_THROW", "T_TRY", "T_CLONE", "T_HALT_COMPILER", "FORCE_GZIP", + "FORCE_DEFLATE", "XML_ELEMENT_NODE", "XML_ATTRIBUTE_NODE", "XML_TEXT_NODE", + "XML_CDATA_SECTION_NODE", "XML_ENTITY_REF_NODE", "XML_ENTITY_NODE", + "XML_PI_NODE", "XML_COMMENT_NODE", "XML_DOCUMENT_NODE", + "XML_DOCUMENT_TYPE_NODE", "XML_DOCUMENT_FRAG_NODE", "XML_NOTATION_NODE", + "XML_HTML_DOCUMENT_NODE", "XML_DTD_NODE", "XML_ELEMENT_DECL_NODE", + "XML_ATTRIBUTE_DECL_NODE", "XML_ENTITY_DECL_NODE", "XML_NAMESPACE_DECL_NODE", + "XML_LOCAL_NAMESPACE", "XML_ATTRIBUTE_CDATA", "XML_ATTRIBUTE_ID", + "XML_ATTRIBUTE_IDREF", "XML_ATTRIBUTE_IDREFS", "XML_ATTRIBUTE_ENTITY", + "XML_ATTRIBUTE_NMTOKEN", "XML_ATTRIBUTE_NMTOKENS", "XML_ATTRIBUTE_ENUMERATION", + "XML_ATTRIBUTE_NOTATION", "DOM_PHP_ERR", "DOM_INDEX_SIZE_ERR", + "DOMSTRING_SIZE_ERR", "DOM_HIERARCHY_REQUEST_ERR", "DOM_WRONG_DOCUMENT_ERR", + "DOM_INVALID_CHARACTER_ERR", "DOM_NO_DATA_ALLOWED_ERR", + "DOM_NO_MODIFICATION_ALLOWED_ERR", "DOM_NOT_FOUND_ERR", + "DOM_NOT_SUPPORTED_ERR", "DOM_INUSE_ATTRIBUTE_ERR", "DOM_INVALID_STATE_ERR", + "DOM_SYNTAX_ERR", "DOM_INVALID_MODIFICATION_ERR", "DOM_NAMESPACE_ERR", + "DOM_INVALID_ACCESS_ERR", "DOM_VALIDATION_ERR", "XML_ERROR_NONE", + "XML_ERROR_NO_MEMORY", "XML_ERROR_SYNTAX", "XML_ERROR_NO_ELEMENTS", + "XML_ERROR_INVALID_TOKEN", "XML_ERROR_UNCLOSED_TOKEN", + "XML_ERROR_PARTIAL_CHAR", "XML_ERROR_TAG_MISMATCH", + "XML_ERROR_DUPLICATE_ATTRIBUTE", "XML_ERROR_JUNK_AFTER_DOC_ELEMENT", + "XML_ERROR_PARAM_ENTITY_REF", "XML_ERROR_UNDEFINED_ENTITY", + "XML_ERROR_RECURSIVE_ENTITY_REF", "XML_ERROR_ASYNC_ENTITY", + "XML_ERROR_BAD_CHAR_REF", "XML_ERROR_BINARY_ENTITY_REF", + "XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF", "XML_ERROR_MISPLACED_XML_PI", + "XML_ERROR_UNKNOWN_ENCODING", "XML_ERROR_INCORRECT_ENCODING", + "XML_ERROR_UNCLOSED_CDATA_SECTION", "XML_ERROR_EXTERNAL_ENTITY_HANDLING", + "XML_OPTION_CASE_FOLDING", "XML_OPTION_TARGET_ENCODING", + "XML_OPTION_SKIP_TAGSTART", "XML_OPTION_SKIP_WHITE", "XML_SAX_IMPL", "IMG_GIF", + "IMG_JPG", "IMG_JPEG", "IMG_PNG", "IMG_WBMP", "IMG_XPM", "IMG_COLOR_TILED", + "IMG_COLOR_STYLED", "IMG_COLOR_BRUSHED", "IMG_COLOR_STYLEDBRUSHED", + "IMG_COLOR_TRANSPARENT", "IMG_ARC_ROUNDED", "IMG_ARC_PIE", "IMG_ARC_CHORD", + "IMG_ARC_NOFILL", "IMG_ARC_EDGED", "IMG_GD2_RAW", "IMG_GD2_COMPRESSED", + "IMG_EFFECT_REPLACE", "IMG_EFFECT_ALPHABLEND", "IMG_EFFECT_NORMAL", + "IMG_EFFECT_OVERLAY", "GD_BUNDLED", "IMG_FILTER_NEGATE", + "IMG_FILTER_GRAYSCALE", "IMG_FILTER_BRIGHTNESS", "IMG_FILTER_CONTRAST", + "IMG_FILTER_COLORIZE", "IMG_FILTER_EDGEDETECT", "IMG_FILTER_GAUSSIAN_BLUR", + "IMG_FILTER_SELECTIVE_BLUR", "IMG_FILTER_EMBOSS", "IMG_FILTER_MEAN_REMOVAL", + "IMG_FILTER_SMOOTH", "PNG_NO_FILTER", "PNG_FILTER_NONE", "PNG_FILTER_SUB", + "PNG_FILTER_UP", "PNG_FILTER_AVG", "PNG_FILTER_PAETH", "PNG_ALL_FILTERS", + "MB_OVERLOAD_MAIL", "MB_OVERLOAD_STRING", "MB_OVERLOAD_REGEX", "MB_CASE_UPPER", + "MB_CASE_LOWER", "MB_CASE_TITLE", "MYSQL_ASSOC", "MYSQL_NUM", "MYSQL_BOTH", + "MYSQL_CLIENT_COMPRESS", "MYSQL_CLIENT_SSL", "MYSQL_CLIENT_INTERACTIVE", + "MYSQL_CLIENT_IGNORE_SPACE", "MYSQLI_READ_DEFAULT_GROUP", + "MYSQLI_READ_DEFAULT_FILE", "MYSQLI_OPT_CONNECT_TIMEOUT", + "MYSQLI_OPT_LOCAL_INFILE", "MYSQLI_INIT_COMMAND", "MYSQLI_CLIENT_SSL", + "MYSQLI_CLIENT_COMPRESS", "MYSQLI_CLIENT_INTERACTIVE", + "MYSQLI_CLIENT_IGNORE_SPACE", "MYSQLI_CLIENT_NO_SCHEMA", + "MYSQLI_CLIENT_FOUND_ROWS", "MYSQLI_STORE_RESULT", "MYSQLI_USE_RESULT", + "MYSQLI_ASSOC", "MYSQLI_NUM", "MYSQLI_BOTH", + "MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH", "MYSQLI_STMT_ATTR_CURSOR_TYPE", + "MYSQLI_CURSOR_TYPE_NO_CURSOR", "MYSQLI_CURSOR_TYPE_READ_ONLY", + "MYSQLI_CURSOR_TYPE_FOR_UPDATE", "MYSQLI_CURSOR_TYPE_SCROLLABLE", + "MYSQLI_STMT_ATTR_PREFETCH_ROWS", "MYSQLI_NOT_NULL_FLAG", + "MYSQLI_PRI_KEY_FLAG", "MYSQLI_UNIQUE_KEY_FLAG", "MYSQLI_MULTIPLE_KEY_FLAG", + "MYSQLI_BLOB_FLAG", "MYSQLI_UNSIGNED_FLAG", "MYSQLI_ZEROFILL_FLAG", + "MYSQLI_AUTO_INCREMENT_FLAG", "MYSQLI_TIMESTAMP_FLAG", "MYSQLI_SET_FLAG", + "MYSQLI_NUM_FLAG", "MYSQLI_PART_KEY_FLAG", "MYSQLI_GROUP_FLAG", + "MYSQLI_TYPE_DECIMAL", "MYSQLI_TYPE_TINY", "MYSQLI_TYPE_SHORT", + "MYSQLI_TYPE_LONG", "MYSQLI_TYPE_FLOAT", "MYSQLI_TYPE_DOUBLE", + "MYSQLI_TYPE_NULL", "MYSQLI_TYPE_TIMESTAMP", "MYSQLI_TYPE_LONGLONG", + "MYSQLI_TYPE_INT24", "MYSQLI_TYPE_DATE", "MYSQLI_TYPE_TIME", + "MYSQLI_TYPE_DATETIME", "MYSQLI_TYPE_YEAR", "MYSQLI_TYPE_NEWDATE", + "MYSQLI_TYPE_ENUM", "MYSQLI_TYPE_SET", "MYSQLI_TYPE_TINY_BLOB", + "MYSQLI_TYPE_MEDIUM_BLOB", "MYSQLI_TYPE_LONG_BLOB", "MYSQLI_TYPE_BLOB", + "MYSQLI_TYPE_VAR_STRING", "MYSQLI_TYPE_STRING", "MYSQLI_TYPE_CHAR", + "MYSQLI_TYPE_INTERVAL", "MYSQLI_TYPE_GEOMETRY", "MYSQLI_TYPE_NEWDECIMAL", + "MYSQLI_TYPE_BIT", "MYSQLI_RPL_MASTER", "MYSQLI_RPL_SLAVE", "MYSQLI_RPL_ADMIN", + "MYSQLI_NO_DATA", "MYSQLI_DATA_TRUNCATED", "MYSQLI_REPORT_INDEX", + "MYSQLI_REPORT_ERROR", "MYSQLI_REPORT_STRICT", "MYSQLI_REPORT_ALL", + "MYSQLI_REPORT_OFF", "AF_UNIX", "AF_INET", "AF_INET6", "SOCK_STREAM", + "SOCK_DGRAM", "SOCK_RAW", "SOCK_SEQPACKET", "SOCK_RDM", "MSG_OOB", + "MSG_WAITALL", "MSG_PEEK", "MSG_DONTROUTE", "SO_DEBUG", "SO_REUSEADDR", + "SO_KEEPALIVE", "SO_DONTROUTE", "SO_LINGER", "SO_BROADCAST", "SO_OOBINLINE", + "SO_SNDBUF", "SO_RCVBUF", "SO_SNDLOWAT", "SO_RCVLOWAT", "SO_SNDTIMEO", + "SO_RCVTIMEO", "SO_TYPE", "SO_ERROR", "SOL_SOCKET", "SOMAXCONN", + "PHP_NORMAL_READ", "PHP_BINARY_READ", "SOCKET_EINTR", "SOCKET_EBADF", + "SOCKET_EACCES", "SOCKET_EFAULT", "SOCKET_EINVAL", "SOCKET_EMFILE", + "SOCKET_EWOULDBLOCK", "SOCKET_EINPROGRESS", "SOCKET_EALREADY", + "SOCKET_ENOTSOCK", "SOCKET_EDESTADDRREQ", "SOCKET_EMSGSIZE", + "SOCKET_EPROTOTYPE", "SOCKET_ENOPROTOOPT", "SOCKET_EPROTONOSUPPORT", + "SOCKET_ESOCKTNOSUPPORT", "SOCKET_EOPNOTSUPP", "SOCKET_EPFNOSUPPORT", + "SOCKET_EAFNOSUPPORT", "SOCKET_EADDRINUSE", "SOCKET_EADDRNOTAVAIL", + "SOCKET_ENETDOWN", "SOCKET_ENETUNREACH", "SOCKET_ENETRESET", + "SOCKET_ECONNABORTED", "SOCKET_ECONNRESET", "SOCKET_ENOBUFS", "SOCKET_EISCONN", + "SOCKET_ENOTCONN", "SOCKET_ESHUTDOWN", "SOCKET_ETOOMANYREFS", + "SOCKET_ETIMEDOUT", "SOCKET_ECONNREFUSED", "SOCKET_ELOOP", + "SOCKET_ENAMETOOLONG", "SOCKET_EHOSTDOWN", "SOCKET_EHOSTUNREACH", + "SOCKET_ENOTEMPTY", "SOCKET_EPROCLIM", "SOCKET_EUSERS", "SOCKET_EDQUOT", + "SOCKET_ESTALE", "SOCKET_EREMOTE", "SOCKET_EDISCON", "SOCKET_SYSNOTREADY", + "SOCKET_VERNOTSUPPORTED", "SOCKET_NOTINITIALISED", "SOCKET_HOST_NOT_FOUND", + "SOCKET_TRY_AGAIN", "SOCKET_NO_RECOVERY", "SOCKET_NO_DATA", + "SOCKET_NO_ADDRESS", "SOL_TCP", "SOL_UDP", "EACCELERATOR_VERSION", + "EACCELERATOR_SHM_AND_DISK", "EACCELERATOR_SHM", "EACCELERATOR_SHM_ONLY", + "EACCELERATOR_DISK_ONLY", "EACCELERATOR_NONE", "XDEBUG_TRACE_APPEND", + "XDEBUG_TRACE_COMPUTERIZED", "XDEBUG_TRACE_HTML", "XDEBUG_CC_UNUSED", + "XDEBUG_CC_DEAD_CODE", "STDIN", "STDOUT", "STDERR", "DNS_HINFO", + "DNS_PTR", "SQLITE_EMPTY", "SVN_SHOW_UPDATES", "SVN_NO_IGNORE", "MSG_EOF", + "DNS_MX", "GD_EXTRA_VERSION", "PHP_VERSION_ID", "SQLITE_OK", + "LIBXML_LOADED_VERSION", "RADIXCHAR", "OPENSSL_VERSION_TEXT", "OPENSSL_VERSION_NUMBER", + "PCRE_VERSION", "CURLOPT_FILE", "CURLOPT_INFILE", "CURLOPT_URL", "CURLOPT_PROXY", + "CURLE_FUNCTION_NOT_FOUND", "SOCKET_ENOMSG", "CURLOPT_HTTPHEADER", "SOCKET_EIDRM", + "CURLOPT_PROGRESSFUNCTION", "SOCKET_ECHRNG", "SOCKET_EL2NSYNC", "SOCKET_EL3HLT", + "SOCKET_EL3RST", "SOCKET_ELNRNG", "SOCKET_ENOCSI", "SOCKET_EL2HLT", "SOCKET_EBADE", + "SOCKET_EXFULL", "CURLOPT_USERPWD", "CURLOPT_PROXYUSERPWD", "CURLOPT_RANGE", + "CURLOPT_TIMEOUT_MS", "CURLOPT_POSTFIELDS", "CURLOPT_REFERER", "CURLOPT_USERAGENT", + "CURLOPT_FTPPORT", "SOCKET_ERESTART", "SQLITE_CONSTRAINT", "SQLITE_MISMATCH", + "SQLITE_MISUSE", "CURLOPT_COOKIE", "CURLE_SSL_CERTPROBLEM", "CURLOPT_SSLCERT", + "CURLOPT_KEYPASSWD", "CURLOPT_WRITEHEADER", "CURLOPT_SSL_VERIFYHOST", + "CURLOPT_COOKIEFILE", "CURLE_HTTP_RANGE_ERROR", "CURLE_HTTP_POST_ERROR", + "CURLOPT_CUSTOMREQUEST", "CURLOPT_STDERR", "SOCKET_EBADR", "CURLOPT_RETURNTRANSFER", + "CURLOPT_QUOTE", "CURLOPT_POSTQUOTE", "CURLOPT_INTERFACE", "CURLOPT_KRB4LEVEL", + "SOCKET_ENODATA", "SOCKET_ESRMNT", "CURLOPT_WRITEFUNCTION", "CURLOPT_READFUNCTION", + "CURLOPT_HEADERFUNCTION", "SOCKET_EADV", "SOCKET_EPROTO", "SOCKET_EMULTIHOP", + "SOCKET_EBADMSG", "CURLOPT_FORBID_REUSE", "CURLOPT_RANDOM_FILE", "CURLOPT_EGDSOCKET", + "SOCKET_EREMCHG", "CURLOPT_CONNECTTIMEOUT_MS", "CURLOPT_CAINFO", "CURLOPT_CAPATH", + "CURLOPT_COOKIEJAR", "CURLOPT_SSL_CIPHER_LIST", "CURLOPT_BINARYTRANSFER", + "SQLITE_DONE", "CURLOPT_HTTP_VERSION", "CURLOPT_SSLKEY", "CURLOPT_SSLKEYTYPE", + "CURLOPT_SSLENGINE", "CURLOPT_SSLCERTTYPE", "CURLE_OUT_OF_MEMORY", "CURLOPT_ENCODING", + "CURLE_SSL_CIPHER", "SOCKET_EREMOTEIO", "CURLOPT_HTTP200ALIASES", "CURLAUTH_ANY", + "CURLAUTH_ANYSAFE", "CURLOPT_PRIVATE", "CURLINFO_EFFECTIVE_URL", "CURLINFO_HTTP_CODE", + "CURLINFO_HEADER_SIZE", "CURLINFO_REQUEST_SIZE", "CURLINFO_TOTAL_TIME", + "CURLINFO_NAMELOOKUP_TIME", "CURLINFO_CONNECT_TIME", "CURLINFO_PRETRANSFER_TIME", + "CURLINFO_SIZE_UPLOAD", "CURLINFO_SIZE_DOWNLOAD", "CURLINFO_SPEED_DOWNLOAD", + "CURLINFO_SPEED_UPLOAD", "CURLINFO_FILETIME", "CURLINFO_SSL_VERIFYRESULT", + "CURLINFO_CONTENT_LENGTH_DOWNLOAD", "CURLINFO_CONTENT_LENGTH_UPLOAD", + "CURLINFO_STARTTRANSFER_TIME", "CURLINFO_CONTENT_TYPE", "CURLINFO_REDIRECT_TIME", + "CURLINFO_REDIRECT_COUNT", "CURLINFO_PRIVATE", "CURLINFO_CERTINFO", + "SQLITE_PROTOCOL", "SQLITE_SCHEMA", "SQLITE_TOOBIG", "SQLITE_NOLFS", + "SQLITE_AUTH", "SQLITE_FORMAT", "SOCKET_ENOTTY", "SQLITE_NOTADB", + "SOCKET_ENOSPC", "SOCKET_ESPIPE", "SOCKET_EROFS", "SOCKET_EMLINK", "GD_RELEASE_VERSION", + "SOCKET_ENOLCK", "SOCKET_ENOSYS", "SOCKET_EUNATCH", "SOCKET_ENOANO", "SOCKET_EBADRQC", + "SOCKET_EBADSLT", "SOCKET_ENOSTR", "SOCKET_ETIME", "SOCKET_ENOSR", "SVN_REVISION_HEAD", + "XSD_ENTITY", "XSD_NOTATION", "CURLOPT_CERTINFO", "CURLOPT_POSTREDIR", "CURLOPT_SSH_AUTH_TYPES", + "CURLOPT_SSH_PUBLIC_KEYFILE", "CURLOPT_SSH_PRIVATE_KEYFILE", "CURLOPT_SSH_HOST_PUBLIC_KEY_MD5", + "CURLE_SSH", "CURLOPT_REDIR_PROTOCOLS", "CURLOPT_PROTOCOLS", "XSD_NONNEGATIVEINTEGER", + "XSD_BYTE","DNS_SRV","DNS_A6", "DNS_NAPTR", "DNS_AAAA", "FILTER_SANITIZE_FULL_SPECIAL_CHARS", + "ABDAY_1", "SVN_REVISION_UNSPECIFIED", "SVN_REVISION_BASE", "SVN_REVISION_COMMITTED", + "SVN_REVISION_PREV", "GD_VERSION", "MCRYPT_TRIPLEDES", "MCRYPT_ARCFOUR_IV", "MCRYPT_ARCFOUR", + "MCRYPT_BLOWFISH", "MCRYPT_BLOWFISH_COMPAT", "MCRYPT_CAST_128", "MCRYPT_CAST_256", + "MCRYPT_ENIGNA", "MCRYPT_DES", "MCRYPT_GOST", "MCRYPT_LOKI97", "MCRYPT_PANAMA", + "MCRYPT_RC2", "MCRYPT_RIJNDAEL_128", "MCRYPT_RIJNDAEL_192", "MCRYPT_RIJNDAEL_256", + "MCRYPT_SAFER64", "MCRYPT_SAFER128","MCRYPT_SAFERPLUS", "MCRYPT_SERPENT", "MCRYPT_THREEWAY", + "MCRYPT_TWOFISH", "MCRYPT_WAKE", "MCRYPT_XTEA", "MCRYPT_IDEA", "MCRYPT_MARS", + "MCRYPT_RC6", "MCRYPT_SKIPJACK", "MCRYPT_MODE_CBC", "MCRYPT_MODE_CFB", "MCRYPT_MODE_ECB", + "MCRYPT_MODE_NOFB", "MCRYPT_MODE_OFB", "MCRYPT_MODE_STREAM", "CL_EXPUNGE", + "SQLITE_ROW", "POSIX_S_IFBLK", "POSIX_S_IFSOCK", "XSD_IDREF", "ABDAY_2", + "ABDAY_3", "ABDAY_4", "ABDAY_5", "ABDAY_6", "ABDAY_7", "DAY_1", "DAY_2", + "DAY_3", "DAY_4", "DAY_5", "DAY_6", "DAY_7", "ABMON_1", "ABMON_2", "ABMON_3", + "ABMON_4", "ABMON_5", "ABMON_6", "ABMON_7","ABMON_8", "ABMON_9", "ABMON_10", + "ABMON_11", "ABMON_12", "MON_1", "MON_2", "MON_3", "MON_4", "MON_5", "MON_6", + "MON_7", "MON_8", "MON_9", "MON_10", "MON_11", "MON_12", "AM_STR", "PM_STR", + "D_T_FMT", "D_FMT", "T_FMT", "T_FMT_AMPM", "ERA", "ERA_D_T_FMT", "ERA_D_FMT", + "ERA_T_FMT", "ALT_DIGITS", "CRNCYSTR", "THOUSEP", "YESEXPR", "NOEXPR", + "SOCKET_ENOMEDIUM", "GLOB_AVAILABLE_FLAGS", "XSD_SHORT", "XSD_NMTOKENS", + "LOG_LOCAL3", "LOG_LOCAL4", "LOG_LOCAL5", "LOG_LOCAL6", "LOG_LOCAL7", + "DNS_ANY", "DNS_ALL", "SOCKET_ENOLINK", "SOCKET_ECOMM", "SOAP_FUNCTIONS_ALL", + "UNKNOWN_TYPE", "XSD_BASE64BINARY", "XSD_ANYURI", "XSD_QNAME", "SOCKET_EISNAM", + "SOCKET_EMEDIUMTYPE", "XSD_NCNAME", "XSD_ID", "XSD_ENTITIES", "XSD_INTEGER", + "XSD_NONPOSITIVEINTEGER", "XSD_NEGATIVEINTEGER", "XSD_LONG", "XSD_INT", + "XSD_UNSIGNEDLONG", "XSD_UNSIGNEDINT", "XSD_UNSIGNEDSHORT", "XSD_UNSIGNEDBYTE", + "XSD_POSITIVEINTEGER", "XSD_ANYTYPE", "XSD_ANYXML", "APACHE_MAP", "XSD_1999_TIMEINSTANT", + "XSD_NAMESPACE", "XSD_1999_NAMESPACE", "SOCKET_ENOTUNIQ", "SOCKET_EBADFD", + "SOCKET_ESTRPIPE", "T_GOTO", "T_NAMESPACE", "T_NS_C", "T_DIR", "T_NS_SEPARATOR", + "LIBXSLT_VERSION","LIBEXSLT_DOTTED_VERSION", "LIBEXSLT_VERSION", "SVN_AUTH_PARAM_DEFAULT_USERNAME", + "SVN_AUTH_PARAM_DEFAULT_PASSWORD", "SVN_AUTH_PARAM_NON_INTERACTIVE", + "SVN_AUTH_PARAM_DONT_STORE_PASSWORDS", "SVN_AUTH_PARAM_NO_AUTH_CACHE", + "SVN_AUTH_PARAM_SSL_SERVER_FAILURES", "SVN_AUTH_PARAM_SSL_SERVER_CERT_INFO", + "SVN_AUTH_PARAM_CONFIG", "SVN_AUTH_PARAM_SERVER_GROUP", + "SVN_AUTH_PARAM_CONFIG_DIR", "PHP_SVN_AUTH_PARAM_IGNORE_SSL_VERIFY_ERRORS", + "SVN_FS_CONFIG_FS_TYPE", "SVN_FS_TYPE_BDB", "SVN_FS_TYPE_FSFS", "SVN_PROP_REVISION_DATE", + "SVN_PROP_REVISION_ORIG_DATE", "SVN_PROP_REVISION_AUTHOR", "SVN_PROP_REVISION_LOG" + ].forEach(function(element, index, array) { + result[element] = token("atom", "php-predefined-constant"); + }); + + // PHP declared classes - output of get_declared_classes(). Differs from http://php.net/manual/en/reserved.classes.php + [ "stdClass", "Exception", "ErrorException", "COMPersistHelper", "com_exception", + "com_safearray_proxy", "variant", "com", "dotnet", "ReflectionException", + "Reflection", "ReflectionFunctionAbstract", "ReflectionFunction", + "ReflectionParameter", "ReflectionMethod", "ReflectionClass", + "ReflectionObject", "ReflectionProperty", "ReflectionExtension", "DateTime", + "DateTimeZone", "LibXMLError", "__PHP_Incomplete_Class", "php_user_filter", + "Directory", "SimpleXMLElement", "DOMException", "DOMStringList", + "DOMNameList", "DOMImplementationList", "DOMImplementationSource", + "DOMImplementation", "DOMNode", "DOMNameSpaceNode", "DOMDocumentFragment", + "DOMDocument", "DOMNodeList", "DOMNamedNodeMap", "DOMCharacterData", "DOMAttr", + "DOMElement", "DOMText", "DOMComment", "DOMTypeinfo", "DOMUserDataHandler", + "DOMDomError", "DOMErrorHandler", "DOMLocator", "DOMConfiguration", + "DOMCdataSection", "DOMDocumentType", "DOMNotation", "DOMEntity", + "DOMEntityReference", "DOMProcessingInstruction", "DOMStringExtend", + "DOMXPath", "RecursiveIteratorIterator", "IteratorIterator", "FilterIterator", + "RecursiveFilterIterator", "ParentIterator", "LimitIterator", + "CachingIterator", "RecursiveCachingIterator", "NoRewindIterator", + "AppendIterator", "InfiniteIterator", "RegexIterator", + "RecursiveRegexIterator", "EmptyIterator", "ArrayObject", "ArrayIterator", + "RecursiveArrayIterator", "SplFileInfo", "DirectoryIterator", + "RecursiveDirectoryIterator", "SplFileObject", "SplTempFileObject", + "SimpleXMLIterator", "LogicException", "BadFunctionCallException", + "BadMethodCallException", "DomainException", "InvalidArgumentException", + "LengthException", "OutOfRangeException", "RuntimeException", + "OutOfBoundsException", "OverflowException", "RangeException", + "UnderflowException", "UnexpectedValueException", "SplObjectStorage", + "XMLReader", "XMLWriter", "mysqli_sql_exception", "mysqli_driver", "mysqli", + "mysqli_warning", "mysqli_result", "mysqli_stmt", "PDOException", "PDO", + "PDOStatement", "PDORow","Closure", "DateInterval", "DatePeriod", "FilesystemIterator", + "GlobIterator", "MultipleIterator", "RecursiveTreeIterator", "SoapClient", + "SoapFault", "SoapHeader", "SoapParam", "SoapServer", "SoapVar", "SplDoublyLinkedList", + "SplFixedArray", "SplHeap", "SplMaxHeap", "SplMinHeap", "SplPriorityQueue", + "SplQueue", "SplStack", "SQLite3", "SQLite3Result", "SQLite3Stmt", "SQLiteDatabase", + "SQLiteException", "SQLiteResult", "SQLiteUnbuffered", "Svn", "SvnNode", "SvnWc", + "SvnWcSchedule", "XSLTProcessor", "ZipArchive", + ].forEach(function(element, index, array) { + result[element] = token("t_string", "php-predefined-class"); + }); + + return result; + + }(); + + // Helper regexps + var isOperatorChar = /[+*&%\/=<>!?.|^@-]/; + var isHexDigit = /[0-9A-Fa-f]/; + var isWordChar = /[\w\$_\\]/; + + // Wrapper around phpToken that helps maintain parser state (whether + // we are inside of a multi-line comment) + function phpTokenState(inside) { + return function(source, setState) { + var newInside = inside; + var type = phpToken(inside, source, function(c) {newInside = c;}); + if (newInside != inside) + setState(phpTokenState(newInside)); + return type; + }; + } + + // The token reader, inteded to be used by the tokenizer from + // tokenize.js (through phpTokenState). Advances the source stream + // over a token, and returns an object containing the type and style + // of that token. + function phpToken(inside, source, setInside) { + function readHexNumber(){ + source.next(); // skip the 'x' + source.nextWhileMatches(isHexDigit); + return {type: "number", style: "php-atom"}; + } + + function readNumber() { + source.nextWhileMatches(/[0-9]/); + if (source.equals(".")){ + source.next(); + source.nextWhileMatches(/[0-9]/); + } + if (source.equals("e") || source.equals("E")){ + source.next(); + if (source.equals("-")) + source.next(); + source.nextWhileMatches(/[0-9]/); + } + return {type: "number", style: "php-atom"}; + } + // Read a word and look it up in the keywords array. If found, it's a + // keyword of that type; otherwise it's a PHP T_STRING. + function readWord() { + source.nextWhileMatches(isWordChar); + var word = source.get(); + var known = keywords.hasOwnProperty(word) && keywords.propertyIsEnumerable(word) && keywords[word]; + // since we called get(), tokenize::take won't get() anything. Thus, we must set token.content + return known ? {type: known.type, style: known.style, content: word} : + {type: "t_string", style: "php-t_string", content: word}; + } + function readVariable() { + source.nextWhileMatches(isWordChar); + var word = source.get(); + // in PHP, '$this' is a reserved word, but 'this' isn't. You can have function this() {...} + if (word == "$this") + return {type: "variable", style: "php-keyword", content: word}; + else + return {type: "variable", style: "php-variable", content: word}; + } + + // Advance the stream until the given character (not preceded by a + // backslash) is encountered, or the end of the line is reached. + function nextUntilUnescaped(source, end) { + var escaped = false; + while(!source.endOfLine()){ + var next = source.next(); + if (next == end && !escaped) + return false; + escaped = next == "\\" && !escaped; + } + return escaped; + } + + function readSingleLineComment() { + // read until the end of the line or until ?>, which terminates single-line comments + // ` foo` will display "1 foo" + while(!source.lookAhead("?>") && !source.endOfLine()) + source.next(); + return {type: "comment", style: "php-comment"}; + } + /* For multi-line comments, we want to return a comment token for + every line of the comment, but we also want to return the newlines + in them as regular newline tokens. We therefore need to save a + state variable ("inside") to indicate whether we are inside a + multi-line comment. + */ + + function readMultilineComment(start){ + var newInside = "/*"; + var maybeEnd = (start == "*"); + while (true) { + if (source.endOfLine()) + break; + var next = source.next(); + if (next == "/" && maybeEnd){ + newInside = null; + break; + } + maybeEnd = (next == "*"); + } + setInside(newInside); + return {type: "comment", style: "php-comment"}; + } + + // similar to readMultilineComment and nextUntilUnescaped + // unlike comments, strings are not stopped by ?> + function readMultilineString(start){ + var newInside = start; + var escaped = false; + while (true) { + if (source.endOfLine()) + break; + var next = source.next(); + if (next == start && !escaped){ + newInside = null; // we're outside of the string now + break; + } + escaped = (next == "\\" && !escaped); + } + setInside(newInside); + return { + type: newInside == null? "string" : "string_not_terminated", + style: (start == "'"? "php-string-single-quoted" : "php-string-double-quoted") + }; + } + + // http://php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc + // See also 'nowdoc' on the page. Heredocs are not interrupted by the '?>' token. + function readHeredoc(identifier){ + var token = {}; + if (identifier == "<<<") { + // on our first invocation after reading the <<<, we must determine the closing identifier + if (source.equals("'")) { + // nowdoc + source.nextWhileMatches(isWordChar); + identifier = "'" + source.get() + "'"; + source.next(); // consume the closing "'" + } else if (source.matches(/[A-Za-z_]/)) { + // heredoc + source.nextWhileMatches(isWordChar); + identifier = source.get(); + } else { + // syntax error + setInside(null); + return { type: "error", style: "syntax-error" }; + } + setInside(identifier); + token.type = "string_not_terminated"; + token.style = identifier.charAt(0) == "'"? "php-string-single-quoted" : "php-string-double-quoted"; + token.content = identifier; + } else { + token.style = identifier.charAt(0) == "'"? "php-string-single-quoted" : "php-string-double-quoted"; + // consume a line of heredoc and check if it equals the closing identifier plus an optional semicolon + if (source.lookAhead(identifier, true) && (source.lookAhead(";\n") || source.endOfLine())) { + // the closing identifier can only appear at the beginning of the line + // note that even whitespace after the ";" is forbidden by the PHP heredoc syntax + token.type = "string"; + token.content = source.get(); // don't get the ";" if there is one + setInside(null); + } else { + token.type = "string_not_terminated"; + source.nextWhileMatches(/[^\n]/); + token.content = source.get(); + } + } + return token; + } + + function readOperator() { + source.nextWhileMatches(isOperatorChar); + return {type: "operator", style: "php-operator"}; + } + function readStringSingleQuoted() { + var endBackSlash = nextUntilUnescaped(source, "'", false); + setInside(endBackSlash ? "'" : null); + return {type: "string", style: "php-string-single-quoted"}; + } + function readStringDoubleQuoted() { + var endBackSlash = nextUntilUnescaped(source, "\"", false); + setInside(endBackSlash ? "\"": null); + return {type: "string", style: "php-string-double-quoted"}; + } + + // Fetch the next token. Dispatches on first character in the + // stream, or first two characters when the first is a slash. + switch (inside) { + case null: + case false: break; + case "'": + case "\"": return readMultilineString(inside); + case "/*": return readMultilineComment(source.next()); + default: return readHeredoc(inside); + } + var ch = source.next(); + if (ch == "'" || ch == "\"") + return readMultilineString(ch); + else if (ch == "#") + return readSingleLineComment(); + else if (ch == "$") + return readVariable(); + else if (ch == ":" && source.equals(":")) { + source.next(); + // the T_DOUBLE_COLON can only follow a T_STRING (class name) + return {type: "t_double_colon", style: "php-operator"}; + } + // with punctuation, the type of the token is the symbol itself + else if (/[\[\]{}\(\),;:]/.test(ch)) { + return {type: ch, style: "php-punctuation"}; + } + else if (ch == "0" && (source.equals("x") || source.equals("X"))) + return readHexNumber(); + else if (/[0-9]/.test(ch)) + return readNumber(); + else if (ch == "/") { + if (source.equals("*")) + { source.next(); return readMultilineComment(ch); } + else if (source.equals("/")) + return readSingleLineComment(); + else + return readOperator(); + } + else if (ch == "<") { + if (source.lookAhead("<<", true)) { + setInside("<<<"); + return {type: "<<<", style: "php-punctuation"}; + } + else + return readOperator(); + } + else if (isOperatorChar.test(ch)) + return readOperator(); + else + return readWord(); + } + + // The external interface to the tokenizer. + return function(source, startState) { + return tokenizer(source, startState || phpTokenState(false, true)); + }; +})(); diff --git a/gulliver/js/codemirrorOld/contrib/plsql/LICENSE b/gulliver/js/codemirrorOld/contrib/plsql/LICENSE new file mode 100644 index 000000000..b9ae48b4d --- /dev/null +++ b/gulliver/js/codemirrorOld/contrib/plsql/LICENSE @@ -0,0 +1,22 @@ + Copyright (c) 2010 Peter Raganitsch + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any + damages arising from the use of this software. + + Permission is granted to anyone to use this software for any + purpose, including commercial applications, and to alter it and + redistribute it freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product + documentation would be appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must + not be misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source + distribution. + + Peter Raganitsch diff --git a/gulliver/js/codemirrorOld/contrib/plsql/css/plsqlcolors.css b/gulliver/js/codemirrorOld/contrib/plsql/css/plsqlcolors.css new file mode 100644 index 000000000..bc64c20b7 --- /dev/null +++ b/gulliver/js/codemirrorOld/contrib/plsql/css/plsqlcolors.css @@ -0,0 +1,57 @@ +html { + cursor: text; +} + +.editbox { + margin: .4em; + padding: 0; + font-family: monospace; + font-size: 10pt; + color: black; +} + +.editbox p { + margin: 0; +} + +span.plsql-keyword { + color: blue; +} + +span.plsql-var { + color: red; +} + +span.plsql-comment { + color: #AA7700; +} + +span.plsql-literal { + color: green; +} + +span.plsql-operator { + color: blue; +} + +span.plsql-word { + color: black; +} + +span.plsql-function { + color: darkorange; +} + +span.plsql-type { + color: purple; +} + +span.plsql-separator { + color: #666666; +} + +span.plsql-number { + color: darkcyan; +} + + diff --git a/gulliver/js/codemirrorOld/contrib/plsql/index.html b/gulliver/js/codemirrorOld/contrib/plsql/index.html new file mode 100644 index 000000000..5c8c14726 --- /dev/null +++ b/gulliver/js/codemirrorOld/contrib/plsql/index.html @@ -0,0 +1,67 @@ + + + + CodeMirror: PLSQL demonstration + + + + +

Demonstration of CodeMirror's PLSQL +highlighter.

+ +

Written by Peter Raganitsch (license), based +on John Benediktsson SQL parser.

+ +
+ +
+ + + + + diff --git a/gulliver/js/codemirrorOld/contrib/plsql/js/parseplsql.js b/gulliver/js/codemirrorOld/contrib/plsql/js/parseplsql.js new file mode 100644 index 000000000..cc35c8c1a --- /dev/null +++ b/gulliver/js/codemirrorOld/contrib/plsql/js/parseplsql.js @@ -0,0 +1,233 @@ +var PlsqlParser = Editor.Parser = (function() { + + function wordRegexp(words) { + return new RegExp("^(?:" + words.join("|") + ")$", "i"); + } + + var functions = wordRegexp([ +"abs","acos","add_months","ascii","asin","atan","atan2","average", +"bfilename", +"ceil","chartorowid","chr","concat","convert","cos","cosh","count", +"decode","deref","dual","dump","dup_val_on_index", +"empty","error","exp", +"false","floor","found", +"glb","greatest", +"hextoraw", +"initcap","instr","instrb","isopen", +"last_day","least","lenght","lenghtb","ln","lower","lpad","ltrim","lub", +"make_ref","max","min","mod","months_between", +"new_time","next_day","nextval","nls_charset_decl_len","nls_charset_id","nls_charset_name","nls_initcap","nls_lower", +"nls_sort","nls_upper","nlssort","no_data_found","notfound","null","nvl", +"others", +"power", +"rawtohex","reftohex","round","rowcount","rowidtochar","rpad","rtrim", +"sign","sin","sinh","soundex","sqlcode","sqlerrm","sqrt","stddev","substr","substrb","sum","sysdate", +"tan","tanh","to_char","to_date","to_label","to_multi_byte","to_number","to_single_byte","translate","true","trunc", +"uid","upper","user","userenv", +"variance","vsize" + + ]); + + var keywords = wordRegexp([ +"abort","accept","access","add","all","alter","and","any","array","arraylen","as","asc","assert","assign","at","attributes","audit", +"authorization","avg", +"base_table","begin","between","binary_integer","body","boolean","by", +"case","cast","char","char_base","check","close","cluster","clusters","colauth","column","comment","commit","compress","connect", +"connected","constant","constraint","crash","create","current","currval","cursor", +"data_base","database","date","dba","deallocate","debugoff","debugon","decimal","declare","default","definition","delay","delete", +"desc","digits","dispose","distinct","do","drop", +"else","elsif","enable","end","entry","escape","exception","exception_init","exchange","exclusive","exists","exit","external", +"fast","fetch","file","for","force","form","from","function", +"generic","goto","grant","group", +"having", +"identified","if","immediate","in","increment","index","indexes","indicator","initial","initrans","insert","interface","intersect", +"into","is", +"key", +"level","library","like","limited","local","lock","log","logging","long","loop", +"master","maxextents","maxtrans","member","minextents","minus","mislabel","mode","modify","multiset", +"new","next","no","noaudit","nocompress","nologging","noparallel","not","nowait","number_base", +"object","of","off","offline","on","online","only","open","option","or","order","out", +"package","parallel","partition","pctfree","pctincrease","pctused","pls_integer","positive","positiven","pragma","primary","prior", +"private","privileges","procedure","public", +"raise","range","raw","read","rebuild","record","ref","references","refresh","release","rename","replace","resource","restrict","return", +"returning","reverse","revoke","rollback","row","rowid","rowlabel","rownum","rows","run", +"savepoint","schema","segment","select","separate","session","set","share","snapshot","some","space","split","sql","start","statement", +"storage","subtype","successful","synonym", +"tabauth","table","tables","tablespace","task","terminate","then","to","trigger","truncate","type", +"union","unique","unlimited","unrecoverable","unusable","update","use","using", +"validate","value","values","variable","view","views", +"when","whenever","where","while","with","work" + ]); + + var types = wordRegexp([ +"bfile","blob", +"character","clob", +"dec", +"float", +"int","integer", +"mlslabel", +"natural","naturaln","nchar","nclob","number","numeric","nvarchar2", +"real","rowtype", +"signtype","smallint","string", +"varchar","varchar2" + ]); + + var operators = wordRegexp([ + ":=", "<", "<=", "==", "!=", "<>", ">", ">=", "like", "rlike", "in", "xor", "between" + ]); + + var operatorChars = /[*+\-<>=&|:\/]/; + + var tokenizeSql = (function() { + function normal(source, setState) { + var ch = source.next(); + if (ch == "@" || ch == "$") { + source.nextWhileMatches(/[\w\d]/); + return "plsql-var"; + } + else if (ch == "\"" || ch == "'" || ch == "`") { + setState(inLiteral(ch)); + return null; + } + else if (ch == "," || ch == ";") { + return "plsql-separator" + } + else if (ch == '-') { + if (source.peek() == "-") { + while (!source.endOfLine()) source.next(); + return "plsql-comment"; + } + else if (/\d/.test(source.peek())) { + source.nextWhileMatches(/\d/); + if (source.peek() == '.') { + source.next(); + source.nextWhileMatches(/\d/); + } + return "plsql-number"; + } + else + return "plsql-operator"; + } + else if (operatorChars.test(ch)) { + source.nextWhileMatches(operatorChars); + return "plsql-operator"; + } + else if (/\d/.test(ch)) { + source.nextWhileMatches(/\d/); + if (source.peek() == '.') { + source.next(); + source.nextWhileMatches(/\d/); + } + return "plsql-number"; + } + else if (/[()]/.test(ch)) { + return "plsql-punctuation"; + } + else { + source.nextWhileMatches(/[_\w\d]/); + var word = source.get(), type; + if (operators.test(word)) + type = "plsql-operator"; + else if (keywords.test(word)) + type = "plsql-keyword"; + else if (functions.test(word)) + type = "plsql-function"; + else if (types.test(word)) + type = "plsql-type"; + else + type = "plsql-word"; + return {style: type, content: word}; + } + } + + function inLiteral(quote) { + return function(source, setState) { + var escaped = false; + while (!source.endOfLine()) { + var ch = source.next(); + if (ch == quote && !escaped) { + setState(normal); + break; + } + escaped = !escaped && ch == "\\"; + } + return quote == "`" ? "plsql-word" : "plsql-literal"; + }; + } + + return function(source, startState) { + return tokenizer(source, startState || normal); + }; + })(); + + function indentSql(context) { + return function(nextChars) { + var firstChar = nextChars && nextChars.charAt(0); + var closing = context && firstChar == context.type; + if (!context) + return 0; + else if (context.align) + return context.col - (closing ? context.width : 0); + else + return context.indent + (closing ? 0 : indentUnit); + } + } + + function parseSql(source) { + var tokens = tokenizeSql(source); + var context = null, indent = 0, col = 0; + function pushContext(type, width, align) { + context = {prev: context, indent: indent, col: col, type: type, width: width, align: align}; + } + function popContext() { + context = context.prev; + } + + var iter = { + next: function() { + var token = tokens.next(); + var type = token.style, content = token.content, width = token.value.length; + + if (content == "\n") { + token.indentation = indentSql(context); + indent = col = 0; + if (context && context.align == null) context.align = false; + } + else if (type == "whitespace" && col == 0) { + indent = width; + } + else if (!context && type != "plsql-comment") { + pushContext(";", 0, false); + } + + if (content != "\n") col += width; + + if (type == "plsql-punctuation") { + if (content == "(") + pushContext(")", width); + else if (content == ")") + popContext(); + } + else if (type == "plsql-separator" && content == ";" && context && !context.prev) { + popContext(); + } + + return token; + }, + + copy: function() { + var _context = context, _indent = indent, _col = col, _tokenState = tokens.state; + return function(source) { + tokens = tokenizeSql(source, _tokenState); + context = _context; + indent = _indent; + col = _col; + return iter; + }; + } + }; + return iter; + } + + return {make: parseSql, electricChars: ")"}; +})(); diff --git a/gulliver/js/codemirrorOld/contrib/python/LICENSE b/gulliver/js/codemirrorOld/contrib/python/LICENSE new file mode 100644 index 000000000..9512de2ef --- /dev/null +++ b/gulliver/js/codemirrorOld/contrib/python/LICENSE @@ -0,0 +1,32 @@ +Copyright (c) 2009, Timothy Farrell +All rights reserved. + +This software is provided for use in connection with the +CodeMirror suite of modules and utilities, hosted and maintained +at http://codemirror.net/. + +Redistribution and use of this software in source and binary forms, +with or without modification, are permitted provided that the +following conditions are met: + +* Redistributions of source code must retain the above + copyright notice, this list of conditions and the + following disclaimer. + +* Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the + following disclaimer in the documentation and/or other + materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. diff --git a/gulliver/js/codemirrorOld/contrib/python/css/pythoncolors.css b/gulliver/js/codemirrorOld/contrib/python/css/pythoncolors.css new file mode 100644 index 000000000..fb9cea4b2 --- /dev/null +++ b/gulliver/js/codemirrorOld/contrib/python/css/pythoncolors.css @@ -0,0 +1,58 @@ +html { + cursor: text; +} + +.editbox { + padding: .4em; + margin: 0; + font-family: monospace; + font-size: 10pt; + line-height: 1.1em; + color: black; +} + +pre.code, .editbox { + color: #666666; +} + +.editbox p { + margin: 0; +} + +span.py-delimiter, span.py-special { + color: #666666; +} + +span.py-operator { + color: #666666; +} + +span.py-error { + background-color: #660000; + color: #FFFFFF; +} + +span.py-keyword { + color: #770088; + font-weight: bold; +} + +span.py-literal { + color: #228811; +} + +span.py-identifier, span.py-func { + color: black; +} + +span.py-type, span.py-decorator { + color: #0000FF; +} + +span.py-comment { + color: #AA7700; +} + +span.py-string, span.py-bytes, span.py-raw, span.py-unicode { + color: #AA2222; +} diff --git a/gulliver/js/codemirrorOld/contrib/python/index.html b/gulliver/js/codemirrorOld/contrib/python/index.html new file mode 100644 index 000000000..28af80dd3 --- /dev/null +++ b/gulliver/js/codemirrorOld/contrib/python/index.html @@ -0,0 +1,141 @@ + + + + CodeMirror: Python demonstration + + + +

+ This is a simple demonstration of the Python syntax highlighting module + for CodeMirror. +

+

+ Features of this parser include: +

+ +

Written by Timothy Farrell (license). Special +thanks to Adam Brand and Marijn Haverbeke for their help in debugging +and providing for this parser.

+ +
+ +
+ + + + diff --git a/gulliver/js/codemirrorOld/contrib/python/js/parsepython.js b/gulliver/js/codemirrorOld/contrib/python/js/parsepython.js new file mode 100644 index 000000000..787703db0 --- /dev/null +++ b/gulliver/js/codemirrorOld/contrib/python/js/parsepython.js @@ -0,0 +1,541 @@ +var PythonParser = Editor.Parser = (function() { + function wordRegexp(words) { + return new RegExp("^(?:" + words.join("|") + ")$"); + } + var DELIMITERCLASS = 'py-delimiter'; + var LITERALCLASS = 'py-literal'; + var ERRORCLASS = 'py-error'; + var OPERATORCLASS = 'py-operator'; + var IDENTIFIERCLASS = 'py-identifier'; + var STRINGCLASS = 'py-string'; + var BYTESCLASS = 'py-bytes'; + var UNICODECLASS = 'py-unicode'; + var RAWCLASS = 'py-raw'; + var NORMALCONTEXT = 'normal'; + var STRINGCONTEXT = 'string'; + var singleOperators = '+-*/%&|^~<>'; + var doubleOperators = wordRegexp(['==', '!=', '\\<=', '\\>=', '\\<\\>', + '\\<\\<', '\\>\\>', '\\/\\/', '\\*\\*']); + var singleDelimiters = '()[]{}@,:`=;'; + var doubleDelimiters = ['\\+=', '\\-=', '\\*=', '/=', '%=', '&=', '\\|=', + '\\^=']; + var tripleDelimiters = wordRegexp(['//=','\\>\\>=','\\<\\<=','\\*\\*=']); + var singleStarters = singleOperators + singleDelimiters + '=!'; + var doubleStarters = '=<>*/'; + var identifierStarters = /[_A-Za-z]/; + + var wordOperators = wordRegexp(['and', 'or', 'not', 'is', 'in']); + var commonkeywords = ['as', 'assert', 'break', 'class', 'continue', + 'def', 'del', 'elif', 'else', 'except', 'finally', + 'for', 'from', 'global', 'if', 'import', + 'lambda', 'pass', 'raise', 'return', + 'try', 'while', 'with', 'yield']; + var commontypes = ['bool', 'classmethod', 'complex', 'dict', 'enumerate', + 'float', 'frozenset', 'int', 'list', 'object', + 'property', 'reversed', 'set', 'slice', 'staticmethod', + 'str', 'super', 'tuple', 'type']; + var py2 = {'types': ['basestring', 'buffer', 'file', 'long', 'unicode', + 'xrange'], + 'keywords': ['exec', 'print'], + 'version': 2 }; + var py3 = {'types': ['bytearray', 'bytes', 'filter', 'map', 'memoryview', + 'open', 'range', 'zip'], + 'keywords': ['nonlocal'], + 'version': 3}; + + var py, keywords, types, stringStarters, stringTypes, config; + + function configure(conf) { + if (!conf.hasOwnProperty('pythonVersion')) { + conf.pythonVersion = 2; + } + if (!conf.hasOwnProperty('strictErrors')) { + conf.strictErrors = true; + } + if (conf.pythonVersion != 2 && conf.pythonVersion != 3) { + alert('CodeMirror: Unknown Python Version "' + + conf.pythonVersion + + '", defaulting to Python 2.x.'); + conf.pythonVersion = 2; + } + if (conf.pythonVersion == 3) { + py = py3; + stringStarters = /[\'\"rbRB]/; + stringTypes = /[rb]/; + doubleDelimiters.push('\\-\\>'); + } else { + py = py2; + stringStarters = /[\'\"RUru]/; + stringTypes = /[ru]/; + } + config = conf; + keywords = wordRegexp(commonkeywords.concat(py.keywords)); + types = wordRegexp(commontypes.concat(py.types)); + doubleDelimiters = wordRegexp(doubleDelimiters); + } + + var tokenizePython = (function() { + function normal(source, setState) { + var stringDelim, threeStr, temp, type, word, possible = {}; + var ch = source.next(); + + function filterPossible(token, styleIfPossible) { + if (!possible.style && !possible.content) { + return token; + } else if (typeof(token) == STRINGCONTEXT) { + token = {content: source.get(), style: token}; + } + if (possible.style || styleIfPossible) { + token.style = styleIfPossible ? styleIfPossible : possible.style; + } + if (possible.content) { + token.content = possible.content + token.content; + } + possible = {}; + return token; + } + + // Handle comments + if (ch == '#') { + while (!source.endOfLine()) { + source.next(); + } + return 'py-comment'; + } + // Handle special chars + if (ch == '\\') { + if (!source.endOfLine()) { + var whitespace = true; + while (!source.endOfLine()) { + if(!(/[\s\u00a0]/.test(source.next()))) { + whitespace = false; + } + } + if (!whitespace) { + return ERRORCLASS; + } + } + return 'py-special'; + } + // Handle operators and delimiters + if (singleStarters.indexOf(ch) != -1 || (ch == "." && !source.matches(/\d/))) { + if (doubleStarters.indexOf(source.peek()) != -1) { + temp = ch + source.peek(); + // It must be a double delimiter or operator or triple delimiter + if (doubleOperators.test(temp)) { + source.next(); + var nextChar = source.peek(); + if (nextChar && tripleDelimiters.test(temp + nextChar)) { + source.next(); + return DELIMITERCLASS; + } else { + return OPERATORCLASS; + } + } else if (doubleDelimiters.test(temp)) { + source.next(); + return DELIMITERCLASS; + } + } + // It must be a single delimiter or operator + if (singleOperators.indexOf(ch) != -1 || ch == ".") { + return OPERATORCLASS; + } else if (singleDelimiters.indexOf(ch) != -1) { + if (ch == '@' && source.matches(/\w/)) { + source.nextWhileMatches(/[\w\d_]/); + return {style:'py-decorator', + content: source.get()}; + } else { + return DELIMITERCLASS; + } + } else { + return ERRORCLASS; + } + } + // Handle number literals + if (/\d/.test(ch) || (ch == "." && source.matches(/\d/))) { + if (ch === '0' && !source.endOfLine()) { + switch (source.peek()) { + case 'o': + case 'O': + source.next(); + source.nextWhileMatches(/[0-7]/); + return filterPossible(LITERALCLASS, ERRORCLASS); + case 'x': + case 'X': + source.next(); + source.nextWhileMatches(/[0-9A-Fa-f]/); + return filterPossible(LITERALCLASS, ERRORCLASS); + case 'b': + case 'B': + source.next(); + source.nextWhileMatches(/[01]/); + return filterPossible(LITERALCLASS, ERRORCLASS); + } + } + source.nextWhileMatches(/\d/); + if (ch != '.' && source.peek() == '.') { + source.next(); + source.nextWhileMatches(/\d/); + } + // Grab an exponent + if (source.matches(/e/i)) { + source.next(); + if (source.peek() == '+' || source.peek() == '-') { + source.next(); + } + if (source.matches(/\d/)) { + source.nextWhileMatches(/\d/); + } else { + return filterPossible(ERRORCLASS); + } + } + // Grab a complex number + if (source.matches(/j/i)) { + source.next(); + } + + return filterPossible(LITERALCLASS); + } + // Handle strings + if (stringStarters.test(ch)) { + var peek = source.peek(); + var stringType = STRINGCLASS; + if ((stringTypes.test(ch)) && (peek == '"' || peek == "'")) { + switch (ch.toLowerCase()) { + case 'b': + stringType = BYTESCLASS; + break; + case 'r': + stringType = RAWCLASS; + break; + case 'u': + stringType = UNICODECLASS; + break; + } + ch = source.next(); + stringDelim = ch; + if (source.peek() != stringDelim) { + setState(inString(stringType, stringDelim)); + return null; + } else { + source.next(); + if (source.peek() == stringDelim) { + source.next(); + threeStr = stringDelim + stringDelim + stringDelim; + setState(inString(stringType, threeStr)); + return null; + } else { + return stringType; + } + } + } else if (ch == "'" || ch == '"') { + stringDelim = ch; + if (source.peek() != stringDelim) { + setState(inString(stringType, stringDelim)); + return null; + } else { + source.next(); + if (source.peek() == stringDelim) { + source.next(); + threeStr = stringDelim + stringDelim + stringDelim; + setState(inString(stringType, threeStr)); + return null; + } else { + return stringType; + } + } + } + } + // Handle Identifier + if (identifierStarters.test(ch)) { + source.nextWhileMatches(/[\w\d_]/); + word = source.get(); + if (wordOperators.test(word)) { + type = OPERATORCLASS; + } else if (keywords.test(word)) { + type = 'py-keyword'; + } else if (types.test(word)) { + type = 'py-type'; + } else { + type = IDENTIFIERCLASS; + while (source.peek() == '.') { + source.next(); + if (source.matches(identifierStarters)) { + source.nextWhileMatches(/[\w\d]/); + } else { + type = ERRORCLASS; + break; + } + } + word = word + source.get(); + } + return filterPossible({style: type, content: word}); + } + + // Register Dollar sign and Question mark as errors. Always! + if (/\$\?/.test(ch)) { + return filterPossible(ERRORCLASS); + } + + return filterPossible(ERRORCLASS); + } + + function inString(style, terminator) { + return function(source, setState) { + var matches = []; + var found = false; + while (!found && !source.endOfLine()) { + var ch = source.next(), newMatches = []; + // Skip escaped characters + if (ch == '\\') { + if (source.peek() == '\n') { + break; + } + ch = source.next(); + } + if (ch == terminator.charAt(0)) { + matches.push(terminator); + } + for (var i = 0; i < matches.length; i++) { + var match = matches[i]; + if (match.charAt(0) == ch) { + if (match.length == 1) { + setState(normal); + found = true; + break; + } else { + newMatches.push(match.slice(1)); + } + } + } + matches = newMatches; + } + return style; + }; + } + + return function(source, startState) { + return tokenizer(source, startState || normal); + }; + })(); + + function parsePython(source, basecolumn) { + if (!keywords) { + configure({}); + } + basecolumn = basecolumn || 0; + + var tokens = tokenizePython(source); + var lastToken = null; + var column = basecolumn; + var context = {prev: null, + endOfScope: false, + startNewScope: false, + level: basecolumn, + next: null, + type: NORMALCONTEXT + }; + + function pushContext(level, type) { + type = type ? type : NORMALCONTEXT; + context = {prev: context, + endOfScope: false, + startNewScope: false, + level: level, + next: null, + type: type + }; + } + + function popContext(remove) { + remove = remove ? remove : false; + if (context.prev) { + if (remove) { + context = context.prev; + context.next = null; + } else { + context.prev.next = context; + context = context.prev; + } + } + } + + function indentPython(context) { + var temp; + return function(nextChars, currentLevel, direction) { + if (direction === null || direction === undefined) { + if (nextChars) { + while (context.next) { + context = context.next; + } + } + return context.level; + } + else if (direction === true) { + if (currentLevel == context.level) { + if (context.next) { + return context.next.level; + } else { + return context.level; + } + } else { + temp = context; + while (temp.prev && temp.prev.level > currentLevel) { + temp = temp.prev; + } + return temp.level; + } + } else if (direction === false) { + if (currentLevel > context.level) { + return context.level; + } else if (context.prev) { + temp = context; + while (temp.prev && temp.prev.level >= currentLevel) { + temp = temp.prev; + } + if (temp.prev) { + return temp.prev.level; + } else { + return temp.level; + } + } + } + return context.level; + }; + } + + var iter = { + next: function() { + var token = tokens.next(); + var type = token.style; + var content = token.content; + + if (lastToken) { + if (lastToken.content == 'def' && type == IDENTIFIERCLASS) { + token.style = 'py-func'; + } + if (lastToken.content == '\n') { + var tempCtx = context; + // Check for a different scope + if (type == 'whitespace' && context.type == NORMALCONTEXT) { + if (token.value.length < context.level) { + while (token.value.length < context.level) { + popContext(); + } + + if (token.value.length != context.level) { + context = tempCtx; + if (config.strictErrors) { + token.style = ERRORCLASS; + } + } else { + context.next = null; + } + } + } else if (context.level !== basecolumn && + context.type == NORMALCONTEXT) { + while (basecolumn !== context.level) { + popContext(); + } + + if (context.level !== basecolumn) { + context = tempCtx; + if (config.strictErrors) { + token.style = ERRORCLASS; + } + } + } + } + } + + // Handle Scope Changes + switch(type) { + case STRINGCLASS: + case BYTESCLASS: + case RAWCLASS: + case UNICODECLASS: + if (context.type !== STRINGCONTEXT) { + pushContext(context.level + 1, STRINGCONTEXT); + } + break; + default: + if (context.type === STRINGCONTEXT) { + popContext(true); + } + break; + } + switch(content) { + case '.': + case '@': + // These delimiters don't appear by themselves + if (content !== token.value) { + token.style = ERRORCLASS; + } + break; + case ':': + // Colons only delimit scope inside a normal scope + if (context.type === NORMALCONTEXT) { + context.startNewScope = context.level+indentUnit; + } + break; + case '(': + case '[': + case '{': + // These start a sequence scope + pushContext(column + content.length, 'sequence'); + break; + case ')': + case ']': + case '}': + // These end a sequence scope + popContext(true); + break; + case 'pass': + case 'return': + // These end a normal scope + if (context.type === NORMALCONTEXT) { + context.endOfScope = true; + } + break; + case '\n': + // Reset our column + column = basecolumn; + // Make any scope changes + if (context.endOfScope) { + context.endOfScope = false; + popContext(); + } else if (context.startNewScope !== false) { + var temp = context.startNewScope; + context.startNewScope = false; + pushContext(temp, NORMALCONTEXT); + } + // Newlines require an indentation function wrapped in a closure for proper context. + token.indentation = indentPython(context); + break; + } + + // Keep track of current column for certain scopes. + if (content != '\n') { + column += token.value.length; + } + + lastToken = token; + return token; + }, + + copy: function() { + var _context = context, _tokenState = tokens.state; + return function(source) { + tokens = tokenizePython(source, _tokenState); + context = _context; + return iter; + }; + } + }; + return iter; + } + + return {make: parsePython, + electricChars: "", + configure: configure}; +})(); diff --git a/gulliver/js/codemirrorOld/contrib/regex/css/js-regexcolors.css b/gulliver/js/codemirrorOld/contrib/regex/css/js-regexcolors.css new file mode 100644 index 000000000..1fa691db5 --- /dev/null +++ b/gulliver/js/codemirrorOld/contrib/regex/css/js-regexcolors.css @@ -0,0 +1,214 @@ +/*///////////////////////////////*/ +html { + cursor: text; +} +.editbox { + margin: .4em; + padding: 0; + font-family: monospace; + font-size: 10pt; + color: black; +} +.editbox p { + margin: 0; +} + +html, body { +background: #cccccc !important; +} + +/*///////////////////////////////*/ +/* Inside character classes */ +span.regex-class-special-escape { + color: Coral; +} +span.regex-class-begin, span.regex-class-end { + color: YellowGreen; +} +span.regex-class-negator { + color: Wheat; +} +span.regex-class-range-hyphen { + color: Turquoise; +} +span.regex-class-final-hyphen { + color: Violet; +} + +/*///////////////////////////////*/ +/* Inside character classes (suffixable by -begin-range or -end-range if beginning or ending a range) */ +span.regex-unicode-class-inside { + color: Tomato; +} +span.regex-class-initial-hyphen { + color: Teal; +} +span.regex-class-character { + color: Tan; +} +span.regex-class-octal { + color: SteelBlue; +} +span.regex-class-hex { + color: SpringGreen; +} +span.regex-class-unicode-escape { + color: SlateGray; +} +span.regex-class-ascii-control { + color: SlateBlue; +} +span.regex-class-extra-escaped { + color: SkyBlue; +} +span.regex-class-escaped-special { + color: CornflowerBlue; +} + +/*///////////////////////////////*/ +span.class-special-escape-begin-range, span.class-special-escape-end-range { + color: Brown; +} +span.regex-unicode-class-inside-begin-range, span.regex-unicode-class-inside-end-range { + color: Silver; +} +span.regex-class-initial-hyphen-begin-range, span.regex-class-initial-hyphen-end-range { + color: SeaGreen; +} +span.regex-class-character-begin-range, span.regex-class-character-end-range { + color: SandyBrown; +} +span.regex-class-octal-begin-range, span.regex-class-octal-end-range { + color: Salmon; +} +span.regex-class-hex-begin-range, span.regex-class-hex-end-range { + color: SaddleBrown; +} +span.regex-class-unicode-escape-begin-range, span.regex-class-unicode-escape-end-range { + color: RoyalBlue; +} +span.regex-class-ascii-control-begin-range, span.regex-class-ascii-control-end-range { + color: RosyBrown; +} +span.regex-class-extra-escaped-begin-range, span.regex-class-extra-escaped-end-range { + color: Orange; +} +span.regex-class-escaped-special-begin-range, span.regex-class-escaped-special-end-range { + color: DarkKhaki; +} + + +/*///////////////////////////////*/ +/* Outside character classes */ +span.regex-special-escape { + color: Chocolate; +} +span.regex-escaped-special { + color: Orange; +} +span.regex-alternator { + color: darkpink; +} +span.regex-unicode-class-outside { + color: Green; +} +span.regex-octal { + color: MediumVioletRed; +} +span.regex-ascii { + color: MediumTurquoise; +} +span.regex-hex { + color: MediumSpringGreen; +} +span.regex-unicode-escape { + color:pink; +} +span.regex-ascii-control { + color: MediumSlateBlue; +} +span.regex-extra-escaped { + color: MediumSeaGreen; +} +span.regex-quantifier-escape { + color: Azure; +} +span.regex-quantifiers { + color: MediumPurple; +} +span.regex-repetition { + color: MediumOrchid; +} +span.regex-literal-begin, span.regex-literal-end { + color: MediumBlue; +} +span.regex-character { + color: Navy; +} + +/*///////////////////////////////*/ +/* Literals/Surrounding characters */ +span.regex-flags { + color: Green; +} + +/*///////////////////////////////*/ +/* Optional outside character class features*/ +span.regex-empty-class { + color: Lime; +} +span.regex-named-backreference { + color: LightSlateGray; +} +span.regex-free-spacing-mode { + background-color: LightSeaGreen; +} +span.regex-mode-modifier { + color: LightSalmon; +} +span.regex-comment-pattern { + color: LightGreen; +} +span.regex-capturing-group, span.regex-ending-capturing-group { + color: LightGray; +} +span.regex-named-capturing-group, span.regex-ending-named-capturing-group { + color: LightCoral; +} +span.regex-group, span.regex-ending-group { + color: LawnGreen; +} + + +span.regex-capturing-group1-1, span.regex-ending-capturing-group1-1 { + background-color: red; +} +span.regex-capturing-group1-2, span.regex-ending-capturing-group1-2 { + background-color: orange; +} +span.regex-capturing-group2-1, span.regex-ending-capturing-group2-1 { + background-color: yellow; +} +span.regex-capturing-group2-2, span.regex-ending-capturing-group2-2 { + background-color: green; +} + +/*///////////////////////////////*/ +/* Closing parentheses without opening, etc. */ +span.regex-bad-character, span.regex-bad-sequence { + color: red; +} + +/* Used if "uniform" inner_group_mode is used */ +span.regex-group-1-1 { + background-color: blue; +} +span.regex-group-1-2 { + background-color: green; +} +span.regex-group-2-1 { + background-color: pink; +} +span.regex-group-2-2 { + background-color: yellow; +} diff --git a/gulliver/js/codemirrorOld/contrib/regex/css/regexcolors.css b/gulliver/js/codemirrorOld/contrib/regex/css/regexcolors.css new file mode 100644 index 000000000..49ae6e91d --- /dev/null +++ b/gulliver/js/codemirrorOld/contrib/regex/css/regexcolors.css @@ -0,0 +1,214 @@ +/*///////////////////////////////*/ +html { + cursor: text; +} +.editbox { + margin: .4em; + padding: 0; + font-family: monospace; + font-size: 10pt; + color: black; +} +.editbox p { + margin: 0; +} + +html, body { +background: #555555 !important; +} + +/*///////////////////////////////*/ +/* Inside character classes */ +span.regex-class-special-escape { + color: Coral; +} +span.regex-class-begin, span.regex-class-end { + color: YellowGreen; +} +span.regex-class-negator { + color: Wheat; +} +span.regex-class-range-hyphen { + color: Turquoise; +} +span.regex-class-final-hyphen { + color: Violet; +} + +/*///////////////////////////////*/ +/* Inside character classes (suffixable by -begin-range or -end-range if beginning or ending a range) */ +span.regex-unicode-class-inside { + color: Tomato; +} +span.regex-class-initial-hyphen { + color: Teal; +} +span.regex-class-character { + color: Tan; +} +span.regex-class-octal { + color: SteelBlue; +} +span.regex-class-hex { + color: SpringGreen; +} +span.regex-class-unicode-escape { + color: LightGray; +} +span.regex-class-ascii-control { + color: SlateBlue; +} +span.regex-class-extra-escaped { + color: SkyBlue; +} +span.regex-class-escaped-special { + color: CornflowerBlue; +} + +/*///////////////////////////////*/ +span.class-special-escape-begin-range, span.class-special-escape-end-range { + color: Brown; +} +span.regex-unicode-class-inside-begin-range, span.regex-unicode-class-inside-end-range { + color: Silver; +} +span.regex-class-initial-hyphen-begin-range, span.regex-class-initial-hyphen-end-range { + color: SeaGreen; +} +span.regex-class-character-begin-range, span.regex-class-character-end-range { + color: SandyBrown; +} +span.regex-class-octal-begin-range, span.regex-class-octal-end-range { + color: Salmon; +} +span.regex-class-hex-begin-range, span.regex-class-hex-end-range { + color: Tan; +} +span.regex-class-unicode-escape-begin-range, span.regex-class-unicode-escape-end-range { + color: LightBlue; +} +span.regex-class-ascii-control-begin-range, span.regex-class-ascii-control-end-range { + color: RosyBrown; +} +span.regex-class-extra-escaped-begin-range, span.regex-class-extra-escaped-end-range { + color: Orange; +} +span.regex-class-escaped-special-begin-range, span.regex-class-escaped-special-end-range { + color: DarkKhaki; +} + + +/*///////////////////////////////*/ +/* Outside character classes */ +span.regex-special-escape { + color: Chocolate; +} +span.regex-escaped-special { + color: Orange; +} +span.regex-alternator { + color: BurlyWood; +} +span.regex-unicode-class-outside { + color: Gold; +} +span.regex-octal { + color: MediumVioletRed; +} +span.regex-ascii { + color: MediumTurquoise; +} +span.regex-hex { + color: MediumSpringGreen; +} +span.regex-unicode-escape { + color:pink; +} +span.regex-ascii-control { + color: MediumSlateBlue; +} +span.regex-extra-escaped { + color: MediumSeaGreen; +} +span.regex-quantifier-escape { + color: Azure; +} +span.regex-quantifiers { + color: MediumPurple; +} +span.regex-repetition { + color: MediumOrchid; +} +span.regex-literal-begin, span.regex-literal-end { + color: MediumBlue; +} +span.regex-character { + color: #FFFFAA; +} + +/*///////////////////////////////*/ +/* Literals/Surrounding characters */ +span.regex-flags { + color: LimeGreen; +} + +/*///////////////////////////////*/ +/* Optional outside character class features*/ +span.regex-empty-class { + color: Lime; +} +span.regex-named-backreference { + color: LightSlateGray; +} +span.regex-free-spacing-mode { + background-color: LightSeaGreen; +} +span.regex-mode-modifier { + color: LightSalmon; +} +span.regex-comment-pattern { + color: LightGreen; +} +span.regex-capturing-group, span.regex-ending-capturing-group { + color: LightGray; +} +span.regex-named-capturing-group, span.regex-ending-named-capturing-group { + color: LightCoral; +} +span.regex-group, span.regex-ending-group { + color: LawnGreen; +} + + +span.regex-capturing-group1-1, span.regex-ending-capturing-group1-1 { + background-color: red; +} +span.regex-capturing-group1-2, span.regex-ending-capturing-group1-2 { + background-color: orange; +} +span.regex-capturing-group2-1, span.regex-ending-capturing-group2-1 { + background-color: yellow; +} +span.regex-capturing-group2-2, span.regex-ending-capturing-group2-2 { + background-color: green; +} + +/*///////////////////////////////*/ +/* Closing parentheses without opening, etc. */ +span.regex-bad-character, span.regex-bad-sequence { + color: red; +} + +/* Used if "uniform" inner_group_mode is used */ +span.regex-group-1-1 { + color: lightblue; +} +span.regex-group-1-2 { + color: lightgreen; +} +span.regex-group-2-1 { + color: pink; +} +span.regex-group-2-2 { + color: yellow; +} diff --git a/gulliver/js/codemirrorOld/contrib/regex/index.html b/gulliver/js/codemirrorOld/contrib/regex/index.html new file mode 100644 index 000000000..6b9d996a2 --- /dev/null +++ b/gulliver/js/codemirrorOld/contrib/regex/index.html @@ -0,0 +1,114 @@ + + + +CodeMirror Regex Highlighting + + + + + +
+

CodeMirror Regex Code Editor Demonstration

+

The Regex parser for CodeMirror allows syntax coloring on regular expressions with some beginning customizability by + Regex flavor/language. For integrating styling of regular expression literals into JavaScript syntax highlighting, see this + JavaScript+Regex Demo.

+

Styling ability is fine-grained, so any token should be distinctly stylable if so desired. Parenthetical groups can + be styled with the same styles for inner content, and the script also enables styling by nesting depth and sequence, + including by imposing a limit such that styles will alternate.

+

Information can also be passed on (especially when the parseregex-unicode.js file is included) for use in CodeMirror's + activeTokens argument such as demonstrated below by tooltips which show which characters are present in a given + range or Unicode class.

+

Note that this editor does not support free-spacing mode, so it is not recommended to use multiple lines for input, but + for demonstration purposes, multiple lines are shown.

+ + +
+ + diff --git a/gulliver/js/codemirrorOld/contrib/regex/js-regex.html b/gulliver/js/codemirrorOld/contrib/regex/js-regex.html new file mode 100644 index 000000000..9940f2734 --- /dev/null +++ b/gulliver/js/codemirrorOld/contrib/regex/js-regex.html @@ -0,0 +1,118 @@ + + + +CodeMirror Regex Highlighting + + + + + +
+

CodeMirror JavaScript-Integrated Regex Code Editor Demonstration

+

This demonstrates a parser in the regex folder which wraps the regular CodeMirror JavaScript editor and adds syntax coloring to + regular expression literals in JavaScript.

+ + +

While the above styles by depth or sequence no matter the grouping type, this parser also allows styling distinctly by grouping type (capturing, named, non-capturing), while also still allowing alternating of colors within a type.

+ +

One may also simply turn off the styling of content inside groups, allowing only individual tokens to be styled per the stylesheet (though the parentheses tokens themselves can still indicate depth or sequence):

+ +
+ + diff --git a/gulliver/js/codemirrorOld/contrib/regex/js/parsejavascript_and_regex.js b/gulliver/js/codemirrorOld/contrib/regex/js/parsejavascript_and_regex.js new file mode 100644 index 000000000..6a63d0d98 --- /dev/null +++ b/gulliver/js/codemirrorOld/contrib/regex/js/parsejavascript_and_regex.js @@ -0,0 +1,91 @@ +// See the dependencies parsejavascript.js and parseregex.js (optionally with parseregex-unicode.js) for options + +var JSAndRegexParser = Editor.Parser = (function() { + // Parser + var run = function () {}, + regexParser, jsParser, lastRegexSrc, + regexPG = {}, jsPG = {}; + + function simpleStream (s) { + var str = s, pos = 0; + return { + next : function () { + if (pos >= str.length) { + throw StopIteration; + } + return str.charAt(pos++); + } + }; + } + + function regex () { + var token; + try { + token = regexParser.next(); + } + catch(e) { + _setState(js); + return js(); + } + _setState(regex); + return token; + } + function js () { + var token = jsParser.next(); + if (token.type === 'regexp') { + lastRegexSrc = stringStream(simpleStream(token.content)); + regexParser = RegexParser.make(lastRegexSrc); + return regex(); + } + return token; + } + + function _setState (func) { + run = func; + } + + function parseJSAndRegex (stream, basecolumn) { + JSParser.configure(jsPG); + RegexParser.configure(regexPG); + jsParser = JSParser.make(stream, basecolumn); + _setState(js); + + var iter = { + next: function() { + return run(stream); + }, + copy: function() { + var _run = run, _lastRegexSrc = lastRegexSrc, + _jsParser = jsParser.copy(), + _regexParser = regexParser && regexParser.copy(); + + return function (_stream) { + stream = _stream; + jsParser = _jsParser(_stream); + regexParser = _regexParser && _regexParser(_lastRegexSrc); + run = _run; + return iter; + }; + } + }; + return iter; + } + + // Parser object + return { + make: parseJSAndRegex, + configure: function (parserConfig) { + for (var opt in parserConfig) { + if ((/^regex_/).test(opt)) { + regexPG[opt.replace(/^regex_/, '')] = parserConfig[opt]; + } + else { // Doesn't need a js- prefix, but we'll strip if it does + jsPG[opt.replace(/^js_/, '')] = parserConfig[opt]; + } + } + regexPG.flavor = regexPG.flavor || 'ecma-262-ed3'; // Allow ed5, etc. if specified + regexPG.literal = true; // This is only for literals, since can't easily detect whether will be used for RegExp + regexPG.literal_initial = '/'; // Ensure it's always this for JavaScript regex literals + } + }; +})(); diff --git a/gulliver/js/codemirrorOld/contrib/regex/js/parseregex-unicode.js b/gulliver/js/codemirrorOld/contrib/regex/js/parseregex-unicode.js new file mode 100644 index 000000000..583a4f195 --- /dev/null +++ b/gulliver/js/codemirrorOld/contrib/regex/js/parseregex-unicode.js @@ -0,0 +1,284 @@ + /* + * Note: To include Unicode validation, you must include your CodeMirror parserfile option in this sequence: + * parserfile: ["parseregex.js", "parseregex-unicode.js"] +*/ +(function () { + + +// Fix: Add non-BMP code points + +var UnicodeCategories = { + C: "0000-001F007F-009F00AD03780379037F-0383038B038D03A20526-05300557055805600588058B-059005C8-05CF05EB-05EF05F5-0605061C061D0620065F06DD070E070F074B074C07B2-07BF07FB-07FF082E082F083F-08FF093A093B094F095609570973-097809800984098D098E0991099209A909B109B3-09B509BA09BB09C509C609C909CA09CF-09D609D8-09DB09DE09E409E509FC-0A000A040A0B-0A0E0A110A120A290A310A340A370A3A0A3B0A3D0A43-0A460A490A4A0A4E-0A500A52-0A580A5D0A5F-0A650A76-0A800A840A8E0A920AA90AB10AB40ABA0ABB0AC60ACA0ACE0ACF0AD1-0ADF0AE40AE50AF00AF2-0B000B040B0D0B0E0B110B120B290B310B340B3A0B3B0B450B460B490B4A0B4E-0B550B58-0B5B0B5E0B640B650B72-0B810B840B8B-0B8D0B910B96-0B980B9B0B9D0BA0-0BA20BA5-0BA70BAB-0BAD0BBA-0BBD0BC3-0BC50BC90BCE0BCF0BD1-0BD60BD8-0BE50BFB-0C000C040C0D0C110C290C340C3A-0C3C0C450C490C4E-0C540C570C5A-0C5F0C640C650C70-0C770C800C810C840C8D0C910CA90CB40CBA0CBB0CC50CC90CCE-0CD40CD7-0CDD0CDF0CE40CE50CF00CF3-0D010D040D0D0D110D290D3A-0D3C0D450D490D4E-0D560D58-0D5F0D640D650D76-0D780D800D810D840D97-0D990DB20DBC0DBE0DBF0DC7-0DC90DCB-0DCE0DD50DD70DE0-0DF10DF5-0E000E3B-0E3E0E5C-0E800E830E850E860E890E8B0E8C0E8E-0E930E980EA00EA40EA60EA80EA90EAC0EBA0EBE0EBF0EC50EC70ECE0ECF0EDA0EDB0EDE-0EFF0F480F6D-0F700F8C-0F8F0F980FBD0FCD0FD9-0FFF10C6-10CF10FD-10FF1249124E124F12571259125E125F1289128E128F12B112B612B712BF12C112C612C712D7131113161317135B-135E137D-137F139A-139F13F5-13FF169D-169F16F1-16FF170D1715-171F1737-173F1754-175F176D17711774-177F17B417B517DE17DF17EA-17EF17FA-17FF180F181A-181F1878-187F18AB-18AF18F6-18FF191D-191F192C-192F193C-193F1941-1943196E196F1975-197F19AC-19AF19CA-19CF19DB-19DD1A1C1A1D1A5F1A7D1A7E1A8A-1A8F1A9A-1A9F1AAE-1AFF1B4C-1B4F1B7D-1B7F1BAB-1BAD1BBA-1BFF1C38-1C3A1C4A-1C4C1C80-1CCF1CF3-1CFF1DE7-1DFC1F161F171F1E1F1F1F461F471F4E1F4F1F581F5A1F5C1F5E1F7E1F7F1FB51FC51FD41FD51FDC1FF01FF11FF51FFF200B-200F202A-202E2060-206F20722073208F2095-209F20B9-20CF20F1-20FF218A-218F23E9-23FF2427-243F244B-245F26CE26E226E4-26E727002705270A270B2728274C274E2753-2755275F27602795-279727B027BF27CB27CD-27CF2B4D-2B4F2B5A-2BFF2C2F2C5F2CF2-2CF82D26-2D2F2D66-2D6E2D70-2D7F2D97-2D9F2DA72DAF2DB72DBF2DC72DCF2DD72DDF2E32-2E7F2E9A2EF4-2EFF2FD6-2FEF2FFC-2FFF3040309730983100-3104312E-3130318F31B8-31BF31E4-31EF321F32FF4DB6-4DBF9FCC-9FFFA48D-A48FA4C7-A4CFA62C-A63FA660A661A674-A67BA698-A69FA6F8-A6FFA78D-A7FAA82C-A82FA83A-A83FA878-A87FA8C5-A8CDA8DA-A8DFA8FC-A8FFA954-A95EA97D-A97FA9CEA9DA-A9DDA9E0-A9FFAA37-AA3FAA4EAA4FAA5AAA5BAA7C-AA7FAAC3-AADAAAE0-ABBFABEEABEFABFA-ABFFD7A4-D7AFD7C7-D7CAD7FC-F8FFFA2EFA2FFA6EFA6FFADA-FAFFFB07-FB12FB18-FB1CFB37FB3DFB3FFB42FB45FBB2-FBD2FD40-FD4FFD90FD91FDC8-FDEFFDFEFDFFFE1A-FE1FFE27-FE2FFE53FE67FE6C-FE6FFE75FEFD-FF00FFBF-FFC1FFC8FFC9FFD0FFD1FFD8FFD9FFDD-FFDFFFE7FFEF-FFFBFFFEFFFF", + Cc: "0000-001F007F-009F", + Cf: "00AD0600-060306DD070F17B417B5200B-200F202A-202E2060-2064206A-206FFEFFFFF9-FFFB", + Co: "E000-F8FF", + Cs: "D800-DFFF", + Cn: "03780379037F-0383038B038D03A20526-05300557055805600588058B-059005C8-05CF05EB-05EF05F5-05FF06040605061C061D0620065F070E074B074C07B2-07BF07FB-07FF082E082F083F-08FF093A093B094F095609570973-097809800984098D098E0991099209A909B109B3-09B509BA09BB09C509C609C909CA09CF-09D609D8-09DB09DE09E409E509FC-0A000A040A0B-0A0E0A110A120A290A310A340A370A3A0A3B0A3D0A43-0A460A490A4A0A4E-0A500A52-0A580A5D0A5F-0A650A76-0A800A840A8E0A920AA90AB10AB40ABA0ABB0AC60ACA0ACE0ACF0AD1-0ADF0AE40AE50AF00AF2-0B000B040B0D0B0E0B110B120B290B310B340B3A0B3B0B450B460B490B4A0B4E-0B550B58-0B5B0B5E0B640B650B72-0B810B840B8B-0B8D0B910B96-0B980B9B0B9D0BA0-0BA20BA5-0BA70BAB-0BAD0BBA-0BBD0BC3-0BC50BC90BCE0BCF0BD1-0BD60BD8-0BE50BFB-0C000C040C0D0C110C290C340C3A-0C3C0C450C490C4E-0C540C570C5A-0C5F0C640C650C70-0C770C800C810C840C8D0C910CA90CB40CBA0CBB0CC50CC90CCE-0CD40CD7-0CDD0CDF0CE40CE50CF00CF3-0D010D040D0D0D110D290D3A-0D3C0D450D490D4E-0D560D58-0D5F0D640D650D76-0D780D800D810D840D97-0D990DB20DBC0DBE0DBF0DC7-0DC90DCB-0DCE0DD50DD70DE0-0DF10DF5-0E000E3B-0E3E0E5C-0E800E830E850E860E890E8B0E8C0E8E-0E930E980EA00EA40EA60EA80EA90EAC0EBA0EBE0EBF0EC50EC70ECE0ECF0EDA0EDB0EDE-0EFF0F480F6D-0F700F8C-0F8F0F980FBD0FCD0FD9-0FFF10C6-10CF10FD-10FF1249124E124F12571259125E125F1289128E128F12B112B612B712BF12C112C612C712D7131113161317135B-135E137D-137F139A-139F13F5-13FF169D-169F16F1-16FF170D1715-171F1737-173F1754-175F176D17711774-177F17DE17DF17EA-17EF17FA-17FF180F181A-181F1878-187F18AB-18AF18F6-18FF191D-191F192C-192F193C-193F1941-1943196E196F1975-197F19AC-19AF19CA-19CF19DB-19DD1A1C1A1D1A5F1A7D1A7E1A8A-1A8F1A9A-1A9F1AAE-1AFF1B4C-1B4F1B7D-1B7F1BAB-1BAD1BBA-1BFF1C38-1C3A1C4A-1C4C1C80-1CCF1CF3-1CFF1DE7-1DFC1F161F171F1E1F1F1F461F471F4E1F4F1F581F5A1F5C1F5E1F7E1F7F1FB51FC51FD41FD51FDC1FF01FF11FF51FFF2065-206920722073208F2095-209F20B9-20CF20F1-20FF218A-218F23E9-23FF2427-243F244B-245F26CE26E226E4-26E727002705270A270B2728274C274E2753-2755275F27602795-279727B027BF27CB27CD-27CF2B4D-2B4F2B5A-2BFF2C2F2C5F2CF2-2CF82D26-2D2F2D66-2D6E2D70-2D7F2D97-2D9F2DA72DAF2DB72DBF2DC72DCF2DD72DDF2E32-2E7F2E9A2EF4-2EFF2FD6-2FEF2FFC-2FFF3040309730983100-3104312E-3130318F31B8-31BF31E4-31EF321F32FF4DB6-4DBF9FCC-9FFFA48D-A48FA4C7-A4CFA62C-A63FA660A661A674-A67BA698-A69FA6F8-A6FFA78D-A7FAA82C-A82FA83A-A83FA878-A87FA8C5-A8CDA8DA-A8DFA8FC-A8FFA954-A95EA97D-A97FA9CEA9DA-A9DDA9E0-A9FFAA37-AA3FAA4EAA4FAA5AAA5BAA7C-AA7FAAC3-AADAAAE0-ABBFABEEABEFABFA-ABFFD7A4-D7AFD7C7-D7CAD7FC-D7FFFA2EFA2FFA6EFA6FFADA-FAFFFB07-FB12FB18-FB1CFB37FB3DFB3FFB42FB45FBB2-FBD2FD40-FD4FFD90FD91FDC8-FDEFFDFEFDFFFE1A-FE1FFE27-FE2FFE53FE67FE6C-FE6FFE75FEFDFEFEFF00FFBF-FFC1FFC8FFC9FFD0FFD1FFD8FFD9FFDD-FFDFFFE7FFEF-FFF8FFFEFFFF", + L: "0041-005A0061-007A00AA00B500BA00C0-00D600D8-00F600F8-02C102C6-02D102E0-02E402EC02EE0370-037403760377037A-037D03860388-038A038C038E-03A103A3-03F503F7-0481048A-05250531-055605590561-058705D0-05EA05F0-05F20621-064A066E066F0671-06D306D506E506E606EE06EF06FA-06FC06FF07100712-072F074D-07A507B107CA-07EA07F407F507FA0800-0815081A082408280904-0939093D09500958-0961097109720979-097F0985-098C098F09900993-09A809AA-09B009B209B6-09B909BD09CE09DC09DD09DF-09E109F009F10A05-0A0A0A0F0A100A13-0A280A2A-0A300A320A330A350A360A380A390A59-0A5C0A5E0A72-0A740A85-0A8D0A8F-0A910A93-0AA80AAA-0AB00AB20AB30AB5-0AB90ABD0AD00AE00AE10B05-0B0C0B0F0B100B13-0B280B2A-0B300B320B330B35-0B390B3D0B5C0B5D0B5F-0B610B710B830B85-0B8A0B8E-0B900B92-0B950B990B9A0B9C0B9E0B9F0BA30BA40BA8-0BAA0BAE-0BB90BD00C05-0C0C0C0E-0C100C12-0C280C2A-0C330C35-0C390C3D0C580C590C600C610C85-0C8C0C8E-0C900C92-0CA80CAA-0CB30CB5-0CB90CBD0CDE0CE00CE10D05-0D0C0D0E-0D100D12-0D280D2A-0D390D3D0D600D610D7A-0D7F0D85-0D960D9A-0DB10DB3-0DBB0DBD0DC0-0DC60E01-0E300E320E330E40-0E460E810E820E840E870E880E8A0E8D0E94-0E970E99-0E9F0EA1-0EA30EA50EA70EAA0EAB0EAD-0EB00EB20EB30EBD0EC0-0EC40EC60EDC0EDD0F000F40-0F470F49-0F6C0F88-0F8B1000-102A103F1050-1055105A-105D106110651066106E-10701075-1081108E10A0-10C510D0-10FA10FC1100-1248124A-124D1250-12561258125A-125D1260-1288128A-128D1290-12B012B2-12B512B8-12BE12C012C2-12C512C8-12D612D8-13101312-13151318-135A1380-138F13A0-13F41401-166C166F-167F1681-169A16A0-16EA1700-170C170E-17111720-17311740-17511760-176C176E-17701780-17B317D717DC1820-18771880-18A818AA18B0-18F51900-191C1950-196D1970-19741980-19AB19C1-19C71A00-1A161A20-1A541AA71B05-1B331B45-1B4B1B83-1BA01BAE1BAF1C00-1C231C4D-1C4F1C5A-1C7D1CE9-1CEC1CEE-1CF11D00-1DBF1E00-1F151F18-1F1D1F20-1F451F48-1F4D1F50-1F571F591F5B1F5D1F5F-1F7D1F80-1FB41FB6-1FBC1FBE1FC2-1FC41FC6-1FCC1FD0-1FD31FD6-1FDB1FE0-1FEC1FF2-1FF41FF6-1FFC2071207F2090-209421022107210A-211321152119-211D212421262128212A-212D212F-2139213C-213F2145-2149214E218321842C00-2C2E2C30-2C5E2C60-2CE42CEB-2CEE2D00-2D252D30-2D652D6F2D80-2D962DA0-2DA62DA8-2DAE2DB0-2DB62DB8-2DBE2DC0-2DC62DC8-2DCE2DD0-2DD62DD8-2DDE2E2F300530063031-3035303B303C3041-3096309D-309F30A1-30FA30FC-30FF3105-312D3131-318E31A0-31B731F0-31FF3400-4DB54E00-9FCBA000-A48CA4D0-A4FDA500-A60CA610-A61FA62AA62BA640-A65FA662-A66EA67F-A697A6A0-A6E5A717-A71FA722-A788A78BA78CA7FB-A801A803-A805A807-A80AA80C-A822A840-A873A882-A8B3A8F2-A8F7A8FBA90A-A925A930-A946A960-A97CA984-A9B2A9CFAA00-AA28AA40-AA42AA44-AA4BAA60-AA76AA7AAA80-AAAFAAB1AAB5AAB6AAB9-AABDAAC0AAC2AADB-AADDABC0-ABE2AC00-D7A3D7B0-D7C6D7CB-D7FBF900-FA2DFA30-FA6DFA70-FAD9FB00-FB06FB13-FB17FB1DFB1F-FB28FB2A-FB36FB38-FB3CFB3EFB40FB41FB43FB44FB46-FBB1FBD3-FD3DFD50-FD8FFD92-FDC7FDF0-FDFBFE70-FE74FE76-FEFCFF21-FF3AFF41-FF5AFF66-FFBEFFC2-FFC7FFCA-FFCFFFD2-FFD7FFDA-FFDC", + Ll: "0061-007A00AA00B500BA00DF-00F600F8-00FF01010103010501070109010B010D010F01110113011501170119011B011D011F01210123012501270129012B012D012F01310133013501370138013A013C013E014001420144014601480149014B014D014F01510153015501570159015B015D015F01610163016501670169016B016D016F0171017301750177017A017C017E-0180018301850188018C018D019201950199-019B019E01A101A301A501A801AA01AB01AD01B001B401B601B901BA01BD-01BF01C601C901CC01CE01D001D201D401D601D801DA01DC01DD01DF01E101E301E501E701E901EB01ED01EF01F001F301F501F901FB01FD01FF02010203020502070209020B020D020F02110213021502170219021B021D021F02210223022502270229022B022D022F02310233-0239023C023F0240024202470249024B024D024F-02930295-02AF037103730377037B-037D039003AC-03CE03D003D103D5-03D703D903DB03DD03DF03E103E303E503E703E903EB03ED03EF-03F303F503F803FB03FC0430-045F04610463046504670469046B046D046F04710473047504770479047B047D047F0481048B048D048F04910493049504970499049B049D049F04A104A304A504A704A904AB04AD04AF04B104B304B504B704B904BB04BD04BF04C204C404C604C804CA04CC04CE04CF04D104D304D504D704D904DB04DD04DF04E104E304E504E704E904EB04ED04EF04F104F304F504F704F904FB04FD04FF05010503050505070509050B050D050F05110513051505170519051B051D051F0521052305250561-05871D00-1D2B1D62-1D771D79-1D9A1E011E031E051E071E091E0B1E0D1E0F1E111E131E151E171E191E1B1E1D1E1F1E211E231E251E271E291E2B1E2D1E2F1E311E331E351E371E391E3B1E3D1E3F1E411E431E451E471E491E4B1E4D1E4F1E511E531E551E571E591E5B1E5D1E5F1E611E631E651E671E691E6B1E6D1E6F1E711E731E751E771E791E7B1E7D1E7F1E811E831E851E871E891E8B1E8D1E8F1E911E931E95-1E9D1E9F1EA11EA31EA51EA71EA91EAB1EAD1EAF1EB11EB31EB51EB71EB91EBB1EBD1EBF1EC11EC31EC51EC71EC91ECB1ECD1ECF1ED11ED31ED51ED71ED91EDB1EDD1EDF1EE11EE31EE51EE71EE91EEB1EED1EEF1EF11EF31EF51EF71EF91EFB1EFD1EFF-1F071F10-1F151F20-1F271F30-1F371F40-1F451F50-1F571F60-1F671F70-1F7D1F80-1F871F90-1F971FA0-1FA71FB0-1FB41FB61FB71FBE1FC2-1FC41FC61FC71FD0-1FD31FD61FD71FE0-1FE71FF2-1FF41FF61FF7210A210E210F2113212F21342139213C213D2146-2149214E21842C30-2C5E2C612C652C662C682C6A2C6C2C712C732C742C76-2C7C2C812C832C852C872C892C8B2C8D2C8F2C912C932C952C972C992C9B2C9D2C9F2CA12CA32CA52CA72CA92CAB2CAD2CAF2CB12CB32CB52CB72CB92CBB2CBD2CBF2CC12CC32CC52CC72CC92CCB2CCD2CCF2CD12CD32CD52CD72CD92CDB2CDD2CDF2CE12CE32CE42CEC2CEE2D00-2D25A641A643A645A647A649A64BA64DA64FA651A653A655A657A659A65BA65DA65FA663A665A667A669A66BA66DA681A683A685A687A689A68BA68DA68FA691A693A695A697A723A725A727A729A72BA72DA72F-A731A733A735A737A739A73BA73DA73FA741A743A745A747A749A74BA74DA74FA751A753A755A757A759A75BA75DA75FA761A763A765A767A769A76BA76DA76FA771-A778A77AA77CA77FA781A783A785A787A78CFB00-FB06FB13-FB17FF41-FF5A", + Lu: "0041-005A00C0-00D600D8-00DE01000102010401060108010A010C010E01100112011401160118011A011C011E01200122012401260128012A012C012E01300132013401360139013B013D013F0141014301450147014A014C014E01500152015401560158015A015C015E01600162016401660168016A016C016E017001720174017601780179017B017D018101820184018601870189-018B018E-0191019301940196-0198019C019D019F01A001A201A401A601A701A901AC01AE01AF01B1-01B301B501B701B801BC01C401C701CA01CD01CF01D101D301D501D701D901DB01DE01E001E201E401E601E801EA01EC01EE01F101F401F6-01F801FA01FC01FE02000202020402060208020A020C020E02100212021402160218021A021C021E02200222022402260228022A022C022E02300232023A023B023D023E02410243-02460248024A024C024E03700372037603860388-038A038C038E038F0391-03A103A3-03AB03CF03D2-03D403D803DA03DC03DE03E003E203E403E603E803EA03EC03EE03F403F703F903FA03FD-042F04600462046404660468046A046C046E04700472047404760478047A047C047E0480048A048C048E04900492049404960498049A049C049E04A004A204A404A604A804AA04AC04AE04B004B204B404B604B804BA04BC04BE04C004C104C304C504C704C904CB04CD04D004D204D404D604D804DA04DC04DE04E004E204E404E604E804EA04EC04EE04F004F204F404F604F804FA04FC04FE05000502050405060508050A050C050E05100512051405160518051A051C051E0520052205240531-055610A0-10C51E001E021E041E061E081E0A1E0C1E0E1E101E121E141E161E181E1A1E1C1E1E1E201E221E241E261E281E2A1E2C1E2E1E301E321E341E361E381E3A1E3C1E3E1E401E421E441E461E481E4A1E4C1E4E1E501E521E541E561E581E5A1E5C1E5E1E601E621E641E661E681E6A1E6C1E6E1E701E721E741E761E781E7A1E7C1E7E1E801E821E841E861E881E8A1E8C1E8E1E901E921E941E9E1EA01EA21EA41EA61EA81EAA1EAC1EAE1EB01EB21EB41EB61EB81EBA1EBC1EBE1EC01EC21EC41EC61EC81ECA1ECC1ECE1ED01ED21ED41ED61ED81EDA1EDC1EDE1EE01EE21EE41EE61EE81EEA1EEC1EEE1EF01EF21EF41EF61EF81EFA1EFC1EFE1F08-1F0F1F18-1F1D1F28-1F2F1F38-1F3F1F48-1F4D1F591F5B1F5D1F5F1F68-1F6F1FB8-1FBB1FC8-1FCB1FD8-1FDB1FE8-1FEC1FF8-1FFB21022107210B-210D2110-211221152119-211D212421262128212A-212D2130-2133213E213F214521832C00-2C2E2C602C62-2C642C672C692C6B2C6D-2C702C722C752C7E-2C802C822C842C862C882C8A2C8C2C8E2C902C922C942C962C982C9A2C9C2C9E2CA02CA22CA42CA62CA82CAA2CAC2CAE2CB02CB22CB42CB62CB82CBA2CBC2CBE2CC02CC22CC42CC62CC82CCA2CCC2CCE2CD02CD22CD42CD62CD82CDA2CDC2CDE2CE02CE22CEB2CEDA640A642A644A646A648A64AA64CA64EA650A652A654A656A658A65AA65CA65EA662A664A666A668A66AA66CA680A682A684A686A688A68AA68CA68EA690A692A694A696A722A724A726A728A72AA72CA72EA732A734A736A738A73AA73CA73EA740A742A744A746A748A74AA74CA74EA750A752A754A756A758A75AA75CA75EA760A762A764A766A768A76AA76CA76EA779A77BA77DA77EA780A782A784A786A78BFF21-FF3A", + Lt: "01C501C801CB01F21F88-1F8F1F98-1F9F1FA8-1FAF1FBC1FCC1FFC", + Lm: "02B0-02C102C6-02D102E0-02E402EC02EE0374037A0559064006E506E607F407F507FA081A0824082809710E460EC610FC17D718431AA71C78-1C7D1D2C-1D611D781D9B-1DBF2071207F2090-20942C7D2D6F2E2F30053031-3035303B309D309E30FC-30FEA015A4F8-A4FDA60CA67FA717-A71FA770A788A9CFAA70AADDFF70FF9EFF9F", + Lo: "01BB01C0-01C3029405D0-05EA05F0-05F20621-063F0641-064A066E066F0671-06D306D506EE06EF06FA-06FC06FF07100712-072F074D-07A507B107CA-07EA0800-08150904-0939093D09500958-096109720979-097F0985-098C098F09900993-09A809AA-09B009B209B6-09B909BD09CE09DC09DD09DF-09E109F009F10A05-0A0A0A0F0A100A13-0A280A2A-0A300A320A330A350A360A380A390A59-0A5C0A5E0A72-0A740A85-0A8D0A8F-0A910A93-0AA80AAA-0AB00AB20AB30AB5-0AB90ABD0AD00AE00AE10B05-0B0C0B0F0B100B13-0B280B2A-0B300B320B330B35-0B390B3D0B5C0B5D0B5F-0B610B710B830B85-0B8A0B8E-0B900B92-0B950B990B9A0B9C0B9E0B9F0BA30BA40BA8-0BAA0BAE-0BB90BD00C05-0C0C0C0E-0C100C12-0C280C2A-0C330C35-0C390C3D0C580C590C600C610C85-0C8C0C8E-0C900C92-0CA80CAA-0CB30CB5-0CB90CBD0CDE0CE00CE10D05-0D0C0D0E-0D100D12-0D280D2A-0D390D3D0D600D610D7A-0D7F0D85-0D960D9A-0DB10DB3-0DBB0DBD0DC0-0DC60E01-0E300E320E330E40-0E450E810E820E840E870E880E8A0E8D0E94-0E970E99-0E9F0EA1-0EA30EA50EA70EAA0EAB0EAD-0EB00EB20EB30EBD0EC0-0EC40EDC0EDD0F000F40-0F470F49-0F6C0F88-0F8B1000-102A103F1050-1055105A-105D106110651066106E-10701075-1081108E10D0-10FA1100-1248124A-124D1250-12561258125A-125D1260-1288128A-128D1290-12B012B2-12B512B8-12BE12C012C2-12C512C8-12D612D8-13101312-13151318-135A1380-138F13A0-13F41401-166C166F-167F1681-169A16A0-16EA1700-170C170E-17111720-17311740-17511760-176C176E-17701780-17B317DC1820-18421844-18771880-18A818AA18B0-18F51900-191C1950-196D1970-19741980-19AB19C1-19C71A00-1A161A20-1A541B05-1B331B45-1B4B1B83-1BA01BAE1BAF1C00-1C231C4D-1C4F1C5A-1C771CE9-1CEC1CEE-1CF12135-21382D30-2D652D80-2D962DA0-2DA62DA8-2DAE2DB0-2DB62DB8-2DBE2DC0-2DC62DC8-2DCE2DD0-2DD62DD8-2DDE3006303C3041-3096309F30A1-30FA30FF3105-312D3131-318E31A0-31B731F0-31FF3400-4DB54E00-9FCBA000-A014A016-A48CA4D0-A4F7A500-A60BA610-A61FA62AA62BA66EA6A0-A6E5A7FB-A801A803-A805A807-A80AA80C-A822A840-A873A882-A8B3A8F2-A8F7A8FBA90A-A925A930-A946A960-A97CA984-A9B2AA00-AA28AA40-AA42AA44-AA4BAA60-AA6FAA71-AA76AA7AAA80-AAAFAAB1AAB5AAB6AAB9-AABDAAC0AAC2AADBAADCABC0-ABE2AC00-D7A3D7B0-D7C6D7CB-D7FBF900-FA2DFA30-FA6DFA70-FAD9FB1DFB1F-FB28FB2A-FB36FB38-FB3CFB3EFB40FB41FB43FB44FB46-FBB1FBD3-FD3DFD50-FD8FFD92-FDC7FDF0-FDFBFE70-FE74FE76-FEFCFF66-FF6FFF71-FF9DFFA0-FFBEFFC2-FFC7FFCA-FFCFFFD2-FFD7FFDA-FFDC", + M: "0300-036F0483-04890591-05BD05BF05C105C205C405C505C70610-061A064B-065E067006D6-06DC06DE-06E406E706E806EA-06ED07110730-074A07A6-07B007EB-07F30816-0819081B-08230825-08270829-082D0900-0903093C093E-094E0951-0955096209630981-098309BC09BE-09C409C709C809CB-09CD09D709E209E30A01-0A030A3C0A3E-0A420A470A480A4B-0A4D0A510A700A710A750A81-0A830ABC0ABE-0AC50AC7-0AC90ACB-0ACD0AE20AE30B01-0B030B3C0B3E-0B440B470B480B4B-0B4D0B560B570B620B630B820BBE-0BC20BC6-0BC80BCA-0BCD0BD70C01-0C030C3E-0C440C46-0C480C4A-0C4D0C550C560C620C630C820C830CBC0CBE-0CC40CC6-0CC80CCA-0CCD0CD50CD60CE20CE30D020D030D3E-0D440D46-0D480D4A-0D4D0D570D620D630D820D830DCA0DCF-0DD40DD60DD8-0DDF0DF20DF30E310E34-0E3A0E47-0E4E0EB10EB4-0EB90EBB0EBC0EC8-0ECD0F180F190F350F370F390F3E0F3F0F71-0F840F860F870F90-0F970F99-0FBC0FC6102B-103E1056-1059105E-10601062-10641067-106D1071-10741082-108D108F109A-109D135F1712-17141732-1734175217531772177317B6-17D317DD180B-180D18A91920-192B1930-193B19B0-19C019C819C91A17-1A1B1A55-1A5E1A60-1A7C1A7F1B00-1B041B34-1B441B6B-1B731B80-1B821BA1-1BAA1C24-1C371CD0-1CD21CD4-1CE81CED1CF21DC0-1DE61DFD-1DFF20D0-20F02CEF-2CF12DE0-2DFF302A-302F3099309AA66F-A672A67CA67DA6F0A6F1A802A806A80BA823-A827A880A881A8B4-A8C4A8E0-A8F1A926-A92DA947-A953A980-A983A9B3-A9C0AA29-AA36AA43AA4CAA4DAA7BAAB0AAB2-AAB4AAB7AAB8AABEAABFAAC1ABE3-ABEAABECABEDFB1EFE00-FE0FFE20-FE26", + Mn: "0300-036F0483-04870591-05BD05BF05C105C205C405C505C70610-061A064B-065E067006D6-06DC06DF-06E406E706E806EA-06ED07110730-074A07A6-07B007EB-07F30816-0819081B-08230825-08270829-082D0900-0902093C0941-0948094D0951-095509620963098109BC09C1-09C409CD09E209E30A010A020A3C0A410A420A470A480A4B-0A4D0A510A700A710A750A810A820ABC0AC1-0AC50AC70AC80ACD0AE20AE30B010B3C0B3F0B41-0B440B4D0B560B620B630B820BC00BCD0C3E-0C400C46-0C480C4A-0C4D0C550C560C620C630CBC0CBF0CC60CCC0CCD0CE20CE30D41-0D440D4D0D620D630DCA0DD2-0DD40DD60E310E34-0E3A0E47-0E4E0EB10EB4-0EB90EBB0EBC0EC8-0ECD0F180F190F350F370F390F71-0F7E0F80-0F840F860F870F90-0F970F99-0FBC0FC6102D-10301032-10371039103A103D103E10581059105E-10601071-1074108210851086108D109D135F1712-17141732-1734175217531772177317B7-17BD17C617C9-17D317DD180B-180D18A91920-19221927192819321939-193B1A171A181A561A58-1A5E1A601A621A65-1A6C1A73-1A7C1A7F1B00-1B031B341B36-1B3A1B3C1B421B6B-1B731B801B811BA2-1BA51BA81BA91C2C-1C331C361C371CD0-1CD21CD4-1CE01CE2-1CE81CED1DC0-1DE61DFD-1DFF20D0-20DC20E120E5-20F02CEF-2CF12DE0-2DFF302A-302F3099309AA66FA67CA67DA6F0A6F1A802A806A80BA825A826A8C4A8E0-A8F1A926-A92DA947-A951A980-A982A9B3A9B6-A9B9A9BCAA29-AA2EAA31AA32AA35AA36AA43AA4CAAB0AAB2-AAB4AAB7AAB8AABEAABFAAC1ABE5ABE8ABEDFB1EFE00-FE0FFE20-FE26", + Mc: "0903093E-09400949-094C094E0982098309BE-09C009C709C809CB09CC09D70A030A3E-0A400A830ABE-0AC00AC90ACB0ACC0B020B030B3E0B400B470B480B4B0B4C0B570BBE0BBF0BC10BC20BC6-0BC80BCA-0BCC0BD70C01-0C030C41-0C440C820C830CBE0CC0-0CC40CC70CC80CCA0CCB0CD50CD60D020D030D3E-0D400D46-0D480D4A-0D4C0D570D820D830DCF-0DD10DD8-0DDF0DF20DF30F3E0F3F0F7F102B102C10311038103B103C105610571062-10641067-106D108310841087-108C108F109A-109C17B617BE-17C517C717C81923-19261929-192B193019311933-193819B0-19C019C819C91A19-1A1B1A551A571A611A631A641A6D-1A721B041B351B3B1B3D-1B411B431B441B821BA11BA61BA71BAA1C24-1C2B1C341C351CE11CF2A823A824A827A880A881A8B4-A8C3A952A953A983A9B4A9B5A9BAA9BBA9BD-A9C0AA2FAA30AA33AA34AA4DAA7BABE3ABE4ABE6ABE7ABE9ABEAABEC", + Me: "0488048906DE20DD-20E020E2-20E4A670-A672", + N: "0030-003900B200B300B900BC-00BE0660-066906F0-06F907C0-07C90966-096F09E6-09EF09F4-09F90A66-0A6F0AE6-0AEF0B66-0B6F0BE6-0BF20C66-0C6F0C78-0C7E0CE6-0CEF0D66-0D750E50-0E590ED0-0ED90F20-0F331040-10491090-10991369-137C16EE-16F017E0-17E917F0-17F91810-18191946-194F19D0-19DA1A80-1A891A90-1A991B50-1B591BB0-1BB91C40-1C491C50-1C5920702074-20792080-20892150-21822185-21892460-249B24EA-24FF2776-27932CFD30073021-30293038-303A3192-31953220-32293251-325F3280-328932B1-32BFA620-A629A6E6-A6EFA830-A835A8D0-A8D9A900-A909A9D0-A9D9AA50-AA59ABF0-ABF9FF10-FF19", + Nd: "0030-00390660-066906F0-06F907C0-07C90966-096F09E6-09EF0A66-0A6F0AE6-0AEF0B66-0B6F0BE6-0BEF0C66-0C6F0CE6-0CEF0D66-0D6F0E50-0E590ED0-0ED90F20-0F291040-10491090-109917E0-17E91810-18191946-194F19D0-19DA1A80-1A891A90-1A991B50-1B591BB0-1BB91C40-1C491C50-1C59A620-A629A8D0-A8D9A900-A909A9D0-A9D9AA50-AA59ABF0-ABF9FF10-FF19", + Nl: "16EE-16F02160-21822185-218830073021-30293038-303AA6E6-A6EF", + No: "00B200B300B900BC-00BE09F4-09F90BF0-0BF20C78-0C7E0D70-0D750F2A-0F331369-137C17F0-17F920702074-20792080-20892150-215F21892460-249B24EA-24FF2776-27932CFD3192-31953220-32293251-325F3280-328932B1-32BFA830-A835", + P: "0021-00230025-002A002C-002F003A003B003F0040005B-005D005F007B007D00A100AB00B700BB00BF037E0387055A-055F0589058A05BE05C005C305C605F305F40609060A060C060D061B061E061F066A-066D06D40700-070D07F7-07F90830-083E0964096509700DF40E4F0E5A0E5B0F04-0F120F3A-0F3D0F850FD0-0FD4104A-104F10FB1361-13681400166D166E169B169C16EB-16ED1735173617D4-17D617D8-17DA1800-180A1944194519DE19DF1A1E1A1F1AA0-1AA61AA8-1AAD1B5A-1B601C3B-1C3F1C7E1C7F1CD32010-20272030-20432045-20512053-205E207D207E208D208E2329232A2768-277527C527C627E6-27EF2983-299829D8-29DB29FC29FD2CF9-2CFC2CFE2CFF2E00-2E2E2E302E313001-30033008-30113014-301F3030303D30A030FBA4FEA4FFA60D-A60FA673A67EA6F2-A6F7A874-A877A8CEA8CFA8F8-A8FAA92EA92FA95FA9C1-A9CDA9DEA9DFAA5C-AA5FAADEAADFABEBFD3EFD3FFE10-FE19FE30-FE52FE54-FE61FE63FE68FE6AFE6BFF01-FF03FF05-FF0AFF0C-FF0FFF1AFF1BFF1FFF20FF3B-FF3DFF3FFF5BFF5DFF5F-FF65", + Pd: "002D058A05BE140018062010-20152E172E1A301C303030A0FE31FE32FE58FE63FF0D", + Ps: "0028005B007B0F3A0F3C169B201A201E2045207D208D23292768276A276C276E27702772277427C527E627E827EA27EC27EE2983298529872989298B298D298F299129932995299729D829DA29FC2E222E242E262E283008300A300C300E3010301430163018301A301DFD3EFE17FE35FE37FE39FE3BFE3DFE3FFE41FE43FE47FE59FE5BFE5DFF08FF3BFF5BFF5FFF62", + Pe: "0029005D007D0F3B0F3D169C2046207E208E232A2769276B276D276F27712773277527C627E727E927EB27ED27EF298429862988298A298C298E2990299229942996299829D929DB29FD2E232E252E272E293009300B300D300F3011301530173019301B301E301FFD3FFE18FE36FE38FE3AFE3CFE3EFE40FE42FE44FE48FE5AFE5CFE5EFF09FF3DFF5DFF60FF63", + Pi: "00AB2018201B201C201F20392E022E042E092E0C2E1C2E20", + Pf: "00BB2019201D203A2E032E052E0A2E0D2E1D2E21", + Pc: "005F203F20402054FE33FE34FE4D-FE4FFF3F", + Po: "0021-00230025-0027002A002C002E002F003A003B003F0040005C00A100B700BF037E0387055A-055F058905C005C305C605F305F40609060A060C060D061B061E061F066A-066D06D40700-070D07F7-07F90830-083E0964096509700DF40E4F0E5A0E5B0F04-0F120F850FD0-0FD4104A-104F10FB1361-1368166D166E16EB-16ED1735173617D4-17D617D8-17DA1800-18051807-180A1944194519DE19DF1A1E1A1F1AA0-1AA61AA8-1AAD1B5A-1B601C3B-1C3F1C7E1C7F1CD3201620172020-20272030-2038203B-203E2041-20432047-205120532055-205E2CF9-2CFC2CFE2CFF2E002E012E06-2E082E0B2E0E-2E162E182E192E1B2E1E2E1F2E2A-2E2E2E302E313001-3003303D30FBA4FEA4FFA60D-A60FA673A67EA6F2-A6F7A874-A877A8CEA8CFA8F8-A8FAA92EA92FA95FA9C1-A9CDA9DEA9DFAA5C-AA5FAADEAADFABEBFE10-FE16FE19FE30FE45FE46FE49-FE4CFE50-FE52FE54-FE57FE5F-FE61FE68FE6AFE6BFF01-FF03FF05-FF07FF0AFF0CFF0EFF0FFF1AFF1BFF1FFF20FF3CFF61FF64FF65", + S: "0024002B003C-003E005E0060007C007E00A2-00A900AC00AE-00B100B400B600B800D700F702C2-02C502D2-02DF02E5-02EB02ED02EF-02FF03750384038503F604820606-0608060B060E060F06E906FD06FE07F609F209F309FA09FB0AF10B700BF3-0BFA0C7F0CF10CF20D790E3F0F01-0F030F13-0F170F1A-0F1F0F340F360F380FBE-0FC50FC7-0FCC0FCE0FCF0FD5-0FD8109E109F13601390-139917DB194019E0-19FF1B61-1B6A1B74-1B7C1FBD1FBF-1FC11FCD-1FCF1FDD-1FDF1FED-1FEF1FFD1FFE20442052207A-207C208A-208C20A0-20B8210021012103-21062108210921142116-2118211E-2123212521272129212E213A213B2140-2144214A-214D214F2190-2328232B-23E82400-24262440-244A249C-24E92500-26CD26CF-26E126E326E8-26FF2701-27042706-2709270C-27272729-274B274D274F-27522756-275E2761-276727942798-27AF27B1-27BE27C0-27C427C7-27CA27CC27D0-27E527F0-29822999-29D729DC-29FB29FE-2B4C2B50-2B592CE5-2CEA2E80-2E992E9B-2EF32F00-2FD52FF0-2FFB300430123013302030363037303E303F309B309C319031913196-319F31C0-31E33200-321E322A-32503260-327F328A-32B032C0-32FE3300-33FF4DC0-4DFFA490-A4C6A700-A716A720A721A789A78AA828-A82BA836-A839AA77-AA79FB29FDFCFDFDFE62FE64-FE66FE69FF04FF0BFF1C-FF1EFF3EFF40FF5CFF5EFFE0-FFE6FFE8-FFEEFFFCFFFD", + Sm: "002B003C-003E007C007E00AC00B100D700F703F60606-060820442052207A-207C208A-208C2140-2144214B2190-2194219A219B21A021A321A621AE21CE21CF21D221D421F4-22FF2308-230B23202321237C239B-23B323DC-23E125B725C125F8-25FF266F27C0-27C427C7-27CA27CC27D0-27E527F0-27FF2900-29822999-29D729DC-29FB29FE-2AFF2B30-2B442B47-2B4CFB29FE62FE64-FE66FF0BFF1C-FF1EFF5CFF5EFFE2FFE9-FFEC", + Sc: "002400A2-00A5060B09F209F309FB0AF10BF90E3F17DB20A0-20B8A838FDFCFE69FF04FFE0FFE1FFE5FFE6", + Sk: "005E006000A800AF00B400B802C2-02C502D2-02DF02E5-02EB02ED02EF-02FF0375038403851FBD1FBF-1FC11FCD-1FCF1FDD-1FDF1FED-1FEF1FFD1FFE309B309CA700-A716A720A721A789A78AFF3EFF40FFE3", + So: "00A600A700A900AE00B000B60482060E060F06E906FD06FE07F609FA0B700BF3-0BF80BFA0C7F0CF10CF20D790F01-0F030F13-0F170F1A-0F1F0F340F360F380FBE-0FC50FC7-0FCC0FCE0FCF0FD5-0FD8109E109F13601390-1399194019E0-19FF1B61-1B6A1B74-1B7C210021012103-21062108210921142116-2118211E-2123212521272129212E213A213B214A214C214D214F2195-2199219C-219F21A121A221A421A521A7-21AD21AF-21CD21D021D121D321D5-21F32300-2307230C-231F2322-2328232B-237B237D-239A23B4-23DB23E2-23E82400-24262440-244A249C-24E92500-25B625B8-25C025C2-25F72600-266E2670-26CD26CF-26E126E326E8-26FF2701-27042706-2709270C-27272729-274B274D274F-27522756-275E2761-276727942798-27AF27B1-27BE2800-28FF2B00-2B2F2B452B462B50-2B592CE5-2CEA2E80-2E992E9B-2EF32F00-2FD52FF0-2FFB300430123013302030363037303E303F319031913196-319F31C0-31E33200-321E322A-32503260-327F328A-32B032C0-32FE3300-33FF4DC0-4DFFA490-A4C6A828-A82BA836A837A839AA77-AA79FDFDFFE4FFE8FFEDFFEEFFFCFFFD", + Z: "002000A01680180E2000-200A20282029202F205F3000", + Zs: "002000A01680180E2000-200A202F205F3000", + Zl: "2028", + Zp: "2029" +}; + +var UnicodeBlocks = { + InBasic_Latin: "0000-007F", + InLatin_1_Supplement: "0080-00FF", + InLatin_Extended_A: "0100-017F", + InLatin_Extended_B: "0180-024F", + InIPA_Extensions: "0250-02AF", + InSpacing_Modifier_Letters: "02B0-02FF", + InCombining_Diacritical_Marks: "0300-036F", + InGreek_and_Coptic: "0370-03FF", + InCyrillic: "0400-04FF", + InCyrillic_Supplement: "0500-052F", + InArmenian: "0530-058F", + InHebrew: "0590-05FF", + InArabic: "0600-06FF", + InSyriac: "0700-074F", + InArabic_Supplement: "0750-077F", + InThaana: "0780-07BF", + InNKo: "07C0-07FF", + InSamaritan: "0800-083F", + InDevanagari: "0900-097F", + InBengali: "0980-09FF", + InGurmukhi: "0A00-0A7F", + InGujarati: "0A80-0AFF", + InOriya: "0B00-0B7F", + InTamil: "0B80-0BFF", + InTelugu: "0C00-0C7F", + InKannada: "0C80-0CFF", + InMalayalam: "0D00-0D7F", + InSinhala: "0D80-0DFF", + InThai: "0E00-0E7F", + InLao: "0E80-0EFF", + InTibetan: "0F00-0FFF", + InMyanmar: "1000-109F", + InGeorgian: "10A0-10FF", + InHangul_Jamo: "1100-11FF", + InEthiopic: "1200-137F", + InEthiopic_Supplement: "1380-139F", + InCherokee: "13A0-13FF", + InUnified_Canadian_Aboriginal_Syllabics: "1400-167F", + InOgham: "1680-169F", + InRunic: "16A0-16FF", + InTagalog: "1700-171F", + InHanunoo: "1720-173F", + InBuhid: "1740-175F", + InTagbanwa: "1760-177F", + InKhmer: "1780-17FF", + InMongolian: "1800-18AF", + InUnified_Canadian_Aboriginal_Syllabics_Extended: "18B0-18FF", + InLimbu: "1900-194F", + InTai_Le: "1950-197F", + InNew_Tai_Lue: "1980-19DF", + InKhmer_Symbols: "19E0-19FF", + InBuginese: "1A00-1A1F", + InTai_Tham: "1A20-1AAF", + InBalinese: "1B00-1B7F", + InSundanese: "1B80-1BBF", + InLepcha: "1C00-1C4F", + InOl_Chiki: "1C50-1C7F", + InVedic_Extensions: "1CD0-1CFF", + InPhonetic_Extensions: "1D00-1D7F", + InPhonetic_Extensions_Supplement: "1D80-1DBF", + InCombining_Diacritical_Marks_Supplement: "1DC0-1DFF", + InLatin_Extended_Additional: "1E00-1EFF", + InGreek_Extended: "1F00-1FFF", + InGeneral_Punctuation: "2000-206F", + InSuperscripts_and_Subscripts: "2070-209F", + InCurrency_Symbols: "20A0-20CF", + InCombining_Diacritical_Marks_for_Symbols: "20D0-20FF", + InLetterlike_Symbols: "2100-214F", + InNumber_Forms: "2150-218F", + InArrows: "2190-21FF", + InMathematical_Operators: "2200-22FF", + InMiscellaneous_Technical: "2300-23FF", + InControl_Pictures: "2400-243F", + InOptical_Character_Recognition: "2440-245F", + InEnclosed_Alphanumerics: "2460-24FF", + InBox_Drawing: "2500-257F", + InBlock_Elements: "2580-259F", + InGeometric_Shapes: "25A0-25FF", + InMiscellaneous_Symbols: "2600-26FF", + InDingbats: "2700-27BF", + InMiscellaneous_Mathematical_Symbols_A: "27C0-27EF", + InSupplemental_Arrows_A: "27F0-27FF", + InBraille_Patterns: "2800-28FF", + InSupplemental_Arrows_B: "2900-297F", + InMiscellaneous_Mathematical_Symbols_B: "2980-29FF", + InSupplemental_Mathematical_Operators: "2A00-2AFF", + InMiscellaneous_Symbols_and_Arrows: "2B00-2BFF", + InGlagolitic: "2C00-2C5F", + InLatin_Extended_C: "2C60-2C7F", + InCoptic: "2C80-2CFF", + InGeorgian_Supplement: "2D00-2D2F", + InTifinagh: "2D30-2D7F", + InEthiopic_Extended: "2D80-2DDF", + InCyrillic_Extended_A: "2DE0-2DFF", + InSupplemental_Punctuation: "2E00-2E7F", + InCJK_Radicals_Supplement: "2E80-2EFF", + InKangxi_Radicals: "2F00-2FDF", + InIdeographic_Description_Characters: "2FF0-2FFF", + InCJK_Symbols_and_Punctuation: "3000-303F", + InHiragana: "3040-309F", + InKatakana: "30A0-30FF", + InBopomofo: "3100-312F", + InHangul_Compatibility_Jamo: "3130-318F", + InKanbun: "3190-319F", + InBopomofo_Extended: "31A0-31BF", + InCJK_Strokes: "31C0-31EF", + InKatakana_Phonetic_Extensions: "31F0-31FF", + InEnclosed_CJK_Letters_and_Months: "3200-32FF", + InCJK_Compatibility: "3300-33FF", + InCJK_Unified_Ideographs_Extension_A: "3400-4DBF", + InYijing_Hexagram_Symbols: "4DC0-4DFF", + InCJK_Unified_Ideographs: "4E00-9FFF", + InYi_Syllables: "A000-A48F", + InYi_Radicals: "A490-A4CF", + InLisu: "A4D0-A4FF", + InVai: "A500-A63F", + InCyrillic_Extended_B: "A640-A69F", + InBamum: "A6A0-A6FF", + InModifier_Tone_Letters: "A700-A71F", + InLatin_Extended_D: "A720-A7FF", + InSyloti_Nagri: "A800-A82F", + InCommon_Indic_Number_Forms: "A830-A83F", + InPhags_pa: "A840-A87F", + InSaurashtra: "A880-A8DF", + InDevanagari_Extended: "A8E0-A8FF", + InKayah_Li: "A900-A92F", + InRejang: "A930-A95F", + InHangul_Jamo_Extended_A: "A960-A97F", + InJavanese: "A980-A9DF", + InCham: "AA00-AA5F", + InMyanmar_Extended_A: "AA60-AA7F", + InTai_Viet: "AA80-AADF", + InMeetei_Mayek: "ABC0-ABFF", + InHangul_Syllables: "AC00-D7AF", + InHangul_Jamo_Extended_B: "D7B0-D7FF", + InHigh_Surrogates: "D800-DB7F", + InHigh_Private_Use_Surrogates: "DB80-DBFF", + InLow_Surrogates: "DC00-DFFF", + InPrivate_Use_Area: "E000-F8FF", + InCJK_Compatibility_Ideographs: "F900-FAFF", + InAlphabetic_Presentation_Forms: "FB00-FB4F", + InArabic_Presentation_Forms_A: "FB50-FDFF", + InVariation_Selectors: "FE00-FE0F", + InVertical_Forms: "FE10-FE1F", + InCombining_Half_Marks: "FE20-FE2F", + InCJK_Compatibility_Forms: "FE30-FE4F", + InSmall_Form_Variants: "FE50-FE6F", + InArabic_Presentation_Forms_B: "FE70-FEFF", + InHalfwidth_and_Fullwidth_Forms: "FF00-FFEF", + InSpecials: "FFF0-FFFF" +}; + +var UnicodeScripts = { + Common: "0000-0040005B-0060007B-00A900AB-00B900BB-00BF00D700F702B9-02DF02E5-02FF0374037E0385038705890600-0603060C061B061F06400660-066906DD0964096509700CF10CF20E3F0FD5-0FD810FB16EB-16ED173517361802180318051CD31CE11CE9-1CEC1CEE-1CF22000-200B200E-2064206A-20702074-207E2080-208E20A0-20B82100-21252127-2129212C-21312133-214D214F-215F21892190-23E82400-24262440-244A2460-26CD26CF-26E126E326E8-26FF2701-27042706-2709270C-27272729-274B274D274F-27522756-275E2761-27942798-27AF27B1-27BE27C0-27CA27CC27D0-27FF2900-2B4C2B50-2B592E00-2E312FF0-2FFB3000-300430063008-30203030-3037303C-303F309B309C30A030FB30FC3190-319F31C0-31E33220-325F327F-32CF3358-33FF4DC0-4DFFA700-A721A788-A78AA830-A839FD3EFD3FFDFDFE10-FE19FE30-FE52FE54-FE66FE68-FE6BFEFFFF01-FF20FF3B-FF40FF5B-FF65FF70FF9EFF9FFFE0-FFE6FFE8-FFEEFFF9-FFFD", + Arabic: "0606-060B060D-061A061E0621-063F0641-064A0656-065E066A-066F0671-06DC06DE-06FF0750-077FFB50-FBB1FBD3-FD3DFD50-FD8FFD92-FDC7FDF0-FDFCFE70-FE74FE76-FEFC", + Armenian: "0531-05560559-055F0561-0587058AFB13-FB17", + Balinese: "1B00-1B4B1B50-1B7C", + Bamum: "A6A0-A6F7", + Bengali: "0981-09830985-098C098F09900993-09A809AA-09B009B209B6-09B909BC-09C409C709C809CB-09CE09D709DC09DD09DF-09E309E6-09FB", + Bopomofo: "3105-312D31A0-31B7", + Braille: "2800-28FF", + Buginese: "1A00-1A1B1A1E1A1F", + Buhid: "1740-1753", + Canadian_Aboriginal: "1400-167F18B0-18F5", + Cham: "AA00-AA36AA40-AA4DAA50-AA59AA5C-AA5F", + Cherokee: "13A0-13F4", + Coptic: "03E2-03EF2C80-2CF12CF9-2CFF", + Cyrillic: "0400-04840487-05251D2B1D782DE0-2DFFA640-A65FA662-A673A67C-A697", + Devanagari: "0900-0939093C-094E09500953-09550958-09630966-096F097109720979-097FA8E0-A8FB", + Ethiopic: "1200-1248124A-124D1250-12561258125A-125D1260-1288128A-128D1290-12B012B2-12B512B8-12BE12C012C2-12C512C8-12D612D8-13101312-13151318-135A135F-137C1380-13992D80-2D962DA0-2DA62DA8-2DAE2DB0-2DB62DB8-2DBE2DC0-2DC62DC8-2DCE2DD0-2DD62DD8-2DDE", + Georgian: "10A0-10C510D0-10FA10FC2D00-2D25", + Glagolitic: "2C00-2C2E2C30-2C5E", + Greek: "0370-03730375-0377037A-037D038403860388-038A038C038E-03A103A3-03E103F0-03FF1D26-1D2A1D5D-1D611D66-1D6A1DBF1F00-1F151F18-1F1D1F20-1F451F48-1F4D1F50-1F571F591F5B1F5D1F5F-1F7D1F80-1FB41FB6-1FC41FC6-1FD31FD6-1FDB1FDD-1FEF1FF2-1FF41FF6-1FFE2126", + Gujarati: "0A81-0A830A85-0A8D0A8F-0A910A93-0AA80AAA-0AB00AB20AB30AB5-0AB90ABC-0AC50AC7-0AC90ACB-0ACD0AD00AE0-0AE30AE6-0AEF0AF1", + Gurmukhi: "0A01-0A030A05-0A0A0A0F0A100A13-0A280A2A-0A300A320A330A350A360A380A390A3C0A3E-0A420A470A480A4B-0A4D0A510A59-0A5C0A5E0A66-0A75", + Han: "2E80-2E992E9B-2EF32F00-2FD5300530073021-30293038-303B3400-4DB54E00-9FCBF900-FA2DFA30-FA6DFA70-FAD9", + Hangul: "1100-11FF3131-318E3200-321E3260-327EA960-A97CAC00-D7A3D7B0-D7C6D7CB-D7FBFFA0-FFBEFFC2-FFC7FFCA-FFCFFFD2-FFD7FFDA-FFDC", + Hanunoo: "1720-1734", + Hebrew: "0591-05C705D0-05EA05F0-05F4FB1D-FB36FB38-FB3CFB3EFB40FB41FB43FB44FB46-FB4F", + Hiragana: "3041-3096309D-309F", + Inherited: "0300-036F04850486064B-06550670095109521CD0-1CD21CD4-1CE01CE2-1CE81CED1DC0-1DE61DFD-1DFF200C200D20D0-20F0302A-302F3099309AFE00-FE0FFE20-FE26", + Javanese: "A980-A9CDA9CF-A9D9A9DEA9DF", + Kannada: "0C820C830C85-0C8C0C8E-0C900C92-0CA80CAA-0CB30CB5-0CB90CBC-0CC40CC6-0CC80CCA-0CCD0CD50CD60CDE0CE0-0CE30CE6-0CEF", + Katakana: "30A1-30FA30FD-30FF31F0-31FF32D0-32FE3300-3357FF66-FF6FFF71-FF9D", + Kayah_Li: "A900-A92F", + Khmer: "1780-17DD17E0-17E917F0-17F919E0-19FF", + Lao: "0E810E820E840E870E880E8A0E8D0E94-0E970E99-0E9F0EA1-0EA30EA50EA70EAA0EAB0EAD-0EB90EBB-0EBD0EC0-0EC40EC60EC8-0ECD0ED0-0ED90EDC0EDD", + Latin: "0041-005A0061-007A00AA00BA00C0-00D600D8-00F600F8-02B802E0-02E41D00-1D251D2C-1D5C1D62-1D651D6B-1D771D79-1DBE1E00-1EFF2071207F2090-2094212A212B2132214E2160-21882C60-2C7FA722-A787A78BA78CA7FB-A7FFFB00-FB06FF21-FF3AFF41-FF5A", + Lepcha: "1C00-1C371C3B-1C491C4D-1C4F", + Limbu: "1900-191C1920-192B1930-193B19401944-194F", + Lisu: "A4D0-A4FF", + Malayalam: "0D020D030D05-0D0C0D0E-0D100D12-0D280D2A-0D390D3D-0D440D46-0D480D4A-0D4D0D570D60-0D630D66-0D750D79-0D7F", + Meetei_Mayek: "ABC0-ABEDABF0-ABF9", + Mongolian: "1800180118041806-180E1810-18191820-18771880-18AA", + Myanmar: "1000-109FAA60-AA7B", + New_Tai_Lue: "1980-19AB19B0-19C919D0-19DA19DE19DF", + NKo: "07C0-07FA", + Ogham: "1680-169C", + Ol_Chiki: "1C50-1C7F", + Oriya: "0B01-0B030B05-0B0C0B0F0B100B13-0B280B2A-0B300B320B330B35-0B390B3C-0B440B470B480B4B-0B4D0B560B570B5C0B5D0B5F-0B630B66-0B71", + Phags_Pa: "A840-A877", + Rejang: "A930-A953A95F", + Runic: "16A0-16EA16EE-16F0", + Samaritan: "0800-082D0830-083E", + Saurashtra: "A880-A8C4A8CE-A8D9", + Sinhala: "0D820D830D85-0D960D9A-0DB10DB3-0DBB0DBD0DC0-0DC60DCA0DCF-0DD40DD60DD8-0DDF0DF2-0DF4", + Sundanese: "1B80-1BAA1BAE-1BB9", + Syloti_Nagri: "A800-A82B", + Syriac: "0700-070D070F-074A074D-074F", + Tagalog: "1700-170C170E-1714", + Tagbanwa: "1760-176C176E-177017721773", + Tai_Le: "1950-196D1970-1974", + Tai_Tham: "1A20-1A5E1A60-1A7C1A7F-1A891A90-1A991AA0-1AAD", + Tai_Viet: "AA80-AAC2AADB-AADF", + Tamil: "0B820B830B85-0B8A0B8E-0B900B92-0B950B990B9A0B9C0B9E0B9F0BA30BA40BA8-0BAA0BAE-0BB90BBE-0BC20BC6-0BC80BCA-0BCD0BD00BD70BE6-0BFA", + Telugu: "0C01-0C030C05-0C0C0C0E-0C100C12-0C280C2A-0C330C35-0C390C3D-0C440C46-0C480C4A-0C4D0C550C560C580C590C60-0C630C66-0C6F0C78-0C7F", + Thaana: "0780-07B1", + Thai: "0E01-0E3A0E40-0E5B", + Tibetan: "0F00-0F470F49-0F6C0F71-0F8B0F90-0F970F99-0FBC0FBE-0FCC0FCE-0FD4", + Tifinagh: "2D30-2D652D6F", + Vai: "A500-A62B", + Yi: "A000-A48CA490-A4C6" +}; + +var unicode = { + categories: UnicodeCategories, + blocks: UnicodeBlocks, + scripts: UnicodeScripts +}; + +// EXPORTS +RegexParser.unicode = unicode; + +}()); diff --git a/gulliver/js/codemirrorOld/contrib/regex/js/parseregex.js b/gulliver/js/codemirrorOld/contrib/regex/js/parseregex.js new file mode 100644 index 000000000..8c2f2039d --- /dev/null +++ b/gulliver/js/codemirrorOld/contrib/regex/js/parseregex.js @@ -0,0 +1,847 @@ +/* Simple parser for Regular Expressions */ +/* Thanks to Marijn for patiently addressing some questions and to + * Steven Levithan for XRegExp http://xregexp.com/ for pointing the way to the regexps for the regex (I + * only discovered his own regex syntax editor RegexPal later on) */ + +/* +// Possible future to-dos: +0) Unicode plugin fix for astral and update for Unicode 6.0.0 +1) Allow parsing of string escaped regular expressions (e.g., \\ as \ and regular \n as an actual newline) and + could potentially integrate into parsing for other languages where known (e.g., string inside RegExp constructor) +2) If configured, allow parsing of replace strings (e.g., $1, \1) +3) Shared classes + a) As with ranges and unicode classes, could also try to supply equivalents which list all + characters inside a whole character class + b) Add common classes for ranges, inside char. classes, and allow for alternation of colors +4) Groups + a) detect max's (or even inner_group_mode) from CSS if specified as "max-available" + _cssPropertyExists('span.regex-max-available') || _cssPropertyExists('.regex-max-available'); + b) Remove inner_group_mode and just always both uniform and type-based styles? (first improve + inner_group_mode performance when on) +5) Expand configuration for different flavors of regex or language implementations corresponding to config + options +6) Allow free-spacing mode to work with newlines? +*/ + +/** + * OPTIONS (SETUP): + * "possible_flags": {String} All flags to support (as a string of joined characters); default is 'imgxs'; + * if 'literal' is on, this will check for validity against the literal flags, but + * use the literal flags + * "flags": {String} List of flags to use on this query; will be added to any literals; default is '' + * "literal": {Boolean} Whether inside a literal or not + * "literal_initial": {String} The initial character to surround regular expression (optionally followed by flags); + * A forward slash ("/"), by default + * + * OPTIONS (STYLING) + * "inner_group_mode": {'type'|'uniform'} Indicates how (if at all) to style content inside groups; if by "type", + * the class will be assigned by type; if "uniform", a class named + * "regex-group--" where is the nesting level and + * is the sequence number; the "uniform" option allows grouped + * content to be styled consistently (but potentially differently from + * the parentheses themselves) no matter the type of group + * "max_levels": {Number|String} Maximum number of nesting levels before class numbers repeat + * "max_alternating": {Number|String} Maximum number of alternating sequences at the same level before + * class numbers repeat + * + * OPTIONS (PATTERNS) + * "flavor": {'all'|'ecma-262-ed5'|'ecma-262-ed3'} Sets defaults for the following patterns according to the regex flavor + * + * "unicode_mode": {'simple'|'validate'|'store'} Mode for handling Unicode classes; unless 'simple' is chosen, may + * affect performance given initial need to load and subsequent need + * to parse and validate (i.e., selectively color), and, if 'store' is chosen, + * also makes these (many) additional values on the token object, e.g., + * for use by activeTokens for adding tooltips; Default is 'simple' which + * simply checks that the values are plausible; + * Note: To include Unicode validation, you must include your + * CodeMirror parserfile in this sequence: + * parserfile: ["parseregex.js", "parseregex-unicode.js"] + * "unicode_classes": {Boolean} Whether to accept all Unicode classes (unless overridden); default is true + * "unicode_blocks": {Boolean} Whether to accept Unicode blocks (overrides unicode_classes default); e.g., \p{InArabic} + * "unicode_scripts": {Boolean} Whether to accept Unicode scripts (overrides unicode_classes default); e.g., \p{Hebrew} + * "unicode_categories": {Boolean} Whether to accept Unicode categories (overrides unicode_classes default); e.g., \p{Ll} (for lower-case letters) + * "named_backreferences": {Boolean} Whether to accept named backreferences; default is true + * "empty_char_class": {Boolean} Whether to allow [] or [^] as character classes; default is true + * "mode_modifier": {Boolean} Whether to allow (?imsx) mode modifiers + * + * NOTE + * You can add the following to your CodeMirror configuration object in order to get simple tooltips showing the + * character equivalent of an escape sequence: + activeTokens : function (spanNode, tokenObject, editor) { + if (tokenObject.equivalent) { + spanNode.title = tokenObject.equivalent; + } + }, +....or this more advanced one which adds ranges (though you may wish to change the character limit, being + aware that browsers have a limitation on tooltip size, unless you were to also use a tooltip library which used + this information to expand the visible content): + activeTokens : (function () { + var charLimit = 500; + var lastEquivalent, rangeBegan, lastRangeHyphen; + + function _buildTitle (beginChar, endChar) { + var beginCode = beginChar.charCodeAt(0), endCode = endChar.charCodeAt(0); + var title = ''; + if (endCode - beginCode <= charLimit) { + for (var i = beginCode; i <= endCode; i++) { + title += String.fromCharCode(i); + } + } + return title; + } + + return function (spanNode, token, editor) { + var content = token.content; + if (lastEquivalent && token.style === 'regex-class-range-hyphen') { + rangeBegan = true; + lastRangeHyphen = spanNode; + } + else if (rangeBegan) { + var beginChar = lastEquivalent; + var endChar = (token.equivalent || content); + lastRangeHyphen.title = _buildTitle(beginChar, endChar); + rangeBegan = false; + lastEquivalent = null; + //editor.reparseBuffer(); // title must be redrawn since already added previously (do below instead as locking up on undo?); too intensive to call this, but keeping here for record + } + else if (content === ']') { + rangeBegan = false; + } + else { + rangeBegan = false; + // Fix: 'regex-unicode-class-inside' not supported and should not be since it wouldn't make sense as a starting range? + lastEquivalent = token.equivalent || content; + } + + if (token.display) { + spanNode.title = token.display; + } + else if (token.equivalent) { + if (token.unicode) { + var range = /(.)-(.)/g; + spanNode.title = token.equivalent.replace(range, + function (n0, n1, n2) { + return _buildTitle(n1, n2); + } + ); + // editor.reparseBuffer(); // too intensive to call this, but keeping here for record + } + else { + spanNode.title = token.equivalent; + // editor.reparseBuffer(); // too intensive to call this, but keeping here for record + } + } + }; + }()), + */ + + +var RegexParser = Editor.Parser = (function() { + + var regexConfigBooleanOptions = ['unicode_blocks', 'unicode_scripts', 'unicode_categories', + 'unicode_classes', 'named_backreferences', 'empty_char_class', 'mode_modifier'], + regexConfigStringOptions = ['unicode_mode'], // Just for record-keeping + possibleFlags = 'imgxs', + config = {}, ucl; + // Resettable + var initialFound, endFound, charClassRangeBegun, negatedCharClass, mode_modifier_begun, flags = '', + groupTypes, groupCounts; + + config.literal_initial = '/'; + + // Adapted from tokenize.js (not distinctly treating whitespace except for newlines) + function noWSTokenizer (source, state) { + var tokenizer = { + state: state, + take: function(type) { + if (typeof(type) == "string") + type = {style: type, type: type}; + type.content = (type.content || "") + source.get(); + type.value = type.content + source.get(); + return type; + }, + next: function () { + if (!source.more()) throw StopIteration; + var type; + if (source.equals("\n")) { + source.next(); + return this.take("whitespace"); + } + while (!type) + type = this.state(source, function(s) {tokenizer.state = s;}); + return this.take(type); + } + }; + return tokenizer; + } + + // Private static utilities + function _expandRange (type, name) { // More efficient than unpack in targeting only which we need (though ideally would not need to convert at all) + var codePt = /\w{4}/g, + unicode = RegexParser.unicode, group = unicode[type]; + if (group.hasOwnProperty(name)) { + // group[name] = group[name].replace(codePt, '\\u$&'); // We shouldn't need this unless we start validating against a matching string + return group[name].replace(codePt, + function (n0) { + if (n0 === '002D') { + return 'U+' + n0; // Leave genuine hyphens unresolved so they won't get confused with range hyphens + } + return String.fromCharCode(parseInt('0x' + n0, 16)); // Fix: Would be more efficient to store as Unicode characters like this from the start + }); + } + return false; + } + + function _copyObj (obj, deep) { + var ret = {}; + for (var p in obj) { + if (obj.hasOwnProperty(p)) { + if (deep && typeof obj[p] === 'object' && obj[p] !== null) { + ret[p] = _copyObj(obj[p], deep); + } + else { + ret[p] = obj[p]; + } + } + } + return ret; + } + + function _forEach (arr, h) { + for (var i = 0, arrl = arr.length; i < arrl; i++) { + h(arr[i], i); + } + } + function _setOptions (arr, value) { + arr = typeof arr === 'string' ? [arr] : arr; + _forEach(arr, function (item) { + config[item] = value; + }); + } + + function _cssPropertyExists (selectorText) { + var i = 0, j = 0, dsl = 0, crl = 0, ss, d = document, + _getPropertyFromStyleSheet = + function (ss, selectorText) { + var rules = ss.cssRules ? ss.cssRules : ss.rules; /* Mozilla or IE */ + for (j = 0, crl = rules.length; j < crl; j++) { + var rule = rules[j]; + try { + if (rule.type === CSSRule.STYLE_RULE && rule.selectorText === selectorText) { + return true; + } + } + catch (err) { /* IE */ + if (rule.selectorText === selectorText) { + return true; + } + } + } + return false; + }; + + var value; + for (i = 0, dsl = d.styleSheets.length; i < dsl; i++) { + ss = d.styleSheets[i]; + value = _getPropertyFromStyleSheet(ss, selectorText); + if (value) { + break; + } + } + return value; + } + + function _addFlags (f) { + if ((/[^a-z]/).test(f)) { // Could insist on particular flags + throw 'Invalid flag supplied to the regular expression parser'; + } + flags += f; + } + function _setPossibleFlags (f) { + if ((/[^a-z]/).test(f)) { // Could insist on particular flags + throw 'Invalid flag supplied to the regular expression parser'; + } + possibleFlags = f; + } + function _esc (s) { + return s.replace(/"[.\\+*?\[\^\]$(){}=!<>|:\-]/g, '\\$&'); + } + + var tokenizeRegex = (function() { + // Private utilities + function _hasFlag (f) { + return flags.indexOf(f) > -1; + } + function _lookAheadMatches (source, regex) { + var matches = source.lookAheadRegex(regex, true); + if (matches && matches.length > 1) { // Allow us to return the position of a match out of alternates + for (var i = matches.length - 1; i >= 0; i--) { + if (matches[i] != null) { + return i; + } + } + } + return 0; + } + + function validateUnicodeClass (negated, place, source) { + var neg = ' regex-' + negated + 'unicode', ret = 'regex-unicode-class-' + place + neg, + name, unicode = RegexParser.unicode; + if (!unicode) { + throw 'Unicode plugin of the regular expression parser not properly loaded'; + } + if (config.unicode_categories) { + var categories = source.lookAheadRegex(/^\\[pP]{\^?([A-Z][a-z]?)}/, true); + if (categories) { + name = categories[1]; + if (unicode.categories[name]) { + return ret + '-category-' + place + neg + '-category-' + name + '-' + place; + } + return 'regex-bad-sequence'; + } + } + if (config.unicode_blocks) { + var blocks = source.lookAheadRegex(/^\\[pP]{\^?(In[A-Z][^}]*)}/, true); + if (blocks) { + name = blocks[1]; + if (unicode.blocks[name]) { + return ret + '-block-' + place + neg + '-block-' + name + '-' + place; + } + return 'regex-bad-sequence'; + } + } + if (config.unicode_scripts) { + var scripts = source.lookAheadRegex(/^\\[pP]{\^?([^}]*)}/, true); + if (scripts) { + name = scripts[1]; + if (unicode.scripts[name]) { + return ret + '-script-' + place + neg + '-script-' + name + '-' + place; + } + return 'regex-bad-sequence'; + } + } + return false; + } + + function unicode_class (source, place) { + var ret = 'regex-unicode-class-' + place + ' ', negated = ''; + if (source.lookAheadRegex(/^\\P/) || source.lookAheadRegex(/^\\p{\^/)) { + negated = 'negated'; + } + else if (source.lookAheadRegex(/^\\P{\^/)) { // Double-negative + return false; + } + switch (config.unicode_mode) { + case 'validate': case 'store': + return validateUnicodeClass(negated, place, source); + case 'simple': // Fall-through + default: + // generic: /^\\[pP]{\^?[^}]*}/ + if (config.unicode_categories && source.lookAheadRegex(/^\\[pP]{\^?[A-Z][a-z]?}/, true)) { + return ret + 'regex-' + negated + 'unicode-category'; + } + if (config.unicode_blocks && source.lookAheadRegex(/^\\[pP]{\^?In[A-Z][^}]*}/, true)) { + return ret + 'regex-' + negated + 'unicode-block'; + } + if (config.unicode_scripts && source.lookAheadRegex(/^\\[pP]{\^?[^}]*}/, true)) { + return ret + 'regex-' + negated + 'unicode-script'; + } + break; + } + return false; + } + + // State functions + // Changed [\s\S] to [^\n] to avoid accidentally grabbing a terminating (auto-inserted place-holder?) newline + var inside_class_meta = /^\\(?:([0-3][0-7]{0,2}|[4-7][0-7]?)|(x[\dA-Fa-f]{2})|(u[\dA-Fa-f]{4})|(c[A-Za-z])|(-\\]^)|([bBdDfnrsStvwW0])|([^\n]))/; + function inside_class (source, setState) { + var ret; + if (source.lookAhead(']', true)) { + // charClassRangeBegun = false; // Shouldn't be needed + setState(customOutsideClass); + return 'regex-class-end'; + } + if (negatedCharClass && source.lookAhead('^', true)) { + negatedCharClass = false; + return 'regex-class-negator'; + } + if (source.lookAhead('-', true)) { + if (!charClassRangeBegun) { + ret = 'regex-class-initial-hyphen'; + } + else if (source.equals(']')) { + ret = 'regex-class-final-hyphen'; + } + else { + return 'regex-class-range-hyphen'; + } + } + else if (!source.equals('\\')) { + var ch = source.next(); + if (config.literal && ch === config.literal_initial) { + return 'regex-bad-character'; + } + ret = 'regex-class-character'; + } + else if ((ucl = unicode_class(source, 'inside'))) { + ret = ucl; + } + else if (source.lookAheadRegex(/^\\(\n|$)/)) { // Treat an ending backslash like a bad + // character to avoid auto-adding of extra text + source.next(); + ret = 'regex-bad-character'; + } + else { + switch (_lookAheadMatches(source, inside_class_meta)) { + case 1: + ret = 'regex-class-octal'; + break; + case 2: + ret = 'regex-class-hex'; + break; + case 3: + ret = 'regex-class-unicode-escape'; + break; + case 4: + ret = 'regex-class-ascii-control'; + break; + case 5: + ret = 'regex-class-escaped-special'; + break; + case 6: + ret = 'regex-class-special-escape'; + break; + case 7: + ret = 'regex-class-extra-escaped'; + break; + default: + throw 'Unexpected character inside class, beginning ' + + source.lookAheadRegex(/^[\s\S]+$/)[0] + ' and of length '+ + source.lookAheadRegex(/^[\s\S]+$/)[0].length; // Shouldn't reach here + } + } + // Fix: Add this as a token property in the parser instead? + if (charClassRangeBegun) { + charClassRangeBegun = false; + ret += '-end-range'; + } + else if (source.equals('-')) { + charClassRangeBegun = true; + ret += '-begin-range'; + } + return ret; + } + + // Changed [\s\S] to [^\n] to avoid accidentally grabbing a terminating (auto-inserted place-holder?) newline + var outside_class_meta = /^(?:\\(?:(0(?:[0-3][0-7]{0,2}|[4-7][0-7]?)?)|([1-9]\d*)|(x[\dA-Fa-f]{2})|(u[\dA-Fa-f]{4})|(c[A-Za-z])|([bBdDfnrsStvwW0])|([?*+])|([.\\[$|{])|([^\n]))|([?*+]\??)|({\d+(?:,\d*)?}\??))/; + function outside_class (source, setState) { + if ((ucl = unicode_class(source, 'outside'))) { + return ucl; + } + switch (_lookAheadMatches(source, outside_class_meta)) { + case 1: + return 'regex-octal'; + case 2: + return 'regex-ascii'; + case 3: + return 'regex-hex'; + case 4: + return 'regex-unicode-escape'; + case 5: + return 'regex-ascii-control'; + case 6: + return 'regex-special-escape'; + case 7: + return 'regex-quantifier-escape'; // Fix: could probably just merge with escaped-special + case 8: + return 'regex-escaped-special'; + case 9: + return 'regex-extra-escaped'; + case 10: + return 'regex-quantifiers'; + case 11: + return 'regex-repetition'; + default: + if (config.literal && source.lookAhead(config.literal_initial, true)) { + if (!initialFound) { + initialFound = true; + return 'regex-literal-begin'; + } + endFound = true; + setState(beginFlags); + return 'regex-literal-end'; + } + if (source.lookAhead('|', true)) { + return 'regex-alternator'; + } + if (source.lookAheadRegex(/^\\$/, true)) { + return 'regex-bad-character'; + } + source.next(); + return 'regex-character'; + } + } + function beginFlags (source, setState) { + var endFlags = source.lookAheadRegex(new RegExp('^[' + possibleFlags + ']*', ''), true); + if (endFlags == null) { + // Unrecognized flag used in regular expression literal + return 'regex-bad-character'; + } + // Already confirmed validity earlier + setState(finished); + return 'regex-flags'; + } + function finished () { + throw StopIteration; + } + + function customOutsideClass (source, setState) { + if (config.named_backreferences && source.lookAheadRegex(/^\\k<([\w$]+)>/, true)) { + return 'regex-named-backreference'; + } + if (_hasFlag('x') && source.lookAheadRegex(/^(?:#.*)+?/, true)) { // Fix: lookAheadRegex will avoid new lines; added extra '?' at end + // Regex should be /^(?:\s+|#.*)+?/ but this was problematic + return 'regex-free-spacing-mode'; + } + + if (source.lookAhead('[', true)) { + if (source.lookAheadRegex(/^\^?]/, true)) { + return config.empty_char_class ? 'regex-empty-class' : 'regex-bad-character'; + } + if (source.equals('^')) { + negatedCharClass = true; + } + setState(inside_class); + return 'regex-class-begin'; + } + + // Unmatched ending parentheses + if (source.lookAhead(')', true)) { + return 'regex-ending-group'; + } + if (source.lookAhead('(', true)) { + if (config.mode_modifier && mode_modifier_begun) { + var mode_modifier = source.lookAheadRegex(/^\?([imsx]+)\)/, true); + if (mode_modifier) { // We know it should exist if we're here + // addFlags(mode_modifier[1]); // Handle flags earlier + mode_modifier_begun = false; + return 'regex-mode-modifier'; + } + } + if (source.lookAheadRegex(/^\?#[^)]*\)/, true)) { // No apparent nesting of comments? + return 'regex-comment-pattern'; + } + + var ret; + if (source.lookAheadRegex(/^(?!\?)/, true)) { + ret = 'regex-capturing-group'; + } + if (source.lookAheadRegex(/^\?<([$\w]+)>/, true)) { + ret = 'regex-named-capturing-group'; + } + if (source.lookAheadRegex(/^\?[:=!]/, true)) { + ret = 'regex-grouping'; + } + if (!ret) { + return 'regex-bad-character'; // 'Uncaught parenthetical in tokenizing regular expression'; + } + return ret; + } + return outside_class(source, setState); + } + + return function(source, startState) { + return noWSTokenizer(source, startState || customOutsideClass); + }; + })(); + + + function resetStateVariables () { + initialFound = false, endFound = false, charClassRangeBegun = false, negatedCharClass = false, + mode_modifier_begun = false; + flags = ''; + if (config.flags) { // Reset to configuration value + _addFlags(config.flags); + } + groupTypes = [], + groupCounts = { + 'capturing-group': {currentCount: 0}, + 'named-capturing-group': {currentCount: 0}, + 'grouping': {currentCount: 0} + }; + } + + // Parser + function parseRegex (source) { + resetStateVariables(); + + var tokens = tokenizeRegex(source); + + if (config.literal && !source.equals(config.literal_initial)) { + throw 'Regular expression literals must include a beginning "'+config.literal_initial+'"'; + } + + if (config.literal) { + var regex = new RegExp('^[\\s\\S]*' + _esc(config.literal_initial) + '([' + possibleFlags + ']*)$', ''); + var endFlags = source.lookAheadRegex(regex); + if (endFlags == null) { + // Unrecognized flag used in regular expression literal + } + else { + _addFlags(endFlags[1]); + } + } + else if (config.mode_modifier) { // Fix: We are not allowing both a mode modifier and + // literal syntax (presumably redundant) + var mode_modifier = source.lookAheadRegex(/^\(\?([imsx]+)\)/, true); + if (mode_modifier) { + mode_modifier_begun = true; + _addFlags(mode_modifier[1]); + } + } + var iter = { + next: function() { + try { + var level_num, + token = tokens.next(), + style = token.style, + content = token.content, + lastChildren, currentChildren, currentCount, currentGroupStyle, + type = style.replace(/^regex-/, ''); + + switch (type) { + case 'ending-group': + if (!groupTypes.length) { + // Closing parenthesis without an opening one + token.style = 'regex-bad-character'; + } + else { + level_num = config.max_levels ? + ((groupTypes.length % config.max_levels) || config.max_levels) : groupTypes.length; + var popped = groupTypes.pop(); + // Allow numbered classes + currentChildren = groupCounts[popped]; + while (currentChildren && currentChildren.currentChildren && + currentChildren.currentChildren.currentChildren) { // Find lowest level parent + currentChildren = currentChildren.currentChildren; + } + delete currentChildren.currentChildren; // Use parent to delete children + currentCount = currentChildren.currentCount; // Use parent as new child to get current count + currentCount = config.max_alternating ? + ((currentCount % config.max_alternating) || config.max_alternating) : currentCount; + + currentGroupStyle = level_num + '-' + currentCount; + token.style = 'regex-ending-' + popped + ' regex-ending-' + popped + currentGroupStyle; + if (config.inner_group_mode === 'uniform') { // 'type' is automatically processed for ending + token.style += ' regex-group-' + currentGroupStyle; + } + } + break; + case 'capturing-group': + case 'named-capturing-group': + case 'grouping': + lastChildren = groupCounts[type], + currentChildren = groupCounts[type].currentChildren; + while (currentChildren) { + lastChildren = currentChildren; + currentChildren = currentChildren.currentChildren; + } + currentCount = ++lastChildren.currentCount; + if (!lastChildren.currentChildren) { + lastChildren.currentChildren = {currentCount: 0}; + } + + groupTypes.push(type); + level_num = config.max_levels ? + ((groupTypes.length % config.max_levels) || config.max_levels) : groupTypes.length; + // Allow numbered classes + currentCount = config.max_alternating ? + ((currentCount % config.max_alternating) || config.max_alternating) : currentCount; + currentGroupStyle = level_num + '-' + currentCount; + var currentStyle = ' ' + token.style; + + + if (config.inner_group_mode) { + token.style += config.inner_group_mode === 'type' ? + currentStyle + currentGroupStyle : + ' regex-group-' + currentGroupStyle; + token.style += ' ' + style + currentGroupStyle; + } + else { + token.style += currentStyle + currentGroupStyle; + } + lastChildren.currentGroupStyle = currentGroupStyle; + lastChildren.currentStyle = currentStyle; + break; + // Allow ability to extract information on character equivalence, e.g., for use on tooltips + case 'class-octal': case 'octal': // Fall-through + case 'class-octal-begin-range': case 'class-octal-end-range': // Fall-through + case 'class-ascii-begin-range': case 'class-ascii-end-range': // Fall-through + case 'class-ascii': case 'ascii': // Firefox apparently treats ascii here as octals + token.equivalent = String.fromCharCode(parseInt(content.replace(/^\\/, ''), 8)); + break; + case 'class-hex': case 'hex': // Fall-through + case 'class-hex-begin-range': case 'class-hex-end-range': // Fall-through + case 'class-unicode-escape': case 'class-unicode-escape-begin-range': // Fall-through + case 'class-unicode-escape-end-range': case 'unicode-escape': + token.equivalent = String.fromCharCode(parseInt('0x'+content.replace(/^\\(x|u)/, ''), 16)); + break; + case 'class-ascii-control-begin-range': case 'class-ascii-control-end-range': // Fall-through + case 'class-ascii-control': case 'ascii-control': + token.equivalent = String.fromCharCode(content.replace(/^\\c/, '').charCodeAt(0) - 64); + break; + case 'class-special-escape': case 'class-special-escape-begin-range': // Fall-through + case 'class-special-escape-end-range': case 'special-escape': + // Others to ignore (though some (\d, \s, \w) could have theirs listed): bBdDsSwW + var chr = content.replace(/^\\/, ''), + pos = 'fnrtv'.indexOf(chr), + specialEquivs = '\f\n\r\t\v'; + if (pos !== -1) { // May not be visible without conversion to codepoints + var c = specialEquivs.charAt(pos); + var hex = c.charCodeAt(0).toString(16).toUpperCase(); + token.display = 'U+' + Array(5 - hex.length).join('0') + hex; + token.equivalent = c; + } + break; + case 'regex-class-escaped-special': case 'regex-class-escaped-special-begin-range': + case 'regex-class-escaped-special-end-range': + case 'class-extra-escaped-begin-range': case 'class-extra-escaped-end-range': + case 'class-extra-escaped': case 'extra-escaped': + token.equivalent = content.replace(/^\\/, ''); + break; + default: + if (config.unicode_mode === 'store') { + if (config.unicode_categories) { + var cat = type.match(/regex-unicode-category-(\w+?)-(?:outside|inside)/); + if (cat) { + token.equivalent = _expandRange('categories', cat[1]) || ''; + token.unicode = true; + break; + } + } + if (config.unicode_blocks) { + var block = type.match(/regex-unicode-block-(\w+)-(?:outside|inside)/); + if (block) { + token.equivalent = _expandRange('blocks', block[1]) || ''; + token.unicode = true; + break; + } + } + if (config.unicode_scripts) { + var script = type.match(/regex-unicode-script-(\w+)-(?:outside|inside)/); + if (script) { + token.equivalent = _expandRange('scripts', script[1]) || ''; + token.unicode = true; + break; + } + } + } + break; + } + if (config.inner_group_mode && type !== 'ending-group' && type !== 'capturing-group' && type !== 'named-capturing-group' && + type !== 'grouping') { + level_num = config.max_levels ? + ((groupTypes.length % config.max_levels) || config.max_levels) : groupTypes.length; + // Allow numbered classes + var last = groupTypes[groupTypes.length - 1]; + if (last) { + currentChildren = groupCounts[last]; + while (currentChildren && currentChildren.currentChildren && + currentChildren.currentChildren.currentChildren) { // Find lowest level parent + currentChildren = currentChildren.currentChildren; + } + token.style += config.inner_group_mode === 'type' ? + currentChildren.currentStyle + currentChildren.currentGroupStyle : + ' regex-group-' + currentChildren.currentGroupStyle; + } + } + if (!source.more()) { + if (groupTypes.length) { // Opening group without a closing parenthesis + token.style = 'regex-bad-character'; + } + else if (config.literal && !endFound) { + //throw 'Regular expression literals must include a (non-escaped) ending "' + + // config.literal_initial + '" (with optional flags).'; + token.style = 'regex-bad-character'; + } + } + } + catch (e) { +if (e != StopIteration) { + alert(e + '::'+e.lineNumber); +} + throw e; + } + return token; + }, + copy: function() { + var _initialFound = initialFound, _charClassRangeBegun = charClassRangeBegun, + _negatedCharClass = negatedCharClass, _flags = flags, + _endFound = endFound, _groupTypes = groupTypes, + _mode_modifier_begun = mode_modifier_begun, + _tokenState = tokens.state, + _groupCounts = _copyObj(groupCounts, true); + return function(source) { + initialFound = _initialFound; + charClassRangeBegun = _charClassRangeBegun; + negatedCharClass = _negatedCharClass; + flags = _flags; + endFound = _endFound; + groupTypes = _groupTypes; + mode_modifier_begun = _mode_modifier_begun; + tokens = tokenizeRegex(source, _tokenState); + groupCounts = _groupCounts; + return iter; + }; + } + }; + return iter; + } + + // Parser object + return { + make: parseRegex, + configure: function (parserConfig) { + var unicode = this.unicode; + + // Overridable + _setOptions('unicode_mode', 'simple'); + _setOptions(regexConfigBooleanOptions, false); + if (parserConfig.unicode_classes) { + _setOptions(['unicode_blocks', 'unicode_scripts', 'unicode_categories'], true); + } + switch (parserConfig.flavor) { + case 'ecma-262-ed5': + _setOptions(['empty_char_class'], true); + // Fall-through + case 'ecma-262-ed3': + config.possible_flags = 'gim'; // If wish for Firefox 'y', add it on parserConfig + break; + case 'all': + default: + _setOptions(regexConfigBooleanOptions, true); + break; + } + + // Setting with possible overrides + for (var opt in parserConfig) { + if ((/^regex_/).test(opt)) { // Use for compatibility with JS+Regex + config[opt.replace(/^regex_/, '')] = parserConfig[opt]; + continue; + } + config[opt] = parserConfig[opt]; + } + + // Post-processing + if (config.possible_flags) { + _setPossibleFlags(config.possible_flags); + } + + if (config.unicode_mode !== 'simple') { + if (!unicode) { + throw 'You must include the parseregex-unicode.js file in order to use validate or storage mode Unicode'; + } + } + } + }; +})(); diff --git a/gulliver/js/codemirrorOld/contrib/scheme/LICENSE b/gulliver/js/codemirrorOld/contrib/scheme/LICENSE new file mode 100644 index 000000000..9f8a9f340 --- /dev/null +++ b/gulliver/js/codemirrorOld/contrib/scheme/LICENSE @@ -0,0 +1,23 @@ + Copyright (c) 2010 Danny Yoo + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any + damages arising from the use of this software. + + Permission is granted to anyone to use this software for any + purpose, including commercial applications, and to alter it and + redistribute it freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product + documentation would be appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must + not be misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source + distribution. + + Danny Yoo + dyoo@cs.wpi.edu diff --git a/gulliver/js/codemirrorOld/contrib/scheme/css/schemecolors.css b/gulliver/js/codemirrorOld/contrib/scheme/css/schemecolors.css new file mode 100644 index 000000000..7283510bc --- /dev/null +++ b/gulliver/js/codemirrorOld/contrib/scheme/css/schemecolors.css @@ -0,0 +1,45 @@ +html { + cursor: text; + width: 100%; + height: 100%; + background-color: white; +} + +.editbox { + width: 100%; + height: 100%; + margin: 0pt; + padding: 0; + font-family: monospace; + font-size: 10pt; + color: black; +} + + + +pre.code, .editbox { + color: #666666; +} + +.editbox p { + margin: 0; +} + +span.scheme-string {color: green;} +span.scheme-number {color: blue;} +span.scheme-boolean {color: darkred;} +span.scheme-character {color: orange;} +span.scheme-symbol {color: steelblue;} +span.scheme-punctuation {color: black;} +span.scheme-lparen {color: black;} +span.scheme-rparen {color: black;} +span.scheme-comment { color: orange; } + +span.good-matching-paren { + font-weight: bold; + color: #3399FF; +} +span.bad-matching-paren { + font-weight: bold; + color: red; +} diff --git a/gulliver/js/codemirrorOld/contrib/scheme/index.html b/gulliver/js/codemirrorOld/contrib/scheme/index.html new file mode 100644 index 000000000..f47dbae67 --- /dev/null +++ b/gulliver/js/codemirrorOld/contrib/scheme/index.html @@ -0,0 +1,82 @@ + + + + + CodeMirror: Scheme demonstration + + + + + + +

This page demonstrates CodeMirror's +Scheme parser. (license)

+ +
+ +
+ + + + + diff --git a/gulliver/js/codemirrorOld/contrib/scheme/js/parsescheme.js b/gulliver/js/codemirrorOld/contrib/scheme/js/parsescheme.js new file mode 100644 index 000000000..6b1ffba88 --- /dev/null +++ b/gulliver/js/codemirrorOld/contrib/scheme/js/parsescheme.js @@ -0,0 +1,428 @@ +var SchemeParser = Editor.Parser = (function() { + + + // isLparen: char -> boolean + var isLparen = function(ch) { + return ch === '(' || ch === '[' || ch === '{'; + }; + + // isRparen: char -> boolean + var isRparen = function(ch) { + return ch === ')' || ch === ']' || ch === '}'; + }; + + // isMatchingParens: char char -> boolean + var isMatchingParens = function(lparen, rparen) { + return ((lparen === '(' && rparen === ')') || + (lparen === '[' && rparen === ']') || + (lparen === '{' && rparen === '}')); + }; + + + // Compute the indentation context enclosing the end of the token + // sequence tokens. + // The context is the token sequence of the enclosing s-expression, + // augmented with column information. + var getIndentationContext = function(tokenStack) { + var EMPTY_CONTEXT = []; + + var pendingParens = [], i = 0, j, line, column, context; + var tokens = []; + + // Scan for the start of the indentation context, accumulating tokens. + while (! isEmptyPair(tokenStack)) { + i++; + tokens.push(pairFirst(tokenStack)); + if (isLparen(pairFirst(tokenStack).type)) { + if (pendingParens.length === 0) { + break; + } else { + if (isMatchingParens(pairFirst(tokenStack).value, + pendingParens[pendingParens.length - 1])) { + pendingParens.pop(); + } else { + // Error condition: we see mismatching parens, + // so we exit with no known indentation context. + return EMPTY_CONTEXT; + } + } + } else if (isRparen(pairFirst(tokenStack).type)) { + pendingParens.push(pairFirst(tokenStack).type); + } + tokenStack = pairRest(tokenStack); + } + + // If we scanned backward too far, we couldn't find a context. Just + // return the empty context. + if (isEmptyPair(tokenStack)) { + return EMPTY_CONTEXT; + } + + // Position tokenStack to the next token beyond. + tokenStack = pairRest(tokenStack); + + // We now scan backwards to closest newline to figure out the column + // number: + while (! isEmptyPair(tokenStack)) { + if(pairFirst(tokenStack).type === 'whitespace' && + pairFirst(tokenStack).value === '\n') { + break; + } + tokens.push(pairFirst(tokenStack)); + tokenStack = pairRest(tokenStack); + } + + line = 0; + column = 0; + context = []; + // Start generating the context, walking forward. + for (j = tokens.length-1; j >= 0; j--) { + if (j < i) { + context.push({ type: tokens[j].type, + value: tokens[j].value, + line: line, + column: column }); + } + + if (tokens[j].type === 'whitespace' && + tokens[j].value === '\n') { + column = 0; + line++; + } else { + column += tokens[j].value.length; + } + } + return context; + + + }; + + + + + + // calculateIndentationFromContext: indentation-context number -> number + var calculateIndentationFromContext = function(context, currentIndentation) { + if (context.length === 0) { + return 0; + } + if (isBeginLikeContext(context)) { + return beginLikeIndentation(context); + } + if (isDefineLikeContext(context)) { + return defineLikeIndentation(context); + } + if (isLambdaLikeContext(context)) { + return lambdaLikeIndentation(context); + } + return beginLikeIndentation(context, 0); + }; + + + + // findContextElement: indentation-context number -> index or -1 + var findContextElement = function(context, index) { + var depth = 0; + for(var i = 0; i < context.length; i++) { + if (context[i].type !== 'whitespace' && depth === 1) { + if (index === 0) + return i; + else + index--; + } + + if (isLparen(context[i].type)) { + depth++; + } + if (isRparen(context[i].type)) { + depth = Math.max(depth - 1, 0); + } + } + return -1; + }; + + // contextElement: context -> (arrayof index) + var contextElements = function(context) { + var i = 0, index, results = []; + + while ((index = findContextElement(context, i++)) != -1) { + results.push(index); + } + return results; + }; + + + + ////////////////////////////////////////////////////////////////////// + + var BEGIN_LIKE_KEYWORDS = ["case-lambda", + "compound-unit", + "compound-unit/sig", + "cond", + "delay", + "inherit", + "match-lambda", + "match-lambda*", + "override", + "private", + "public", + "sequence", + "unit"]; + + var isBeginLikeContext = function(context) { + var j = findContextElement(context, 0); + if (j === -1) { return false; } + return (/^begin/.test(context[j].value) || + isMember(context[j].value, BEGIN_LIKE_KEYWORDS)); + }; + + + // Begin: if there's no elements within the begin context, + // the indentation is that of the begin keyword's column + offset. + // Otherwise, find the leading element on the last line. + // Also used for default indentation. + var beginLikeIndentation = function(context, offset) { + if (typeof(offset) === 'undefined') { offset = 1; } + + var indices = contextElements(context), j; + if (indices.length === 0) { + return context[0].column + 1; + } else if (indices.length === 1) { + // if we only see the begin keyword, indentation is based + // off the keyword. + return context[indices[0]].column + offset; + } else { + // Otherwise, we scan for the contextElement of the last line + for (j = indices.length -1; j > 1; j--) { + if (context[indices[j]].line !== + context[indices[j-1]].line) { + return context[indices[j]].column; + } + } + return context[indices[j]].column; + } + }; + + + + ////////////////////////////////////////////////////////////////////// + + + var DEFINE_LIKE_KEYWORDS = ["local"]; + + var isDefineLikeContext = function(context) { + var j = findContextElement(context, 0); + if (j === -1) { return false; } + return (/^def/.test(context[j].value) || + isMember(context[j].value, DEFINE_LIKE_KEYWORDS)); + }; + + + var defineLikeIndentation = function(context) { + var i = findContextElement(context, 0); + if (i === -1) { return 0; } + return context[i].column +1; + }; + + ////////////////////////////////////////////////////////////////////// + + var LAMBDA_LIKE_KEYWORDS = ["cases", + "instantiate", + "super-instantiate", + "syntax/loc", + "quasisyntax/loc", + "lambda", + "let", + "let*", + "letrec", + "recur", + "lambda/kw", + "letrec-values", + "with-syntax", + "with-continuation-mark", + "module", + "match", + "match-let", + "match-let*", + "match-letrec", + "let/cc", + "let/ec", + "letcc", + "catch", + "let-syntax", + "letrec-syntax", + "fluid-let-syntax", + "letrec-syntaxes+values", + "for", + "for/list", + "for/hash", + "for/hasheq", + "for/and", + "for/or", + "for/lists", + "for/first", + "for/last", + "for/fold", + "for*", + "for*/list", + "for*/hash", + "for*/hasheq", + "for*/and", + "for*/or", + "for*/lists", + "for*/first", + "for*/last", + "for*/fold", + "kernel-syntax-case", + "syntax-case", + "syntax-case*", + "syntax-rules", + "syntax-id-rules", + "let-signature", + "fluid-let", + "let-struct", + "let-macro", + "let-values", + "let*-values", + "case", + "when", + "unless", + "let-enumerate", + "class", + "class*", + "class-asi", + "class-asi*", + "class*/names", + "class100", + "class100*", + "class100-asi", + "class100-asi*", + "class100*/names", + "rec", + "make-object", + "mixin", + "define-some", + "do", + "opt-lambda", + "send*", + "with-method", + "define-record", + "catch", + "shared", + "unit/sig", + "unit/lang", + "with-handlers", + "interface", + "parameterize", + "call-with-input-file", + "call-with-input-file*", + "with-input-from-file", + "with-input-from-port", + "call-with-output-file", + "with-output-to-file", + "with-output-to-port", + "for-all"]; + + + var isLambdaLikeContext = function(context) { + var j = findContextElement(context, 0); + if (j === -1) { return false; } + return (isMember(context[j].value, LAMBDA_LIKE_KEYWORDS)); + }; + + + var lambdaLikeIndentation = function(context) { + var i = findContextElement(context, 0); + if (i === -1) { return 0; } + var j = findContextElement(context, 1); + if (j === -1) { + return context[i].column + 4; + } else { + return context[i].column + 1; + } + }; + + + + + ////////////////////////////////////////////////////////////////////// + // Helpers + var isMember = function(x, l) { + for (var i = 0; i < l.length; i++) { + if (x === l[i]) { return true; } + } + return false; + }; + + + + ////////////////////////////////////////////////////////////////////// + + var pair = function(x, y) { + return [x,y]; + }; + var EMPTY_PAIR = []; + var pairFirst = function(p) { return p[0]; } + var pairRest = function(p) { return p[1]; } + var isEmptyPair = function(p) { return p === EMPTY_PAIR; } + var pairLength = function(p) { + var l = 0; + while (! isEmptyPair(p)) { + p = pairRest(p); + } + return l; + }; + + ////////////////////////////////////////////////////////////////////// + + + + + var indentTo = function(tokenStack) { + return function(tokenText, currentIndentation, direction) { + + // If we're in the middle of an unclosed token, + // do not change indentation. + if ((! isEmptyPair(tokenStack)) && + (! isEmptyPair(pairRest(tokenStack))) && + (pairFirst(pairRest(tokenStack)).isUnclosed)) { + return currentIndentation; + } + + var indentationContext = + getIndentationContext(tokenStack); + return calculateIndentationFromContext(indentationContext, + currentIndentation); + }; + }; + + + var startParse = function(source) { + source = tokenizeScheme(source); + var tokenStack = EMPTY_PAIR; + var iter = { + next: function() { + var tok = source.next(); + tokenStack = pair(tok, tokenStack); + if (tok.type === "whitespace") { + if (tok.value === "\n") { + tok.indentation = indentTo(tokenStack); + } + } + return tok; + }, + + copy: function() { + var _tokenStack = tokenStack; + var _tokenState = source.state; + return function(_source) { + tokenStack = _tokenStack; + source = tokenizeScheme(_source, _tokenState); + return iter; + }; + } + }; + return iter; + }; + return { make: startParse }; +})(); diff --git a/gulliver/js/codemirrorOld/contrib/scheme/js/tokenizescheme.js b/gulliver/js/codemirrorOld/contrib/scheme/js/tokenizescheme.js new file mode 100644 index 000000000..37df0bb9e --- /dev/null +++ b/gulliver/js/codemirrorOld/contrib/scheme/js/tokenizescheme.js @@ -0,0 +1,241 @@ +/* Tokenizer for Scheme code */ + + + + +/** + TODO: follow the definitions in: + + http://docs.racket-lang.org/reference/reader.html + + to the letter; at the moment, we've just done something quick-and-dirty. + +*/ + + +var tokenizeScheme = (function() { + var isWhiteSpace = function(ch) { + // The messy regexp is because IE's regexp matcher is of the + // opinion that non-breaking spaces are no whitespace. + return ch != "\n" && /^[\s\u00a0]*$/.test(ch); + }; + + + // scanUntilUnescaped: string-stream char -> boolean + // Advances the stream until the given character (not preceded by a + // backslash) is encountered. + // Returns true if we hit end of line without closing. + // Returns false otherwise. + var scanUntilUnescaped = function(source, end) { + var escaped = false; + while (true) { + if (source.endOfLine()) { + return true; + } + var next = source.next(); + if (next == end && !escaped) + return false; + escaped = !escaped && next == "\\"; + } + return false; + } + + + // Advance the stream until endline. + var scanUntilEndline = function(source, end) { + while (!source.endOfLine()) { + source.next(); + } + } + + + // Some helper regexps + var isHexDigit = /[0-9A-Fa-f]/; + + + var whitespaceChar = new RegExp("[\\s\\u00a0]"); + + var isDelimiterChar = + new RegExp("[\\s\\\(\\\)\\\[\\\]\\\{\\\}\\\"\\\,\\\'\\\`\\\;]"); + + var isNotDelimiterChar = + new RegExp("[^\\s\\\(\\\)\\\[\\\]\\\{\\\}\\\"\\\,\\\'\\\`\\\;]"); + + + var numberHeader = ("(?:(?:\\d+\\/\\d+)|"+ + ( "(?:(?:\\d+\\.\\d+|\\d+\\.|\\.\\d+)(?:[eE][+\\-]?\\d+)?)|")+ + ( "(?:\\d+(?:[eE][+\\-]?\\d+)?))")); + var numberPatterns = [ + // complex numbers + new RegExp("^((?:(?:\\#[ei])?[+\\-]?" + numberHeader +")?" + + "(?:[+\\-]" + numberHeader + ")i$)"), + /^((?:\#[ei])?[+-]inf.0)$/, + /^((?:\#[ei])?[+-]nan.0)$/, + new RegExp("^((?:\\#[ei])?[+\\-]?" + numberHeader + "$)"), + new RegExp("^0[xX][0-9A-Fa-f]+$")]; + + + // looksLikeNumber: string -> boolean + // Returns true if string s looks like a number. + var looksLikeNumber = function(s) { + for (var i = 0; i < numberPatterns.length; i++) { + if (numberPatterns[i].test(s)) { + return true; + } + } + return false; + }; + + + + var UNCLOSED_STRING = function(source, setState) { + var readNewline = function() { + var content = source.get(); + return { type:'whitespace', style:'whitespace', content: content }; + }; + + var ch = source.peek(); + if (ch === '\n') { + source.next(); + return readNewline(); + } else { + var isUnclosedString = scanUntilUnescaped(source, '"'); + if (isUnclosedString) { + setState(UNCLOSED_STRING); + } else { + setState(START); + } + var content = source.get(); + return {type: "string", style: "scheme-string", content: content, + isUnclosed: isUnclosedString}; + } + }; + + + + var START = function(source, setState) { + // Read a word, look it up in keywords. If not found, it is a + // variable, otherwise it is a keyword of the type found. + var readWordOrNumber = function() { + source.nextWhileMatches(isNotDelimiterChar); + var word = source.get(); + if (looksLikeNumber(word)) { + return {type: "number", style: "scheme-number", content: word}; + } else { + return {type: "variable", style: "scheme-symbol", content: word}; + } + }; + + + var readString = function(quote) { + var isUnclosedString = scanUntilUnescaped(source, quote); + if (isUnclosedString) { + setState(UNCLOSED_STRING); + } + var word = source.get(); + return {type: "string", style: "scheme-string", content: word, + isUnclosed: isUnclosedString}; + }; + + + var readPound = function() { + var text; + // FIXME: handle special things here + if (source.equals(";")) { + source.next(); + text = source.get(); + return {type: text, + style:"scheme-symbol", + content: text}; + } else { + text = source.get(); + + return {type : "symbol", + style: "scheme-symbol", + content: text}; + } + + }; + + var readLineComment = function() { + scanUntilEndline(source); + var text = source.get(); + return { type: "comment", style: "scheme-comment", content: text}; + }; + + + var readWhitespace = function() { + source.nextWhile(isWhiteSpace); + var content = source.get(); + return { type: 'whitespace', style:'whitespace', content: content }; + }; + + var readNewline = function() { + var content = source.get(); + return { type:'whitespace', style:'whitespace', content: content }; + }; + + + // Fetch the next token. Dispatches on first character in the + // stream, or first two characters when the first is a slash. + var ch = source.next(); + if (ch === '\n') { + return readNewline(); + } else if (whitespaceChar.test(ch)) { + return readWhitespace(); + } else if (ch === "#") { + return readPound(); + } else if (ch ===';') { + return readLineComment(); + } else if (ch === "\"") { + return readString(ch); + } else if (isDelimiterChar.test(ch)) { + return {type: ch, style: "scheme-punctuation"}; + } else { + return readWordOrNumber(); + } + } + + + + + + + + var makeTokenizer = function(source, state) { + // Newlines are always a separate token. + + var tokenizer = { + state: state, + + take: function(type) { + if (typeof(type) == "string") + type = {style: type, type: type}; + + type.content = (type.content || "") + source.get(); + type.value = type.content; + return type; + }, + + next: function () { + if (!source.more()) throw StopIteration; + + var type; + while (!type) { + type = tokenizer.state(source, function(s) { + tokenizer.state = s; + }); + } + var result = this.take(type); + return result; + } + }; + return tokenizer; + }; + + + // The external interface to the tokenizer. + return function(source, startState) { + return makeTokenizer(source, startState || START); + }; +})(); diff --git a/gulliver/js/codemirrorOld/contrib/sql/LICENSE b/gulliver/js/codemirrorOld/contrib/sql/LICENSE new file mode 100644 index 000000000..e3c6d2174 --- /dev/null +++ b/gulliver/js/codemirrorOld/contrib/sql/LICENSE @@ -0,0 +1,22 @@ + Copyright (c) 2009 John Benediktsson + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any + damages arising from the use of this software. + + Permission is granted to anyone to use this software for any + purpose, including commercial applications, and to alter it and + redistribute it freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product + documentation would be appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must + not be misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source + distribution. + + John Benediktsson diff --git a/gulliver/js/codemirrorOld/contrib/sql/css/sqlcolors.css b/gulliver/js/codemirrorOld/contrib/sql/css/sqlcolors.css new file mode 100644 index 000000000..958425222 --- /dev/null +++ b/gulliver/js/codemirrorOld/contrib/sql/css/sqlcolors.css @@ -0,0 +1,59 @@ +html { + cursor: text; +} + +.editbox { + margin: .4em; + padding: 0; + font-family: monospace; + font-size: 10pt; + color: black; +} + +.editbox p { + margin: 0; +} + +span.sql-keyword { + color: blue; +} + +span.sql-var { + color: red; +} + +span.sql-comment { + color: #AA7700; +} + +span.sql-literal { + color: green; +} + +span.sql-operator { + color: blue; +} + +span.sql-word { + color: black; +} + +span.sql-quoted-word { + color: #680; +} + +span.sql-function { + color: darkorange; +} + +span.sql-type { + color: purple; +} + +span.sql-separator { + color: #666666; +} + +span.sql-number { + color: darkcyan; +} diff --git a/gulliver/js/codemirrorOld/contrib/sql/index.html b/gulliver/js/codemirrorOld/contrib/sql/index.html new file mode 100644 index 000000000..4c3e27bc5 --- /dev/null +++ b/gulliver/js/codemirrorOld/contrib/sql/index.html @@ -0,0 +1,56 @@ + + + + CodeMirror: SQL demonstration + + + + +

Demonstration of CodeMirror's SQL +highlighter.

+ +

Written by John Benediktsson (license).

+ +
+ +
+ + + + + diff --git a/gulliver/js/codemirrorOld/contrib/sql/js/parsesql.js b/gulliver/js/codemirrorOld/contrib/sql/js/parsesql.js new file mode 100644 index 000000000..9b05d6066 --- /dev/null +++ b/gulliver/js/codemirrorOld/contrib/sql/js/parsesql.js @@ -0,0 +1,267 @@ +var SqlParser = Editor.Parser = (function() { + + function wordRegexp(words) { + return new RegExp("^(?:" + words.join("|") + ")$", "i"); + } + + var functions = wordRegexp([ + "abs", "acos", "adddate", "aes_encrypt", "aes_decrypt", "ascii", + "asin", "atan", "atan2", "avg", "benchmark", "bin", "bit_and", + "bit_count", "bit_length", "bit_or", "cast", "ceil", "ceiling", + "char_length", "character_length", "coalesce", "concat", "concat_ws", + "connection_id", "conv", "convert", "cos", "cot", "count", "curdate", + "current_date", "current_time", "current_timestamp", "current_user", + "curtime", "database", "date_add", "date_format", "date_sub", + "dayname", "dayofmonth", "dayofweek", "dayofyear", "decode", "degrees", + "des_encrypt", "des_decrypt", "elt", "encode", "encrypt", "exp", + "export_set", "extract", "field", "find_in_set", "floor", "format", + "found_rows", "from_days", "from_unixtime", "get_lock", "greatest", + "group_unique_users", "hex", "ifnull", "inet_aton", "inet_ntoa", "instr", + "interval", "is_free_lock", "isnull", "last_insert_id", "lcase", "least", + "left", "length", "ln", "load_file", "locate", "log", "log2", "log10", + "lower", "lpad", "ltrim", "make_set", "master_pos_wait", "max", "md5", + "mid", "min", "mod", "monthname", "now", "nullif", "oct", "octet_length", + "ord", "password", "period_add", "period_diff", "pi", "position", + "pow", "power", "quarter", "quote", "radians", "rand", "release_lock", + "repeat", "reverse", "right", "round", "rpad", "rtrim", "sec_to_time", + "session_user", "sha", "sha1", "sign", "sin", "soundex", "space", "sqrt", + "std", "stddev", "strcmp", "subdate", "substring", "substring_index", + "sum", "sysdate", "system_user", "tan", "time_format", "time_to_sec", + "to_days", "trim", "ucase", "unique_users", "unix_timestamp", "upper", + "user", "version", "week", "weekday", "yearweek" + ]); + + var keywords = wordRegexp([ + "alter", "grant", "revoke", "primary", "key", "table", "start", "top", + "transaction", "select", "update", "insert", "delete", "create", "describe", + "from", "into", "values", "where", "join", "inner", "left", "natural", "and", + "or", "in", "not", "xor", "like", "using", "on", "order", "group", "by", + "asc", "desc", "limit", "offset", "union", "all", "as", "distinct", "set", + "commit", "rollback", "replace", "view", "database", "separator", "if", + "exists", "null", "truncate", "status", "show", "lock", "unique", "having", + "drop", "procedure", "begin", "end", "delimiter", "call", "else", "leave", + "declare", "temporary", "then" + ]); + + var types = wordRegexp([ + "bigint", "binary", "bit", "blob", "bool", "char", "character", "date", + "datetime", "dec", "decimal", "double", "enum", "float", "float4", "float8", + "int", "int1", "int2", "int3", "int4", "int8", "integer", "long", "longblob", + "longtext", "mediumblob", "mediumint", "mediumtext", "middleint", "nchar", + "numeric", "real", "set", "smallint", "text", "time", "timestamp", "tinyblob", + "tinyint", "tinytext", "varbinary", "varchar", "year" + ]); + + var operators = wordRegexp([ + ":=", "<", "<=", "==", "<>", ">", ">=", "like", "rlike", "in", "xor", "between" + ]); + + var operatorChars = /[*+\-<>=&|:\/]/; + + var CFG = {}; + + var tokenizeSql = (function() { + function normal(source, setState) { + var ch = source.next(); + if (ch == "@" || ch == "$") { + source.nextWhileMatches(/[\w\d]/); + return "sql-var"; + } + else if (ch == "["){ + setState(inAlias(ch)) + return null; + } + else if (ch == "\"" || ch == "'" || ch == "`") { + setState(inLiteral(ch)); + return null; + } + else if (ch == "," || ch == ";") { + return "sql-separator" + } + else if (ch == '#') { + while (!source.endOfLine()) source.next(); + return "sql-comment"; + } + else if (ch == '-') { + if (source.peek() == "-") { + while (!source.endOfLine()) source.next(); + return "sql-comment"; + } + else if (/\d/.test(source.peek())) { + source.nextWhileMatches(/\d/); + if (source.peek() == '.') { + source.next(); + source.nextWhileMatches(/\d/); + } + return "sql-number"; + } + else + return "sql-operator"; + } + else if (operatorChars.test(ch)) { + + if(ch == "/" && source.peek() == "*"){ + setState(inBlock("sql-comment", "*/")); + return null; + } + else{ + source.nextWhileMatches(operatorChars); + return "sql-operator"; + } + + } + else if (/\d/.test(ch)) { + source.nextWhileMatches(/\d/); + if (source.peek() == '.') { + source.next(); + source.nextWhileMatches(/\d/); + } + return "sql-number"; + } + else if (/[()]/.test(ch)) { + return "sql-punctuation"; + } + else { + source.nextWhileMatches(/[_\w\d]/); + var word = source.get(), type; + if (operators.test(word)) + type = "sql-operator"; + else if (keywords.test(word)) + type = "sql-keyword"; + else if (functions.test(word)) + type = "sql-function"; + else if (types.test(word)) + type = "sql-type"; + else + type = "sql-word"; + return {style: type, content: word}; + } + } + + function inAlias(quote) { + return function(source, setState) { + while (!source.endOfLine()) { + var ch = source.next(); + if (ch == ']') { + setState(normal); + break; + } + } + return "sql-word"; + } + } + + function inLiteral(quote) { + return function(source, setState) { + var escaped = false; + while (!source.endOfLine()) { + var ch = source.next(); + if (ch == quote && !escaped) { + setState(normal); + break; + } + escaped = CFG.extension == 'T-SQL' ? + !escaped && quote == ch && source.equals(quote) : + !escaped && ch == "\\"; + } + return quote == "`" ? "sql-quoted-word" : "sql-literal"; + }; + } + + function inBlock(style, terminator) { + return function(source, setState) { + while (!source.endOfLine()) { + if (source.lookAhead(terminator, true)) { + setState(normal); + break; + } + source.next(); + } + return style; + }; + } + + return function(source, startState) { + return tokenizer(source, startState || normal); + }; + })(); + + function indentSql(context) { + return function(nextChars) { + var firstChar = nextChars && nextChars.charAt(0); + var closing = context && firstChar == context.type; + if (!context) + return 0; + else if (context.align) + return context.col - (closing ? context.width : 0); + else + return context.indent + (closing ? 0 : indentUnit); + } + } + + function parseSql(source) { + var tokens = tokenizeSql(source); + var context = null, indent = 0, col = 0; + function pushContext(type, width, align) { + context = {prev: context, indent: indent, col: col, type: type, width: width, align: align}; + } + function popContext() { + context = context.prev; + } + + var iter = { + next: function() { + var token = tokens.next(); + var type = token.style, content = token.content, width = token.value.length; + + if (content == "\n") { + token.indentation = indentSql(context); + indent = col = 0; + if (context && context.align == null) context.align = false; + } + else if (type == "whitespace" && col == 0) { + indent = width; + } + else if (!context && type != "sql-comment") { + pushContext(";", 0, false); + } + + if (content != "\n") col += width; + + if (type == "sql-punctuation") { + if (content == "(") + pushContext(")", width); + else if (content == ")") + popContext(); + } + else if (type == "sql-separator" && content == ";" && context && !context.prev) { + popContext(); + } + + return token; + }, + + copy: function() { + var _context = context, _indent = indent, _col = col, _tokenState = tokens.state; + return function(source) { + tokens = tokenizeSql(source, _tokenState); + context = _context; + indent = _indent; + col = _col; + return iter; + }; + } + }; + return iter; + } + + function configure (parserConfig) { + for (var p in parserConfig) { + if (parserConfig.hasOwnProperty(p)) { + CFG[p] = parserConfig[p]; + } + } + } + + return {make: parseSql, electricChars: ")", configure: configure}; +})(); diff --git a/gulliver/js/codemirrorOld/contrib/xquery/LICENSE b/gulliver/js/codemirrorOld/contrib/xquery/LICENSE new file mode 100644 index 000000000..dd8e3e824 --- /dev/null +++ b/gulliver/js/codemirrorOld/contrib/xquery/LICENSE @@ -0,0 +1,13 @@ +Copyright 2010 Mike Brevoort + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/gulliver/js/codemirrorOld/contrib/xquery/css/xqcolors-dark.css b/gulliver/js/codemirrorOld/contrib/xquery/css/xqcolors-dark.css new file mode 100644 index 000000000..97e538307 --- /dev/null +++ b/gulliver/js/codemirrorOld/contrib/xquery/css/xqcolors-dark.css @@ -0,0 +1,93 @@ + +.editbox { + margin: .4em; + padding: 0; + font-family: monospace; + font-size: 10pt; + color: white; + background-color: black; + line-height: 16px; +} + +span.word { + color:white; +} + +span.xqueryKeyword { + color: #ffbd40; + /* font-weight: bold; */ +} + +span.xqueryComment { + color: #CDCDCD; + font-style:italic; +} + +span.xqueryModifier { +color:#6c8cd5; + font-weight: bold; +} + +span.xqueryType { + color:#6c8cd5; + font-weight: bold; +} + +span.xqueryAtom { + color:#6c8cd5; + font-weight: bold; +} + +span.xqueryString { + color: #9fee00; +} + +span.xqueryRegexp { + color: rgb(128,0,64); +} + +span.xqueryNumber { + color: rgb(255,0,0); +} + +span.xqueryVariable { + +} + +span.xqueryFunction { + color:#FFF700; +} + +span.xqueryLocalvariable { + color: white; +} + +span.xqueryProperty +{ + color: white; +} + +span.xqueryOperator { + color: orange; +} + +span.xqueryPunctuation { + color: white; +} + +span.xquery-doc-directive { + color: white; +} + +span.xml-tagname { + color: #ffbd40; ; +} + +span.xml-attribute { + color: #FFF700; +} + +span.xml-attribute-value { + color: #FFF700; + font-style:italic; +} \ No newline at end of file diff --git a/gulliver/js/codemirrorOld/contrib/xquery/css/xqcolors.css b/gulliver/js/codemirrorOld/contrib/xquery/css/xqcolors.css new file mode 100644 index 000000000..058c1815f --- /dev/null +++ b/gulliver/js/codemirrorOld/contrib/xquery/css/xqcolors.css @@ -0,0 +1,99 @@ +/* +Copyright 2010 Mike Brevoort http://mike.brevoort.com (twitter:@mbrevoort) + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +This is an indirect collective derivative of the other parses in this package + +*/ +.editbox { + margin: .4em; + padding: 0; + font-family: monospace; + font-size: 10pt; + color: black; + background-color: white; + line-height: 16px; +} + +span.word { +} + +span.xqueryKeyword { + color: red; /* #1240AB; */ + /* font-weight: bold; */ +} + +span.xqueryComment { + color: gray; + font-style: italic; +} + +span.xqueryModifier { + color: rgb(0,102,153); + font-weight: bold; +} + +span.xqueryType { + color: purple; + font-weight: bold; +} + +span.xqueryAtom { + color: rgb(0,102,153); + font-weight: bold; +} + +span.xqueryString { + color: green; +} + +span.xqueryRegexp { + color: rgb(128,0,64); +} + +span.xqueryNumber { + color: #1240AB; +} + +span.xqueryVariable { + /* color: red; */ +} + +span.xqueryFunction { + color: #1240AB; + /* font-weight:bold; */ +} + + +span.xqueryOperator { + color: red; +} + +span.xqueryPunctuation { + color: DIMGray; +} + +span.xml-tagname { + color: purple; +} + +span.xml-attribute { + color: purple; + font-style:italic; +} + +span.xml-attribute-value { + color: purple; + font-style:italic; +} \ No newline at end of file diff --git a/gulliver/js/codemirrorOld/contrib/xquery/css/xqcolors2.css b/gulliver/js/codemirrorOld/contrib/xquery/css/xqcolors2.css new file mode 100644 index 000000000..accb7f734 --- /dev/null +++ b/gulliver/js/codemirrorOld/contrib/xquery/css/xqcolors2.css @@ -0,0 +1,96 @@ +/* +Copyright 2010 Mike Brevoort http://mike.brevoort.com (twitter:@mbrevoort) + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +This is an indirect collective derivative of the other parses in this package + +*/ +.editbox { + margin: .4em; + padding: 0; + font-family: monospace; + font-size: 10pt; + color: black; + background-color: white; + line-height: 16px; +} + +span.word { +} + +span.xqueryKeyword { + color: blue; + /* font-weight: bold; */ +} + +span.xqueryComment { + color: gray; +} + +span.xqueryModifier { + color: rgb(0,102,153); + font-weight: bold; +} + +span.xqueryType { + color: rgb(0,135,255); + font-weight: bold; +} + +span.xqueryAtom { + color: rgb(0,102,153); + font-weight: bold; +} + +span.xqueryString { + color: green; +} + +span.xqueryRegexp { + color: rgb(128,0,64); +} + +span.xqueryNumber { + color: rgb(255,0,0); +} + +span.xqueryVariable { + color: red; +} + +span.xqueryFunction { + text-decoration:underline +} + + +span.xqueryOperator { + color: DimGray; +} + +span.xqueryPunctuation { +} + +span.xml-tagname { + color: purple; +} + +span.xml-attribute { + color: purple; + font-style:italic; +} + +span.xml-attribute-value { + color: purple; + font-style:italic; +} \ No newline at end of file diff --git a/gulliver/js/codemirrorOld/contrib/xquery/index.html b/gulliver/js/codemirrorOld/contrib/xquery/index.html new file mode 100644 index 000000000..a1d49764c --- /dev/null +++ b/gulliver/js/codemirrorOld/contrib/xquery/index.html @@ -0,0 +1,552 @@ + + + + + CodeMirror: XQuery highlighting demonstration + + + + +
+

XQuery Syntax Support for CodeMirror

+

This is a demonstration of the XQuery highlighting module +for CodeMirror. The formatting is CSS driven and very easy to customize to your liking. +There are three sample styles sets below. +You can edit or paste in any code below to give it a test run. +

+ +Light 1 Light 2 Dark + +
+ +
+ + +
+ + + diff --git a/gulliver/js/codemirrorOld/contrib/xquery/js/parsexquery.js b/gulliver/js/codemirrorOld/contrib/xquery/js/parsexquery.js new file mode 100644 index 000000000..56468c2db --- /dev/null +++ b/gulliver/js/codemirrorOld/contrib/xquery/js/parsexquery.js @@ -0,0 +1,234 @@ +/* +Copyright 2010 Mike Brevoort http://mike.brevoort.com (twitter:@mbrevoort) + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +This is an indirect collective derivative of the other parses in this package + +*/ + +// The XQuery parser uses the xquery tokenizer in tokenizexquery.js. Given the +// stream of tokens, it makes decisions to override the tokens styles by evaluating +// it's context with respect to the other tokens. + +var XqueryParser = Editor.Parser = (function() { + function xqueryLexical(startColumn, currentToken, align, previousToken, encloseLevel) { + this.startColumn = startColumn; + this.currentToken = currentToken; + if (align != null) + this.align = align; + this.previousToken = previousToken; + this.encloseLevel = encloseLevel; + } + + // Xquery indentation rules. + function indentXquery(lexical) { + return function(firstChars, curIndent, direction) { + // test if this is next row after the open brace + if (lexical.encloseLevel !== 0 && firstChars === "}") { + return lexical.startColumn - indentUnit; + } + + return lexical.startColumn; + }; + } + + function parseXquery(source) { + var tokens = tokenizeXquery(source); + + var column = 0; + // tells the first non-whitespace symbol from the + // start of row. + var previousToken = null; + var previousTokens = []; + //mb + var align = false; + // tells if the text after the open brace + var encloseLevel = 0; + // tells curent opened braces quantity + var cc = [statements]; + var consume, + marked; + + var iter = { + next: function() { + var token = tokens.next(); + // since attribute and elements can be named the same, assume the + // following word of each is a variable + if (previousToken && (previousToken.content == "attribute" || previousToken.content == "element") && previousToken.type == "xqueryKeywordC") { + token.type = "variable"; + token.style = "xqueryVariable"; + } + + else if (previousToken && previousToken.content == "xquery" && token.content == "version") { + //token.type="variable"; + token.style = "xqueryModifier"; + } + + else if (token.type == "word" && (getPrevious(3).style == "xml-attribute" || (previousToken && previousToken.type == "xml-tag-open")) && + previousToken.content.substring(previousToken.content.length - 1) != ">") { + token.style = "xml-attribute"; + } + else if (previousToken && previousToken.content == "=" && previousTokens.length > 2 + && getPrevious(2).style == "xml-attribute") { + token.style = "xml-attribute-value"; + } + else if(token.type == "string" && previousToken && previousToken.type == "}") { + // looking for expressions within a string and detecting if the expression is within an attribute + var i=0; + while(i++ < previousTokens.length-1) { + if(getPrevious(i).style == "xml-attribute-value" ) { + token.style = "xml-attribute-value"; + break; + } + else if(getPrevious(i).type == "string") { + break; + } + } + } + else if(token.type == "string") { + // brute force check for strings inside XML TODO... something else + var i=0; + var closeCount = 0; + while(i++ < previousTokens.length-1) { + var prev = getPrevious(i); + if(prev.type == "xml-tag-open") { + if(closeCount == 0) { + token.style = "word"; + break; + } else { + closeCount--; + } + } + else if(prev.type == "xml-tag-close") { + closeCount++; + } + else if(prev.content == ":=" || prev.content == "return" || prev.content == "{") + break; + } + } + else if(getPrevious(2).content == "module" && getPrevious(1).content == "namespace") + token.style="xqueryFunction"; + else if(token.content == "=" && getPrevious(1).style == "xml-attribute") + token.style="xml-attribute" + + if (token.type == "whitespace") { + if (token.value == "\n") { + // test if this is end of line + if (previousToken !== null) { + if (previousToken.type === "{") { + // test if there is open brace at the end of line + align = true; + column += indentUnit; + encloseLevel++; + } + else + if (previousToken.type === "}") { + // test if there is close brace at the end of line + align = false; + if (encloseLevel > 0) { + encloseLevel--; + } + else { + encloseLevel = 0; + } + } + var lexical = new xqueryLexical(column, token, align, previousToken, encloseLevel); + token.indentation = indentXquery(lexical); + } + } + else + column = token.value.length; + } + + // maintain the previous tokens array so that it doesn't continue to leak + // keep only the last 5000 + if(previousTokens.length > 5000) previousTokens.shift(); + + while (true) { + consume = marked = false; + // Take and execute the topmost action. + cc.pop()(token.type, token.content); + if (consume) { + // Marked is used to change the style of the current token. + if (marked) + token.style = marked; + // Here we differentiate between local and global variables. + previousToken = token; + previousTokens[previousTokens.length] = token; + return token; + } + } + + }, + + copy: function() { + var _cc = cc.concat([]), + _tokenState = tokens.state, + _column = column; + + return function copyParser(_source) { + cc = _cc.concat([]); + column = indented = _column; + tokens = tokenizeXquery(_source, _tokenState); + return iter; + }; + + }, + + }; + + function statements(type) { + return pass(statement, statements); + } + + function statement(type) { + cont(); + } + + function push(fs) { + for (var i = fs.length - 1; i >= 0; i--) + cc.push(fs[i]); + } + + function cont() { + push(arguments); + consume = true; + } + + function pass() { + push(arguments); + consume = false; + } + + + function getPrevious(numberFromCurrent) { + var l = previousTokens.length; + if (l - numberFromCurrent >= 0) + return previousTokens[l - numberFromCurrent]; + else + return { + type: "", + style: "", + content: "" + }; + } + + return iter; + + + } + return { + make: parseXquery + }; +})(); \ No newline at end of file diff --git a/gulliver/js/codemirrorOld/contrib/xquery/js/tokenizexquery.js b/gulliver/js/codemirrorOld/contrib/xquery/js/tokenizexquery.js new file mode 100644 index 000000000..7f68b578f --- /dev/null +++ b/gulliver/js/codemirrorOld/contrib/xquery/js/tokenizexquery.js @@ -0,0 +1,457 @@ +/* +Copyright 2010 Mike Brevoort http://mike.brevoort.com (twitter:@mbrevoort) + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +This is an indirect collective derivative of the other parses in this package + +*/ + +// A tokenizer for xQuery, looks at the source stream and tokenizes, applying +// metadata to be able to apply the proper CSS classes in the parser. + +var tokenizeXquery = (function() { + // Advance the stream until the given character (not preceded by a + // backslash) is encountered, or the end of the line is reached. + function nextUntilUnescaped(source, end) { + var escaped = false; + while (!source.endOfLine()) { + var next = source.next(); + if (next == end && !escaped) + return false; + escaped = !escaped && next == "\\"; + } + return escaped; + } + + // A map of Xquery's keywords. The a/b/c keyword distinction is + // very rough, but it gives the parser enough information to parse + // correct code correctly (we don't care that much how we parse + // incorrect code). The style information included in these objects + // is used by the highlighter to pick the correct CSS style for a + // token. + var keywords = function() { + function result(type, style) { + return { + type: type, + style: style + }; + } + + var allKeywords = {}; + var keywordsList = {}; + + // an array of all of the keywords that will be used by default, otherwise keywords will be more specifically specified and overridden below + var allKeywordsArray = new Array('after','ancestor','ancestor-or-self','and','as','ascending','assert','attribute','before','by','case','cast','child','comment','comment','declare','default','define','descendant','descendant-or-self','descending','document-node','element','element','else','eq','every','except','external','following','following-sibling','follows','for','function','if','import','in','instance','intersect','item','let','module','namespace','node','node','of','only','or','order','parent','precedes','preceding','preceding-sibling','processing-instruction','ref','return','returns','satisfies','schema','schema-element','self','some','sortby','stable','text','then','to','treat','typeswitch','union','variable','version','where','xquery'); + + for(var i in allKeywordsArray) { + allKeywords[allKeywordsArray[i]] = result("keyword", "xqueryKeyword"); + } + + /* This next bit is broken down this was for future indentation support */ + // keywords that take a parenthised expression, and then a statement (if) + keywordsList['xqueryKeywordA'] = new Array('if', 'switch', 'while', 'for'); + + // keywords that take just a statement (else) + keywordsList['xqueryKeywordB'] = new Array('else', 'then', 'try', 'finally'); + + // keywords that optionally take an expression, and form a statement (return) + keywordsList['xqueryKeywordC'] = new Array('element', 'attribute', 'let', 'implements', 'import', 'module', 'namespace', 'return', 'super', 'this', 'throws', 'where'); + + keywordsList['xqueryOperator'] = new Array('eq', 'ne', 'lt', 'le', 'gt', 'ge'); + + for (var keywordType in keywordsList) { + for (var i = 0; i < keywordsList[keywordType].length; i++) { + allKeywords[keywordsList[keywordType][i]] = result(keywordType, "xqueryKeyword"); + } + } + + keywordsList = {}; + + keywordsList['xqueryAtom'] = new Array('null', 'fn:false()', 'fn:true()'); + for (var keywordType in keywordsList) { + for (var i = 0; i < keywordsList[keywordType].length; i++) { + allKeywords[keywordsList[keywordType][i]] = result(keywordType, keywordType); + } + } + + keywordsList = {}; + keywordsList['xqueryModifier'] = new Array('xquery', 'ascending', 'descending'); + keywordsList['xqueryType'] = new Array('xs:string', 'xs:float', 'xs:decimal', 'xs:double', 'xs:integer', 'xs:boolean', 'xs:date', 'xs:dateTime', 'xs:time', 'xs:duration', 'xs:dayTimeDuration', 'xs:time', 'xs:yearMonthDuration', 'numeric', 'xs:hexBinary', 'xs:base64Binary', 'xs:anyURI', 'xs:QName', 'xs:byte','xs:boolean','xs:anyURI','xf:yearMonthDuration'); + for (var keywordType in keywordsList) { + for (var i = 0; i < keywordsList[keywordType].length; i++) { + allKeywords[keywordsList[keywordType][i]] = result('function', keywordType); + } + } + + allKeywords = objectConcat(allKeywords, { + "catch": result("catch", "xqueryKeyword"), + "for": result("for", "xqueryKeyword"), + "case": result("case", "xqueryKeyword"), + "default": result("default", "xqueryKeyword"), + "instanceof": result("operator", "xqueryKeyword") + }); + + // ------------------- xquery keywords + var keywordsList = {}; + + // keywords that optionally take an expression, and form a statement (return) + keywordsList['xqueryKeywordC'] = new Array('assert', 'property'); + for (var i = 0; i < keywordsList['xqueryKeywordC'].length; i++) { + allKeywords[keywordsList['xqueryKeywordC'][i]] = result("xqueryKeywordC", "xqueryKeyword"); + } + + // other xquery keywords + allKeywords = objectConcat(allKeywords, { + "as": result("operator", "xqueryKeyword"), + "in": result("operator", "xqueryKeyword"), + "at": result("operator", "xqueryKeyword"), + "declare": result("function", "xqueryKeyword"), + "function": result("function", "xqueryKeyword") + }); + return allKeywords; + } (); + + // there are some special cases where ordinarily text like xs:string() would + // look like a function call when it is really a type, etc. + function specialCases(source, word) { + if (word in { + "fn:true": "", + "fn:false": "" + } && source.lookAhead("()", false)) { + source.next(); + source.next(); + source.get(); + return { + type: "function", + style: "xqueryAtom", + content: word + "()" + }; + } + else if (word in { + "node": "", + "item": "", + "text": "" + } && source.lookAhead("()", false)) { + source.next(); + source.next(); + source.get(); + return { + type: "function", + style: "xqueryType", + content: word + "()" + }; + } + else if (source.lookAhead("(")) { + return { + type: "function", + style: "xqueryFunction", + content: word + }; + } + else return null; + } + + // Some helper regexp matchers. + var isOperatorChar = /[=+\-*&%!?@\/]/; + var isDigit = /[0-9]/; + var isHexDigit = /^[0-9A-Fa-f]$/; + var isWordChar = /[\w\:\-\$_]/; + var isVariableChar = /[\w\$_-]/; + var isXqueryVariableChar = /[\w\.()\[\]{}]/; + var isPunctuation = /[\[\]{}\(\),;\.]/; + var isStringDelimeter = /^[\/'"]$/; + var isRegexpDelimeter = /^[\/'$]/; + var tagnameChar = /[<\w\:\-\/_]/; + + // Wrapper around xqueryToken that helps maintain parser state (whether + // we are inside of a multi-line comment and whether the next token + // could be a regular expression). + function xqueryTokenState(inside, regexp) { + return function(source, setState) { + var newInside = inside; + var type = xqueryToken(inside, regexp, source, + function(c) { + newInside = c; + }); + var newRegexp = type.type == "operator" || type.type == "xqueryKeywordC" || type.type == "xqueryKeywordC" || type.type.match(/^[\[{}\(,;:]$/); + if (newRegexp != regexp || newInside != inside) + setState(xqueryTokenState(newInside, newRegexp)); + return type; + }; + } + + // The token reader, inteded to be used by the tokenizer from + // tokenize.js (through xqueryTokenState). Advances the source stream + // over a token, and returns an object containing the type and style + // of that token. + function xqueryToken(inside, regexp, source, setInside) { + function readHexNumber() { + setInside(null); + source.next(); + // skip the 'x' + source.nextWhileMatches(isHexDigit); + return { + type: "number", + style: "xqueryNumber" + }; + } + + function readNumber() { + setInside(null); + source.nextWhileMatches(isDigit); + if (source.equals(".")) { + source.next(); + + // read ranges + if (source.equals(".")) + source.next(); + + source.nextWhileMatches(isDigit); + } + if (source.equals("e") || source.equals("E")) { + source.next(); + if (source.equals("-")) + source.next(); + source.nextWhileMatches(isDigit); + } + return { + type: "number", + style: "xqueryNumber" + }; + } + // Read a word, look it up in keywords. If not found, it is a + // variable, otherwise it is a keyword of the type found. + function readWord() { + //setInside(null); + source.nextWhileMatches(isWordChar); + var word = source.get(); + var specialCase = specialCases(source, word); + if (specialCase) return specialCase; + var known = keywords.hasOwnProperty(word) && keywords.propertyIsEnumerable(word) && keywords[word]; + if (known) return { + type: known.type, + style: known.style, + content: word + } + return { + type: "word", + style: "word", + content: word + }; + } + + + // read regexp like /\w{1}:\\.+\\.+/ + function readRegexp() { + // go to the end / not \/ + nextUntilUnescaped(source, "/"); + + return { + type: "regexp", + style: "xqueryRegexp" + }; + } + + // Mutli-line comments are tricky. We want to return the newlines + // embedded in them as regular newline tokens, and then continue + // returning a comment token for every line of the comment. So + // some state has to be saved (inside) to indicate whether we are + // inside a (: :) sequence. + function readMultilineComment(start) { + var newInside = "(:"; + var maybeEnd = (start == ":"); + while (true) { + if (source.endOfLine()) + break; + var next = source.next(); + if (next == ")" && maybeEnd) { + newInside = null; + break; + } + maybeEnd = (next == ":"); + } + setInside(newInside); + return { + type: "comment", + style: "xqueryComment" + }; + } + + function readOperator() { + if (ch == "=") + setInside("=") + else if (ch == "~") + setInside("~") + else if (ch == ":" && source.equals("=")) { + setInside(null); + source.nextWhileMatches(/[:=]/); + var word = source.get(); + return { + type: "operator", + style: "xqueryOperator", + content: word + }; + } + else setInside(null); + + return { + type: "operator", + style: "xqueryOperator" + }; + } + + // read a string, but look for embedded expressions wrapped in curly + // brackets. + function readString(quote) { + var newInside = quote; + var previous = ""; + while (true) { + if (source.endOfLine()) + break; + if(source.lookAhead("{", false)) { + newInside = quote + "{"; + break; + } + var next = source.next(); + if (next == quote && previous != "\\") { + newInside = null; + break; + } + previous = next; + } + setInside(newInside); + return { + type: "string", + style: "xqueryString" + }; + } + + // Given an expression end by a closing curly bracket, mark the } as + // punctuation an resume the string processing by setting "inside" to + // the type of string it's embedded in. + // This is known because the readString() function sets inside to the + // quote type then an open curly bracket like "{ or '{ + function readExpressionEndInString(inside) { + var quote = inside.substr(0,1); + setInside(quote); + return { type: ch, style: "xqueryPunctuation"}; + } + + function readVariable() { + //setInside(null); + source.nextWhileMatches(isVariableChar); + var word = source.get(); + return { + type: "variable", + style: "xqueryVariable", + content: word + }; + } + + // read an XML Tagname, both closing and opening + function readTagname(lt) { + var tagtype = (source.lookAhead("/", false)) ? "xml-tag-close": "xml-tag-open"; + source.nextWhileMatches(tagnameChar); + var word = source.get(); + if (source.lookAhead(">", false)) { + source.next(); + } + return { + type: tagtype, + style: "xml-tagname", + content: word + }; + } + + // Fetch the next token. Dispatches on first character in the stream + // what follows is a big if statement that makes decisions based on the + // character, the following character and the inside variable + + if (inside == "\"" || inside == "'") + return readString(inside); + + var ch = source.next(); + if (inside && inside.indexOf("{") == 1 && ch == "}") { + return readExpressionEndInString(inside); + } + if (inside == "(:") + return readMultilineComment(ch); + else if (ch == "\"" || ch == "'") + return readString(ch); + + + // test if this is range + else if (ch == "." && source.equals(".")) { + source.next(); + return { + type: "..", + style: "xqueryOperator" + }; + } + + else if (ch == "(" && source.equals(":")) { + source.next(); + return readMultilineComment(ch); + } + else if (ch == "$") + return readVariable(); + else if (ch == ":" && source.equals("=")) + return readOperator(); + + // with punctuation, the type of the token is the symbol itself + else if (isPunctuation.test(ch)) + return { + type: ch, + style: "xqueryPunctuation" + }; + else if (ch == "0" && (source.equals("x") || source.equals("X"))) + return readHexNumber(); + else if (isDigit.test(ch)) + return readNumber(); + + else if (ch == "~") { + setInside("~"); + // prepare to read slashy string like ~ /\w{1}:\\.+\\.+/ + return readOperator(ch); + } + else if (isOperatorChar.test(ch)) { + return readOperator(ch); + } + // some xml handling stuff + else if (ch == "<") + return readTagname(ch); + else if (ch == ">") + return { + type: "xml-tag", + style: "xml-tagname" + }; + else + return readWord(); + } + + // returns new object = object1 + object2 + function objectConcat(object1, object2) { + for (var name in object2) { + if (!object2.hasOwnProperty(name)) continue; + if (object1.hasOwnProperty(name)) continue; + object1[name] = object2[name]; + } + return object1; + } + + // The external interface to the tokenizer. + return function(source, startState) { + return tokenizer(source, startState || xqueryTokenState(false, true)); + }; +})(); \ No newline at end of file diff --git a/gulliver/js/codemirrorOld/js/codemirror.js b/gulliver/js/codemirrorOld/js/codemirror.js new file mode 100644 index 000000000..99678d61b --- /dev/null +++ b/gulliver/js/codemirrorOld/js/codemirror.js @@ -0,0 +1,584 @@ +/* CodeMirror main module (http://codemirror.net/) + * + * Implements the CodeMirror constructor and prototype, which take care + * of initializing the editor frame, and providing the outside interface. + */ + +// The CodeMirrorConfig object is used to specify a default +// configuration. If you specify such an object before loading this +// file, the values you put into it will override the defaults given +// below. You can also assign to it after loading. +var CodeMirrorConfig = window.CodeMirrorConfig || {}; + +var CodeMirror = (function(){ + function setDefaults(object, defaults) { + for (var option in defaults) { + if (!object.hasOwnProperty(option)) + object[option] = defaults[option]; + } + } + function forEach(array, action) { + for (var i = 0; i < array.length; i++) + action(array[i]); + } + function createHTMLElement(el) { + if (document.createElementNS && document.documentElement.namespaceURI !== null) + return document.createElementNS("http://www.w3.org/1999/xhtml", el) + else + return document.createElement(el) + } + + // These default options can be overridden by passing a set of + // options to a specific CodeMirror constructor. See manual.html for + // their meaning. + setDefaults(CodeMirrorConfig, { + stylesheet: [], + path: "", + parserfile: [], + basefiles: ["util.js", "stringstream.js", "select.js", "undo.js", "editor.js", "tokenize.js"], + iframeClass: null, + passDelay: 200, + passTime: 50, + lineNumberDelay: 200, + lineNumberTime: 50, + continuousScanning: false, + saveFunction: null, + onLoad: null, + onChange: null, + undoDepth: 50, + undoDelay: 800, + disableSpellcheck: true, + textWrapping: true, + readOnly: false, + width: "", + height: "300px", + minHeight: 100, + autoMatchParens: false, + markParen: null, + unmarkParen: null, + parserConfig: null, + tabMode: "indent", // or "spaces", "default", "shift" + enterMode: "indent", // or "keep", "flat" + electricChars: true, + reindentOnLoad: false, + activeTokens: null, + onCursorActivity: null, + lineNumbers: false, + firstLineNumber: 1, + onLineNumberClick: null, + indentUnit: 2, + domain: null, + noScriptCaching: false, + incrementalLoading: false + }); + + function addLineNumberDiv(container, firstNum) { + var nums = createHTMLElement("div"), + scroller = createHTMLElement("div"); + nums.style.position = "absolute"; + nums.style.height = "100%"; + if (nums.style.setExpression) { + try {nums.style.setExpression("height", "this.previousSibling.offsetHeight + 'px'");} + catch(e) {} // Seems to throw 'Not Implemented' on some IE8 versions + } + nums.style.top = "0px"; + nums.style.left = "0px"; + nums.style.overflow = "hidden"; + container.appendChild(nums); + scroller.className = "CodeMirror-line-numbers"; + nums.appendChild(scroller); + scroller.innerHTML = "
" + firstNum + "
"; + return nums; + } + + function frameHTML(options) { + if (typeof options.parserfile == "string") + options.parserfile = [options.parserfile]; + if (typeof options.basefiles == "string") + options.basefiles = [options.basefiles]; + if (typeof options.stylesheet == "string") + options.stylesheet = [options.stylesheet]; + + var html = [""]; + // Hack to work around a bunch of IE8-specific problems. + //html.push(""); + var queryStr = options.noScriptCaching ? "?nocache=" + new Date().getTime().toString(16) : ""; + forEach(options.stylesheet, function(file) { + html.push(""); + }); + forEach(options.basefiles.concat(options.parserfile), function(file) { + if (!/^https?:/.test(file)) file = options.path + file; + html.push("