Debian Codegraph @

runtime/syntax/groovy.yaml

raw
1 filetype: groovy
2
3 detect:
4 filename: "(\\.(groovy|gy|gvy|gsh|gradle)$|^[Jj]enkinsfile$)"
5 header: "^#!.*/(env +)?groovy *$"
6
7 rules:
8 # And the style guide for constants is CONSTANT_CASE
9 - identifier: "\\b[A-Z_$]+\\b"
10 # The style guide for JVM languages is PascalCase for classes and interfaces
11 - identifier.class: "\\b[A-Z][a-zA-Z0-9$]+\\b"
12
13 # Primitive types
14 - type: "\\b(byte|short|int|long|float|double|char|boolean|void)\\b"
15
16 # Type-related keywords
17 - type.keyword: "\\b(private|public|protected|static|final|var|def)\\b"
18
19 # Keywords
20 - statement: "\\b(for|while|do|if|else|switch|case|default|try|catch|finally)\\b"
21 - statement: "\\b(break|continue|return|throw|assert)\\b"
22 - statement: "\\b(package|import|class|interface|trait|enum|extends|implements|throws)\\b"
23 - statement: "\\b(this|super)\\b"
24 # Unsused, but reserved keywords
25 - statement: "\\b(goto|const)\\b"
26
27 # Operators and punctuation
28 - symbol.operator: "[-+*/%=<>^~&|!?:;,.@]|\\b(in|is|as|instanceof|new)\\b"
29 - symbol.brackets: "[(){}]|\\[|\\]"
30
31 # Decimal integer literal
32 - constant.number: "(?i)\\b[1-9]([_0-9]*[0-9])?[GLIDF]?\\b"
33 # Binary integer literal
34 - constant.number: "(?i)\\b0b[01]([01_]*[01])?[GLIDF]?\\b"
35 # Octal integer literal
36 - constant.number: "(?i)\\b0[0-7]([0-7_]*[0-7])?[GLIDF]?\\b"
37 # Hexadecimal integer literal
38 - constant.number: "(?i)\\b0x[0-9a-fA-F]([0-9a-f_]*[0-9a-fA-F])?[GLIDF]?\\b"
39 # Floating-point literal
40 - constant.number: "(?i)\\b[0-9]([0-9_]*[0-9])?([.][0-9]([0-9_]*[0-9])?)?(e[+-]?[0-9]([0-9_]*[0-9])?)?[DF]?\\b"
41 - constant.bool: "\\b(true|false|null)\\b"
42
43 # Annotations
44 - identifier: "@[A-Za-z_$][A-Za-z0-9_$]*\\b"
45
46 # Triple-double-quoted strings
47 - constant.string:
48 start: "\"\"\""
49 end: "\"\"\""
50 skip: "\\\\."
51 rules:
52 - constant.specialChar: "\\\\([\"'bfnrst\\x24\\\\]|u[a-fA-F0-9]{4})"
53 - identifier.var: "\\x24[\\w\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF\u0100-\uFFFE]+([.][a-zA-Z0-9_\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF\u0100-\uFFFE]+)*"
54 - identifier:
55 start: "[$][{]"
56 end: "[}]"
57 rules: []
58
59 # Triple-single-quoted strings
60 - constant.string:
61 start: "'''"
62 end: "'''"
63 skip: "\\\\."
64 rules:
65 - constant.specialChar: "\\\\([\"'bfnrst\\x24\\\\]|u[a-fA-F0-9]{4})"
66
67 # Nesting ${} are never going to be matched correctly with just regex either, so highlighting will break if one is to nest interpolation
68 # Double-quoted strings
69 - constant.string:
70 start: "\""
71 end: "\""
72 skip: "\\\\."
73 rules:
74 - constant.specialChar: "\\\\([\"'bfnrst\\x24\\\\]|u[a-fA-F0-9]{4})"
75 - identifier.var: "\\x24[\\w\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF\u0100-\uFFFE]+([.][a-zA-Z0-9_\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF\u0100-\uFFFE]+)*"
76 - identifier: "\\x24[{].*[}]"
77
78 # Single-quoted strings
79 - constant.string:
80 start: "'"
81 end: "'"
82 skip: "\\\\."
83 rules:
84 - constant.specialChar: "\\\\([\"'bfnrst\\x24\\\\]|u[a-fA-F0-9]{4})"
85
86 # Slashy strings are left out, because they match in unwanted places pretty much all the time
87 # Dollar-slashy strings
88 - constant.string:
89 start: "[$]/"
90 end: "/[$]"
91 rules: []
92
93 # Single-line comments
94 - comment:
95 start: "//"
96 end: "$"
97 rules:
98 - todo: "(TODO|XXX|FIXME):?"
99
100 # Multiline comments
101 - comment:
102 start: "/[*]"
103 end: "[*]/"
104 rules:
105 - todo: "(TODO|XXX|FIXME):?"
106
107 # Groovydoc comments
108 - comment:
109 start: "/[*][*]@?"
110 end: "[*]/"
111 rules: []