Debian Codegraph @

runtime/syntax/jsonnet.yaml

raw
1 filetype: jsonnet
2
3 detect:
4 filename: "\\.jsonnet$"
5
6 # Spec: https://jsonnet.org/ref/spec.html
7
8 rules:
9 # built-in objects
10 # FIXME: $ won't match
11 - constant: "\\b(self|\\$|super)\\b"
12 # boolean constants
13 - constant.bool: "\\b(null|true|false)\\b"
14 # the standard library
15 - identifier: "\\bstd\\.(extVar|thisFile|type|length|objectHas|objectFields|objectHasAll|objectFieldsAll|prune|mapWithKey|abs|sign|max|min|pow|exp|log|exponent|mantissa|floor|ceil|sqrt|sin|cos|tan|asin|acos|atan|mod|assertEqual|toString|codepoint|char|substr|findSubstr|startsWith|endsWith|split|splitLimit|strReplace|asciiUpper|asciiLower|stringChars|format|escapeStringDollars|escapeStringPython|parseInt|parseOctal|parseHex|parseJson|encodeUTF8|decodeUTF8|manifestIni|manifestPython|manifestPythonVars|manifestJsonEx|manifestYamlDoc|manifestYamlStream|manifestXmlJsonml|makeArray|count|find|map|mapWithIndex|filterMap|filter|foldl|foldr|range|join|lines|flattenArrays|sort|uniq|set|setInter|setUnion|setDiff|setMember|base64|base64DecodeBytes|base64Decode|md5|mergePatch|trace)\\b"
16 # unquoted object keys
17 - type: "[_a-zA-Z][_a-zA-Z0-9]*\\s*:"
18 # object key separator
19 - statement: ":"
20 # keywords
21 - statement: "\\b(assert|else|error|for|function|if|import|importstr|in|local|tailstrict|then)\\b"
22 # operators
23 - symbol.operator: "([.;,+*|=!\\%]|<|>|/|-|&)"
24 # parentheses
25 - symbol.brackets: "([(){}]|\\[|\\])"
26 # numbers
27 - constant.number: "\\b(0|([1-9][0-9]*))(\\.[0-9]+)?([eE][\\+-]?[0-9]+)?\\b"
28
29 # double-quoted string
30 - constant.string:
31 start: "\""
32 end: "\""
33 skip: "\\\\\""
34 rules:
35 - constant.specialChar: "\\\\u[0-9a-fA-F]{4}|\\\\[bfnrt'\"/\\\\]"
36
37 # single-quoted string
38 - constant.string:
39 start: "'"
40 end: "'"
41 skip: "\\\\'"
42 rules:
43 - constant.specialChar: "\\\\u[0-9a-fA-F]{4}|\\\\[bfnrt'\"/\\\\]"
44
45 # double-quoted verbatim string
46 - constant.string:
47 start: "@\""
48 end: "\""
49 skip: "\\\\\""
50 rules:
51 - constant.specialChar: "\\\\\""
52
53 # single-quoted verbatim string
54 - constant.string:
55 start: "@'"
56 end: "'"
57 skip: "\\\\'"
58 rules:
59 - constant.specialChar: "\\\\'"
60
61 # block string
62 - constant.string:
63 # FIXME:
64 # This isn't quite right.
65 # The spec says this:
66
67 # beginning with |||, followed by optional whitespace and a new-line.
68 # The next non-blank line must be prefixed with some non-zero length
69 # whitespace W. The block ends at the first subsequent line that does
70 # not begin with W, and it is an error if this line does not contain
71 # some optional whitespace followed by |||.
72
73 # We need to match ^(\s+) on the first non-blank line after |||
74 # Then we need to skip ^\1.*$
75
76 start: "\\|\\|\\| *$"
77 end: "^ *\\|\\|\\|"
78 rules: []
79
80 # multi-line comment
81 - comment:
82 start: "/\\*"
83 end: "\\*/"
84 rules:
85 - todo: "(TODO|XXX|FIXME):?"
86
87 # single-line comment
88 - comment:
89 start: "#|(//)"
90 end: "$"
91 rules:
92 - todo: "(TODO|XXX|FIXME):?"