├── LICENSE
├── bigtest.html
├── compress.html
├── contrib
├── csharp
│ ├── css
│ │ └── csharpcolors.css
│ ├── index.html
│ └── js
│ │ ├── parsecsharp.js
│ │ └── tokenizecsharp.js
├── freemarker
│ ├── LICENSE
│ ├── css
│ │ └── freemarkercolors.css
│ ├── index.html
│ └── js
│ │ └── parsefreemarker.js
├── groovy
│ └── index.html
├── java
│ ├── LICENSE
│ ├── css
│ │ └── javacolors.css
│ ├── index.html
│ └── js
│ │ ├── parsejava.js
│ │ └── tokenizejava.js
├── lua
│ ├── LICENSE
│ ├── css
│ │ └── luacolors.css
│ ├── index.html
│ └── js
│ │ └── parselua.js
├── ometa
│ ├── LICENSE
│ ├── css
│ │ └── ometacolors.css
│ ├── index.html
│ └── js
│ │ ├── parseometa.js
│ │ └── tokenizeometa.js
├── php
│ ├── LICENSE
│ ├── css
│ │ └── phpcolors.css
│ ├── index.html
│ └── js
│ │ ├── parsephp.js
│ │ ├── parsephphtmlmixed.js
│ │ └── tokenizephp.js
├── plsql
│ ├── LICENSE
│ ├── css
│ │ └── plsqlcolors.css
│ ├── index.html
│ └── js
│ │ └── parseplsql.js
├── python
│ ├── LICENSE
│ ├── css
│ │ └── pythoncolors.css
│ ├── index.html
│ └── js
│ │ └── parsepython.js
├── regex
│ ├── css
│ │ ├── js-regexcolors.css
│ │ └── regexcolors.css
│ ├── index.html
│ ├── js-regex.html
│ └── js
│ │ ├── parsejavascript_and_regex.js
│ │ ├── parseregex-unicode.js
│ │ └── parseregex.js
├── scheme
│ ├── LICENSE
│ ├── css
│ │ └── schemecolors.css
│ ├── index.html
│ └── js
│ │ ├── parsescheme.js
│ │ └── tokenizescheme.js
├── sql
│ ├── LICENSE
│ ├── css
│ │ └── sqlcolors.css
│ ├── index.html
│ └── js
│ │ └── parsesql.js
└── xquery
│ ├── LICENSE
│ ├── css
│ ├── xqcolors-dark.css
│ ├── xqcolors.css
│ └── xqcolors2.css
│ ├── index.html
│ └── js
│ ├── parsexquery.js
│ └── tokenizexquery.js
├── css
├── baboon.png
├── baboon_vector.svg
├── csscolors.css
├── docs.css
├── font.js
├── jscolors.css
├── people.jpg
├── sparqlcolors.css
└── xmlcolors.css
├── csstest.html
├── faq.html
├── highlight.html
├── htmltest.html
├── index.html
├── js
├── codemirror.js
├── editor.js
├── highlight.js
├── mirrorframe.js
├── parsecss.js
├── parsedummy.js
├── parsehtmlmixed.js
├── parsejavascript.js
├── parsesparql.js
├── parsexml.js
├── select.js
├── stringstream.js
├── tokenize.js
├── tokenizejavascript.js
├── undo.js
├── unittests.js
└── util.js
├── jstest.html
├── manual.html
├── mixedtest.html
├── readme.md
├── sparqltest.html
├── story.html
├── unittests.html
└── xhtmltest.xhtml
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2007-2010 Marijn Haverbeke
2 |
3 | This software is provided 'as-is', without any express or implied
4 | warranty. In no event will the authors be held liable for any
5 | damages arising from the use of this software.
6 |
7 | Permission is granted to anyone to use this software for any
8 | purpose, including commercial applications, and to alter it and
9 | redistribute it freely, subject to the following restrictions:
10 |
11 | 1. The origin of this software must not be misrepresented; you must
12 | not claim that you wrote the original software. If you use this
13 | software in a product, an acknowledgment in the product
14 | documentation would be appreciated but is not required.
15 |
16 | 2. Altered source versions must be plainly marked as such, and must
17 | not be misrepresented as being the original software.
18 |
19 | 3. This notice may not be removed or altered from any source
20 | distribution.
21 |
22 | Marijn Haverbeke
23 | marijnh@gmail.com
24 |
--------------------------------------------------------------------------------
/contrib/csharp/css/csharpcolors.css:
--------------------------------------------------------------------------------
1 | html {
2 | cursor: text;
3 | }
4 |
5 | .editbox {
6 | margin: .4em;
7 | padding: 0;
8 | font-family: monospace;
9 | font-size: 10pt;
10 | color: black;
11 | }
12 |
13 | pre.code, .editbox {
14 | color: #666666;
15 | }
16 |
17 | .editbox p {
18 | margin: 0;
19 | }
20 |
21 | span.csharp-punctuation {
22 | color: green;
23 | }
24 |
25 | span.csharp-operator {
26 | color: purple;
27 | }
28 |
29 | span.csharp-keyword {
30 | color: blue;
31 | }
32 |
33 | span.csharp-atom {
34 | color: brown;
35 | }
36 |
37 | span.csharp-variable {
38 | color: black;
39 | }
40 |
41 | span.csharp-variabledef {
42 | color: #0000FF;
43 | }
44 |
45 | span.csharp-localvariable {
46 | color: #004499;
47 | }
48 |
49 | span.csharp-property {
50 | color: black;
51 | }
52 |
53 | span.csharp-comment {
54 | color: green;
55 | }
56 |
57 | span.csharp-string {
58 | color: red;
59 | }
60 |
61 |
--------------------------------------------------------------------------------
/contrib/csharp/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | CodeMirror: C# demonstration
5 |
6 |
7 |
8 |
9 | Demonstration of CodeMirror 's C# highlighter.
10 |
11 | Written by Boris Gaber and Christopher Buchino.
12 |
13 |
14 |
48 |
49 |
50 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/contrib/csharp/js/tokenizecsharp.js:
--------------------------------------------------------------------------------
1 | /* Tokenizer for CSharp code */
2 |
3 | var tokenizeCSharp = (function() {
4 | // Advance the stream until the given character (not preceded by a
5 | // backslash) is encountered, or the end of the line is reached.
6 | function nextUntilUnescaped(source, end) {
7 | var escaped = false;
8 | var next;
9 | while (!source.endOfLine()) {
10 | var next = source.next();
11 | if (next == end && !escaped)
12 | return false;
13 | escaped = !escaped && next == "\\";
14 | }
15 | return escaped;
16 | }
17 |
18 | // A map of JavaScript's keywords. The a/b/c keyword distinction is
19 | // very rough, but it gives the parser enough information to parse
20 | // correct code correctly (we don't care that much how we parse
21 | // incorrect code). The style information included in these objects
22 | // is used by the highlighter to pick the correct CSS style for a
23 | // token.
24 | var keywords = function(){
25 | function result(type, style){
26 | return {type: type, style: "csharp-" + style};
27 | }
28 | // keywords that take a parenthised expression, and then a
29 | // statement (if)
30 | var keywordA = result("keyword a", "keyword");
31 | // keywords that take just a statement (else)
32 | var keywordB = result("keyword b", "keyword");
33 | // keywords that optionally take an expression, and form a
34 | // statement (return)
35 | var keywordC = result("keyword c", "keyword");
36 | var operator = result("operator", "keyword");
37 | var atom = result("atom", "atom");
38 | // just a keyword with no indentation implications
39 | var keywordD = result("keyword d", "keyword");
40 |
41 | return {
42 | "if": keywordA, "while": keywordA, "with": keywordA,
43 | "else": keywordB, "do": keywordB, "try": keywordB, "finally": keywordB,
44 | "return": keywordC, "break": keywordC, "continue": keywordC, "new": keywordC, "delete": keywordC, "throw": keywordC,
45 | "in": operator, "typeof": operator, "instanceof": operator,
46 | "var": result("var", "keyword"), "function": result("function", "keyword"), "catch": result("catch", "keyword"),
47 | "for": result("for", "keyword"), "switch": result("switch", "keyword"),
48 | "case": result("case", "keyword"), "default": result("default", "keyword"),
49 | "true": atom, "false": atom, "null": atom,
50 |
51 | "class": result("class", "keyword"), "namespace": result("class", "keyword"),
52 |
53 | "public": keywordD, "private": keywordD, "protected": keywordD, "internal": keywordD,
54 | "extern": keywordD, "override": keywordD, "virtual": keywordD, "abstract": keywordD,
55 | "static": keywordD, "out": keywordD, "ref": keywordD, "const": keywordD,
56 |
57 | "foreach": result("for", "keyword"), "using": keywordC,
58 |
59 | "int": keywordD, "double": keywordD, "long": keywordD, "bool": keywordD, "char": keywordD,
60 | "void": keywordD, "string": keywordD, "byte": keywordD, "sbyte": keywordD, "decimal": keywordD,
61 | "float": keywordD, "uint": keywordD, "ulong": keywordD, "object": keywordD,
62 | "short": keywordD, "ushort": keywordD,
63 |
64 | "get": keywordD, "set": keywordD, "value": keywordD
65 | };
66 | }();
67 |
68 | // Some helper regexps
69 | var isOperatorChar = /[+\-*&%=<>!?|]/;
70 | var isHexDigit = /[0-9A-Fa-f]/;
71 | var isWordChar = /[\w\$_]/;
72 |
73 | // Wrapper around jsToken that helps maintain parser state (whether
74 | // we are inside of a multi-line comment and whether the next token
75 | // could be a regular expression).
76 | function jsTokenState(inside, regexp) {
77 | function state(source, setState) {
78 | var newInside = inside;
79 | var type = jsToken(inside, regexp, source, function(c) {newInside = c;});
80 | var newRegexp = type.type == "operator" || type.type == "keyword c" || type.type.match(/^[\[{}\(,;:]$/);
81 | if (newRegexp != regexp || newInside != inside)
82 | setState(jsTokenState(newInside, newRegexp));
83 | return type;
84 | };
85 | state.doNotIndent = inside == "@\"";
86 | return state;
87 | }
88 |
89 | // The token reader, intended to be used by the tokenizer from
90 | // tokenize.js (through jsTokenState). Advances the source stream
91 | // over a token, and returns an object containing the type and style
92 | // of that token.
93 | function jsToken(inside, regexp, source, setInside) {
94 | function readHexNumber(){
95 | source.next(); // skip the 'x'
96 | source.nextWhileMatches(isHexDigit);
97 | return {type: "number", style: "csharp-atom"};
98 | }
99 |
100 | function readNumber() {
101 | source.nextWhileMatches(/[0-9]/);
102 | if (source.equals(".")){
103 | source.next();
104 | source.nextWhileMatches(/[0-9]/);
105 | }
106 | if (source.equals("e") || source.equals("E")){
107 | source.next();
108 | if (source.equals("-"))
109 | source.next();
110 | source.nextWhileMatches(/[0-9]/);
111 | }
112 | return {type: "number", style: "csharp-atom"};
113 | }
114 | // Read a word, look it up in keywords. If not found, it is a
115 | // variable, otherwise it is a keyword of the type found.
116 | function readWord() {
117 | source.nextWhileMatches(isWordChar);
118 | var word = source.get();
119 | var known = keywords.hasOwnProperty(word) && keywords.propertyIsEnumerable(word) && keywords[word];
120 | return known ? {type: known.type, style: known.style, content: word} :
121 | {type: "variable", style: "csharp-variable", content: word};
122 | }
123 | function readRegexp() {
124 | nextUntilUnescaped(source, "/");
125 | source.nextWhileMatches(/[gi]/);
126 | return {type: "regexp", style: "csharp-string"};
127 | }
128 | // Mutli-line comments are tricky. We want to return the newlines
129 | // embedded in them as regular newline tokens, and then continue
130 | // returning a comment token for every line of the comment. So
131 | // some state has to be saved (inside) to indicate whether we are
132 | // inside a /* */ sequence.
133 | function readMultilineComment(start){
134 | var newInside = "/*";
135 | var maybeEnd = (start == "*");
136 | while (true) {
137 | if (source.endOfLine())
138 | break;
139 | var next = source.next();
140 | if (next == "/" && maybeEnd){
141 | newInside = null;
142 | break;
143 | }
144 | maybeEnd = (next == "*");
145 | }
146 | setInside(newInside);
147 | return {type: "comment", style: "csharp-comment"};
148 | }
149 | function readOperator() {
150 | source.nextWhileMatches(isOperatorChar);
151 | return {type: "operator", style: "csharp-operator"};
152 | }
153 | function readString(quote) {
154 | var endBackSlash = nextUntilUnescaped(source, quote);
155 | setInside(endBackSlash ? quote : null);
156 | return {type: "string", style: "csharp-string"};
157 | }
158 | function readVerbatimString(start){
159 | var newInside = "@\"";
160 | var maybeEnd = (start == "\"");
161 | while (true) {
162 | if (maybeEnd) {
163 | if (source.peek() == "\"") {
164 | source.next();
165 | }
166 | else {
167 | newInside = null;
168 | break;
169 | }
170 | }
171 | if (source.endOfLine())
172 | break;
173 | var next = source.next();
174 | maybeEnd = (next == "\"");
175 | }
176 | setInside(newInside);
177 | return {type: "string", style: "csharp-string"};
178 | }
179 |
180 | // Fetch the next token. Dispatches on first character in the
181 | // stream, or first two characters when the first is a slash.
182 | if (inside == "\"" || inside == "'")
183 | return readString(inside);
184 | var ch = source.next();
185 | if (inside == "/*")
186 | return readMultilineComment(ch);
187 | else if (inside == "@\"")
188 | return readVerbatimString(ch);
189 | else if (ch == "\"" || ch == "'")
190 | return readString(ch);
191 | // with punctuation, the type of the token is the symbol itself
192 | else if (/[\[\]{}\(\),;\:\.]/.test(ch))
193 | return {type: ch, style: "csharp-punctuation"};
194 | else if (ch == "0" && (source.equals("x") || source.equals("X")))
195 | return readHexNumber();
196 | else if (/[0-9]/.test(ch))
197 | return readNumber();
198 | else if (ch == "/"){
199 | if (source.equals("*"))
200 | { source.next(); return readMultilineComment(ch); }
201 | else if (source.equals("/"))
202 | { nextUntilUnescaped(source, null); return {type: "comment", style: "csharp-comment"};}
203 | else if (regexp)
204 | return readRegexp();
205 | else
206 | return readOperator();
207 | }
208 | else if (ch == "#") { // treat c# regions like comments
209 | nextUntilUnescaped(source, null); return {type: "comment", style: "csharp-comment"};
210 | }
211 | else if (ch == "@") {
212 | if (source.equals("\"")) {
213 | source.next();
214 | return readVerbatimString(ch);
215 | }
216 | else
217 | return readWord();
218 | }
219 | else if (isOperatorChar.test(ch))
220 | return readOperator();
221 | else
222 | return readWord();
223 | }
224 |
225 | // The external interface to the tokenizer.
226 | return function(source, startState) {
227 | return tokenizer(source, startState || jsTokenState(false, true));
228 | };
229 | })();
230 |
--------------------------------------------------------------------------------
/contrib/freemarker/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2010, Keybroker AB
2 | All rights reserved.
3 |
4 | Redistribution and use in source and binary forms, with or without
5 | modification, are permitted provided that the following conditions are met:
6 | * Redistributions of source code must retain the above copyright
7 | notice, this list of conditions and the following disclaimer.
8 | * Redistributions in binary form must reproduce the above copyright
9 | notice, this list of conditions and the following disclaimer in the
10 | documentation and/or other materials provided with the distribution.
11 | * Neither the name of Keybroker AB nor the
12 | names of its contributors may be used to endorse or promote products
13 | derived from this software without specific prior written permission.
14 |
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 | DISCLAIMED. IN NO EVENT SHALL Keybroker AB BE LIABLE FOR ANY
19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 |
--------------------------------------------------------------------------------
/contrib/freemarker/css/freemarkercolors.css:
--------------------------------------------------------------------------------
1 | html {
2 | cursor: text;
3 | }
4 |
5 | .editbox {
6 | margin: .4em;
7 | padding: 0;
8 | font-family: monospace;
9 | font-size: 12px;
10 | font-size-adjust: none;
11 | font-style: normal;
12 | font-variant: normal;
13 | font-weight: normal;
14 | line-height: normal;
15 | color: black;
16 | }
17 |
18 | pre.code, .editbox {
19 | color: black;
20 | }
21 |
22 | .editbox p {
23 | margin: 0;
24 | }
25 |
26 | span.freemarker-comment {
27 | color: #BB9977;
28 | }
29 |
30 | span.freemarker-generic {
31 | }
32 |
33 | span.freemarker-boundary {
34 | color: darkblue;
35 | }
36 |
37 | span.freemarker-directive {
38 | color: darkblue;
39 | }
40 |
41 | span.freemarker-identifier {
42 | color: purple;
43 | }
44 |
45 | span.freemarker-builtin {
46 | color: gray;
47 | }
48 |
49 | span.freemarker-punctuation {
50 | color: blue;
51 | }
52 |
53 | span.freemarker-string {
54 | color: darkGreen;
55 | }
56 |
57 | span.freemarker-number {
58 | color: blue;
59 | }
60 |
61 | span.freemarker-error {
62 | color: #F00 !important;
63 | }
64 |
--------------------------------------------------------------------------------
/contrib/freemarker/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CodeMirror: Freemarker demonstration
6 |
7 |
20 |
21 |
22 |
23 | This page demonstrates CodeMirror 's
24 | Freemarker parser. Written by Magnus Ljung, released under a BSD-style license .
26 |
27 |
28 |
50 |
51 |
52 |
74 |
75 |
76 |
--------------------------------------------------------------------------------
/contrib/groovy/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | CodeMirror: Groovy demonstration
5 |
6 |
7 |
8 |
9 | Demonstration of CodeMirror 's Groovy highlighter.
10 |
11 | Created by eXo Platform SAS (license ).
12 |
13 | Note that the files for this parser aren't included in the CodeMirror repository, but have to fetched from svn.exoplatform.org :
14 |
15 |
20 |
21 |
22 |
44 |
45 |
46 |
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/contrib/java/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2010 Patrick Wied
2 |
3 | This software is provided 'as-is', without any express or implied
4 | warranty. In no event will the authors be held liable for any
5 | damages arising from the use of this software.
6 |
7 | Permission is granted to anyone to use this software for any
8 | purpose, including commercial applications, and to alter it and
9 | redistribute it freely, subject to the following restrictions:
10 |
11 | 1. The origin of this software must not be misrepresented; you must
12 | not claim that you wrote the original software. If you use this
13 | software in a product, an acknowledgment in the product
14 | documentation would be appreciated but is not required.
15 |
16 | 2. Altered source versions must be plainly marked as such, and must
17 | not be misrepresented as being the original software.
18 |
19 | 3. This notice may not be removed or altered from any source
20 | distribution.
21 |
--------------------------------------------------------------------------------
/contrib/java/css/javacolors.css:
--------------------------------------------------------------------------------
1 |
2 | html {
3 | cursor: text;
4 | }
5 |
6 | .editbox {
7 | margin: .4em;
8 | padding: 0;
9 | font-family: monospace;
10 | font-size: 10pt;
11 | color: black;
12 | }
13 |
14 | pre.code, .editbox {
15 | color: #666666;
16 | }
17 |
18 | .editbox p {
19 | margin: 0;
20 | }
21 |
22 | span.java-punctuation {
23 | color: black;
24 | }
25 |
26 | span.java-operator {
27 | color: purple;
28 | }
29 |
30 | span.java-keyword {
31 | color: #7f0055;
32 | font-weight:bold;
33 | }
34 |
35 | span.java-atom {
36 | color: brown;
37 | }
38 |
39 | span.java-variable {
40 | color: black;
41 | }
42 |
43 |
44 | span.java-property {
45 | color: black;
46 | }
47 |
48 | span.java-comment {
49 | color: green;
50 | }
51 |
52 | span.javadoc-comment {
53 | color: #3e5797;
54 | font-weight:bold;
55 | }
56 |
57 | span.java-string {
58 | color: blue;
59 | }
60 |
61 | span.java-annotation{
62 | color: gray;
63 | }
64 |
65 |
--------------------------------------------------------------------------------
/contrib/java/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Demonstration of CodeMirrors Java highlighter written by Patrick Wied
6 |
7 |
8 |
9 |
10 | Demonstration of CodeMirror 's Java highlighter.
11 |
12 | Written by Patrick Wied .
13 |
14 |
15 |
55 |
56 |
65 |
66 |
67 |
--------------------------------------------------------------------------------
/contrib/java/js/tokenizejava.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Java tokenizer for codemirror
3 | *
4 | * @author Patrick Wied
5 | * @version 2010-10-07
6 | */
7 | var tokenizeJava = (function() {
8 | // Advance the stream until the given character (not preceded by a
9 | // backslash) is encountered, or the end of the line is reached.
10 | function nextUntilUnescaped(source, end) {
11 | var escaped = false;
12 | var next;
13 | while (!source.endOfLine()) {
14 | var next = source.next();
15 | if (next == end && !escaped)
16 | return false;
17 | escaped = !escaped && next == "\\";
18 | }
19 | return escaped;
20 | }
21 |
22 | // A map of Java's keywords. The a/b/c keyword distinction is
23 | // very rough, but it gives the parser enough information to parse
24 | // correct code correctly (we don't care that much how we parse
25 | // incorrect code). The style information included in these objects
26 | // is used by the highlighter to pick the correct CSS style for a
27 | // token.
28 | var keywords = function(){
29 | function result(type, style){
30 | return {type: type, style: "java-" + style};
31 | }
32 | // keywords that take a parenthised expression, and then a
33 | // statement (if)
34 | var keywordA = result("keyword a", "keyword");
35 | // keywords that take just a statement (else)
36 | var keywordB = result("keyword b", "keyword");
37 | // keywords that optionally take an expression, and form a
38 | // statement (return)
39 | var keywordC = result("keyword c", "keyword");
40 | var operator = result("operator", "keyword");
41 | var atom = result("atom", "atom");
42 |
43 | return {
44 | "if": keywordA, "while": keywordA, "with": keywordA,
45 | "else": keywordB, "do": keywordB, "try": keywordB, "finally": keywordB,
46 | "return": keywordC, "break": keywordC, "continue": keywordC, "new": keywordC, "throw": keywordC, "throws": keywordB,
47 | "in": operator, "typeof": operator, "instanceof": operator,
48 | "catch": result("catch", "keyword"), "for": result("for", "keyword"), "switch": result("switch", "keyword"),
49 | "case": result("case", "keyword"), "default": result("default", "keyword"),
50 | "true": atom, "false": atom, "null": atom,
51 |
52 | "class": result("class", "keyword"), "interface": result("interface", "keyword"), "package": keywordC, "import": keywordC,
53 | "implements": keywordC, "extends": keywordC, "super": keywordC,
54 |
55 | "public": keywordC, "private": keywordC, "protected": keywordC, "transient": keywordC, "this": keywordC,
56 | "static": keywordC, "final": keywordC, "const": keywordC, "abstract": keywordC, "static": keywordC,
57 |
58 | "int": keywordC, "double": keywordC, "long": keywordC, "boolean": keywordC, "char": keywordC,
59 | "void": keywordC, "byte": keywordC, "float": keywordC, "short": keywordC
60 | };
61 | }();
62 |
63 | // Some helper regexps
64 | var isOperatorChar = /[+\-*&%=<>!?|]/;
65 | var isHexDigit = /[0-9A-Fa-f]/;
66 | var isWordChar = /[\w\$_]/;
67 | // Wrapper around javaToken that helps maintain parser state (whether
68 | // we are inside of a multi-line comment and whether the next token
69 | // could be a regular expression).
70 | function javaTokenState(inside, regexp) {
71 | return function(source, setState) {
72 | var newInside = inside;
73 | var type = javaToken(inside, regexp, source, function(c) {newInside = c;});
74 | var newRegexp = type.type == "operator" || type.type == "keyword c" || type.type.match(/^[\[{}\(,;:]$/);
75 | if (newRegexp != regexp || newInside != inside)
76 | setState(javaTokenState(newInside, newRegexp));
77 | return type;
78 | };
79 | }
80 |
81 | // The token reader, inteded to be used by the tokenizer from
82 | // tokenize.js (through jsTokenState). Advances the source stream
83 | // over a token, and returns an object containing the type and style
84 | // of that token.
85 | function javaToken(inside, regexp, source, setInside) {
86 | function readHexNumber(){
87 | source.next(); // skip the 'x'
88 | source.nextWhileMatches(isHexDigit);
89 | return {type: "number", style: "java-atom"};
90 | }
91 |
92 | function readNumber() {
93 | source.nextWhileMatches(/[0-9]/);
94 | if (source.equals(".")){
95 | source.next();
96 | source.nextWhileMatches(/[0-9]/);
97 | }
98 | if (source.equals("e") || source.equals("E")){
99 | source.next();
100 | if (source.equals("-"))
101 | source.next();
102 | source.nextWhileMatches(/[0-9]/);
103 | }
104 | return {type: "number", style: "java-atom"};
105 | }
106 | // Read a word, look it up in keywords. If not found, it is a
107 | // variable, otherwise it is a keyword of the type found.
108 | function readWord() {
109 | source.nextWhileMatches(isWordChar);
110 | var word = source.get();
111 | var known = keywords.hasOwnProperty(word) && keywords.propertyIsEnumerable(word) && keywords[word];
112 | return known ? {type: known.type, style: known.style, content: word} :
113 | {type: "variable", style: "java-variable", content: word};
114 | }
115 | function readRegexp() {
116 | nextUntilUnescaped(source, "/");
117 | source.nextWhileMatches(/[gi]/);
118 | return {type: "regexp", style: "java-string"};
119 | }
120 | // Mutli-line comments are tricky. We want to return the newlines
121 | // embedded in them as regular newline tokens, and then continue
122 | // returning a comment token for every line of the comment. So
123 | // some state has to be saved (inside) to indicate whether we are
124 | // inside a /* */ sequence.
125 | function readMultilineComment(start){
126 | var newInside = "/*";
127 | var maybeEnd = (start == "*");
128 | while (true) {
129 | if (source.endOfLine())
130 | break;
131 | var next = source.next();
132 | if (next == "/" && maybeEnd){
133 | newInside = null;
134 | break;
135 | }
136 | maybeEnd = (next == "*");
137 | }
138 | setInside(newInside);
139 | return {type: "comment", style: "java-comment"};
140 | }
141 |
142 | // for reading javadoc
143 | function readJavaDocComment(start){
144 | var newInside = "/**";
145 | var maybeEnd = (start == "*");
146 | while (true) {
147 | if (source.endOfLine())
148 | break;
149 | var next = source.next();
150 | if (next == "/" && maybeEnd){
151 | newInside = null;
152 | break;
153 | }
154 | maybeEnd = (next == "*");
155 | }
156 | setInside(newInside);
157 | return {type: "javadoc", style: "javadoc-comment"};
158 | }
159 | // for reading annotations (word based)
160 | function readAnnotation(){
161 | source.nextWhileMatches(isWordChar);
162 | var word = source.get();
163 | return {type: "annotation", style: "java-annotation", content:word};
164 | }
165 |
166 | function readOperator() {
167 | source.nextWhileMatches(isOperatorChar);
168 | return {type: "operator", style: "java-operator"};
169 | }
170 | function readString(quote) {
171 | var endBackSlash = nextUntilUnescaped(source, quote);
172 | setInside(endBackSlash ? quote : null);
173 | return {type: "string", style: "java-string"};
174 | }
175 |
176 | // Fetch the next token. Dispatches on first character in the
177 | // stream, or first two characters when the first is a slash.
178 | if (inside == "\"" || inside == "'")
179 | return readString(inside);
180 | var ch = source.next();
181 | if (inside == "/*")
182 | return readMultilineComment(ch);
183 | else if(inside == "/**")
184 | return readJavaDocComment(ch);
185 | else if (ch == "\"" || ch == "'")
186 | return readString(ch);
187 | // with punctuation, the type of the token is the symbol itself
188 | else if (/[\[\]{}\(\),;\:\.]/.test(ch))
189 | return {type: ch, style: "java-punctuation"};
190 | else if (ch == "0" && (source.equals("x") || source.equals("X")))
191 | return readHexNumber();
192 | else if (/[0-9]/.test(ch))
193 | return readNumber();
194 | else if (ch == "@"){
195 | return readAnnotation();
196 | }else if (ch == "/"){
197 | if (source.equals("*")){
198 | source.next();
199 |
200 | if(source.equals("*"))
201 | return readJavaDocComment(ch);
202 |
203 | return readMultilineComment(ch);
204 | }
205 | else if (source.equals("/"))
206 | { nextUntilUnescaped(source, null); return {type: "comment", style: "java-comment"};}
207 | else if (regexp)
208 | return readRegexp();
209 | else
210 | return readOperator();
211 | }
212 | else if (isOperatorChar.test(ch))
213 | return readOperator();
214 | else
215 | return readWord();
216 | }
217 |
218 | // The external interface to the tokenizer.
219 | return function(source, startState) {
220 | return tokenizer(source, startState || javaTokenState(false, true));
221 | };
222 | })();
223 |
--------------------------------------------------------------------------------
/contrib/lua/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2009, Franciszek Wawrzak
2 | All rights reserved.
3 |
4 | This software is provided for use in connection with the
5 | CodeMirror suite of modules and utilities, hosted and maintained
6 | at http://codemirror.net/.
7 |
8 | Redistribution and use of this software in source and binary forms,
9 | with or without modification, are permitted provided that the
10 | following conditions are met:
11 |
12 | * Redistributions of source code must retain the above
13 | copyright notice, this list of conditions and the
14 | following disclaimer.
15 |
16 | * Redistributions in binary form must reproduce the above
17 | copyright notice, this list of conditions and the
18 | following disclaimer in the documentation and/or other
19 | materials provided with the distribution.
20 |
21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 | POSSIBILITY OF SUCH DAMAGE.
33 |
--------------------------------------------------------------------------------
/contrib/lua/css/luacolors.css:
--------------------------------------------------------------------------------
1 | html {
2 | cursor: text;
3 | }
4 |
5 | .editbox {
6 | margin: .4em;
7 | padding: 0;
8 | font-family: monospace;
9 | font-size: 10pt;
10 | color: black;
11 | }
12 |
13 | pre.code, .editbox {
14 | color: #666666;
15 | }
16 |
17 | .editbox p {
18 | margin: 0;
19 | }
20 |
21 | span.lua-comment {
22 | color: #BB9977;
23 | }
24 |
25 | span.lua-keyword {
26 | font-weight: bold;
27 | color: blue;
28 | }
29 |
30 | span.lua-string {
31 | color: #AA2222;
32 | }
33 |
34 | span.lua-stdfunc {
35 | font-weight: bold;
36 | color: #077;
37 | }
38 | span.lua-customfunc {
39 | font-weight: bold;
40 | color: #0AA;
41 | }
42 |
43 |
44 | span.lua-identifier {
45 | color: black;
46 | }
47 |
48 | span.lua-number {
49 | color: #3A3;
50 | }
51 |
52 | span.lua-token {
53 | color: #151;
54 | }
55 |
56 | span.lua-error {
57 | color: #FFF;
58 | background-color: #F00;
59 | }
60 |
61 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/contrib/lua/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | CodeMirror: Lua demonstration
5 |
6 |
7 |
8 | This page demonstrates CodeMirror 's
9 | Lua parser. Written by Franciszek
10 | Wawrzak , released under a BSD-style license .
12 |
13 |
14 |
76 |
77 |
78 |
86 |
87 |
88 |
--------------------------------------------------------------------------------
/contrib/lua/js/parselua.js:
--------------------------------------------------------------------------------
1 | /*
2 | Simple parser for LUA
3 | Written for Lua 5.1, based on parsecss and other parsers.
4 | features: highlights keywords, strings, comments (no leveling supported! ("[==[")),tokens, basic indenting
5 |
6 | to make this parser highlight your special functions pass table with this functions names to parserConfig argument of creator,
7 |
8 | parserConfig: ["myfunction1","myfunction2"],
9 | */
10 |
11 |
12 | function findFirstRegexp(words) {
13 | return new RegExp("^(?:" + words.join("|") + ")", "i");
14 | }
15 |
16 | function matchRegexp(words) {
17 | return new RegExp("^(?:" + words.join("|") + ")$", "i");
18 | }
19 |
20 |
21 |
22 | var luaCustomFunctions= matchRegexp([]);
23 |
24 | function configureLUA(parserConfig){
25 | if(parserConfig)
26 | luaCustomFunctions= matchRegexp(parserConfig);
27 | }
28 |
29 |
30 | //long list of standard functions from lua manual
31 | var luaStdFunctions = matchRegexp([
32 | "_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",
33 |
34 | "coroutine.create","coroutine.resume","coroutine.running","coroutine.status","coroutine.wrap","coroutine.yield",
35 |
36 | "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",
37 |
38 | "close","flush","lines","read","seek","setvbuf","write",
39 |
40 | "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",
41 |
42 | "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",
43 |
44 | "os.clock","os.date","os.difftime","os.execute","os.exit","os.getenv","os.remove","os.rename","os.setlocale","os.time","os.tmpname",
45 |
46 | "package.cpath","package.loaded","package.loaders","package.loadlib","package.path","package.preload","package.seeall",
47 |
48 | "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",
49 |
50 | "table.concat","table.insert","table.maxn","table.remove","table.sort"
51 | ]);
52 |
53 |
54 |
55 | var luaKeywords = matchRegexp(["and","break","elseif","false","nil","not","or","return",
56 | "true","function", "end", "if", "then", "else", "do",
57 | "while", "repeat", "until", "for", "in", "local" ]);
58 |
59 | var luaIndentKeys = matchRegexp(["function", "if","repeat","for","while", "[\(]", "{"]);
60 | var luaUnindentKeys = matchRegexp(["end", "until", "[\)]", "}"]);
61 |
62 | var luaUnindentKeys2 = findFirstRegexp(["end", "until", "[\)]", "}"]);
63 | var luaMiddleKeys = findFirstRegexp(["else","elseif"]);
64 |
65 |
66 |
67 | var LUAParser = Editor.Parser = (function() {
68 | var tokenizeLUA = (function() {
69 | function normal(source, setState) {
70 | var ch = source.next();
71 |
72 | if (ch == "-" && source.equals("-")) {
73 | source.next();
74 | setState(inSLComment);
75 | return null;
76 | }
77 | else if (ch == "\"" || ch == "'") {
78 | setState(inString(ch));
79 | return null;
80 | }
81 | if (ch == "[" && (source.equals("[") || source.equals("="))) {
82 | var level = 0;
83 | while(source.equals("=")){
84 | level ++;
85 | source.next();
86 | }
87 | if(! source.equals("[") )
88 | return "lua-error";
89 | setState(inMLSomething(level,"lua-string"));
90 | return null;
91 | }
92 |
93 | else if (ch == "=") {
94 | if (source.equals("="))
95 | source.next();
96 | return "lua-token";
97 | }
98 |
99 | else if (ch == ".") {
100 | if (source.equals("."))
101 | source.next();
102 | if (source.equals("."))
103 | source.next();
104 | return "lua-token";
105 | }
106 |
107 | else if (ch == "+" || ch == "-" || ch == "*" || ch == "/" || ch == "%" || ch == "^" || ch == "#" ) {
108 | return "lua-token";
109 | }
110 | else if (ch == ">" || ch == "<" || ch == "(" || ch == ")" || ch == "{" || ch == "}" || ch == "[" ) {
111 | return "lua-token";
112 | }
113 | else if (ch == "]" || ch == ";" || ch == ":" || ch == ",") {
114 | return "lua-token";
115 | }
116 | else if (source.equals("=") && (ch == "~" || ch == "<" || ch == ">")) {
117 | source.next();
118 | return "lua-token";
119 | }
120 |
121 | else if (/\d/.test(ch)) {
122 | source.nextWhileMatches(/[\w.%]/);
123 | return "lua-number";
124 | }
125 | else {
126 | source.nextWhileMatches(/[\w\\\-_.]/);
127 | return "lua-identifier";
128 | }
129 | }
130 |
131 | function inSLComment(source, setState) {
132 | var start = true;
133 | var count=0;
134 | while (!source.endOfLine()) {
135 | var ch = source.next();
136 | var level = 0;
137 | if ((ch =="[") && start){
138 | while(source.equals("=")){
139 | source.next();
140 | level++;
141 | }
142 | if (source.equals("[")){
143 | setState(inMLSomething(level,"lua-comment"));
144 | return null;
145 | }
146 | }
147 | start = false;
148 | }
149 | setState(normal);
150 | return "lua-comment";
151 |
152 | }
153 |
154 | function inMLSomething(level,what) {
155 | //wat sholud be "lua-string" or "lua-comment", level is the number of "=" in opening mark.
156 | return function(source, setState){
157 | var dashes = 0;
158 | while (!source.endOfLine()) {
159 | var ch = source.next();
160 | if (dashes == level+1 && ch == "]" ) {
161 | setState(normal);
162 | break;
163 | }
164 | if (dashes == 0)
165 | dashes = (ch == "]") ? 1:0;
166 | else
167 | dashes = (ch == "=") ? dashes + 1 : 0;
168 | }
169 | return what;
170 | }
171 | }
172 |
173 |
174 | function inString(quote) {
175 | return function(source, setState) {
176 | var escaped = false;
177 | while (!source.endOfLine()) {
178 | var ch = source.next();
179 | if (ch == quote && !escaped)
180 | break;
181 | escaped = !escaped && ch == "\\";
182 | }
183 | if (!escaped)
184 | setState(normal);
185 | return "lua-string";
186 | };
187 | }
188 |
189 | return function(source, startState) {
190 | return tokenizer(source, startState || normal);
191 | };
192 | })();
193 |
194 | function indentLUA(indentDepth, base) {
195 | return function(nextChars) {
196 |
197 | var closing = (luaUnindentKeys2.test(nextChars) || luaMiddleKeys.test(nextChars));
198 |
199 |
200 | return base + ( indentUnit * (indentDepth - (closing?1:0)) );
201 | };
202 | }
203 |
204 |
205 | function parseLUA(source,basecolumn) {
206 | basecolumn = basecolumn || 0;
207 |
208 | var tokens = tokenizeLUA(source);
209 | var indentDepth = 0;
210 |
211 | var iter = {
212 | next: function() {
213 | var token = tokens.next(), style = token.style, content = token.content;
214 |
215 |
216 |
217 | if (style == "lua-identifier" && luaKeywords.test(content)){
218 | token.style = "lua-keyword";
219 | }
220 | if (style == "lua-identifier" && luaStdFunctions.test(content)){
221 | token.style = "lua-stdfunc";
222 | }
223 | if (style == "lua-identifier" && luaCustomFunctions.test(content)){
224 | token.style = "lua-customfunc";
225 | }
226 |
227 | if ((style != "lua-comment") && (style != "lua-string")){
228 | if (luaIndentKeys.test(content))
229 | indentDepth++;
230 | else if (luaUnindentKeys.test(content))
231 | indentDepth--;
232 | }
233 |
234 | if (content == "\n")
235 | token.indentation = indentLUA( indentDepth, basecolumn);
236 |
237 | return token;
238 | },
239 |
240 | copy: function() {
241 | var _tokenState = tokens.state, _indentDepth = indentDepth;
242 | return function(source) {
243 | tokens = tokenizeLUA(source, _tokenState);
244 |
245 | indentDepth = _indentDepth;
246 | return iter;
247 | };
248 | }
249 | };
250 | return iter;
251 | }
252 |
253 | return {make: parseLUA, configure:configureLUA, electricChars: "delf})"}; //en[d] els[e] unti[l] elsei[f] // this should be taken from Keys keywords
254 | })();
255 |
256 |
--------------------------------------------------------------------------------
/contrib/ometa/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2007-2009 Marijn Haverbeke
2 |
3 | This software is provided 'as-is', without any express or implied
4 | warranty. In no event will the authors be held liable for any
5 | damages arising from the use of this software.
6 |
7 | Permission is granted to anyone to use this software for any
8 | purpose, including commercial applications, and to alter it and
9 | redistribute it freely, subject to the following restrictions:
10 |
11 | 1. The origin of this software must not be misrepresented; you must
12 | not claim that you wrote the original software. If you use this
13 | software in a product, an acknowledgment in the product
14 | documentation would be appreciated but is not required.
15 |
16 | 2. Altered source versions must be plainly marked as such, and must
17 | not be misrepresented as being the original software.
18 |
19 | 3. This notice may not be removed or altered from any source
20 | distribution.
21 |
22 | Marijn Haverbeke
23 | marijnh at gmail
24 |
--------------------------------------------------------------------------------
/contrib/ometa/css/ometacolors.css:
--------------------------------------------------------------------------------
1 | html {
2 | cursor: text;
3 | }
4 |
5 | .editbox {
6 | margin: .4em;
7 | padding: 0;
8 | font-family: monospace;
9 | font-size: 10pt;
10 | color: black;
11 | }
12 |
13 | pre.code, .editbox {
14 | color: #666666;
15 | }
16 |
17 | .editbox p {
18 | margin: 0;
19 | }
20 |
21 | span.js-punctuation {
22 | color: #666666;
23 | }
24 |
25 | span.js-operator {
26 | color: #E1570F;
27 | }
28 |
29 | span.js-keyword {
30 | color: #770088;
31 | }
32 |
33 | span.js-atom {
34 | color: #228811;
35 | }
36 |
37 | span.js-variable {
38 | color: black;
39 | }
40 |
41 | span.js-variabledef {
42 | color: #0000FF;
43 | }
44 |
45 | span.js-localvariable {
46 | color: #004499;
47 | }
48 |
49 | span.js-property {
50 | color: black;
51 | }
52 |
53 | span.js-comment {
54 | color: #AA7700;
55 | }
56 |
57 | span.js-string {
58 | color: #AA2222;
59 | }
60 |
61 | span.ometa-binding {
62 | color: #FF0000;
63 | }
64 |
--------------------------------------------------------------------------------
/contrib/ometa/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | CodeMirror: OmetaJS demonstration
5 |
6 |
7 |
8 |
9 | This page demonstrates CodeMirror 's OmetaJS parser.
11 |
12 | Adapted from the official Javascript parser by Eric KEDJI
13 | <eric.kedji@gmail.com >.
14 |
15 |
16 |
53 |
54 |
55 |
75 |
76 |
77 |
78 |
--------------------------------------------------------------------------------
/contrib/ometa/js/tokenizeometa.js:
--------------------------------------------------------------------------------
1 | /* Tokenizer for JavaScript code */
2 |
3 | var tokenizeJavaScript = (function() {
4 | // Advance the stream until the given character (not preceded by a
5 | // backslash) is encountered, or the end of the line is reached.
6 | function nextUntilUnescaped(source, end) {
7 | var escaped = false;
8 | while (!source.endOfLine()) {
9 | var next = source.next();
10 | if (next == end && !escaped)
11 | return false;
12 | escaped = !escaped && next == "\\";
13 | }
14 | return escaped;
15 | }
16 |
17 | // A map of JavaScript's keywords. The a/b/c keyword distinction is
18 | // very rough, but it gives the parser enough information to parse
19 | // correct code correctly (we don't care that much how we parse
20 | // incorrect code). The style information included in these objects
21 | // is used by the highlighter to pick the correct CSS style for a
22 | // token.
23 | var keywords = function(){
24 | function result(type, style){
25 | return {type: type, style: "js-" + style};
26 | }
27 | // keywords that take a parenthised expression, and then a
28 | // statement (if)
29 | var keywordA = result("keyword a", "keyword");
30 | // keywords that take just a statement (else)
31 | var keywordB = result("keyword b", "keyword");
32 | // keywords that optionally take an expression, and form a
33 | // statement (return)
34 | var keywordC = result("keyword c", "keyword");
35 | var operator = result("operator", "keyword");
36 | var atom = result("atom", "atom");
37 | return {
38 | "if": keywordA, "while": keywordA, "with": keywordA,
39 | "else": keywordB, "do": keywordB, "try": keywordB, "finally": keywordB,
40 | "return": keywordC, "break": keywordC, "continue": keywordC, "new": keywordC, "delete": keywordC, "throw": keywordC,
41 | "in": operator, "typeof": operator, "instanceof": operator,
42 | "var": result("var", "keyword"), "function": result("function", "keyword"), "catch": result("catch", "keyword"),
43 | "for": result("for", "keyword"), "switch": result("switch", "keyword"),
44 | "case": result("case", "keyword"), "default": result("default", "keyword"),
45 | "true": atom, "false": atom, "null": atom, "undefined": atom, "NaN": atom, "Infinity": atom,
46 | "ometa": keywordB
47 | };
48 | }();
49 |
50 | // Some helper regexps
51 | var isOperatorChar = /[+\-*&%=<>!?|~]/;
52 | var isHexDigit = /[0-9A-Fa-f]/;
53 | var isWordChar = /[\w\$_]/;
54 |
55 | // Wrapper around jsToken that helps maintain parser state (whether
56 | // we are inside of a multi-line comment and whether the next token
57 | // could be a regular expression).
58 | function jsTokenState(inside, regexp) {
59 | return function(source, setState) {
60 | var newInside = inside;
61 | var type = jsToken(inside, regexp, source, function(c) {newInside = c;});
62 | var newRegexp = type.type == "operator" || type.type == "keyword c" || type.type.match(/^[\[{}\(,;:]$/);
63 | if (newRegexp != regexp || newInside != inside)
64 | setState(jsTokenState(newInside, newRegexp));
65 | return type;
66 | };
67 | }
68 |
69 | // The token reader, intended to be used by the tokenizer from
70 | // tokenize.js (through jsTokenState). Advances the source stream
71 | // over a token, and returns an object containing the type and style
72 | // of that token.
73 | function jsToken(inside, regexp, source, setInside) {
74 | function readHexNumber(){
75 | source.next(); // skip the 'x'
76 | source.nextWhileMatches(isHexDigit);
77 | return {type: "number", style: "js-atom"};
78 | }
79 |
80 | function readNumber() {
81 | source.nextWhileMatches(/[0-9]/);
82 | if (source.equals(".")){
83 | source.next();
84 | source.nextWhileMatches(/[0-9]/);
85 | }
86 | if (source.equals("e") || source.equals("E")){
87 | source.next();
88 | if (source.equals("-"))
89 | source.next();
90 | source.nextWhileMatches(/[0-9]/);
91 | }
92 | return {type: "number", style: "js-atom"};
93 | }
94 | // Read a word, look it up in keywords. If not found, it is a
95 | // variable, otherwise it is a keyword of the type found.
96 | function readWord() {
97 | source.nextWhileMatches(isWordChar);
98 | var word = source.get();
99 | var known = keywords.hasOwnProperty(word) && keywords.propertyIsEnumerable(word) && keywords[word];
100 | return known ? {type: known.type, style: known.style, content: word} :
101 | {type: "variable", style: "js-variable", content: word};
102 | }
103 | function readRegexp() {
104 | nextUntilUnescaped(source, "/");
105 | source.nextWhileMatches(/[gi]/);
106 | return {type: "regexp", style: "js-string"};
107 | }
108 | // Mutli-line comments are tricky. We want to return the newlines
109 | // embedded in them as regular newline tokens, and then continue
110 | // returning a comment token for every line of the comment. So
111 | // some state has to be saved (inside) to indicate whether we are
112 | // inside a /* */ sequence.
113 | function readMultilineComment(start){
114 | var newInside = "/*";
115 | var maybeEnd = (start == "*");
116 | while (true) {
117 | if (source.endOfLine())
118 | break;
119 | var next = source.next();
120 | if (next == "/" && maybeEnd){
121 | newInside = null;
122 | break;
123 | }
124 | maybeEnd = (next == "*");
125 | }
126 | setInside(newInside);
127 | return {type: "comment", style: "js-comment"};
128 | }
129 | function readMultilineString(start, quotes) {
130 | var newInside = quotes;
131 | var quote = quotes.charAt(0);
132 | var maybeEnd = (start == quote);
133 | while (true) {
134 | if (source.endOfLine())
135 | break;
136 | var next = source.next();
137 | if (next == quote && source.peek() == quote && maybeEnd) {
138 | source.next();
139 | newInside = null;
140 | break;
141 | }
142 | maybeEnd = (next == quote);
143 | }
144 | setInside(newInside);
145 | return {type: "multilineString", style: "js-string"};
146 | }
147 | function readOperator() {
148 | source.nextWhileMatches(isOperatorChar);
149 | return {type: "operator", style: "js-operator"};
150 | }
151 | function readString(quote) {
152 | var endBackSlash = nextUntilUnescaped(source, quote);
153 | setInside(endBackSlash ? quote : null);
154 | return {type: "string", style: "js-string"};
155 | }
156 | function readOmetaIdentifierString() {
157 | source.nextWhileMatches(isWordChar);
158 | return {type: "string", style: "js-string"};
159 | }
160 | function readOmetaBinding() {
161 | source.nextWhileMatches(isWordChar);
162 | return {type: "variable", style: "ometa-binding"};
163 | }
164 |
165 | // Fetch the next token. Dispatches on first character in the
166 | // stream, or first two characters when the first is a slash.
167 | if (inside == "\"" || inside == "'")
168 | return readString(inside);
169 | var ch = source.next();
170 | if (inside == "/*")
171 | return readMultilineComment(ch);
172 | if (inside == '"""' || inside == "'''")
173 | return readMultilineString(ch, inside);
174 | if (ch == '"' && source.lookAhead('""', true) || ch == "'" && source.lookAhead("''", true))
175 | return readMultilineString('-', ch+ch+ch); // work as far as '-' is not '"' nor "'"
176 | else if (ch == "\"" || ch == "'")
177 | return readString(ch);
178 | else if (ch == "`" || ch == "#" )
179 | return readOmetaIdentifierString();
180 | else if (ch == ':' && isWordChar.test(source.peek()))
181 | return readOmetaBinding();
182 | // with punctuation, the type of the token is the symbol itself
183 | else if (/[\[\]{}\(\),;\:\.]/.test(ch))
184 | return {type: ch, style: "js-punctuation"};
185 | else if (ch == "0" && (source.equals("x") || source.equals("X")))
186 | return readHexNumber();
187 | else if (/[0-9]/.test(ch))
188 | return readNumber();
189 | else if (ch == "/"){
190 | if (source.equals("*"))
191 | { source.next(); return readMultilineComment(ch); }
192 | else if (source.equals("/"))
193 | { nextUntilUnescaped(source, null); return {type: "comment", style: "js-comment"};}
194 | else if (regexp)
195 | return readRegexp();
196 | else
197 | return readOperator();
198 | }
199 | else if (isOperatorChar.test(ch))
200 | return readOperator();
201 | else
202 | return readWord();
203 | }
204 |
205 | // The external interface to the tokenizer.
206 | return function(source, startState) {
207 | return tokenizer(source, startState || jsTokenState(false, true));
208 | };
209 | })();
210 |
--------------------------------------------------------------------------------
/contrib/php/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2008-2009, Yahoo! Inc.
2 | All rights reserved.
3 |
4 | This software is provided for use in connection with the
5 | CodeMirror suite of modules and utilities, hosted and maintained
6 | at http://codemirror.net/.
7 |
8 | Redistribution and use of this software in source and binary forms,
9 | with or without modification, are permitted provided that the
10 | following conditions are met:
11 |
12 | * Redistributions of source code must retain the above
13 | copyright notice, this list of conditions and the
14 | following disclaimer.
15 |
16 | * Redistributions in binary form must reproduce the above
17 | copyright notice, this list of conditions and the
18 | following disclaimer in the documentation and/or other
19 | materials provided with the distribution.
20 |
21 | * Neither the name of Yahoo! Inc. nor the names of its
22 | contributors may be used to endorse or promote products
23 | derived from this software without specific prior
24 | written permission of Yahoo! Inc.
25 |
26 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
28 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
29 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
30 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
31 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
32 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
33 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
34 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
36 | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 | POSSIBILITY OF SUCH DAMAGE.
38 |
--------------------------------------------------------------------------------
/contrib/php/css/phpcolors.css:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2008-2009 Yahoo! Inc. All rights reserved.
3 | The copyrights embodied in the content of this file are licensed by
4 | Yahoo! Inc. under the BSD (revised) open source license
5 |
6 | @author Dan Vlad Dascalescu
7 | */
8 |
9 | html {
10 | cursor: text;
11 | }
12 |
13 | .editbox {
14 | margin: .4em;
15 | padding: 0;
16 | font-family: monospace;
17 | font-size: 10pt;
18 | }
19 |
20 | /*We should define specific styles for every element of the syntax.
21 | the setting below will cause some annoying color to show through if we missed
22 | defining a style for a token. This is also the "color" of the whitespace and
23 | of the cursor.
24 | */
25 | pre.code, .editbox {
26 | color: red;
27 | }
28 |
29 | .editbox p {
30 | margin: 0;
31 | }
32 |
33 | span.php-punctuation {
34 | color: blue;
35 | }
36 |
37 | span.php-keyword {
38 | color: #770088;
39 | font-weight: bold;
40 | }
41 |
42 | span.php-operator {
43 | color: blue;
44 | }
45 |
46 | /* __FILE__ etc.; http://php.net/manual/en/reserved.php */
47 | span.php-compile-time-constant {
48 | color: #776088;
49 | font-weight: bold;
50 | }
51 |
52 | /* output of get_defined_constants(). Differs from http://php.net/manual/en/reserved.constants.php */
53 | span.php-predefined-constant {
54 | color: darkgreen;
55 | font-weight: bold;
56 | }
57 |
58 | /* PHP reserved "language constructs"... echo() etc.; http://php.net/manual/en/reserved.php */
59 | span.php-reserved-language-construct {
60 | color: green;
61 | font-weight: bold;
62 | }
63 |
64 | /* PHP built-in functions: glob(), chr() etc.; output of get_defined_functions()["internal"] */
65 | span.php-predefined-function {
66 | color: green;
67 | }
68 |
69 | /* PHP predefined classes: PDO, Exception etc.; output of get_declared_classes() and different from http://php.net/manual/en/reserved.classes.php */
70 | span.php-predefined-class {
71 | color: green;
72 | }
73 |
74 | span.php-atom {
75 | color: #228811;
76 | }
77 |
78 | /* class, interface, namespace or function names, but not $variables */
79 | span.php-t_string {
80 | color: black;
81 | }
82 |
83 | span.php-variable {
84 | color: black;
85 | font-weight: bold;
86 | }
87 |
88 |
89 | span.js-localvariable {
90 | color: #004499;
91 | }
92 |
93 | span.php-comment {
94 | color: #AA7700;
95 | font-stretch: condensed;
96 | /* font-style: italic; This causes line height to slightly change, getting line numbers out of sync */
97 | }
98 |
99 | span.php-string-single-quoted {
100 | color: #AA2222;
101 | }
102 | /* double quoted strings allow interpolation */
103 | span.php-string-double-quoted {
104 | color: #AA2222;
105 | font-weight: bold;
106 | }
107 |
108 | span.syntax-error {
109 | background-color: red;
110 | }
111 |
112 | span.deprecated {
113 | font-size: smaller;
114 | }
115 |
--------------------------------------------------------------------------------
/contrib/php/js/parsephphtmlmixed.js:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2008-2009 Yahoo! Inc. All rights reserved.
3 | The copyrights embodied in the content of this file are licensed by
4 | Yahoo! Inc. under the BSD (revised) open source license
5 |
6 | @author Dan Vlad Dascalescu
7 |
8 | Based on parsehtmlmixed.js by Marijn Haverbeke.
9 | */
10 |
11 | var PHPHTMLMixedParser = Editor.Parser = (function() {
12 | var processingInstructions = ["");
36 | break;
37 | }
38 | }
39 | else if (token.style == "xml-attribute" && token.content == "\"php\"" && inTag == "script" && lastAtt == "language")
40 | inTag = "script/php";
41 | // "xml-processing" tokens are ignored, because they should be handled by a specific local parser
42 | else if (token.content == ">") {
43 | if (inTag == "script/php")
44 | iter.next = local(PHPParser, "");
45 | else if (inTag == "script")
46 | iter.next = local(JSParser, "
2 |
3 |
4 | CodeMirror: PLSQL demonstration
5 |
6 |
7 |
8 |
9 | Demonstration of CodeMirror 's PLSQL
10 | highlighter.
11 |
12 | Written by Peter Raganitsch (license ), based
13 | on John Benediktsson SQL parser .
14 |
15 |
16 |
54 |
55 |
56 |
65 |
66 |
67 |