2024-01-16 21:26:16 +08:00
|
|
|
/*
|
|
|
|
Language: Smalltalk
|
|
|
|
Description: Smalltalk is an object-oriented, dynamically typed reflective programming language.
|
|
|
|
Author: Vladimir Gubarkov <xonixx@gmail.com>
|
|
|
|
Website: https://en.wikipedia.org/wiki/Smalltalk
|
|
|
|
*/
|
|
|
|
|
|
|
|
function smalltalk(hljs) {
|
|
|
|
const VAR_IDENT_RE = '[a-z][a-zA-Z0-9_]*';
|
|
|
|
const CHAR = {
|
2023-12-18 13:12:25 +08:00
|
|
|
className: 'string',
|
|
|
|
begin: '\\$.{1}'
|
|
|
|
};
|
2024-01-16 21:26:16 +08:00
|
|
|
const SYMBOL = {
|
2023-12-18 13:12:25 +08:00
|
|
|
className: 'symbol',
|
|
|
|
begin: '#' + hljs.UNDERSCORE_IDENT_RE
|
|
|
|
};
|
|
|
|
return {
|
2024-01-16 21:26:16 +08:00
|
|
|
name: 'Smalltalk',
|
|
|
|
aliases: [ 'st' ],
|
2023-12-18 13:12:25 +08:00
|
|
|
keywords: 'self super nil true false thisContext', // only 6
|
|
|
|
contains: [
|
|
|
|
hljs.COMMENT('"', '"'),
|
|
|
|
hljs.APOS_STRING_MODE,
|
|
|
|
{
|
|
|
|
className: 'type',
|
|
|
|
begin: '\\b[A-Z][A-Za-z0-9_]*',
|
|
|
|
relevance: 0
|
|
|
|
},
|
|
|
|
{
|
|
|
|
begin: VAR_IDENT_RE + ':',
|
|
|
|
relevance: 0
|
|
|
|
},
|
|
|
|
hljs.C_NUMBER_MODE,
|
|
|
|
SYMBOL,
|
|
|
|
CHAR,
|
|
|
|
{
|
|
|
|
// This looks more complicated than needed to avoid combinatorial
|
|
|
|
// explosion under V8. It effectively means `| var1 var2 ... |` with
|
|
|
|
// whitespace adjacent to `|` being optional.
|
|
|
|
begin: '\\|[ ]*' + VAR_IDENT_RE + '([ ]+' + VAR_IDENT_RE + ')*[ ]*\\|',
|
2024-01-16 21:26:16 +08:00
|
|
|
returnBegin: true,
|
|
|
|
end: /\|/,
|
2023-12-18 13:12:25 +08:00
|
|
|
illegal: /\S/,
|
2024-01-16 21:26:16 +08:00
|
|
|
contains: [ {
|
|
|
|
begin: '(\\|[ ]*)?' + VAR_IDENT_RE
|
|
|
|
} ]
|
2023-12-18 13:12:25 +08:00
|
|
|
},
|
|
|
|
{
|
2024-01-16 21:26:16 +08:00
|
|
|
begin: '#\\(',
|
|
|
|
end: '\\)',
|
2023-12-18 13:12:25 +08:00
|
|
|
contains: [
|
|
|
|
hljs.APOS_STRING_MODE,
|
|
|
|
CHAR,
|
|
|
|
hljs.C_NUMBER_MODE,
|
|
|
|
SYMBOL
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
};
|
2024-01-16 21:26:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = smalltalk;
|