mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 22:02:55 +01:00
Merge pull request #38 from masad-frost/master
Fix Clojure syntax highlighting
This commit is contained in:
commit
a0809e5d56
7 changed files with 468 additions and 448 deletions
16
.editorconfig
Normal file
16
.editorconfig
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
# EditorConfig is awesome: http://EditorConfig.org
|
||||
|
||||
# top-most EditorConfig file
|
||||
root = true
|
||||
|
||||
# Tab indentation
|
||||
[*]
|
||||
indent_style = tab
|
||||
indent_size = 4
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
# The indent size used in the `package.json` file cannot be changed
|
||||
# https://github.com/npm/npm/pull/3180#issuecomment-16336516
|
||||
[{*.yml,*.yaml,package.json}]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
1
.vscode/settings.json
vendored
1
.vscode/settings.json
vendored
|
|
@ -9,5 +9,6 @@
|
|||
"files.insertFinalNewline": true,
|
||||
"editor.tabSize": 4,
|
||||
"editor.insertSpaces": false,
|
||||
"editor.detectIndentation": false,
|
||||
"typescript.tsdk": "./node_modules/typescript/lib"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,11 +8,11 @@ import { registerLanguage } from '../_.contribution';
|
|||
|
||||
// Allow for running under nodejs/requirejs in tests
|
||||
const _monaco: typeof monaco =
|
||||
typeof monaco === 'undefined' ? (<any>self).monaco : monaco;
|
||||
typeof monaco === 'undefined' ? (<any>self).monaco : monaco;
|
||||
|
||||
registerLanguage({
|
||||
id: 'clojure',
|
||||
extensions: ['.clj', '.clojure'],
|
||||
aliases: ['clojure', 'Clojure'],
|
||||
loader: () => _monaco.Promise.wrap(import('./clojure')),
|
||||
id: 'clojure',
|
||||
extensions: ['.clj', '.clojure'],
|
||||
aliases: ['clojure', 'Clojure'],
|
||||
loader: () => _monaco.Promise.wrap(import('./clojure')),
|
||||
});
|
||||
|
|
|
|||
|
|
@ -8,97 +8,83 @@
|
|||
import { testTokenization } from '../test/testRunner';
|
||||
|
||||
testTokenization('clojure', [
|
||||
// Keywords
|
||||
[
|
||||
{
|
||||
line: 'defmacro some',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.clj' },
|
||||
{ startIndex: 8, type: 'white.clj' },
|
||||
{ startIndex: 9, type: 'variable.clj' },
|
||||
],
|
||||
},
|
||||
// Keywords
|
||||
[
|
||||
{
|
||||
line: 'defmacro some',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.clj' },
|
||||
{ startIndex: 8, type: 'white.clj' },
|
||||
{ startIndex: 9, type: 'variable.clj' },
|
||||
],
|
||||
},
|
||||
|
||||
{
|
||||
line: 'comment "text comment"',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.clj' },
|
||||
{ startIndex: 7, type: 'white.clj'},
|
||||
{ startIndex: 8, type: 'string.clj'},
|
||||
],
|
||||
},
|
||||
{
|
||||
line: 'in-ns "user',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.clj' },
|
||||
{ startIndex: 5, type: 'white.clj' },
|
||||
{ startIndex: 6, type: 'string.clj' },
|
||||
],
|
||||
},
|
||||
],
|
||||
{
|
||||
line: 'comment "text comment"',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.clj' },
|
||||
{ startIndex: 7, type: 'white.clj' },
|
||||
{ startIndex: 8, type: 'string.clj' },
|
||||
],
|
||||
},
|
||||
{
|
||||
line: 'in-ns "user',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.clj' },
|
||||
{ startIndex: 5, type: 'white.clj' },
|
||||
{ startIndex: 6, type: 'string.clj' },
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
// comments
|
||||
[
|
||||
{
|
||||
line: ';; comment',
|
||||
tokens: [{ startIndex: 0, type: 'comment.clj' }],
|
||||
},
|
||||
],
|
||||
[
|
||||
{
|
||||
line: '(comment',
|
||||
tokens: [{ startIndex: 0, type: 'comment.clj' }],
|
||||
},
|
||||
{
|
||||
line: '(comment let',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.clj' },
|
||||
{ startIndex: 8, type: 'white.clj' },
|
||||
{ startIndex: 9, type: 'keyword.clj' },
|
||||
],
|
||||
},
|
||||
],
|
||||
// comments
|
||||
[
|
||||
{
|
||||
line: ';; comment',
|
||||
tokens: [{ startIndex: 0, type: 'comment.clj' }],
|
||||
},
|
||||
],
|
||||
|
||||
// strings
|
||||
[
|
||||
{
|
||||
line: '"\\n string "',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'string.clj' },
|
||||
{ startIndex: 1, type: 'string.escape.clj' },
|
||||
{ startIndex: 3, type: 'string.clj' },
|
||||
],
|
||||
},
|
||||
],
|
||||
[
|
||||
{
|
||||
line: '" string \\',
|
||||
tokens: [{ startIndex: 0, type: 'string.clj' }],
|
||||
},
|
||||
{
|
||||
line: 'multiline',
|
||||
tokens: [{ startIndex: 0, type: 'string.clj' }],
|
||||
},
|
||||
{
|
||||
line: ' ',
|
||||
tokens: [
|
||||
// previous line needs to be terminated with \
|
||||
{ startIndex: 0, type: 'white.clj' },
|
||||
],
|
||||
},
|
||||
],
|
||||
// strings
|
||||
[
|
||||
{
|
||||
line: '"\\n string "',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'string.clj' },
|
||||
{ startIndex: 1, type: 'string.escape.clj' },
|
||||
{ startIndex: 3, type: 'string.clj' },
|
||||
],
|
||||
},
|
||||
],
|
||||
[
|
||||
{
|
||||
line: '" string \\',
|
||||
tokens: [{ startIndex: 0, type: 'string.clj' }],
|
||||
},
|
||||
{
|
||||
line: 'multiline',
|
||||
tokens: [{ startIndex: 0, type: 'string.clj' }],
|
||||
},
|
||||
{
|
||||
line: ' ',
|
||||
tokens: [
|
||||
// previous line needs to be terminated with \
|
||||
{ startIndex: 0, type: 'white.clj' },
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
// numbers
|
||||
[
|
||||
{
|
||||
line: '1e2',
|
||||
tokens: [{ startIndex: 0, type: 'number.float.clj' }],
|
||||
},
|
||||
],
|
||||
[
|
||||
{
|
||||
line: '#x03BB',
|
||||
tokens: [{ startIndex: 0, type: 'number.hex.clj' }],
|
||||
},
|
||||
],
|
||||
// numbers
|
||||
[
|
||||
{
|
||||
line: '1e2',
|
||||
tokens: [{ startIndex: 0, type: 'number.float.clj' }],
|
||||
},
|
||||
],
|
||||
[
|
||||
{
|
||||
line: '0xff',
|
||||
tokens: [{ startIndex: 0, type: 'number.hex.clj' }],
|
||||
},
|
||||
],
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -9,205 +9,219 @@ import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration;
|
|||
import ILanguage = monaco.languages.IMonarchLanguage;
|
||||
|
||||
export const conf: IRichLanguageConfiguration = {
|
||||
comments: {
|
||||
lineComment: ';;',
|
||||
blockComment: ['(comment', ')'],
|
||||
},
|
||||
comments: {
|
||||
lineComment: ';;',
|
||||
},
|
||||
|
||||
brackets: [['(', ')'], ['{', '}'], ['[', ']']],
|
||||
brackets: [['(', ')'], ['{', '}'], ['[', ']']],
|
||||
|
||||
autoClosingPairs: [
|
||||
{ open: '{', close: '}' },
|
||||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '"', close: '"' },
|
||||
],
|
||||
autoClosingPairs: [
|
||||
{ open: '{', close: '}' },
|
||||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '"', close: '"' },
|
||||
],
|
||||
|
||||
surroundingPairs: [
|
||||
{ open: '{', close: '}' },
|
||||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '"', close: '"' },
|
||||
],
|
||||
surroundingPairs: [
|
||||
{ open: '{', close: '}' },
|
||||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '"', close: '"' },
|
||||
],
|
||||
};
|
||||
|
||||
export const language = <ILanguage>{
|
||||
defaultToken: '',
|
||||
ignoreCase: true,
|
||||
tokenPostfix: '.clj',
|
||||
defaultToken: '',
|
||||
ignoreCase: true,
|
||||
tokenPostfix: '.clj',
|
||||
|
||||
brackets: [
|
||||
{ open: '(', close: ')', token: 'delimiter.parenthesis' },
|
||||
{ open: '{', close: '}', token: 'delimiter.curly' },
|
||||
{ open: '[', close: ']', token: 'delimiter.square' },
|
||||
],
|
||||
brackets: [
|
||||
{ open: '(', close: ')', token: 'delimiter.parenthesis' },
|
||||
{ open: '{', close: '}', token: 'delimiter.curly' },
|
||||
{ open: '[', close: ']', token: 'delimiter.square' },
|
||||
],
|
||||
|
||||
keywords: [
|
||||
'ns',
|
||||
'ns\-unmap',
|
||||
'create\-ns',
|
||||
'in\-ns',
|
||||
'fn',
|
||||
'def',
|
||||
'defn',
|
||||
'defmacro',
|
||||
'defmulti',
|
||||
'defonce',
|
||||
'require',
|
||||
'import',
|
||||
'new',
|
||||
'refer',
|
||||
'pos',
|
||||
'pos\?',
|
||||
'filter',
|
||||
'map',
|
||||
'reduce',
|
||||
'repeat',
|
||||
'key',
|
||||
'rest',
|
||||
'concat',
|
||||
'into',
|
||||
'reverse',
|
||||
'iterate',
|
||||
'range',
|
||||
'drop',
|
||||
'drop\-while',
|
||||
'take',
|
||||
'take\-while',
|
||||
'neg',
|
||||
'neg?',
|
||||
'bound\-fn',
|
||||
'if',
|
||||
'if\-not',
|
||||
'if\-let',
|
||||
'case,',
|
||||
'contains',
|
||||
'conj',
|
||||
'disj',
|
||||
'sort',
|
||||
'get',
|
||||
'assoc',
|
||||
'merge',
|
||||
'keys',
|
||||
'vals',
|
||||
'nth',
|
||||
'first',
|
||||
'last',
|
||||
'count',
|
||||
'contains?',
|
||||
'cond',
|
||||
'condp',
|
||||
'cond\-\>',
|
||||
'cond\-\>\>',
|
||||
'when',
|
||||
'while',
|
||||
'when\-not',
|
||||
'when\-let',
|
||||
'when\-first',
|
||||
'do',
|
||||
'future',
|
||||
'comment',
|
||||
'doto',
|
||||
'locking',
|
||||
'proxy',
|
||||
'println',
|
||||
'type',
|
||||
'meta',
|
||||
'var',
|
||||
'as\-\>',
|
||||
'reify',
|
||||
'deftype',
|
||||
'defrecord',
|
||||
'defprotocol',
|
||||
'extend',
|
||||
'extend-protocol',
|
||||
'extend-type',
|
||||
'specify',
|
||||
'specify\!',
|
||||
'try',
|
||||
'catch',
|
||||
'finally',
|
||||
'let',
|
||||
'letfn',
|
||||
'binding',
|
||||
'loop',
|
||||
'for',
|
||||
'seq',
|
||||
'doseq',
|
||||
'dotimes',
|
||||
'when\-let',
|
||||
'if\-let',
|
||||
'when\-some',
|
||||
'if\-some',
|
||||
'this\-as',
|
||||
'defmethod',
|
||||
'testing',
|
||||
'deftest',
|
||||
'are',
|
||||
'use\-fixtures',
|
||||
'use',
|
||||
'remove',
|
||||
'run',
|
||||
'run\*',
|
||||
'fresh',
|
||||
'alt!',
|
||||
'alt!!',
|
||||
'go',
|
||||
'go\-loop',
|
||||
'thread',
|
||||
],
|
||||
keywords: [
|
||||
'ns',
|
||||
'ns-unmap',
|
||||
'create-ns',
|
||||
'in-ns',
|
||||
'fn',
|
||||
'def',
|
||||
'defn',
|
||||
'defmacro',
|
||||
'defmulti',
|
||||
'defonce',
|
||||
'require',
|
||||
'import',
|
||||
'new',
|
||||
'refer',
|
||||
'pos',
|
||||
'pos?',
|
||||
'filter',
|
||||
'map',
|
||||
'reduce',
|
||||
'repeat',
|
||||
'key',
|
||||
'rest',
|
||||
'concat',
|
||||
'into',
|
||||
'reverse',
|
||||
'iterate',
|
||||
'range',
|
||||
'drop',
|
||||
'drop-while',
|
||||
'take',
|
||||
'take-while',
|
||||
'neg',
|
||||
'neg?',
|
||||
'bound-fn',
|
||||
'if',
|
||||
'if-not',
|
||||
'if-let',
|
||||
'case,',
|
||||
'contains',
|
||||
'conj',
|
||||
'disj',
|
||||
'sort',
|
||||
'get',
|
||||
'assoc',
|
||||
'merge',
|
||||
'keys',
|
||||
'vals',
|
||||
'nth',
|
||||
'first',
|
||||
'last',
|
||||
'count',
|
||||
'contains?',
|
||||
'cond',
|
||||
'condp',
|
||||
'cond->',
|
||||
'cond->>',
|
||||
'when',
|
||||
'while',
|
||||
'when-not',
|
||||
'when-let',
|
||||
'when-first',
|
||||
'do',
|
||||
'future',
|
||||
'comment',
|
||||
'doto',
|
||||
'locking',
|
||||
'proxy',
|
||||
'println',
|
||||
'type',
|
||||
'meta',
|
||||
'var',
|
||||
'as->',
|
||||
'reify',
|
||||
'deftype',
|
||||
'defrecord',
|
||||
'defprotocol',
|
||||
'extend',
|
||||
'extend-protocol',
|
||||
'extend-type',
|
||||
'specify',
|
||||
'specify!',
|
||||
'try',
|
||||
'catch',
|
||||
'finally',
|
||||
'let',
|
||||
'letfn',
|
||||
'binding',
|
||||
'loop',
|
||||
'for',
|
||||
'seq',
|
||||
'doseq',
|
||||
'dotimes',
|
||||
'when-let',
|
||||
'if-let',
|
||||
'when-some',
|
||||
'if-some',
|
||||
'this-as',
|
||||
'defmethod',
|
||||
'testing',
|
||||
'deftest',
|
||||
'are',
|
||||
'use-fixtures',
|
||||
'use',
|
||||
'remove',
|
||||
'run',
|
||||
'run*',
|
||||
'fresh',
|
||||
'alt!',
|
||||
'alt!!',
|
||||
'go',
|
||||
'go-loop',
|
||||
'thread',
|
||||
'boolean',
|
||||
'str',
|
||||
],
|
||||
|
||||
constants: ['true', 'false', 'nil', 'boolean', 'str'],
|
||||
constants: ['true', 'false', 'nil'],
|
||||
|
||||
operators: ['=', 'not=', '<', '<=', '>', '>=', 'and', 'or', 'not', 'inc', 'dec', 'max', 'min', 'rem', 'bit-and', 'bit-or', 'bit-xor', 'bit-not'],
|
||||
operators: [
|
||||
'=',
|
||||
'not=',
|
||||
'<',
|
||||
'<=',
|
||||
'>',
|
||||
'>=',
|
||||
'and',
|
||||
'or',
|
||||
'not',
|
||||
'inc',
|
||||
'dec',
|
||||
'max',
|
||||
'min',
|
||||
'rem',
|
||||
'bit-and',
|
||||
'bit-or',
|
||||
'bit-xor',
|
||||
'bit-not',
|
||||
],
|
||||
|
||||
tokenizer: {
|
||||
root: [
|
||||
[/#[xXoObB][0-9a-fA-F]+/, 'number.hex'],
|
||||
[/[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?/, 'number.float'],
|
||||
tokenizer: {
|
||||
root: [
|
||||
[/0[xX][0-9a-fA-F]+/, 'number.hex'],
|
||||
[/[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?/, 'number.float'],
|
||||
|
||||
[/(?:\b(?:(def|defn|defmacro|defmulti|defonce|ns|ns-unmap|fn))\b)(\s+)((?:\w|\-|\!|\?)*)/, ['keyword', 'white', 'variable']],
|
||||
[
|
||||
/(?:\b(?:(ns|def|defn|defn-|defmacro|defmulti|defonce|ns|ns-unmap|fn))(?![\w-]))(\s+)((?:\w|\-|\!|\?)*)/,
|
||||
['keyword', 'white', 'variable'],
|
||||
],
|
||||
|
||||
[
|
||||
/[a-zA-Z_#][a-zA-Z0-9_\-\?\!\*]*/,
|
||||
{
|
||||
cases: {
|
||||
'@keywords': 'keyword',
|
||||
'@constants': 'constant',
|
||||
'@operators': 'operators',
|
||||
'@default': 'identifier',
|
||||
},
|
||||
},
|
||||
],
|
||||
[
|
||||
/[a-zA-Z_#][a-zA-Z0-9_\-\?\!\*]*/,
|
||||
{
|
||||
cases: {
|
||||
'@keywords': 'keyword',
|
||||
'@constants': 'constant',
|
||||
'@operators': 'operators',
|
||||
'@default': 'identifier',
|
||||
},
|
||||
},
|
||||
],
|
||||
|
||||
{ include: '@whitespace' },
|
||||
{ include: '@strings' },
|
||||
],
|
||||
[/\/#"(?:\.|(?:\")|[^""\n])*"\/g/, 'regexp'],
|
||||
|
||||
comment: [
|
||||
[/[^\(comment]+/, 'comment'],
|
||||
[/\)/, 'comment', '@push'],
|
||||
[/\(comment/, 'comment', '@pop'],
|
||||
[/[\)]/, 'comment'],
|
||||
],
|
||||
{ include: '@whitespace' },
|
||||
{ include: '@strings' },
|
||||
],
|
||||
|
||||
whitespace: [
|
||||
[/[ \t\r\n]+/, 'white'],
|
||||
[/\(comment/, 'comment', '@comment'],
|
||||
[/;;.*$/, 'comment'],
|
||||
],
|
||||
whitespace: [[/[ \t\r\n]+/, 'white'], [/;;.*$/, 'comment']],
|
||||
|
||||
strings: [
|
||||
[/"$/, 'string', '@popall'],
|
||||
[/"(?=.)/, 'string', '@multiLineString'],
|
||||
],
|
||||
strings: [
|
||||
[/"$/, 'string', '@popall'],
|
||||
[/"(?=.)/, 'string', '@multiLineString'],
|
||||
],
|
||||
|
||||
multiLineString: [
|
||||
[/\\./, 'string.escape'],
|
||||
[/"/, 'string', '@popall'],
|
||||
[/.(?=.*")/, 'string'],
|
||||
[/.*\\$/, 'string'],
|
||||
[/.*$/, 'string', '@popall'],
|
||||
],
|
||||
},
|
||||
multiLineString: [
|
||||
[/\\./, 'string.escape'],
|
||||
[/"/, 'string', '@popall'],
|
||||
[/.(?=.*")/, 'string'],
|
||||
[/.*\\$/, 'string'],
|
||||
[/.*$/, 'string', '@popall'],
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -8,84 +8,84 @@
|
|||
import { testTokenization } from '../test/testRunner';
|
||||
|
||||
testTokenization('scheme', [
|
||||
// Keywords
|
||||
[
|
||||
{
|
||||
line: 'define-macro some',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.scheme' },
|
||||
{ startIndex: 12, type: 'white.scheme' },
|
||||
{ startIndex: 13, type: 'variable.scheme' },
|
||||
],
|
||||
},
|
||||
],
|
||||
// Keywords
|
||||
[
|
||||
{
|
||||
line: 'define-macro some',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.scheme' },
|
||||
{ startIndex: 12, type: 'white.scheme' },
|
||||
{ startIndex: 13, type: 'variable.scheme' },
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
// comments
|
||||
[
|
||||
{
|
||||
line: '; comment',
|
||||
tokens: [{ startIndex: 0, type: 'comment.scheme' }],
|
||||
},
|
||||
],
|
||||
[
|
||||
{
|
||||
line: '|# comment',
|
||||
tokens: [{ startIndex: 0, type: 'comment.scheme' }],
|
||||
},
|
||||
{
|
||||
line: 'multiline',
|
||||
tokens: [{ startIndex: 0, type: 'comment.scheme' }],
|
||||
},
|
||||
{
|
||||
line: '#| cons',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.scheme' },
|
||||
{ startIndex: 2, type: 'white.scheme' },
|
||||
{ startIndex: 3, type: 'keyword.scheme' },
|
||||
],
|
||||
},
|
||||
],
|
||||
// comments
|
||||
[
|
||||
{
|
||||
line: '; comment',
|
||||
tokens: [{ startIndex: 0, type: 'comment.scheme' }],
|
||||
},
|
||||
],
|
||||
[
|
||||
{
|
||||
line: '#| comment',
|
||||
tokens: [{ startIndex: 0, type: 'comment.scheme' }],
|
||||
},
|
||||
{
|
||||
line: 'multiline',
|
||||
tokens: [{ startIndex: 0, type: 'comment.scheme' }],
|
||||
},
|
||||
{
|
||||
line: '|# cons',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.scheme' },
|
||||
{ startIndex: 2, type: 'white.scheme' },
|
||||
{ startIndex: 3, type: 'keyword.scheme' },
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
// strings
|
||||
[
|
||||
{
|
||||
line: '"\\n string "',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'string.scheme' },
|
||||
{ startIndex: 1, type: 'string.escape.scheme' },
|
||||
{ startIndex: 3, type: 'string.scheme' },
|
||||
],
|
||||
},
|
||||
],
|
||||
[
|
||||
{
|
||||
line: '" string \\',
|
||||
tokens: [{ startIndex: 0, type: 'string.scheme' }],
|
||||
},
|
||||
{
|
||||
line: 'multiline',
|
||||
tokens: [{ startIndex: 0, type: 'string.scheme' }],
|
||||
},
|
||||
{
|
||||
line: ' ',
|
||||
tokens: [
|
||||
// previous line needs to be terminated with \
|
||||
{ startIndex: 0, type: 'white.scheme' },
|
||||
],
|
||||
},
|
||||
],
|
||||
// strings
|
||||
[
|
||||
{
|
||||
line: '"\\n string "',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'string.scheme' },
|
||||
{ startIndex: 1, type: 'string.escape.scheme' },
|
||||
{ startIndex: 3, type: 'string.scheme' },
|
||||
],
|
||||
},
|
||||
],
|
||||
[
|
||||
{
|
||||
line: '" string \\',
|
||||
tokens: [{ startIndex: 0, type: 'string.scheme' }],
|
||||
},
|
||||
{
|
||||
line: 'multiline',
|
||||
tokens: [{ startIndex: 0, type: 'string.scheme' }],
|
||||
},
|
||||
{
|
||||
line: ' ',
|
||||
tokens: [
|
||||
// previous line needs to be terminated with \
|
||||
{ startIndex: 0, type: 'white.scheme' },
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
// numbers
|
||||
[
|
||||
{
|
||||
line: '1e2',
|
||||
tokens: [{ startIndex: 0, type: 'number.float.scheme' }],
|
||||
},
|
||||
],
|
||||
[
|
||||
{
|
||||
line: '#x03BB',
|
||||
tokens: [{ startIndex: 0, type: 'number.hex.scheme' }],
|
||||
},
|
||||
],
|
||||
// numbers
|
||||
[
|
||||
{
|
||||
line: '1e2',
|
||||
tokens: [{ startIndex: 0, type: 'number.float.scheme' }],
|
||||
},
|
||||
],
|
||||
[
|
||||
{
|
||||
line: '#x03BB',
|
||||
tokens: [{ startIndex: 0, type: 'number.hex.scheme' }],
|
||||
},
|
||||
],
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -9,116 +9,119 @@ import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration;
|
|||
import ILanguage = monaco.languages.IMonarchLanguage;
|
||||
|
||||
export const conf: IRichLanguageConfiguration = {
|
||||
comments: {
|
||||
lineComment: ';',
|
||||
blockComment: ['#|', '|#'],
|
||||
},
|
||||
comments: {
|
||||
lineComment: ';',
|
||||
blockComment: ['#|', '|#'],
|
||||
},
|
||||
|
||||
brackets: [['(', ')'], ['{', '}'], ['[', ']']],
|
||||
brackets: [['(', ')'], ['{', '}'], ['[', ']']],
|
||||
|
||||
autoClosingPairs: [
|
||||
{ open: '{', close: '}' },
|
||||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '"', close: '"' },
|
||||
],
|
||||
autoClosingPairs: [
|
||||
{ open: '{', close: '}' },
|
||||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '"', close: '"' },
|
||||
],
|
||||
|
||||
surroundingPairs: [
|
||||
{ open: '{', close: '}' },
|
||||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '"', close: '"' },
|
||||
],
|
||||
surroundingPairs: [
|
||||
{ open: '{', close: '}' },
|
||||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '"', close: '"' },
|
||||
],
|
||||
};
|
||||
|
||||
export const language = <ILanguage>{
|
||||
defaultToken: '',
|
||||
ignoreCase: true,
|
||||
tokenPostfix: '.scheme',
|
||||
defaultToken: '',
|
||||
ignoreCase: true,
|
||||
tokenPostfix: '.scheme',
|
||||
|
||||
brackets: [
|
||||
{ open: '(', close: ')', token: 'delimiter.parenthesis' },
|
||||
{ open: '{', close: '}', token: 'delimiter.curly' },
|
||||
{ open: '[', close: ']', token: 'delimiter.square' },
|
||||
],
|
||||
brackets: [
|
||||
{ open: '(', close: ')', token: 'delimiter.parenthesis' },
|
||||
{ open: '{', close: '}', token: 'delimiter.curly' },
|
||||
{ open: '[', close: ']', token: 'delimiter.square' },
|
||||
],
|
||||
|
||||
keywords: [
|
||||
'case',
|
||||
'do',
|
||||
'let',
|
||||
'loop',
|
||||
'if',
|
||||
'else',
|
||||
'when',
|
||||
'cons',
|
||||
'car',
|
||||
'cdr',
|
||||
'cond',
|
||||
'lambda',
|
||||
'lambda*',
|
||||
'syntax-rules',
|
||||
'format',
|
||||
'set!',
|
||||
'quote',
|
||||
'eval',
|
||||
'append',
|
||||
'list',
|
||||
'list?',
|
||||
'member?',
|
||||
'load',
|
||||
],
|
||||
keywords: [
|
||||
'case',
|
||||
'do',
|
||||
'let',
|
||||
'loop',
|
||||
'if',
|
||||
'else',
|
||||
'when',
|
||||
'cons',
|
||||
'car',
|
||||
'cdr',
|
||||
'cond',
|
||||
'lambda',
|
||||
'lambda*',
|
||||
'syntax-rules',
|
||||
'format',
|
||||
'set!',
|
||||
'quote',
|
||||
'eval',
|
||||
'append',
|
||||
'list',
|
||||
'list?',
|
||||
'member?',
|
||||
'load',
|
||||
],
|
||||
|
||||
constants: ['#t', '#f'],
|
||||
constants: ['#t', '#f'],
|
||||
|
||||
operators: ['eq?', 'eqv?', 'equal?', 'and', 'or', 'not', 'null?'],
|
||||
operators: ['eq?', 'eqv?', 'equal?', 'and', 'or', 'not', 'null?'],
|
||||
|
||||
tokenizer: {
|
||||
root: [
|
||||
[/#[xXoObB][0-9a-fA-F]+/, 'number.hex'],
|
||||
[/[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?/, 'number.float'],
|
||||
tokenizer: {
|
||||
root: [
|
||||
[/#[xXoObB][0-9a-fA-F]+/, 'number.hex'],
|
||||
[/[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?/, 'number.float'],
|
||||
|
||||
[/(?:\b(?:(define|define-syntax|define-macro))\b)(\s+)((?:\w|\-|\!|\?)*)/, ['keyword', 'white', 'variable']],
|
||||
[
|
||||
/(?:\b(?:(define|define-syntax|define-macro))\b)(\s+)((?:\w|\-|\!|\?)*)/,
|
||||
['keyword', 'white', 'variable'],
|
||||
],
|
||||
|
||||
[
|
||||
/[a-zA-Z_#][a-zA-Z0-9_\-\?\!\*]*/,
|
||||
{
|
||||
cases: {
|
||||
'@keywords': 'keyword',
|
||||
'@constants': 'constant',
|
||||
'@operators': 'operators',
|
||||
'@default': 'identifier',
|
||||
},
|
||||
},
|
||||
],
|
||||
{ include: '@whitespace' },
|
||||
{ include: '@strings' },
|
||||
|
||||
{ include: '@whitespace' },
|
||||
{ include: '@strings' },
|
||||
],
|
||||
[
|
||||
/[a-zA-Z_#][a-zA-Z0-9_\-\?\!\*]*/,
|
||||
{
|
||||
cases: {
|
||||
'@keywords': 'keyword',
|
||||
'@constants': 'constant',
|
||||
'@operators': 'operators',
|
||||
'@default': 'identifier',
|
||||
},
|
||||
},
|
||||
],
|
||||
],
|
||||
|
||||
comment: [
|
||||
[/[^\|#]+/, 'comment'],
|
||||
[/\|\#/, 'comment', '@push'],
|
||||
[/#\|/, 'comment', '@pop'],
|
||||
[/[\|#]/, 'comment'],
|
||||
],
|
||||
comment: [
|
||||
[/[^\|#]+/, 'comment'],
|
||||
[/#\|/, 'comment', '@push'],
|
||||
[/\|#/, 'comment', '@pop'],
|
||||
[/[\|#]/, 'comment'],
|
||||
],
|
||||
|
||||
whitespace: [
|
||||
[/[ \t\r\n]+/, 'white'],
|
||||
[/\|\#/, 'comment', '@comment'],
|
||||
[/;.*$/, 'comment'],
|
||||
],
|
||||
whitespace: [
|
||||
[/[ \t\r\n]+/, 'white'],
|
||||
[/#\|/, 'comment', '@comment'],
|
||||
[/;.*$/, 'comment'],
|
||||
],
|
||||
|
||||
strings: [
|
||||
[/"$/, 'string', '@popall'],
|
||||
[/"(?=.)/, 'string', '@multiLineString'],
|
||||
],
|
||||
strings: [
|
||||
[/"$/, 'string', '@popall'],
|
||||
[/"(?=.)/, 'string', '@multiLineString'],
|
||||
],
|
||||
|
||||
multiLineString: [
|
||||
[/\\./, 'string.escape'],
|
||||
[/"/, 'string', '@popall'],
|
||||
[/.(?=.*")/, 'string'],
|
||||
[/.*\\$/, 'string'],
|
||||
[/.*$/, 'string', '@popall'],
|
||||
],
|
||||
},
|
||||
multiLineString: [
|
||||
[/\\./, 'string.escape'],
|
||||
[/"/, 'string', '@popall'],
|
||||
[/.(?=.*")/, 'string'],
|
||||
[/.*\\$/, 'string'],
|
||||
[/.*$/, 'string', '@popall'],
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue