codemirror-rails 3.02 → 3.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +1 -1
- data/LICENSE +1 -1
- data/codemirror-rails.gemspec +1 -0
- data/doc/CodeMirror-LICENSE +5 -1
- data/lib/codemirror/rails/version.rb +2 -2
- data/vendor/assets/javascripts/codemirror/{utils → addons/dialog}/dialog.js +4 -0
- data/vendor/assets/javascripts/codemirror/addons/display/placeholder.js +54 -0
- data/vendor/assets/javascripts/codemirror/addons/edit/closebrackets.js +54 -0
- data/vendor/assets/javascripts/codemirror/{utils → addons/edit}/closetag.js +9 -8
- data/vendor/assets/javascripts/codemirror/{utils → addons/edit}/continuecomment.js +12 -4
- data/vendor/assets/javascripts/codemirror/addons/edit/continuelist.js +25 -0
- data/vendor/assets/javascripts/codemirror/{utils → addons/edit}/matchbrackets.js +30 -11
- data/vendor/assets/javascripts/codemirror/addons/fold/brace-fold.js +31 -0
- data/vendor/assets/javascripts/codemirror/addons/fold/foldcode.js +32 -0
- data/vendor/assets/javascripts/codemirror/addons/fold/indent-fold.js +11 -0
- data/vendor/assets/javascripts/codemirror/addons/fold/xml-fold.js +64 -0
- data/vendor/assets/javascripts/codemirror/addons/hint/html-hint.js +582 -0
- data/vendor/assets/javascripts/codemirror/{utils → addons/hint}/javascript-hint.js +15 -11
- data/vendor/assets/javascripts/codemirror/{utils → addons/hint}/pig-hint.js +19 -19
- data/vendor/assets/javascripts/codemirror/{utils → addons/hint}/python-hint.js +2 -2
- data/vendor/assets/javascripts/codemirror/addons/hint/show-hint.js +180 -0
- data/vendor/assets/javascripts/codemirror/{utils → addons/hint}/xml-hint.js +5 -18
- data/vendor/assets/javascripts/codemirror/addons/lint/javascript-lint.js +127 -0
- data/vendor/assets/javascripts/codemirror/addons/lint/json-lint.js +14 -0
- data/vendor/assets/javascripts/codemirror/addons/lint/lint.js +197 -0
- data/vendor/assets/javascripts/codemirror/{utils → addons/mode}/loadmode.js +0 -0
- data/vendor/assets/javascripts/codemirror/{utils → addons/mode}/multiplex.js +2 -2
- data/vendor/assets/javascripts/codemirror/{utils → addons/mode}/overlay.js +2 -2
- data/vendor/assets/javascripts/codemirror/{utils → addons/runmode}/colorize.js +0 -0
- data/vendor/assets/javascripts/codemirror/{utils → addons/runmode}/runmode-standalone.js +2 -3
- data/vendor/assets/javascripts/codemirror/{utils → addons/runmode}/runmode.js +0 -0
- data/vendor/assets/javascripts/codemirror/addons/runmode/runmode.node.js +89 -0
- data/vendor/assets/javascripts/codemirror/addons/search/match-highlighter.js +60 -0
- data/vendor/assets/javascripts/codemirror/{utils → addons/search}/search.js +5 -5
- data/vendor/assets/javascripts/codemirror/{utils → addons/search}/searchcursor.js +37 -30
- data/vendor/assets/javascripts/codemirror/addons/selection/active-line.js +39 -0
- data/vendor/assets/javascripts/codemirror/addons/selection/mark-selection.js +34 -0
- data/vendor/assets/javascripts/codemirror/keymaps/vim.js +721 -188
- data/vendor/assets/javascripts/codemirror/modes/asterisk.js +6 -6
- data/vendor/assets/javascripts/codemirror/modes/clike.js +14 -14
- data/vendor/assets/javascripts/codemirror/modes/clojure.js +23 -7
- data/vendor/assets/javascripts/codemirror/modes/coffeescript.js +2 -2
- data/vendor/assets/javascripts/codemirror/modes/css.js +337 -235
- data/vendor/assets/javascripts/codemirror/modes/ecl.js +12 -12
- data/vendor/assets/javascripts/codemirror/modes/erlang.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/gas.js +326 -0
- data/vendor/assets/javascripts/codemirror/modes/gfm.js +1 -0
- data/vendor/assets/javascripts/codemirror/modes/haskell.js +26 -26
- data/vendor/assets/javascripts/codemirror/modes/haxe.js +17 -17
- data/vendor/assets/javascripts/codemirror/modes/htmlembedded.js +6 -6
- data/vendor/assets/javascripts/codemirror/modes/htmlmixed.js +43 -23
- data/vendor/assets/javascripts/codemirror/modes/javascript.js +78 -33
- data/vendor/assets/javascripts/codemirror/modes/jinja2.js +2 -2
- data/vendor/assets/javascripts/codemirror/modes/less.js +38 -38
- data/vendor/assets/javascripts/codemirror/modes/livescript.js +267 -0
- data/vendor/assets/javascripts/codemirror/modes/lua.js +7 -7
- data/vendor/assets/javascripts/codemirror/modes/markdown.js +108 -57
- data/vendor/assets/javascripts/codemirror/modes/mirc.js +177 -0
- data/vendor/assets/javascripts/codemirror/modes/ntriples.js +22 -22
- data/vendor/assets/javascripts/codemirror/modes/ocaml.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/perl.js +791 -791
- data/vendor/assets/javascripts/codemirror/modes/php.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/pig.js +163 -163
- data/vendor/assets/javascripts/codemirror/modes/python.js +31 -31
- data/vendor/assets/javascripts/codemirror/modes/q.js +124 -0
- data/vendor/assets/javascripts/codemirror/modes/rst.js +486 -250
- data/vendor/assets/javascripts/codemirror/modes/sass.js +3 -3
- data/vendor/assets/javascripts/codemirror/modes/scss_test.js +80 -0
- data/vendor/assets/javascripts/codemirror/modes/shell.js +2 -2
- data/vendor/assets/javascripts/codemirror/modes/sieve.js +10 -10
- data/vendor/assets/javascripts/codemirror/modes/smalltalk.js +129 -129
- data/vendor/assets/javascripts/codemirror/modes/smarty.js +3 -3
- data/vendor/assets/javascripts/codemirror/modes/sparql.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/sql.js +23 -23
- data/vendor/assets/javascripts/codemirror/modes/stex.js +192 -121
- data/vendor/assets/javascripts/codemirror/modes/tcl.js +131 -0
- data/vendor/assets/javascripts/codemirror/modes/test.js +64 -0
- data/vendor/assets/javascripts/codemirror/modes/tiddlywiki.js +345 -345
- data/vendor/assets/javascripts/codemirror/modes/tiki.js +297 -298
- data/vendor/assets/javascripts/codemirror/modes/turtle.js +145 -0
- data/vendor/assets/javascripts/codemirror/modes/vb.js +31 -32
- data/vendor/assets/javascripts/codemirror/modes/vbscript.js +4 -4
- data/vendor/assets/javascripts/codemirror/modes/xml.js +10 -6
- data/vendor/assets/javascripts/codemirror/modes/xquery.js +55 -55
- data/vendor/assets/javascripts/codemirror/modes/yaml.js +90 -90
- data/vendor/assets/javascripts/codemirror/modes/z80.js +82 -110
- data/vendor/assets/javascripts/codemirror.js +1914 -1115
- data/vendor/assets/stylesheets/codemirror/{utils → addons/dialog}/dialog.css +0 -0
- data/vendor/assets/stylesheets/codemirror/addons/hint/show-hint.css +38 -0
- data/vendor/assets/stylesheets/codemirror/addons/lint/lint.css +96 -0
- data/vendor/assets/stylesheets/codemirror/modes/tiki.css +2 -2
- data/vendor/assets/stylesheets/codemirror/themes/ambiance-mobile.css +0 -1
- data/vendor/assets/stylesheets/codemirror/themes/ambiance.css +0 -1
- data/vendor/assets/stylesheets/codemirror/themes/eclipse.css +2 -2
- data/vendor/assets/stylesheets/codemirror/themes/erlang-dark.css +5 -5
- data/vendor/assets/stylesheets/codemirror/themes/midnight.css +52 -0
- data/vendor/assets/stylesheets/codemirror/themes/xq-light.css +43 -0
- data/vendor/assets/stylesheets/codemirror.css +16 -10
- metadata +60 -52
- data/vendor/assets/javascripts/codemirror/modes/mysql.js +0 -203
- data/vendor/assets/javascripts/codemirror/modes/plsql.js +0 -216
- data/vendor/assets/javascripts/codemirror/utils/collapserange.js +0 -68
- data/vendor/assets/javascripts/codemirror/utils/continuelist.js +0 -28
- data/vendor/assets/javascripts/codemirror/utils/foldcode.js +0 -183
- data/vendor/assets/javascripts/codemirror/utils/formatting.js +0 -114
- data/vendor/assets/javascripts/codemirror/utils/match-highlighter.js +0 -46
- data/vendor/assets/javascripts/codemirror/utils/simple-hint.js +0 -102
- data/vendor/assets/stylesheets/codemirror/utils/simple-hint.css +0 -16
@@ -121,7 +121,7 @@
|
|
121
121
|
|
122
122
|
innerMode: function(state) { return {state: state.curState, mode: state.curMode}; }
|
123
123
|
};
|
124
|
-
}, "htmlmixed");
|
124
|
+
}, "htmlmixed", "clike");
|
125
125
|
|
126
126
|
CodeMirror.defineMIME("application/x-httpd-php", "php");
|
127
127
|
CodeMirror.defineMIME("application/x-httpd-php-open", {name: "php", startOpen: true});
|
@@ -1,171 +1,171 @@
|
|
1
1
|
/*
|
2
|
-
*
|
3
|
-
*
|
4
|
-
*
|
2
|
+
* Pig Latin Mode for CodeMirror 2
|
3
|
+
* @author Prasanth Jayachandran
|
4
|
+
* @link https://github.com/prasanthj/pig-codemirror-2
|
5
5
|
* This implementation is adapted from PL/SQL mode in CodeMirror 2.
|
6
|
-
*/
|
6
|
+
*/
|
7
7
|
CodeMirror.defineMode("pig", function(_config, parserConfig) {
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
8
|
+
var keywords = parserConfig.keywords,
|
9
|
+
builtins = parserConfig.builtins,
|
10
|
+
types = parserConfig.types,
|
11
|
+
multiLineStrings = parserConfig.multiLineStrings;
|
12
|
+
|
13
|
+
var isOperatorChar = /[*+\-%<>=&?:\/!|]/;
|
14
|
+
|
15
|
+
function chain(stream, state, f) {
|
16
|
+
state.tokenize = f;
|
17
|
+
return f(stream, state);
|
18
|
+
}
|
19
|
+
|
20
|
+
var type;
|
21
|
+
function ret(tp, style) {
|
22
|
+
type = tp;
|
23
|
+
return style;
|
24
|
+
}
|
25
|
+
|
26
|
+
function tokenComment(stream, state) {
|
27
|
+
var isEnd = false;
|
28
|
+
var ch;
|
29
|
+
while(ch = stream.next()) {
|
30
|
+
if(ch == "/" && isEnd) {
|
31
|
+
state.tokenize = tokenBase;
|
32
|
+
break;
|
33
|
+
}
|
34
|
+
isEnd = (ch == "*");
|
35
|
+
}
|
36
|
+
return ret("comment", "comment");
|
37
|
+
}
|
38
|
+
|
39
|
+
function tokenString(quote) {
|
40
|
+
return function(stream, state) {
|
41
|
+
var escaped = false, next, end = false;
|
42
|
+
while((next = stream.next()) != null) {
|
43
|
+
if (next == quote && !escaped) {
|
44
|
+
end = true; break;
|
45
|
+
}
|
46
|
+
escaped = !escaped && next == "\\";
|
47
|
+
}
|
48
|
+
if (end || !(escaped || multiLineStrings))
|
49
|
+
state.tokenize = tokenBase;
|
50
|
+
return ret("string", "error");
|
51
|
+
};
|
52
|
+
}
|
53
|
+
|
54
|
+
function tokenBase(stream, state) {
|
55
|
+
var ch = stream.next();
|
56
|
+
|
57
|
+
// is a start of string?
|
58
|
+
if (ch == '"' || ch == "'")
|
59
|
+
return chain(stream, state, tokenString(ch));
|
60
|
+
// is it one of the special chars
|
61
|
+
else if(/[\[\]{}\(\),;\.]/.test(ch))
|
62
|
+
return ret(ch);
|
63
|
+
// is it a number?
|
64
|
+
else if(/\d/.test(ch)) {
|
65
|
+
stream.eatWhile(/[\w\.]/);
|
66
|
+
return ret("number", "number");
|
67
|
+
}
|
68
|
+
// multi line comment or operator
|
69
|
+
else if (ch == "/") {
|
70
|
+
if (stream.eat("*")) {
|
71
|
+
return chain(stream, state, tokenComment);
|
72
|
+
}
|
73
|
+
else {
|
74
|
+
stream.eatWhile(isOperatorChar);
|
75
|
+
return ret("operator", "operator");
|
76
|
+
}
|
77
|
+
}
|
78
|
+
// single line comment or operator
|
79
|
+
else if (ch=="-") {
|
80
|
+
if(stream.eat("-")){
|
81
|
+
stream.skipToEnd();
|
82
|
+
return ret("comment", "comment");
|
83
|
+
}
|
84
|
+
else {
|
85
|
+
stream.eatWhile(isOperatorChar);
|
86
|
+
return ret("operator", "operator");
|
87
|
+
}
|
88
|
+
}
|
89
|
+
// is it an operator
|
90
|
+
else if (isOperatorChar.test(ch)) {
|
91
|
+
stream.eatWhile(isOperatorChar);
|
92
|
+
return ret("operator", "operator");
|
93
|
+
}
|
94
|
+
else {
|
95
|
+
// get the while word
|
96
|
+
stream.eatWhile(/[\w\$_]/);
|
97
|
+
// is it one of the listed keywords?
|
98
|
+
if (keywords && keywords.propertyIsEnumerable(stream.current().toUpperCase())) {
|
99
|
+
if (stream.eat(")") || stream.eat(".")) {
|
100
|
+
//keywords can be used as variables like flatten(group), group.$0 etc..
|
101
|
+
}
|
102
|
+
else {
|
103
|
+
return ("keyword", "keyword");
|
104
|
+
}
|
105
|
+
}
|
106
|
+
// is it one of the builtin functions?
|
107
|
+
if (builtins && builtins.propertyIsEnumerable(stream.current().toUpperCase()))
|
108
|
+
{
|
109
|
+
return ("keyword", "variable-2");
|
110
|
+
}
|
111
|
+
// is it one of the listed types?
|
112
|
+
if (types && types.propertyIsEnumerable(stream.current().toUpperCase()))
|
113
|
+
return ("keyword", "variable-3");
|
114
|
+
// default is a 'variable'
|
115
|
+
return ret("variable", "pig-word");
|
116
|
+
}
|
117
|
+
}
|
118
|
+
|
119
|
+
// Interface
|
120
|
+
return {
|
121
|
+
startState: function() {
|
122
|
+
return {
|
123
|
+
tokenize: tokenBase,
|
124
|
+
startOfLine: true
|
125
|
+
};
|
126
|
+
},
|
127
|
+
|
128
|
+
token: function(stream, state) {
|
129
|
+
if(stream.eatSpace()) return null;
|
130
|
+
var style = state.tokenize(stream, state);
|
131
|
+
return style;
|
132
|
+
}
|
133
|
+
};
|
134
134
|
});
|
135
135
|
|
136
136
|
(function() {
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
137
|
+
function keywords(str) {
|
138
|
+
var obj = {}, words = str.split(" ");
|
139
|
+
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
|
140
|
+
return obj;
|
141
|
+
}
|
142
|
+
|
143
|
+
// builtin funcs taken from trunk revision 1303237
|
144
|
+
var pBuiltins = "ABS ACOS ARITY ASIN ATAN AVG BAGSIZE BINSTORAGE BLOOM BUILDBLOOM CBRT CEIL "
|
145
|
+
+ "CONCAT COR COS COSH COUNT COUNT_STAR COV CONSTANTSIZE CUBEDIMENSIONS DIFF DISTINCT DOUBLEABS "
|
146
|
+
+ "DOUBLEAVG DOUBLEBASE DOUBLEMAX DOUBLEMIN DOUBLEROUND DOUBLESUM EXP FLOOR FLOATABS FLOATAVG "
|
147
|
+
+ "FLOATMAX FLOATMIN FLOATROUND FLOATSUM GENERICINVOKER INDEXOF INTABS INTAVG INTMAX INTMIN "
|
148
|
+
+ "INTSUM INVOKEFORDOUBLE INVOKEFORFLOAT INVOKEFORINT INVOKEFORLONG INVOKEFORSTRING INVOKER "
|
149
|
+
+ "ISEMPTY JSONLOADER JSONMETADATA JSONSTORAGE LAST_INDEX_OF LCFIRST LOG LOG10 LOWER LONGABS "
|
150
|
+
+ "LONGAVG LONGMAX LONGMIN LONGSUM MAX MIN MAPSIZE MONITOREDUDF NONDETERMINISTIC OUTPUTSCHEMA "
|
151
|
+
+ "PIGSTORAGE PIGSTREAMING RANDOM REGEX_EXTRACT REGEX_EXTRACT_ALL REPLACE ROUND SIN SINH SIZE "
|
152
|
+
+ "SQRT STRSPLIT SUBSTRING SUM STRINGCONCAT STRINGMAX STRINGMIN STRINGSIZE TAN TANH TOBAG "
|
153
|
+
+ "TOKENIZE TOMAP TOP TOTUPLE TRIM TEXTLOADER TUPLESIZE UCFIRST UPPER UTF8STORAGECONVERTER ";
|
154
|
+
|
155
|
+
// taken from QueryLexer.g
|
156
|
+
var pKeywords = "VOID IMPORT RETURNS DEFINE LOAD FILTER FOREACH ORDER CUBE DISTINCT COGROUP "
|
157
|
+
+ "JOIN CROSS UNION SPLIT INTO IF OTHERWISE ALL AS BY USING INNER OUTER ONSCHEMA PARALLEL "
|
158
|
+
+ "PARTITION GROUP AND OR NOT GENERATE FLATTEN ASC DESC IS STREAM THROUGH STORE MAPREDUCE "
|
159
|
+
+ "SHIP CACHE INPUT OUTPUT STDERROR STDIN STDOUT LIMIT SAMPLE LEFT RIGHT FULL EQ GT LT GTE LTE "
|
160
|
+
+ "NEQ MATCHES TRUE FALSE ";
|
161
|
+
|
162
|
+
// data types
|
163
|
+
var pTypes = "BOOLEAN INT LONG FLOAT DOUBLE CHARARRAY BYTEARRAY BAG TUPLE MAP ";
|
142
164
|
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
+ "ISEMPTY JSONLOADER JSONMETADATA JSONSTORAGE LAST_INDEX_OF LCFIRST LOG LOG10 LOWER LONGABS "
|
150
|
-
+ "LONGAVG LONGMAX LONGMIN LONGSUM MAX MIN MAPSIZE MONITOREDUDF NONDETERMINISTIC OUTPUTSCHEMA "
|
151
|
-
+ "PIGSTORAGE PIGSTREAMING RANDOM REGEX_EXTRACT REGEX_EXTRACT_ALL REPLACE ROUND SIN SINH SIZE "
|
152
|
-
+ "SQRT STRSPLIT SUBSTRING SUM STRINGCONCAT STRINGMAX STRINGMIN STRINGSIZE TAN TANH TOBAG "
|
153
|
-
+ "TOKENIZE TOMAP TOP TOTUPLE TRIM TEXTLOADER TUPLESIZE UCFIRST UPPER UTF8STORAGECONVERTER ";
|
154
|
-
|
155
|
-
// taken from QueryLexer.g
|
156
|
-
var pKeywords = "VOID IMPORT RETURNS DEFINE LOAD FILTER FOREACH ORDER CUBE DISTINCT COGROUP "
|
157
|
-
+ "JOIN CROSS UNION SPLIT INTO IF OTHERWISE ALL AS BY USING INNER OUTER ONSCHEMA PARALLEL "
|
158
|
-
+ "PARTITION GROUP AND OR NOT GENERATE FLATTEN ASC DESC IS STREAM THROUGH STORE MAPREDUCE "
|
159
|
-
+ "SHIP CACHE INPUT OUTPUT STDERROR STDIN STDOUT LIMIT SAMPLE LEFT RIGHT FULL EQ GT LT GTE LTE "
|
160
|
-
+ "NEQ MATCHES TRUE FALSE ";
|
161
|
-
|
162
|
-
// data types
|
163
|
-
var pTypes = "BOOLEAN INT LONG FLOAT DOUBLE CHARARRAY BYTEARRAY BAG TUPLE MAP ";
|
164
|
-
|
165
|
-
CodeMirror.defineMIME("text/x-pig", {
|
166
|
-
name: "pig",
|
167
|
-
builtins: keywords(pBuiltins),
|
168
|
-
keywords: keywords(pKeywords),
|
169
|
-
types: keywords(pTypes)
|
170
|
-
});
|
165
|
+
CodeMirror.defineMIME("text/x-pig", {
|
166
|
+
name: "pig",
|
167
|
+
builtins: keywords(pBuiltins),
|
168
|
+
keywords: keywords(pKeywords),
|
169
|
+
types: keywords(pTypes)
|
170
|
+
});
|
171
171
|
}());
|
@@ -1,16 +1,16 @@
|
|
1
1
|
CodeMirror.defineMode("python", function(conf, parserConf) {
|
2
2
|
var ERRORCLASS = 'error';
|
3
|
-
|
3
|
+
|
4
4
|
function wordRegexp(words) {
|
5
5
|
return new RegExp("^((" + words.join(")|(") + "))\\b");
|
6
6
|
}
|
7
|
-
|
8
|
-
var singleOperators = new RegExp("^[\\+\\-\\*/%&|\\^~<>!]");
|
9
|
-
var singleDelimiters = new RegExp('^[\\(\\)\\[\\]\\{\\}@,:`=;\\.]');
|
10
|
-
var doubleOperators = new RegExp("^((==)|(!=)|(<=)|(>=)|(<>)|(<<)|(>>)|(//)|(\\*\\*))");
|
11
|
-
var doubleDelimiters = new RegExp("^((\\+=)|(\\-=)|(\\*=)|(%=)|(/=)|(&=)|(\\|=)|(\\^=))");
|
12
|
-
var tripleDelimiters = new RegExp("^((//=)|(>>=)|(<<=)|(\\*\\*=))");
|
13
|
-
var identifiers = new RegExp("^[_A-Za-z][_A-Za-z0-9]*");
|
7
|
+
|
8
|
+
var singleOperators = parserConf.singleOperators || new RegExp("^[\\+\\-\\*/%&|\\^~<>!]");
|
9
|
+
var singleDelimiters = parserConf.singleDelimiters || new RegExp('^[\\(\\)\\[\\]\\{\\}@,:`=;\\.]');
|
10
|
+
var doubleOperators = parserConf.doubleOperators || new RegExp("^((==)|(!=)|(<=)|(>=)|(<>)|(<<)|(>>)|(//)|(\\*\\*))");
|
11
|
+
var doubleDelimiters = parserConf.doubleDelimiters || new RegExp("^((\\+=)|(\\-=)|(\\*=)|(%=)|(/=)|(&=)|(\\|=)|(\\^=))");
|
12
|
+
var tripleDelimiters = parserConf.tripleDelimiters || new RegExp("^((//=)|(>>=)|(<<=)|(\\*\\*=))");
|
13
|
+
var identifiers = parserConf.identifiers|| new RegExp("^[_A-Za-z][_A-Za-z0-9]*");
|
14
14
|
|
15
15
|
var wordOperators = wordRegexp(['and', 'or', 'not', 'is', 'in']);
|
16
16
|
var commonkeywords = ['as', 'assert', 'break', 'class', 'continue',
|
@@ -72,15 +72,15 @@ CodeMirror.defineMode("python", function(conf, parserConf) {
|
|
72
72
|
if (stream.eatSpace()) {
|
73
73
|
return null;
|
74
74
|
}
|
75
|
-
|
75
|
+
|
76
76
|
var ch = stream.peek();
|
77
|
-
|
77
|
+
|
78
78
|
// Handle Comments
|
79
79
|
if (ch === '#') {
|
80
80
|
stream.skipToEnd();
|
81
81
|
return 'comment';
|
82
82
|
}
|
83
|
-
|
83
|
+
|
84
84
|
// Handle Number Literals
|
85
85
|
if (stream.match(/^[0-9\.]/, false)) {
|
86
86
|
var floatLiteral = false;
|
@@ -116,13 +116,13 @@ CodeMirror.defineMode("python", function(conf, parserConf) {
|
|
116
116
|
return 'number';
|
117
117
|
}
|
118
118
|
}
|
119
|
-
|
119
|
+
|
120
120
|
// Handle Strings
|
121
121
|
if (stream.match(stringPrefixes)) {
|
122
122
|
state.tokenize = tokenStringFactory(stream.current());
|
123
123
|
return state.tokenize(stream, state);
|
124
124
|
}
|
125
|
-
|
125
|
+
|
126
126
|
// Handle operators and Delimiters
|
127
127
|
if (stream.match(tripleDelimiters) || stream.match(doubleDelimiters)) {
|
128
128
|
return null;
|
@@ -135,31 +135,31 @@ CodeMirror.defineMode("python", function(conf, parserConf) {
|
|
135
135
|
if (stream.match(singleDelimiters)) {
|
136
136
|
return null;
|
137
137
|
}
|
138
|
-
|
138
|
+
|
139
139
|
if (stream.match(keywords)) {
|
140
140
|
return 'keyword';
|
141
141
|
}
|
142
|
-
|
142
|
+
|
143
143
|
if (stream.match(builtins)) {
|
144
144
|
return 'builtin';
|
145
145
|
}
|
146
|
-
|
146
|
+
|
147
147
|
if (stream.match(identifiers)) {
|
148
148
|
return 'variable';
|
149
149
|
}
|
150
|
-
|
150
|
+
|
151
151
|
// Handle non-detected items
|
152
152
|
stream.next();
|
153
153
|
return ERRORCLASS;
|
154
154
|
}
|
155
|
-
|
155
|
+
|
156
156
|
function tokenStringFactory(delimiter) {
|
157
157
|
while ('rub'.indexOf(delimiter.charAt(0).toLowerCase()) >= 0) {
|
158
158
|
delimiter = delimiter.substr(1);
|
159
159
|
}
|
160
160
|
var singleline = delimiter.length == 1;
|
161
161
|
var OUTCLASS = 'string';
|
162
|
-
|
162
|
+
|
163
163
|
function tokenString(stream, state) {
|
164
164
|
while (!stream.eol()) {
|
165
165
|
stream.eatWhile(/[^'"\\]/);
|
@@ -187,7 +187,7 @@ CodeMirror.defineMode("python", function(conf, parserConf) {
|
|
187
187
|
tokenString.isString = true;
|
188
188
|
return tokenString;
|
189
189
|
}
|
190
|
-
|
190
|
+
|
191
191
|
function indent(stream, state, type) {
|
192
192
|
type = type || 'py';
|
193
193
|
var indentUnit = 0;
|
@@ -210,7 +210,7 @@ CodeMirror.defineMode("python", function(conf, parserConf) {
|
|
210
210
|
type: type
|
211
211
|
});
|
212
212
|
}
|
213
|
-
|
213
|
+
|
214
214
|
function dedent(stream, state, type) {
|
215
215
|
type = type || 'py';
|
216
216
|
if (state.scopes.length == 1) return;
|
@@ -259,7 +259,7 @@ CodeMirror.defineMode("python", function(conf, parserConf) {
|
|
259
259
|
}
|
260
260
|
return style;
|
261
261
|
}
|
262
|
-
|
262
|
+
|
263
263
|
// Handle decorators
|
264
264
|
if (current === '@') {
|
265
265
|
return stream.match(identifiers, false) ? 'meta' : ERRORCLASS;
|
@@ -269,7 +269,7 @@ CodeMirror.defineMode("python", function(conf, parserConf) {
|
|
269
269
|
&& state.lastToken === 'meta') {
|
270
270
|
style = 'meta';
|
271
271
|
}
|
272
|
-
|
272
|
+
|
273
273
|
// Handle scope changes.
|
274
274
|
if (current === 'pass' || current === 'return') {
|
275
275
|
state.dedent += 1;
|
@@ -298,7 +298,7 @@ CodeMirror.defineMode("python", function(conf, parserConf) {
|
|
298
298
|
if (state.scopes.length > 1) state.scopes.shift();
|
299
299
|
state.dedent -= 1;
|
300
300
|
}
|
301
|
-
|
301
|
+
|
302
302
|
return style;
|
303
303
|
}
|
304
304
|
|
@@ -312,27 +312,27 @@ CodeMirror.defineMode("python", function(conf, parserConf) {
|
|
312
312
|
dedent: 0
|
313
313
|
};
|
314
314
|
},
|
315
|
-
|
315
|
+
|
316
316
|
token: function(stream, state) {
|
317
317
|
var style = tokenLexer(stream, state);
|
318
|
-
|
318
|
+
|
319
319
|
state.lastToken = style;
|
320
|
-
|
320
|
+
|
321
321
|
if (stream.eol() && stream.lambda) {
|
322
322
|
state.lambda = false;
|
323
323
|
}
|
324
|
-
|
324
|
+
|
325
325
|
return style;
|
326
326
|
},
|
327
|
-
|
327
|
+
|
328
328
|
indent: function(state) {
|
329
329
|
if (state.tokenize != tokenBase) {
|
330
330
|
return state.tokenize.isString ? CodeMirror.Pass : 0;
|
331
331
|
}
|
332
|
-
|
332
|
+
|
333
333
|
return state.scopes[0].offset;
|
334
334
|
}
|
335
|
-
|
335
|
+
|
336
336
|
};
|
337
337
|
return external;
|
338
338
|
});
|
@@ -0,0 +1,124 @@
|
|
1
|
+
CodeMirror.defineMode("q",function(config){
|
2
|
+
var indentUnit=config.indentUnit,
|
3
|
+
curPunc,
|
4
|
+
keywords=buildRE(["abs","acos","aj","aj0","all","and","any","asc","asin","asof","atan","attr","avg","avgs","bin","by","ceiling","cols","cor","cos","count","cov","cross","csv","cut","delete","deltas","desc","dev","differ","distinct","div","do","each","ej","enlist","eval","except","exec","exit","exp","fby","fills","first","fkeys","flip","floor","from","get","getenv","group","gtime","hclose","hcount","hdel","hopen","hsym","iasc","idesc","if","ij","in","insert","inter","inv","key","keys","last","like","list","lj","load","log","lower","lsq","ltime","ltrim","mavg","max","maxs","mcount","md5","mdev","med","meta","min","mins","mmax","mmin","mmu","mod","msum","neg","next","not","null","or","over","parse","peach","pj","plist","prd","prds","prev","prior","rand","rank","ratios","raze","read0","read1","reciprocal","reverse","rload","rotate","rsave","rtrim","save","scan","select","set","setenv","show","signum","sin","sqrt","ss","ssr","string","sublist","sum","sums","sv","system","tables","tan","til","trim","txf","type","uj","ungroup","union","update","upper","upsert","value","var","view","views","vs","wavg","where","where","while","within","wj","wj1","wsum","xasc","xbar","xcol","xcols","xdesc","xexp","xgroup","xkey","xlog","xprev","xrank"]),
|
5
|
+
E=/[|/&^!+:\\\-*%$=~#;@><,?_\'\"\[\(\]\)\s{}]/;
|
6
|
+
function buildRE(w){return new RegExp("^("+w.join("|")+")$");}
|
7
|
+
function tokenBase(stream,state){
|
8
|
+
var sol=stream.sol(),c=stream.next();
|
9
|
+
curPunc=null;
|
10
|
+
if(sol)
|
11
|
+
if(c=="/")
|
12
|
+
return(state.tokenize=tokenLineComment)(stream,state);
|
13
|
+
else if(c=="\\"){
|
14
|
+
if(stream.eol()||/\s/.test(stream.peek()))
|
15
|
+
return stream.skipToEnd(),/^\\\s*$/.test(stream.current())?(state.tokenize=tokenCommentToEOF)(stream, state):state.tokenize=tokenBase,"comment";
|
16
|
+
else
|
17
|
+
return state.tokenize=tokenBase,"builtin";
|
18
|
+
}
|
19
|
+
if(/\s/.test(c))
|
20
|
+
return stream.peek()=="/"?(stream.skipToEnd(),"comment"):"whitespace";
|
21
|
+
if(c=='"')
|
22
|
+
return(state.tokenize=tokenString)(stream,state);
|
23
|
+
if(c=='`')
|
24
|
+
return stream.eatWhile(/[A-Z|a-z|\d|_|:|\/|\.]/),"symbol";
|
25
|
+
if(("."==c&&/\d/.test(stream.peek()))||/\d/.test(c)){
|
26
|
+
var t=null;
|
27
|
+
stream.backUp(1);
|
28
|
+
if(stream.match(/^\d{4}\.\d{2}(m|\.\d{2}([D|T](\d{2}(:\d{2}(:\d{2}(\.\d{1,9})?)?)?)?)?)/)
|
29
|
+
|| stream.match(/^\d+D(\d{2}(:\d{2}(:\d{2}(\.\d{1,9})?)?)?)/)
|
30
|
+
|| stream.match(/^\d{2}:\d{2}(:\d{2}(\.\d{1,9})?)?/)
|
31
|
+
|| stream.match(/^\d+[ptuv]{1}/))
|
32
|
+
t="temporal";
|
33
|
+
else if(stream.match(/^0[NwW]{1}/)
|
34
|
+
|| stream.match(/^0x[\d|a-f|A-F]*/)
|
35
|
+
|| stream.match(/^[0|1]+[b]{1}/)
|
36
|
+
|| stream.match(/^\d+[chijn]{1}/)
|
37
|
+
|| stream.match(/-?\d*(\.\d*)?(e[+\-]?\d+)?(e|f)?/))
|
38
|
+
t="number";
|
39
|
+
return(t&&(!(c=stream.peek())||E.test(c)))?t:(stream.next(),"error");
|
40
|
+
}
|
41
|
+
if(/[A-Z|a-z]|\./.test(c))
|
42
|
+
return stream.eatWhile(/[A-Z|a-z|\.|_|\d]/),keywords.test(stream.current())?"keyword":"variable";
|
43
|
+
if(/[|/&^!+:\\\-*%$=~#;@><\.,?_\']/.test(c))
|
44
|
+
return null;
|
45
|
+
if(/[{}\(\[\]\)]/.test(c))
|
46
|
+
return null;
|
47
|
+
return"error";
|
48
|
+
}
|
49
|
+
function tokenLineComment(stream,state){
|
50
|
+
return stream.skipToEnd(),/\/\s*$/.test(stream.current())?(state.tokenize=tokenBlockComment)(stream,state):(state.tokenize=tokenBase),"comment";
|
51
|
+
}
|
52
|
+
function tokenBlockComment(stream,state){
|
53
|
+
var f=stream.sol()&&stream.peek()=="\\";
|
54
|
+
stream.skipToEnd();
|
55
|
+
if(f&&/^\\\s*$/.test(stream.current()))
|
56
|
+
state.tokenize=tokenBase;
|
57
|
+
return"comment";
|
58
|
+
}
|
59
|
+
function tokenCommentToEOF(stream){return stream.skipToEnd(),"comment";}
|
60
|
+
function tokenString(stream,state){
|
61
|
+
var escaped=false,next,end=false;
|
62
|
+
while((next=stream.next())){
|
63
|
+
if(next=="\""&&!escaped){end=true;break;}
|
64
|
+
escaped=!escaped&&next=="\\";
|
65
|
+
}
|
66
|
+
if(end)state.tokenize=tokenBase;
|
67
|
+
return"string";
|
68
|
+
}
|
69
|
+
function pushContext(state,type,col){state.context={prev:state.context,indent:state.indent,col:col,type:type};}
|
70
|
+
function popContext(state){state.indent=state.context.indent;state.context=state.context.prev;}
|
71
|
+
return{
|
72
|
+
startState:function(){
|
73
|
+
return{tokenize:tokenBase,
|
74
|
+
context:null,
|
75
|
+
indent:0,
|
76
|
+
col:0};
|
77
|
+
},
|
78
|
+
token:function(stream,state){
|
79
|
+
if(stream.sol()){
|
80
|
+
if(state.context&&state.context.align==null)
|
81
|
+
state.context.align=false;
|
82
|
+
state.indent=stream.indentation();
|
83
|
+
}
|
84
|
+
//if (stream.eatSpace()) return null;
|
85
|
+
var style=state.tokenize(stream,state);
|
86
|
+
if(style!="comment"&&state.context&&state.context.align==null&&state.context.type!="pattern"){
|
87
|
+
state.context.align=true;
|
88
|
+
}
|
89
|
+
if(curPunc=="(")pushContext(state,")",stream.column());
|
90
|
+
else if(curPunc=="[")pushContext(state,"]",stream.column());
|
91
|
+
else if(curPunc=="{")pushContext(state,"}",stream.column());
|
92
|
+
else if(/[\]\}\)]/.test(curPunc)){
|
93
|
+
while(state.context&&state.context.type=="pattern")popContext(state);
|
94
|
+
if(state.context&&curPunc==state.context.type)popContext(state);
|
95
|
+
}
|
96
|
+
else if(curPunc=="."&&state.context&&state.context.type=="pattern")popContext(state);
|
97
|
+
else if(/atom|string|variable/.test(style)&&state.context){
|
98
|
+
if(/[\}\]]/.test(state.context.type))
|
99
|
+
pushContext(state,"pattern",stream.column());
|
100
|
+
else if(state.context.type=="pattern"&&!state.context.align){
|
101
|
+
state.context.align=true;
|
102
|
+
state.context.col=stream.column();
|
103
|
+
}
|
104
|
+
}
|
105
|
+
return style;
|
106
|
+
},
|
107
|
+
indent:function(state,textAfter){
|
108
|
+
var firstChar=textAfter&&textAfter.charAt(0);
|
109
|
+
var context=state.context;
|
110
|
+
if(/[\]\}]/.test(firstChar))
|
111
|
+
while (context&&context.type=="pattern")context=context.prev;
|
112
|
+
var closing=context&&firstChar==context.type;
|
113
|
+
if(!context)
|
114
|
+
return 0;
|
115
|
+
else if(context.type=="pattern")
|
116
|
+
return context.col;
|
117
|
+
else if(context.align)
|
118
|
+
return context.col+(closing?0:1);
|
119
|
+
else
|
120
|
+
return context.indent+(closing?0:indentUnit);
|
121
|
+
}
|
122
|
+
};
|
123
|
+
});
|
124
|
+
CodeMirror.defineMIME("text/x-q","q");
|