Debian Codegraph @

runtime/syntax/kvlang.yaml

raw
1 filetype: "kvlang"
2
3 detect:
4 filename: "\\.kv$"
5
6 rules:
7 # layouts
8 - special: "\\b[a-z].+"
9 - identifier: "\\b(self|app|root)\\b"
10
11 - type: "\\b[A-Z].+"
12 - type: "\\b(AnchorLayout|BoxLayout|FloatLayout|RelativeLayout|GridLayout|PageLayout|StackLayout)\\b"
13
14 - type: "\\b(canvas)\\b"
15
16 # functions
17 - identifier.function: "[a-zA-Z_0-9]+\\("
18
19 # built-in functions
20 - type: "\\b(abs|all|any|ascii|bin|bool|breakpoint|bytearray|bytes)\\b"
21 - type: "\\b(callable|chr|classmethod|compile|copyright|credits|oct)\\b"
22 - type: "\\b(delattr|dict|dir|display|divmod|enumerate|eval|filter)\\b"
23 - type: "\\b(float|format|frozenset|get_ipython|getattr|globals|type)\\b"
24 - type: "\\b(hash|help|hex|id|input|int|isinstance|issubclass|iter|len)\\b"
25 - type: "\\b(license|list|locals|map|max|memoryview|min|next|object)\\b"
26 - type: "\\b(open|ord|pow|print|property|range|repr|reversed|round|set)\\b"
27 - type: "\\b(setattr|slice|sorted|staticmethod|hasattr|super|tuple|str)\\b"
28 - type: "\\b(vars|zip|exec|sum|complex)\\b"
29
30 # keywords
31 - statement.built_in: "\\b(and|as|assert|async|await|break|class|continue|def)\\b"
32 - statement.built_in: "\\b(del|elif|else|except|finally|for|from|global|if)\\b"
33 - statement.built_in: "\\b(import|in|is|lambda|nonlocal|not|or|pass|raise)\\b"
34 - statement.built_in: "\\b(return|try|while|with|yield|match|case)\\b"
35
36 # operators
37 - symbol.operator: "([~^.:;,+*|=!\\%]|<|>|/|-|&)"
38
39 # parentheses
40 - symbol.brackets: "([(){}]|\\[|\\])"
41
42 # numbers
43 - constant.number: "\\b[0-9](_?[0-9])*(\\.([0-9](_?[0-9])*)?)?(e[0-9](_?[0-9])*)?\\b" # decimal
44 - constant.number: "\\b0b(_?[01])+\\b" # bin
45 - constant.number: "\\b0o(_?[0-7])+\\b" # oct
46 - constant.number: "\\b0x(_?[0-9a-f])+\\b" # hex
47
48 - constant.bool.none: "\\b(None)\\b"
49 - constant.bool.true: "\\b(True)\\b"
50 - constant.bool.false: "\\b(False)\\b"
51
52 # strings
53 - constant.string:
54 start: "\""
55 end: "(\"|$)"
56 skip: "\\\\."
57 rules: []
58 - constant.string:
59 start: "'"
60 end: "('|$)"
61 skip: "\\\\."
62 rules: []
63
64 - comment:
65 start: "#"
66 end: "$"
67 rules: []