| 1 |
filetype: python |
| 2 |
|
| 3 |
detect: |
| 4 |
filename: "\\.py(3|w)?$" |
| 5 |
header: "^#!.*/(env +)?python(3)?$" |
| 6 |
|
| 7 |
rules: |
| 8 |
# built-in objects |
| 9 |
- constant: "\\b(Ellipsis|None|self|cls|True|False)\\b" |
| 10 |
# built-in attributes |
| 11 |
- constant: "\\b(__bases__|__builtin__|__class__|__debug__|__dict__|__doc__|__file__|__members__|__methods__|__name__|__self__)\\b" |
| 12 |
# built-in functions |
| 13 |
- identifier: "\\b(abs|all|any|ascii|bin|bool|breakpoint|bytearray|bytes|callable|chr|classmethod|compile|complex|delattr|dir|divmod|eval|exec|format|getattr|globals|hasattr|hash|help|hex|id|input|isinstance|issubclass|iter|len|locals|max|min|next|nonlocal|oct|open|ord|pow|print|repr|round|setattr|sorted|sum|vars|__import__)\\b" |
| 14 |
# special method names |
| 15 |
- identifier: "\\b__(abs|add|and|call|cmp|coerce|complex|concat|contains|delattr|delitem|delslice|del|dict|divmod|div|float|getattr|getitem|getslice|hash|hex|iadd|iand|iconcat|ifloordiv|ilshift|imatmul|imod|imul|init|int|invert|inv|ior|ipow|irshift|isub|iter|itruediv|ixor|len|long|lshift|mod|mul|neg|next|nonzero|oct|or|pos|pow|radd|rand|rcmp|rdivmod|rdiv|repeat|repr|rlshift|rmod|rmul|ror|rpow|rrshift|rshift|rsub|rxor|setattr|setitem|setslice|str|sub|xor)__\\b" |
| 16 |
# types |
| 17 |
- type: "\\b(bool|bytearray|bytes|classmethod|complex|dict|enumerate|filter|float|frozenset|int|list|map|memoryview|object|property|range|reversed|set|slice|staticmethod|str|super|tuple|type|zip)\\b" |
| 18 |
# definitions |
| 19 |
- identifier: "def [a-zA-Z_0-9]+" |
| 20 |
# keywords |
| 21 |
- statement: "\\b(and|as|assert|async|await|break|case|class|continue|def|del|elif|else|except|finally|for|from|global|if|import|in|is|lambda|match|nonlocal|not|or|pass|raise|return|try|while|with|yield)\\b" |
| 22 |
# decorators |
| 23 |
- preproc: "^\\s*@[^(]*" |
| 24 |
# operators |
| 25 |
- symbol.operator: "([~^.:;,+*|=!\\%@]|<|>|/|-|&)" |
| 26 |
# parentheses |
| 27 |
- symbol.brackets: "([(){}]|\\[|\\])" |
| 28 |
# numbers |
| 29 |
- constant.number: "\\b[0-9](_?[0-9])*(\\.([0-9](_?[0-9])*)?)?(e[0-9](_?[0-9])*)?\\b" # decimal |
| 30 |
- constant.number: "\\b0b(_?[01])+\\b" # bin |
| 31 |
- constant.number: "\\b0o(_?[0-7])+\\b" # oct |
| 32 |
- constant.number: "\\b0x(_?[0-9a-fA-F])+\\b" # hex |
| 33 |
|
| 34 |
- constant.string: |
| 35 |
start: "\"\"\"" |
| 36 |
end: "\"\"\"" |
| 37 |
rules: [] |
| 38 |
|
| 39 |
- constant.string: |
| 40 |
start: "'''" |
| 41 |
end: "'''" |
| 42 |
rules: [] |
| 43 |
|
| 44 |
- constant.string: |
| 45 |
start: "\"" |
| 46 |
end: "(\"|$)" |
| 47 |
skip: "\\\\." |
| 48 |
rules: |
| 49 |
- constant.specialChar: "\\\\." |
| 50 |
|
| 51 |
- constant.string: |
| 52 |
start: "'" |
| 53 |
end: "('|$)" |
| 54 |
skip: "\\\\." |
| 55 |
rules: |
| 56 |
- constant.specialChar: "\\\\." |
| 57 |
|
| 58 |
- comment: |
| 59 |
start: "#" |
| 60 |
end: "$" |
| 61 |
rules: # AKA Code tags (PEP 350) |
| 62 |
- todo: "(TODO|FIXME|HACK|BUG|NOTE|FAQ|MNEMONIC|REQ|RFE|IDEA|PORT|\\?\\?\\?|!!!|GLOSS|SEE|TODOC|STAT|RVD|CRED):?" |