]> git.lizzy.rs Git - micro.git/blob - runtime/syntax/groovy.yaml
runtime/syntax: add rudimentary Odin support (#2296)
[micro.git] / runtime / syntax / groovy.yaml
1 filetype: groovy
2
3 detect:
4     filename: "\\.(groovy|gy|gvy|gsh|gradle)$"
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-f]([0-9a-f_]*[0-9a-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     # Single-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     
54     # This also matches the Triple-double-quoted strings region, but I can't really find a way to mitigate it, all the while still matching "" as a string correctly
55     # Also, nesting ${} are never going to be matched correctly with just regex either, so highlighting will break if one is to nest interpolation
56     # These two problems combined mean slight mistakes in highlighing that the user is just going to have to deal with
57     # Double-quoted strings
58     - constant.string:
59         start: "\""
60         end: "\""
61         skip: "\\\\."
62         rules:
63             - constant.specialChar: "\\\\([\"'bfnrst\\x24\\\\]|u[a-fA-F0-9]{4})"
64             - identifier.var: "\\x24[\\w\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF\u0100-\uFFFE]+([.][a-zA-Z0-9_\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF\u0100-\uFFFE]+)*"
65             - identifier: "\\x24[{].*[}]"
66     
67     # Triple-double-quoted strings
68     - constant.string:
69         start: "\"\"\""
70         end: "\"\"\""
71         skip: "\\\\."
72         rules:
73             - constant.specialChar: "\\\\([\"'bfnrst\\x24\\\\]|u[a-fA-F0-9]{4})"
74             - identifier.var: "\\x24[\\w\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF\u0100-\uFFFE]+([.][a-zA-Z0-9_\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF\u0100-\uFFFE]+)*"
75             - identifier:
76                 start: "[$][{]"
77                 end: "[}]"
78                 rules: []
79     
80     # Triple-single-quoted strings
81     - constant.string:
82         start: "'''"
83         end: "'''"
84         skip: "\\\\."
85         rules:
86             - constant.specialChar: "\\\\([\"'bfnrst\\x24\\\\]|u[a-fA-F0-9]{4})"
87     
88     # Slashy strings are left out, because they match in unwanted places pretty much all the time
89     # Dollar-slashy strings
90     - constant.string:
91         start: "[$]/"
92         end: "/[$]"
93         rules: []
94     
95     # Single-line comments
96     - comment:
97         start: "//"
98         end: "$"
99         rules:
100             - todo: "(TODO|XXX|FIXME):?"
101     
102     # Multiline comments
103     - comment:
104         start: "/[*]"
105         end: "[*]/"
106         rules:
107             - todo: "(TODO|XXX|FIXME):?"
108     
109     # Groovydoc comments
110     - comment:
111         start: "/[*][*]@?"
112         end: "[*]/"
113         rules: []