mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 23:13:02 +01:00
add language configuration
This commit is contained in:
parent
16850dd85a
commit
ab0f110432
1 changed files with 113 additions and 97 deletions
|
|
@ -5,6 +5,28 @@
|
|||
|
||||
import type { languages } from '../fillers/monaco-editor-core';
|
||||
|
||||
export const conf: languages.LanguageConfiguration = {
|
||||
comments: {
|
||||
lineComment: '//'
|
||||
},
|
||||
brackets: [
|
||||
['{', '}'],
|
||||
['[', ']'],
|
||||
['(', ')']
|
||||
],
|
||||
autoClosingPairs: [
|
||||
{ open: '{', close: '}' },
|
||||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '"', close: '"', notIn: ['string', 'comment'] }
|
||||
],
|
||||
surroundingPairs: [
|
||||
{ open: '{', close: '}' },
|
||||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '"', close: '"' }
|
||||
]
|
||||
};
|
||||
|
||||
export const language = <languages.IMonarchLanguage>{
|
||||
// Set defaultToken to invalid to see what you do not tokenize yet
|
||||
|
|
@ -45,7 +67,7 @@ export const language = <languages.IMonarchLanguage> {
|
|||
'intrinsic',
|
||||
'let',
|
||||
'set',
|
||||
'w\/',
|
||||
'w/',
|
||||
'new',
|
||||
'not',
|
||||
'and',
|
||||
|
|
@ -136,16 +158,7 @@ export const language = <languages.IMonarchLanguage> {
|
|||
'volatile'
|
||||
],
|
||||
|
||||
constants: [
|
||||
'true',
|
||||
'false',
|
||||
'PauliI',
|
||||
'PauliX',
|
||||
'PauliY',
|
||||
'PauliZ',
|
||||
'One',
|
||||
'Zero'
|
||||
],
|
||||
constants: ['true', 'false', 'PauliI', 'PauliX', 'PauliY', 'PauliZ', 'One', 'Zero'],
|
||||
|
||||
builtin: [
|
||||
'X',
|
||||
|
|
@ -235,22 +248,26 @@ export const language = <languages.IMonarchLanguage> {
|
|||
tokenizer: {
|
||||
root: [
|
||||
// identifiers and keywords
|
||||
[/[a-zA-Z_$][\w$]*/, { cases: { '@typeKeywords': 'type',
|
||||
[
|
||||
/[a-zA-Z_$][\w$]*/,
|
||||
{
|
||||
cases: {
|
||||
'@typeKeywords': 'type',
|
||||
'@keywords': 'keyword',
|
||||
'@constants': 'constant',
|
||||
'@builtin': 'keyword',
|
||||
'@invalidKeywords': 'invalid',
|
||||
'@default': 'identifier'
|
||||
} }],
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
// whitespace
|
||||
{ include: '@whitespace' },
|
||||
|
||||
// delimiters and operators
|
||||
[/[{}()\[\]]/, '@brackets'],
|
||||
[/@symbols/, { cases: { '@operators': 'operator',
|
||||
'@default' : '' } } ],
|
||||
|
||||
[/@symbols/, { cases: { '@operators': 'operator', '@default': '' } }],
|
||||
|
||||
// numbers
|
||||
[/\d*\.\d+([eE][\-+]?\d+)?/, 'number.float'],
|
||||
|
|
@ -261,8 +278,7 @@ export const language = <languages.IMonarchLanguage> {
|
|||
|
||||
// strings
|
||||
//[/"([^"\\]|\\.)*$/, 'string.invalid' ], // non-teminated string
|
||||
[/"/, { token: 'string.quote', bracket: '@open', next: '@string' } ],
|
||||
|
||||
[/"/, { token: 'string.quote', bracket: '@open', next: '@string' }]
|
||||
],
|
||||
|
||||
string: [
|
||||
|
|
@ -274,6 +290,6 @@ export const language = <languages.IMonarchLanguage> {
|
|||
whitespace: [
|
||||
[/[ \t\r\n]+/, 'white'],
|
||||
[/(\/\/).*/, 'comment']
|
||||
],
|
||||
},
|
||||
]
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue