File: python.lang

package info (click to toggle)
highlight 4.10-1.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,556 kB
  • sloc: cpp: 27,579; makefile: 411; sh: 341; ansic: 264; php: 236; python: 217; ruby: 132; perl: 61; tcl: 1
file content (73 lines) | stat: -rw-r--r-- 2,831 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
Description="Python"

Categories = {"source", "script"}

Digits=[[ (?:0x|0X|0o|0O|0b|0B)[0-9a-fA-F\_]+|\d*[\.\_]?[\d\_]+(?:[eE][\-\+]\d+)?[lLuU]* ]]

Keywords={
  { Id=1,
    List={  "break", "continue", "del", "except", "exec", "finally", "pass",
            "print", "raise", "return", "try", "global", "assert", "lambda", "yield", "def",
            "class", "for", "while", "if", "elif", "else", "and", "in", "is", "not", "or",
            "import", "from", "as", "async", "await", "None", "True", "False", "with"}
  },
  { Id=2,
    List={  "bool", "bytes", "enumerate", "set", "frozenset", "help", "reversed", "sorted",
            "sum", "Ellipsis", "NotImplemented", "__import__", "abs", "apply", "buffer",
            "callable", "chr", "classmethod", "cmp", "coerce", "compile", "complex",
            "delattr", "dict", "dir", "divmod", "eval", "execfile", "file", "filter",
            "float", "getattr", "globals", "hasattr", "hash", "hex", "id", "input", "int",
            "intern", "isinstance", "issubclass", "iter", "len", "list", "locals", "long",
            "map", "max", "min", "object", "oct", "open", "ord", "pow", "property", "range",
            "raw_input", "reduce", "reload", "repr", "round", "setattr", "slice",
            "staticmethod", "str", "super", "tuple", "type", "unichr", "unicode", "vars",
            "xrange", "zip"}
  },
  -- decorators:
  { Id=2,
    Regex=[[@[\w\.]+]],
  },
  { Id=3,
    List={  "ArithmeticError", "AssertionError", "AttributeError",
            "DeprecationWarning", "EOFError", "EnvironmentError", "Exception",
            "FloatingPointError", "IOError", "ImportError", "IndentationError",
            "IndexError", "KeyError", "KeyboardInterrupt", "LookupError", "MemoryError",
            "NameError", "NotImplementedError", "OSError", "OverflowError",
            "OverflowWarning", "ReferenceError", "RuntimeError", "RuntimeWarning",
            "StandardError", "StopIteration", "SyntaxError", "SyntaxWarning", "SystemError",
            "SystemExit", "TabError", "TypeError", "UnboundLocalError", "UnicodeError",
            "UnicodeEncodeError", "UnicodeDecodeError", "UnicodeTranslateError",
            "UserWarning", "ValueError", "Warning", "WindowsError", "ZeroDivisionError"}
  },
  { Id=4,
    Regex=[[(\w+)\s*\(]],
  },
}

Strings={
  Delimiter=[["""|'''|"|']],
  RawPrefix="r",
  Escape=[=[\\[ntvbrfa\\\?'"]|\\\d{3}|\\x[[:xdigit:]]{2}]=],
  Interpolation=[[ %[%#0\-\+diouxXeEfFgGcrs]+|%\(\w+\)[sd]?|\{.+?\} ]]
}

IgnoreCase=false

Comments={
  { Block=false,
    Delimiter= { [[#]] },
  },
}

Operators=[[\(|\)|\[|\]|\{|\}|\,|\;|\.|\:|\&|<|>|\!|\=|\/|\*|\%|\+|\-|\@]]


function OnStateChange(oldState, newState, token, groupID)
  if oldState==HL_STANDARD and string.sub(token,1,1)=="%" then
    return HL_OPERATOR
  end

  return newState
end