1define("ace/mode/python_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) { 2"use strict"; 3 4var oop = require("../lib/oop"); 5var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; 6 7var PythonHighlightRules = function() { 8 9 var keywords = ( 10 "and|as|assert|break|class|continue|def|del|elif|else|except|exec|" + 11 "finally|for|from|global|if|import|in|is|lambda|not|or|pass|print|" + 12 "raise|return|try|while|with|yield|async|await" 13 ); 14 15 var builtinConstants = ( 16 "True|False|None|NotImplemented|Ellipsis|__debug__" 17 ); 18 19 var builtinFunctions = ( 20 "abs|divmod|input|open|staticmethod|all|enumerate|int|ord|str|any|" + 21 "eval|isinstance|pow|sum|basestring|execfile|issubclass|print|super|" + 22 "binfile|iter|property|tuple|bool|filter|len|range|type|bytearray|" + 23 "float|list|raw_input|unichr|callable|format|locals|reduce|unicode|" + 24 "chr|frozenset|long|reload|vars|classmethod|getattr|map|repr|xrange|" + 25 "cmp|globals|max|reversed|zip|compile|hasattr|memoryview|round|" + 26 "__import__|complex|hash|min|set|apply|delattr|help|next|setattr|" + 27 "buffer|dict|hex|object|slice|coerce|dir|id|oct|sorted|intern" 28 ); 29 var keywordMapper = this.createKeywordMapper({ 30 "invalid.deprecated": "debugger", 31 "support.function": builtinFunctions, 32 "constant.language": builtinConstants, 33 "keyword": keywords 34 }, "identifier"); 35 36 var strPre = "(?:r|u|ur|R|U|UR|Ur|uR)?"; 37 38 var decimalInteger = "(?:(?:[1-9]\\d*)|(?:0))"; 39 var octInteger = "(?:0[oO]?[0-7]+)"; 40 var hexInteger = "(?:0[xX][\\dA-Fa-f]+)"; 41 var binInteger = "(?:0[bB][01]+)"; 42 var integer = "(?:" + decimalInteger + "|" + octInteger + "|" + hexInteger + "|" + binInteger + ")"; 43 44 var exponent = "(?:[eE][+-]?\\d+)"; 45 var fraction = "(?:\\.\\d+)"; 46 var intPart = "(?:\\d+)"; 47 var pointFloat = "(?:(?:" + intPart + "?" + fraction + ")|(?:" + intPart + "\\.))"; 48 var exponentFloat = "(?:(?:" + pointFloat + "|" + intPart + ")" + exponent + ")"; 49 var floatNumber = "(?:" + exponentFloat + "|" + pointFloat + ")"; 50 51 var stringEscape = "\\\\(x[0-9A-Fa-f]{2}|[0-7]{3}|[\\\\abfnrtv'\"]|U[0-9A-Fa-f]{8}|u[0-9A-Fa-f]{4})"; 52 53 this.$rules = { 54 "start" : [ { 55 token : "comment", 56 regex : "#.*$" 57 }, { 58 token : "string", // multi line """ string start 59 regex : strPre + '"{3}', 60 next : "qqstring3" 61 }, { 62 token : "string", // " string 63 regex : strPre + '"(?=.)', 64 next : "qqstring" 65 }, { 66 token : "string", // multi line ''' string start 67 regex : strPre + "'{3}", 68 next : "qstring3" 69 }, { 70 token : "string", // ' string 71 regex : strPre + "'(?=.)", 72 next : "qstring" 73 }, { 74 token : "constant.numeric", // imaginary 75 regex : "(?:" + floatNumber + "|\\d+)[jJ]\\b" 76 }, { 77 token : "constant.numeric", // float 78 regex : floatNumber 79 }, { 80 token : "constant.numeric", // long integer 81 regex : integer + "[lL]\\b" 82 }, { 83 token : "constant.numeric", // integer 84 regex : integer + "\\b" 85 }, { 86 token : keywordMapper, 87 regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" 88 }, { 89 token : "keyword.operator", 90 regex : "\\+|\\-|\\*|\\*\\*|\\/|\\/\\/|%|<<|>>|&|\\||\\^|~|<|>|<=|=>|==|!=|<>|=" 91 }, { 92 token : "paren.lparen", 93 regex : "[\\[\\(\\{]" 94 }, { 95 token : "paren.rparen", 96 regex : "[\\]\\)\\}]" 97 }, { 98 token : "text", 99 regex : "\\s+" 100 } ], 101 "qqstring3" : [ { 102 token : "constant.language.escape", 103 regex : stringEscape 104 }, { 105 token : "string", // multi line """ string end 106 regex : '"{3}', 107 next : "start" 108 }, { 109 defaultToken : "string" 110 } ], 111 "qstring3" : [ { 112 token : "constant.language.escape", 113 regex : stringEscape 114 }, { 115 token : "string", // multi line ''' string end 116 regex : "'{3}", 117 next : "start" 118 }, { 119 defaultToken : "string" 120 } ], 121 "qqstring" : [{ 122 token : "constant.language.escape", 123 regex : stringEscape 124 }, { 125 token : "string", 126 regex : "\\\\$", 127 next : "qqstring" 128 }, { 129 token : "string", 130 regex : '"|$', 131 next : "start" 132 }, { 133 defaultToken: "string" 134 }], 135 "qstring" : [{ 136 token : "constant.language.escape", 137 regex : stringEscape 138 }, { 139 token : "string", 140 regex : "\\\\$", 141 next : "qstring" 142 }, { 143 token : "string", 144 regex : "'|$", 145 next : "start" 146 }, { 147 defaultToken: "string" 148 }] 149 }; 150}; 151 152oop.inherits(PythonHighlightRules, TextHighlightRules); 153 154exports.PythonHighlightRules = PythonHighlightRules; 155}); 156 157define("ace/mode/folding/pythonic",["require","exports","module","ace/lib/oop","ace/mode/folding/fold_mode"], function(require, exports, module) { 158"use strict"; 159 160var oop = require("../../lib/oop"); 161var BaseFoldMode = require("./fold_mode").FoldMode; 162 163var FoldMode = exports.FoldMode = function(markers) { 164 this.foldingStartMarker = new RegExp("([\\[{])(?:\\s*)$|(" + markers + ")(?:\\s*)(?:#.*)?$"); 165}; 166oop.inherits(FoldMode, BaseFoldMode); 167 168(function() { 169 170 this.getFoldWidgetRange = function(session, foldStyle, row) { 171 var line = session.getLine(row); 172 var match = line.match(this.foldingStartMarker); 173 if (match) { 174 if (match[1]) 175 return this.openingBracketBlock(session, match[1], row, match.index); 176 if (match[2]) 177 return this.indentationBlock(session, row, match.index + match[2].length); 178 return this.indentationBlock(session, row); 179 } 180 }; 181 182}).call(FoldMode.prototype); 183 184}); 185 186define("ace/mode/python",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/python_highlight_rules","ace/mode/folding/pythonic","ace/range"], function(require, exports, module) { 187"use strict"; 188 189var oop = require("../lib/oop"); 190var TextMode = require("./text").Mode; 191var PythonHighlightRules = require("./python_highlight_rules").PythonHighlightRules; 192var PythonFoldMode = require("./folding/pythonic").FoldMode; 193var Range = require("../range").Range; 194 195var Mode = function() { 196 this.HighlightRules = PythonHighlightRules; 197 this.foldingRules = new PythonFoldMode("\\:"); 198 this.$behaviour = this.$defaultBehaviour; 199}; 200oop.inherits(Mode, TextMode); 201 202(function() { 203 204 this.lineCommentStart = "#"; 205 206 this.getNextLineIndent = function(state, line, tab) { 207 var indent = this.$getIndent(line); 208 209 var tokenizedLine = this.getTokenizer().getLineTokens(line, state); 210 var tokens = tokenizedLine.tokens; 211 212 if (tokens.length && tokens[tokens.length-1].type == "comment") { 213 return indent; 214 } 215 216 if (state == "start") { 217 var match = line.match(/^.*[\{\(\[:]\s*$/); 218 if (match) { 219 indent += tab; 220 } 221 } 222 223 return indent; 224 }; 225 226 var outdents = { 227 "pass": 1, 228 "return": 1, 229 "raise": 1, 230 "break": 1, 231 "continue": 1 232 }; 233 234 this.checkOutdent = function(state, line, input) { 235 if (input !== "\r\n" && input !== "\r" && input !== "\n") 236 return false;
237 238 var tokens = this.getTokenizer().getLineTokens(line.trim(), state).tokens; 239 240 if (!tokens) 241 return false; 242 do { 243 var last = tokens.pop(); 244 } while (last && (last.type == "comment" || (last.type == "text" && last.value.match(/^\s+$/)))); 245 246 if (!last) 247 return false; 248 249 return (last.type == "keyword" && outdents[last.value]); 250 }; 251 252 this.autoOutdent = function(state, doc, row) { 253 254 row += 1; 255 var indent = this.$getIndent(doc.getLine(row)); 256 var tab = doc.getTabString(); 257 if (indent.slice(-tab.length) == tab) 258 doc.remove(new Range(row, indent.length-tab.length, row, indent.length)); 259 }; 260 261 this.$id = "ace/mode/python"; 262}).call(Mode.prototype); 263 264exports.Mode = Mode; 265});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.