Created
December 12, 2019 14:09
-
-
Save amazzalel-habib/3cda4f8686e049df03c2abe0fd09e8ca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as monaco from "monaco-editor-core"; | |
import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration; | |
import ILanguage = monaco.languages.IMonarchLanguage; | |
export const monarchLanguage = <ILanguage>{ | |
// Set defaultToken to invalid to see what you do not tokenize yet | |
defaultToken: 'invalid', | |
keywords: [ | |
'COMPLETE', 'ADD', | |
], | |
typeKeywords: ['TODO'], | |
escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/, | |
// The main tokenizer for our languages | |
tokenizer: { | |
root: [ | |
// identifiers and keywords | |
[/[a-zA-Z_$][\w$]*/, { | |
cases: { | |
'@keywords': { token: 'keyword' }, | |
'@typeKeywords': { token: 'type' }, | |
'@default': 'identifier' | |
} | |
}], | |
// whitespace | |
{ include: '@whitespace' }, | |
// strings for todos | |
[/"([^"\\]|\\.)*$/, 'string.invalid'], // non-teminated string | |
[/"/, 'string', '@string'], | |
], | |
whitespace: [ | |
[/[ \t\r\n]+/, ''], | |
], | |
string: [ | |
[/[^\\"]+/, 'string'], | |
[/@escapes/, 'string.escape'], | |
[/\\./, 'string.escape.invalid'], | |
[/"/, 'string', '@pop'] | |
] | |
}, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment