MCPcopy Create free account
hub / github.com/evildecay/etcdkeeper / PythonHighlightRules

Function PythonHighlightRules

assets/etcdkeeper/framework/ace/mode-python.js:7–150  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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"
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"

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected