From c2805e03c84b6e598556fd06d1ede7aaeea7ce9c Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 6 Mar 2012 16:17:54 -0800 Subject: Squashed commit FileIO-Build-Candidate into Master Fixing issues with HTML and CSS URLs. Adjusted RegEx logic. Also code a mirror update and undo/redo changes were merged into this request. Signed-off-by: Valerio Virgillito --- imports/codemirror/mode/python/python.js | 41 +++++++++++++++++++------------- 1 file changed, 24 insertions(+), 17 deletions(-) mode change 100755 => 100644 imports/codemirror/mode/python/python.js (limited to 'imports/codemirror/mode/python/python.js') diff --git a/imports/codemirror/mode/python/python.js b/imports/codemirror/mode/python/python.js old mode 100755 new mode 100644 index 382052ba..cfe8a774 --- a/imports/codemirror/mode/python/python.js +++ b/imports/codemirror/mode/python/python.js @@ -18,28 +18,35 @@ CodeMirror.defineMode("python", function(conf, parserConf) { 'for', 'from', 'global', 'if', 'import', 'lambda', 'pass', 'raise', 'return', 'try', 'while', 'with', 'yield']; - var commontypes = ['bool', 'classmethod', 'complex', 'dict', 'enumerate', - 'float', 'frozenset', 'int', 'list', 'object', - 'property', 'reversed', 'set', 'slice', 'staticmethod', - 'str', 'super', 'tuple', 'type']; - var py2 = {'types': ['basestring', 'buffer', 'file', 'long', 'unicode', - 'xrange'], + var commonBuiltins = ['abs', 'all', 'any', 'bin', 'bool', 'bytearray', 'callable', 'chr', + 'classmethod', 'compile', 'complex', 'delattr', 'dict', 'dir', 'divmod', + 'enumerate', 'eval', 'filter', 'float', 'format', 'frozenset', + 'getattr', 'globals', 'hasattr', 'hash', 'help', 'hex', 'id', + 'input', 'int', 'isinstance', 'issubclass', 'iter', 'len', + 'list', 'locals', 'map', 'max', 'memoryview', 'min', 'next', + 'object', 'oct', 'open', 'ord', 'pow', 'property', 'range', + 'repr', 'reversed', 'round', 'set', 'setattr', 'slice', + 'sorted', 'staticmethod', 'str', 'sum', 'super', 'tuple', + 'type', 'vars', 'zip', '__import__', 'NotImplemented', + 'Ellipsis', '__debug__']; + var py2 = {'builtins': ['apply', 'basestring', 'buffer', 'cmp', 'coerce', 'execfile', + 'file', 'intern', 'long', 'raw_input', 'reduce', 'reload', + 'unichr', 'unicode', 'xrange', 'False', 'True', 'None'], 'keywords': ['exec', 'print']}; - var py3 = {'types': ['bytearray', 'bytes', 'filter', 'map', 'memoryview', - 'open', 'range', 'zip'], - 'keywords': ['nonlocal']}; + var py3 = {'builtins': ['ascii', 'bytes', 'exec', 'print'], + 'keywords': ['nonlocal', 'False', 'True', 'None']}; if (!!parserConf.version && parseInt(parserConf.version, 10) === 3) { commonkeywords = commonkeywords.concat(py3.keywords); - commontypes = commontypes.concat(py3.types); + commonBuiltins = commonBuiltins.concat(py3.builtins); var stringPrefixes = new RegExp("^(([rb]|(br))?('{3}|\"{3}|['\"]))", "i"); } else { commonkeywords = commonkeywords.concat(py2.keywords); - commontypes = commontypes.concat(py2.types); + commonBuiltins = commonBuiltins.concat(py2.builtins); var stringPrefixes = new RegExp("^(([rub]|(ur)|(br))?('{3}|\"{3}|['\"]))", "i"); } var keywords = wordRegexp(commonkeywords); - var types = wordRegexp(commontypes); + var builtins = wordRegexp(commonBuiltins); var indentInfo = null; @@ -129,14 +136,14 @@ CodeMirror.defineMode("python", function(conf, parserConf) { return null; } - if (stream.match(types)) { - return 'builtin'; - } - if (stream.match(keywords)) { return 'keyword'; } + if (stream.match(builtins)) { + return 'builtin'; + } + if (stream.match(identifiers)) { return 'variable'; } @@ -244,7 +251,7 @@ CodeMirror.defineMode("python", function(conf, parserConf) { if (current === '.') { style = state.tokenize(stream, state); current = stream.current(); - if (style === 'variable') { + if (style === 'variable' || style === 'builtin') { return 'variable'; } else { return ERRORCLASS; -- cgit v1.2.3