]>
luflow.net public git repositories - flow-web.git/blob - static/highlight/languages/groovy.js
1 /*! `groovy` grammar compiled for Highlight.js 11.11.1 */
3 var hljsGrammar
= (function () {
8 Author: Guillaume Laforge <glaforge@gmail.com>
9 Description: Groovy programming language implementation inspired from Vsevolod's Java mode
10 Website: https://groovy-lang.org
14 function variants(variants
, obj
= {}) {
15 obj
.variants
= variants
;
19 function groovy(hljs
) {
20 const regex
= hljs
.regex
;
21 const IDENT_RE
= '[A-Za-z0-9_$]+';
22 const COMMENT
= variants([
23 hljs
.C_LINE_COMMENT_MODE
,
24 hljs
.C_BLOCK_COMMENT_MODE
,
32 // eat up @'s in emails to prevent them to be recognized as doctags
46 begin: /~?\/[^\/\n]+\//,
47 contains: [ hljs
.BACKSLASH_ESCAPE
]
49 const NUMBER
= variants([
50 hljs
.BINARY_NUMBER_MODE
,
53 const STRING
= variants([
67 hljs
.APOS_STRING_MODE
,
68 hljs
.QUOTE_STRING_MODE
70 { className: "string" }
73 const CLASS_DEFINITION
= {
75 /(class|interface|trait|enum|record|extends|implements)/,
77 hljs
.UNDERSCORE_IDENT_RE
96 // groovy specific keywords
102 // common keywords with Java
142 "variable.language": 'this super',
143 literal: 'true false null',
163 // highlight map keys and named parameters as attrs
165 begin: IDENT_RE
+ '[ \t]*:',
169 // catch middle element of the ternary operator
170 // to avoid highlight it as a label, named parameter, or map key
183 // highlight labeled statements
185 begin: '^[ \t]*' + regex
.lookahead(IDENT_RE
+ ':'),
199 hljs
.registerLanguage('groovy', hljsGrammar
);