2026-07-17 21:42:43 +00:00
|
|
|
import { cLikeLexer } from './BrowserLexer.js';
|
2026-07-17 21:20:21 +00:00
|
|
|
import { CodeMirrorLexerMode } from './CodeMirrorLexerMode.js';
|
|
|
|
|
|
|
|
|
|
const TYPE_TO_CLASS: Record<string, string | null> =
|
|
|
|
|
{
|
2026-07-17 21:42:43 +00:00
|
|
|
SINGLE_LINE_COMMENT: 'comment',
|
|
|
|
|
MULTI_LINE_COMMENT: 'comment',
|
|
|
|
|
DOUBLE_QUOTED_STRING: 'string',
|
|
|
|
|
SINGLE_QUOTED_STRING: 'string',
|
|
|
|
|
NUMBER: 'number',
|
|
|
|
|
BOOL: 'atom',
|
|
|
|
|
NULL: 'atom',
|
|
|
|
|
LOGIC: 'keyword',
|
|
|
|
|
CLASS: 'keyword',
|
|
|
|
|
ACCESS_MODIFIER: 'keyword',
|
|
|
|
|
C_INSTRUCTION: 'meta',
|
|
|
|
|
CFUNCTION: 'variable-2',
|
|
|
|
|
CWORD: 'variable',
|
|
|
|
|
OPERATOR: 'operator',
|
|
|
|
|
BRACKET: 'bracket',
|
|
|
|
|
WHITESPACE: null,
|
|
|
|
|
BREAK: null,
|
|
|
|
|
ANY_SYMBOL: null,
|
2026-07-17 21:20:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const CS_KEYWORDS =
|
|
|
|
|
[
|
|
|
|
|
'abstract', 'as', 'async', 'await', 'base', 'byte',
|
|
|
|
|
'catch', 'char', 'checked', 'const', 'decimal', 'default',
|
|
|
|
|
'delegate', 'double', 'dynamic', 'enum', 'event', 'explicit',
|
|
|
|
|
'extern', 'finally', 'fixed', 'float', 'foreach', 'get',
|
|
|
|
|
'goto', 'implicit', 'in', 'int', 'interface', 'internal',
|
|
|
|
|
'is', 'lock', 'long', 'nameof', 'namespace', 'new',
|
|
|
|
|
'object', 'operator', 'out', 'override', 'params', 'partial',
|
|
|
|
|
'readonly', 'ref', 'remove', 'sbyte', 'sealed', 'set',
|
|
|
|
|
'short', 'sizeof', 'stackalloc', 'static', 'string', 'struct',
|
|
|
|
|
'this', 'throw', 'try', 'typeof', 'uint', 'ulong',
|
|
|
|
|
'unchecked','unsafe', 'ushort', 'using', 'value', 'var',
|
|
|
|
|
'virtual', 'void', 'volatile', 'when', 'where', 'with',
|
|
|
|
|
'yield',
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
export const csharpMode = new CodeMirrorLexerMode(
|
2026-07-17 21:42:43 +00:00
|
|
|
cLikeLexer(),
|
2026-07-17 21:20:21 +00:00
|
|
|
TYPE_TO_CLASS,
|
2026-07-17 21:42:43 +00:00
|
|
|
[ { type: 'MULTI_LINE_COMMENT', start: /\/\*/, end: /\*\//, cmClass: 'comment' } ]
|
2026-07-17 21:20:21 +00:00
|
|
|
);
|
|
|
|
|
|
2026-07-17 21:42:43 +00:00
|
|
|
csharpMode.setKeywordSet( 'keywords', CS_KEYWORDS, 'keyword', [ 'CWORD' ] );
|