Debian Codegraph @

runtime/syntax/csharp.yaml

raw
1 filetype: csharp
2
3 detect:
4 filename: "\\.cs$"
5
6 rules:
7 # Class
8 - identifier.class: "class +[A-Za-z0-9]+ *((:) +[A-Za-z0-9.]+)?"
9
10 # Annotation
11 - identifier.var: "@[A-Za-z]+"
12
13 - preproc: "^[[:space:]]*#[[:space:]]*(define|elif|else|endif|endregion|error|if|line|nullable|pragma|region|undef|warning)"
14 - identifier: "([A-Za-z0-9_]*[[:space:]]*[()])"
15 - type: "\\b(bool|byte|sbyte|char|decimal|double|float|IntPtr|int|uint|long|ulong|managed|unmanaged|nint|nuint|object|short|ushort|string|base|this|var|void)\\b"
16 - statement: "\\b(alias|as|case|catch|checked|default|do|dynamic|else|finally|fixed|for|foreach|goto|if|is|lock|new|null|return|switch|throw|try|unchecked|when|while|with)\\b"
17 - statement: "\\b(abstract|add|and|args|async|await|class|const|delegate|enum|event|explicit|extern|file|get|global|implicit|in|init|internal|interface|nameof|namespace|not|notnull|operator|or|out|override|params|partial|private|protected|public|readonly|record|ref|remove|required|scoped|sealed|set|sizeof|stackalloc|static|struct|typeof|unsafe|using|value|virtual|volatile|yield)\\b"
18 # LINQ-only keywords (ones that cannot be used outside of a LINQ query - lots others can)
19 - statement: "\\b(from|where|select|group|info|orderby|join|let|in|on|equals|by|ascending|descending)\\b"
20 - special: "\\b(break|continue)\\b"
21 - constant.bool: "\\b(true|false)\\b"
22 - symbol.operator: "[\\-+/*=<>?:!~%&|]"
23 - constant.number: "\\b([0-9._]+|0x[A-Fa-f0-9_]+|0b[0-1_]+)[FL]?\\b"
24
25 - constant.string:
26 start: "\""
27 end: "\""
28 skip: "\\\\."
29 rules:
30 - constant.specialChar: "\\\\([btnfr]|'|\\\"|\\\\)"
31 - constant.specialChar: "\\\\u[A-Fa-f0-9]{4}"
32
33 - constant.string:
34 start: "'"
35 end: "'"
36 skip: "\\\\."
37 rules:
38 - constant.specialChar: "\\\\([btnfr]|'|\\\"|\\\\)"
39 - constant.specialChar: "\\\\u[A-Fa-f0-9]{4}"
40
41 - comment:
42 start: "//"
43 end: "$"
44 rules:
45 - todo: "(TODO|XXX|FIXME):?"
46
47 - comment:
48 start: "/\\*"
49 end: "\\*/"
50 rules:
51 - todo: "(TODO|XXX|FIXME):?"
52