mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 15:05:39 +01:00
add language configuration
This commit is contained in:
parent
16850dd85a
commit
ab0f110432
1 changed files with 113 additions and 97 deletions
|
|
@ -5,8 +5,30 @@
|
||||||
|
|
||||||
import type { languages } from '../fillers/monaco-editor-core';
|
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> {
|
export const language = <languages.IMonarchLanguage>{
|
||||||
// Set defaultToken to invalid to see what you do not tokenize yet
|
// Set defaultToken to invalid to see what you do not tokenize yet
|
||||||
defaultToken: 'invalid',
|
defaultToken: 'invalid',
|
||||||
|
|
||||||
|
|
@ -45,7 +67,7 @@ export const language = <languages.IMonarchLanguage> {
|
||||||
'intrinsic',
|
'intrinsic',
|
||||||
'let',
|
'let',
|
||||||
'set',
|
'set',
|
||||||
'w\/',
|
'w/',
|
||||||
'new',
|
'new',
|
||||||
'not',
|
'not',
|
||||||
'and',
|
'and',
|
||||||
|
|
@ -55,7 +77,7 @@ export const language = <languages.IMonarchLanguage> {
|
||||||
'using',
|
'using',
|
||||||
'borrowing',
|
'borrowing',
|
||||||
'mutable'
|
'mutable'
|
||||||
],
|
],
|
||||||
|
|
||||||
typeKeywords: [
|
typeKeywords: [
|
||||||
'Unit',
|
'Unit',
|
||||||
|
|
@ -136,16 +158,7 @@ export const language = <languages.IMonarchLanguage> {
|
||||||
'volatile'
|
'volatile'
|
||||||
],
|
],
|
||||||
|
|
||||||
constants: [
|
constants: ['true', 'false', 'PauliI', 'PauliX', 'PauliY', 'PauliZ', 'One', 'Zero'],
|
||||||
'true',
|
|
||||||
'false',
|
|
||||||
'PauliI',
|
|
||||||
'PauliX',
|
|
||||||
'PauliY',
|
|
||||||
'PauliZ',
|
|
||||||
'One',
|
|
||||||
'Zero'
|
|
||||||
],
|
|
||||||
|
|
||||||
builtin: [
|
builtin: [
|
||||||
'X',
|
'X',
|
||||||
|
|
@ -179,101 +192,104 @@ export const language = <languages.IMonarchLanguage> {
|
||||||
],
|
],
|
||||||
|
|
||||||
operators: [
|
operators: [
|
||||||
'and=',
|
'and=',
|
||||||
'<-',
|
'<-',
|
||||||
'->',
|
'->',
|
||||||
'*',
|
'*',
|
||||||
'*=',
|
'*=',
|
||||||
'@',
|
'@',
|
||||||
'!',
|
'!',
|
||||||
'^',
|
'^',
|
||||||
'^=',
|
'^=',
|
||||||
':',
|
':',
|
||||||
'::',
|
'::',
|
||||||
'..',
|
'..',
|
||||||
'==',
|
'==',
|
||||||
'...',
|
'...',
|
||||||
'=',
|
'=',
|
||||||
'=>',
|
'=>',
|
||||||
'>',
|
'>',
|
||||||
'>=',
|
'>=',
|
||||||
'<',
|
'<',
|
||||||
'<=',
|
'<=',
|
||||||
'-',
|
'-',
|
||||||
'-=',
|
'-=',
|
||||||
'!=',
|
'!=',
|
||||||
'or=',
|
'or=',
|
||||||
'%',
|
'%',
|
||||||
'%=',
|
'%=',
|
||||||
'|',
|
'|',
|
||||||
'+',
|
'+',
|
||||||
'+=',
|
'+=',
|
||||||
'?',
|
'?',
|
||||||
'/',
|
'/',
|
||||||
'/=',
|
'/=',
|
||||||
'&&&',
|
'&&&',
|
||||||
'&&&=',
|
'&&&=',
|
||||||
'^^^',
|
'^^^',
|
||||||
'^^^=',
|
'^^^=',
|
||||||
'>>>',
|
'>>>',
|
||||||
'>>>=',
|
'>>>=',
|
||||||
'<<<',
|
'<<<',
|
||||||
'<<<=',
|
'<<<=',
|
||||||
'|||',
|
'|||',
|
||||||
'|||=',
|
'|||=',
|
||||||
'~~~',
|
'~~~',
|
||||||
'_',
|
'_',
|
||||||
'w/',
|
'w/',
|
||||||
'w/='
|
'w/='
|
||||||
],
|
],
|
||||||
|
|
||||||
symbols: /[=><!~?:&|+\-*\/\^%@._]+/,
|
symbols: /[=><!~?:&|+\-*\/\^%@._]+/,
|
||||||
|
|
||||||
escapes: /\\[\s\S]/,
|
escapes: /\\[\s\S]/,
|
||||||
|
|
||||||
// The main tokenizer for our languages
|
// The main tokenizer for our languages
|
||||||
tokenizer: {
|
tokenizer: {
|
||||||
root: [
|
root: [
|
||||||
// identifiers and keywords
|
// identifiers and keywords
|
||||||
[/[a-zA-Z_$][\w$]*/, { cases: { '@typeKeywords': 'type',
|
[
|
||||||
'@keywords': 'keyword',
|
/[a-zA-Z_$][\w$]*/,
|
||||||
'@constants': 'constant',
|
{
|
||||||
'@builtin': 'keyword',
|
cases: {
|
||||||
'@invalidKeywords': 'invalid',
|
'@typeKeywords': 'type',
|
||||||
'@default': 'identifier'
|
'@keywords': 'keyword',
|
||||||
} }],
|
'@constants': 'constant',
|
||||||
|
'@builtin': 'keyword',
|
||||||
|
'@invalidKeywords': 'invalid',
|
||||||
|
'@default': 'identifier'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
// whitespace
|
// whitespace
|
||||||
{ include: '@whitespace' },
|
{ include: '@whitespace' },
|
||||||
|
|
||||||
// delimiters and operators
|
// delimiters and operators
|
||||||
[/[{}()\[\]]/, '@brackets'],
|
[/[{}()\[\]]/, '@brackets'],
|
||||||
[/@symbols/, { cases: { '@operators': 'operator',
|
[/@symbols/, { cases: { '@operators': 'operator', '@default': '' } }],
|
||||||
'@default' : '' } } ],
|
|
||||||
|
|
||||||
|
// numbers
|
||||||
|
[/\d*\.\d+([eE][\-+]?\d+)?/, 'number.float'],
|
||||||
|
[/\d+/, 'number'],
|
||||||
|
|
||||||
// numbers
|
// delimiter: after number because of .\d floats
|
||||||
[/\d*\.\d+([eE][\-+]?\d+)?/, 'number.float'],
|
[/[;,.]/, 'delimiter'],
|
||||||
[/\d+/, 'number'],
|
|
||||||
|
|
||||||
// delimiter: after number because of .\d floats
|
// strings
|
||||||
[/[;,.]/, 'delimiter'],
|
//[/"([^"\\]|\\.)*$/, 'string.invalid' ], // non-teminated string
|
||||||
|
[/"/, { token: 'string.quote', bracket: '@open', next: '@string' }]
|
||||||
|
],
|
||||||
|
|
||||||
// strings
|
string: [
|
||||||
//[/"([^"\\]|\\.)*$/, 'string.invalid' ], // non-teminated string
|
[/[^\\"]+/, 'string'],
|
||||||
[/"/, { token: 'string.quote', bracket: '@open', next: '@string' } ],
|
[/@escapes/, 'string.escape'],
|
||||||
|
[/"/, { token: 'string.quote', bracket: '@close', next: '@pop' }]
|
||||||
|
],
|
||||||
|
|
||||||
],
|
whitespace: [
|
||||||
|
[/[ \t\r\n]+/, 'white'],
|
||||||
string: [
|
[/(\/\/).*/, 'comment']
|
||||||
[/[^\\"]+/, 'string'],
|
]
|
||||||
[/@escapes/, 'string.escape'],
|
}
|
||||||
[/"/, { token: 'string.quote', bracket: '@close', next: '@pop' } ]
|
};
|
||||||
],
|
|
||||||
|
|
||||||
whitespace: [
|
|
||||||
[/[ \t\r\n]+/, 'white'],
|
|
||||||
[/(\/\/).*/, 'comment']
|
|
||||||
],
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue