]>
luflow.net public git repositories - flow-web.git/blob - static/highlight/languages/scala.js
1 /*! `scala` grammar compiled for Highlight.js 11.11.1 */
3 var hljsGrammar
= ( function () {
9 Author: Jan Berkel <jan.berkel@gmail.com>
10 Contributors: Erik Osheim <d_m@plastic-idolatry.com>
11 Website: https://www.scala-lang.org
14 function scala ( hljs
) {
15 const regex
= hljs
. regex
;
21 // used in strings for escaping/interpolation/substitution
25 { begin : ' \\ $[A-Za-z0-9_]+' },
44 contains : [ hljs
. BACKSLASH_ESCAPE
]
51 hljs
. BACKSLASH_ESCAPE
,
68 begin : ' \\ b[A-Z][A-Za-z0-9_]*' ,
74 begin : /[^ 0 - 9 \n\t "'(),.`{}\[\]:;][^ \n\t " '(),.`{}\[\]:;]+|[^0-9 \n\t "' (),. `{}\[\]:;=]/,
80 beginKeywords: 'class object trait type',
84 hljs.C_LINE_COMMENT_MODE,
85 hljs.C_BLOCK_COMMENT_MODE,
87 beginKeywords: 'extends with',
98 hljs.C_LINE_COMMENT_MODE,
99 hljs.C_BLOCK_COMMENT_MODE,
111 hljs.C_LINE_COMMENT_MODE,
112 hljs.C_BLOCK_COMMENT_MODE,
120 className: 'function',
121 beginKeywords: 'def',
122 end: regex.lookahead(/[:={\[( \n ;]/),
128 /^\s*/, // Is first token on the line
130 /\s+(?=[[(])/, // followed by at least one space and ` [ ` or ` ( `
132 beginScope: { 2: "keyword", }
137 /^\s*/, // Is first token on the line
140 /(extension \b )?/, // ` extension
` is the only marker that follows an ` end
` that cannot be captured by another rule.
148 // TODO: use negative look-behind in future
149 // /(?<!\.) \b inline(?=\s)/
150 const INLINE_MODES = [
151 { match: /\.inline \b / },
153 begin: / \b inline(?=\s)/,
158 const USING_PARAM_CLAUSE = {
160 /\(\s*/, // Opening ` ( ` of a parameter or argument list
162 /\s+(?!\))/, // Spaces not followed by ` ) `
164 beginScope: { 2: "keyword", }
167 // glob all non-whitespace characters as a "string"
168 // sourced from https://github.com/scala/docs.scala-lang/pull/2845
169 const DIRECTIVE_VALUE = {
175 // sourced from https://github.com/scala/docs.scala-lang/pull/2845
176 const USING_DIRECTIVE = {
198 literal: 'true false null',
199 keyword: 'type yield lazy override def with val var sealed abstract private trait object if then forSome for while do throw finally protected extends import final return else break new catch super class case package default try this match continue throws implicit export enum given transparent'
203 hljs.C_LINE_COMMENT_MODE,
204 hljs.C_BLOCK_COMMENT_MODE,
223 hljs.registerLanguage('scala', hljsGrammar);