aboutsummaryrefslogtreecommitdiff
path: root/imports/codemirror/mode/python
diff options
context:
space:
mode:
authorNivesh Rajbhandari2012-03-07 10:32:20 -0800
committerNivesh Rajbhandari2012-03-07 10:32:20 -0800
commitf5b0162a9b148589f0ccc65a0332695ea6fd6be3 (patch)
treee62ae1bc8a14dfa60cca05d40227c13dbfa2746a /imports/codemirror/mode/python
parent443a23289171bb72324e740d8eaa041968a1de99 (diff)
parentcef07085443b7c31e878daaad083b7408c57e104 (diff)
downloadninja-f5b0162a9b148589f0ccc65a0332695ea6fd6be3.tar.gz
Merge branch 'refs/heads/ninja-internal' into WebGLFixes
Diffstat (limited to 'imports/codemirror/mode/python')
-rw-r--r--[-rwxr-xr-x]imports/codemirror/mode/python/LICENSE.txt0
-rw-r--r--[-rwxr-xr-x]imports/codemirror/mode/python/index.html0
-rw-r--r--[-rwxr-xr-x]imports/codemirror/mode/python/python.js41
3 files changed, 24 insertions, 17 deletions
diff --git a/imports/codemirror/mode/python/LICENSE.txt b/imports/codemirror/mode/python/LICENSE.txt
index 918866b4..918866b4 100755..100644
--- a/imports/codemirror/mode/python/LICENSE.txt
+++ b/imports/codemirror/mode/python/LICENSE.txt
diff --git a/imports/codemirror/mode/python/index.html b/imports/codemirror/mode/python/index.html
index 47e0e9d0..47e0e9d0 100755..100644
--- a/imports/codemirror/mode/python/index.html
+++ b/imports/codemirror/mode/python/index.html
diff --git a/imports/codemirror/mode/python/python.js b/imports/codemirror/mode/python/python.js
index 382052ba..cfe8a774 100755..100644
--- a/imports/codemirror/mode/python/python.js
+++ b/imports/codemirror/mode/python/python.js
@@ -18,28 +18,35 @@ CodeMirror.defineMode("python", function(conf, parserConf) {
18 'for', 'from', 'global', 'if', 'import', 18 'for', 'from', 'global', 'if', 'import',
19 'lambda', 'pass', 'raise', 'return', 19 'lambda', 'pass', 'raise', 'return',
20 'try', 'while', 'with', 'yield']; 20 'try', 'while', 'with', 'yield'];
21 var commontypes = ['bool', 'classmethod', 'complex', 'dict', 'enumerate', 21 var commonBuiltins = ['abs', 'all', 'any', 'bin', 'bool', 'bytearray', 'callable', 'chr',
22 'float', 'frozenset', 'int', 'list', 'object', 22 'classmethod', 'compile', 'complex', 'delattr', 'dict', 'dir', 'divmod',
23 'property', 'reversed', 'set', 'slice', 'staticmethod', 23 'enumerate', 'eval', 'filter', 'float', 'format', 'frozenset',
24 'str', 'super', 'tuple', 'type']; 24 'getattr', 'globals', 'hasattr', 'hash', 'help', 'hex', 'id',
25 var py2 = {'types': ['basestring', 'buffer', 'file', 'long', 'unicode', 25 'input', 'int', 'isinstance', 'issubclass', 'iter', 'len',
26 'xrange'], 26 'list', 'locals', 'map', 'max', 'memoryview', 'min', 'next',
27 'object', 'oct', 'open', 'ord', 'pow', 'property', 'range',
28 'repr', 'reversed', 'round', 'set', 'setattr', 'slice',
29 'sorted', 'staticmethod', 'str', 'sum', 'super', 'tuple',
30 'type', 'vars', 'zip', '__import__', 'NotImplemented',
31 'Ellipsis', '__debug__'];
32 var py2 = {'builtins': ['apply', 'basestring', 'buffer', 'cmp', 'coerce', 'execfile',
33 'file', 'intern', 'long', 'raw_input', 'reduce', 'reload',
34 'unichr', 'unicode', 'xrange', 'False', 'True', 'None'],
27 'keywords': ['exec', 'print']}; 35 'keywords': ['exec', 'print']};
28 var py3 = {'types': ['bytearray', 'bytes', 'filter', 'map', 'memoryview', 36 var py3 = {'builtins': ['ascii', 'bytes', 'exec', 'print'],
29 'open', 'range', 'zip'], 37 'keywords': ['nonlocal', 'False', 'True', 'None']};
30 'keywords': ['nonlocal']};
31 38
32 if (!!parserConf.version && parseInt(parserConf.version, 10) === 3) { 39 if (!!parserConf.version && parseInt(parserConf.version, 10) === 3) {
33 commonkeywords = commonkeywords.concat(py3.keywords); 40 commonkeywords = commonkeywords.concat(py3.keywords);
34 commontypes = commontypes.concat(py3.types); 41 commonBuiltins = commonBuiltins.concat(py3.builtins);
35 var stringPrefixes = new RegExp("^(([rb]|(br))?('{3}|\"{3}|['\"]))", "i"); 42 var stringPrefixes = new RegExp("^(([rb]|(br))?('{3}|\"{3}|['\"]))", "i");
36 } else { 43 } else {
37 commonkeywords = commonkeywords.concat(py2.keywords); 44 commonkeywords = commonkeywords.concat(py2.keywords);
38 commontypes = commontypes.concat(py2.types); 45 commonBuiltins = commonBuiltins.concat(py2.builtins);
39 var stringPrefixes = new RegExp("^(([rub]|(ur)|(br))?('{3}|\"{3}|['\"]))", "i"); 46 var stringPrefixes = new RegExp("^(([rub]|(ur)|(br))?('{3}|\"{3}|['\"]))", "i");
40 } 47 }
41 var keywords = wordRegexp(commonkeywords); 48 var keywords = wordRegexp(commonkeywords);
42 var types = wordRegexp(commontypes); 49 var builtins = wordRegexp(commonBuiltins);
43 50
44 var indentInfo = null; 51 var indentInfo = null;
45 52
@@ -129,14 +136,14 @@ CodeMirror.defineMode("python", function(conf, parserConf) {
129 return null; 136 return null;
130 } 137 }
131 138
132 if (stream.match(types)) {
133 return 'builtin';
134 }
135
136 if (stream.match(keywords)) { 139 if (stream.match(keywords)) {
137 return 'keyword'; 140 return 'keyword';
138 } 141 }
139 142
143 if (stream.match(builtins)) {
144 return 'builtin';
145 }
146
140 if (stream.match(identifiers)) { 147 if (stream.match(identifiers)) {
141 return 'variable'; 148 return 'variable';
142 } 149 }
@@ -244,7 +251,7 @@ CodeMirror.defineMode("python", function(conf, parserConf) {
244 if (current === '.') { 251 if (current === '.') {
245 style = state.tokenize(stream, state); 252 style = state.tokenize(stream, state);
246 current = stream.current(); 253 current = stream.current();
247 if (style === 'variable') { 254 if (style === 'variable' || style === 'builtin') {
248 return 'variable'; 255 return 'variable';
249 } else { 256 } else {
250 return ERRORCLASS; 257 return ERRORCLASS;