1
0
Fork 0
management/front/dkha-web-sz-main/node_modules/highlight.js/lib/languages/scala.js

141 lines
2.7 KiB
JavaScript
Raw Normal View History

2024-01-16 21:26:16 +08:00
/*
Language: Scala
Category: functional
Author: Jan Berkel <jan.berkel@gmail.com>
Contributors: Erik Osheim <d_m@plastic-idolatry.com>
Website: https://www.scala-lang.org
*/
2023-12-18 13:12:25 +08:00
2024-01-16 21:26:16 +08:00
function scala(hljs) {
const ANNOTATION = {
className: 'meta',
begin: '@[A-Za-z]+'
};
2023-12-18 13:12:25 +08:00
// used in strings for escaping/interpolation/substitution
2024-01-16 21:26:16 +08:00
const SUBST = {
2023-12-18 13:12:25 +08:00
className: 'subst',
variants: [
2024-01-16 21:26:16 +08:00
{
begin: '\\$[A-Za-z0-9_]+'
},
{
begin: /\$\{/,
end: /\}/
}
2023-12-18 13:12:25 +08:00
]
};
2024-01-16 21:26:16 +08:00
const STRING = {
2023-12-18 13:12:25 +08:00
className: 'string',
variants: [
{
2024-01-16 21:26:16 +08:00
begin: '"""',
end: '"""'
2023-12-18 13:12:25 +08:00
},
{
2024-01-16 21:26:16 +08:00
begin: '"',
end: '"',
illegal: '\\n',
contains: [ hljs.BACKSLASH_ESCAPE ]
2023-12-18 13:12:25 +08:00
},
{
2024-01-16 21:26:16 +08:00
begin: '[a-z]+"',
end: '"',
2023-12-18 13:12:25 +08:00
illegal: '\\n',
2024-01-16 21:26:16 +08:00
contains: [
hljs.BACKSLASH_ESCAPE,
SUBST
]
2023-12-18 13:12:25 +08:00
},
{
className: 'string',
2024-01-16 21:26:16 +08:00
begin: '[a-z]+"""',
end: '"""',
contains: [ SUBST ],
2023-12-18 13:12:25 +08:00
relevance: 10
}
]
};
2024-01-16 21:26:16 +08:00
const SYMBOL = {
2023-12-18 13:12:25 +08:00
className: 'symbol',
begin: '\'\\w[\\w\\d_]*(?!\')'
};
2024-01-16 21:26:16 +08:00
const TYPE = {
2023-12-18 13:12:25 +08:00
className: 'type',
begin: '\\b[A-Z][A-Za-z0-9_]*',
relevance: 0
};
2024-01-16 21:26:16 +08:00
const NAME = {
2023-12-18 13:12:25 +08:00
className: 'title',
begin: /[^0-9\n\t "'(),.`{}\[\]:;][^\n\t "'(),.`{}\[\]:;]+|[^0-9\n\t "'(),.`{}\[\]:;=]/,
relevance: 0
};
2024-01-16 21:26:16 +08:00
const CLASS = {
2023-12-18 13:12:25 +08:00
className: 'class',
beginKeywords: 'class object trait type',
end: /[:={\[\n;]/,
excludeEnd: true,
contains: [
2024-01-16 21:26:16 +08:00
hljs.C_LINE_COMMENT_MODE,
hljs.C_BLOCK_COMMENT_MODE,
2023-12-18 13:12:25 +08:00
{
beginKeywords: 'extends with',
relevance: 10
},
{
begin: /\[/,
end: /\]/,
excludeBegin: true,
excludeEnd: true,
relevance: 0,
2024-01-16 21:26:16 +08:00
contains: [ TYPE ]
2023-12-18 13:12:25 +08:00
},
{
className: 'params',
begin: /\(/,
end: /\)/,
excludeBegin: true,
excludeEnd: true,
relevance: 0,
2024-01-16 21:26:16 +08:00
contains: [ TYPE ]
2023-12-18 13:12:25 +08:00
},
NAME
]
};
2024-01-16 21:26:16 +08:00
const METHOD = {
2023-12-18 13:12:25 +08:00
className: 'function',
beginKeywords: 'def',
end: /[:={\[(\n;]/,
excludeEnd: true,
2024-01-16 21:26:16 +08:00
contains: [ NAME ]
2023-12-18 13:12:25 +08:00
};
return {
2024-01-16 21:26:16 +08:00
name: 'Scala',
2023-12-18 13:12:25 +08:00
keywords: {
literal: 'true false null',
keyword: 'type yield lazy override def with val var sealed abstract private trait object if forSome for while throw finally protected extends import final return else break new catch super class case package default try this match continue throws implicit'
},
contains: [
hljs.C_LINE_COMMENT_MODE,
hljs.C_BLOCK_COMMENT_MODE,
STRING,
SYMBOL,
TYPE,
METHOD,
CLASS,
hljs.C_NUMBER_MODE,
ANNOTATION
]
};
2024-01-16 21:26:16 +08:00
}
module.exports = scala;