add language configuration

This commit is contained in:
Angela Burton 2021-06-29 10:46:23 -07:00
parent 16850dd85a
commit ab0f110432

View file

@ -5,6 +5,28 @@
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
@ -45,7 +67,7 @@ export const language = <languages.IMonarchLanguage> {
'intrinsic', 'intrinsic',
'let', 'let',
'set', 'set',
'w\/', 'w/',
'new', 'new',
'not', 'not',
'and', 'and',
@ -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',
@ -235,22 +248,26 @@ export const language = <languages.IMonarchLanguage> {
tokenizer: { tokenizer: {
root: [ root: [
// identifiers and keywords // identifiers and keywords
[/[a-zA-Z_$][\w$]*/, { cases: { '@typeKeywords': 'type', [
/[a-zA-Z_$][\w$]*/,
{
cases: {
'@typeKeywords': 'type',
'@keywords': 'keyword', '@keywords': 'keyword',
'@constants': 'constant', '@constants': 'constant',
'@builtin': 'keyword', '@builtin': 'keyword',
'@invalidKeywords': 'invalid', '@invalidKeywords': 'invalid',
'@default': 'identifier' '@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 // numbers
[/\d*\.\d+([eE][\-+]?\d+)?/, 'number.float'], [/\d*\.\d+([eE][\-+]?\d+)?/, 'number.float'],
@ -261,8 +278,7 @@ export const language = <languages.IMonarchLanguage> {
// strings // strings
//[/"([^"\\]|\\.)*$/, 'string.invalid' ], // non-teminated string //[/"([^"\\]|\\.)*$/, 'string.invalid' ], // non-teminated string
[/"/, { token: 'string.quote', bracket: '@open', next: '@string' } ], [/"/, { token: 'string.quote', bracket: '@open', next: '@string' }]
], ],
string: [ string: [
@ -274,6 +290,6 @@ export const language = <languages.IMonarchLanguage> {
whitespace: [ whitespace: [
[/[ \t\r\n]+/, 'white'], [/[ \t\r\n]+/, 'white'],
[/(\/\/).*/, 'comment'] [/(\/\/).*/, 'comment']
], ]
}, }
}; };