aboutsummaryrefslogtreecommitdiff
path: root/imports/codemirror/mode/python/python.js
diff options
context:
space:
mode:
authorEric Guzman2012-03-12 15:33:04 -0700
committerEric Guzman2012-03-12 15:33:04 -0700
commit7e3161153b87b891875ac65368a19aed12909fa3 (patch)
treeb80f48d711a9729fc39dbbdff28c4f0620e7302d /imports/codemirror/mode/python/python.js
parent7a28932ba8a7517bbaaabe1f5edf678416aafc9c (diff)
parent69d90467865a1384725b2301901be2180c5a841f (diff)
downloadninja-7e3161153b87b891875ac65368a19aed12909fa3.tar.gz
Merge branch 'refs/heads/master' into CSSPanelUpdates
Conflicts: js/panels/PanelContainer/PanelContainer.reel/PanelContainer.js
Diffstat (limited to 'imports/codemirror/mode/python/python.js')
-rw-r--r--[-rwxr-xr-x]imports/codemirror/mode/python/python.js41
1 files changed, 24 insertions, 17 deletions
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;