Преглед на файлове

Merge pull request #38 from masad-frost/master

Fix Clojure syntax highlighting
Alexandru Dima преди 7 години
родител
ревизия
a0809e5d56
променени са 7 файла, в които са добавени 498 реда и са изтрити 478 реда
  1. 16 0
      .editorconfig
  2. 1 0
      .vscode/settings.json
  3. 5 5
      src/clojure/clojure.contribution.ts
  4. 75 89
      src/clojure/clojure.test.ts
  5. 212 198
      src/clojure/clojure.ts
  6. 77 77
      src/scheme/scheme.test.ts
  7. 112 109
      src/scheme/scheme.ts

+ 16 - 0
.editorconfig

@@ -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 - 0
.vscode/settings.json

@@ -9,5 +9,6 @@
 	"files.insertFinalNewline": true,
 	"editor.tabSize": 4,
 	"editor.insertSpaces": false,
+	"editor.detectIndentation": false,
 	"typescript.tsdk": "./node_modules/typescript/lib"
 }

+ 5 - 5
src/clojure/clojure.contribution.ts

@@ -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')),
 });

+ 75 - 89
src/clojure/clojure.test.ts

@@ -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' }],
+		},
+	],
 ]);

+ 212 - 198
src/clojure/clojure.ts

@@ -9,205 +9,219 @@ import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration;
 import ILanguage = monaco.languages.IMonarchLanguage;
 
 export const conf: IRichLanguageConfiguration = {
-  comments: {
-    lineComment: ';;',
-    blockComment: ['(comment', ')'],
-  },
-
-  brackets: [['(', ')'], ['{', '}'], ['[', ']']],
-
-  autoClosingPairs: [
-    { open: '{', close: '}' },
-    { open: '[', close: ']' },
-    { open: '(', close: ')' },
-    { open: '"', close: '"' },
-  ],
-
-  surroundingPairs: [
-    { open: '{', close: '}' },
-    { open: '[', close: ']' },
-    { open: '(', close: ')' },
-    { open: '"', close: '"' },
-  ],
+	comments: {
+		lineComment: ';;',
+	},
+
+	brackets: [['(', ')'], ['{', '}'], ['[', ']']],
+
+	autoClosingPairs: [
+		{ 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',
-
-  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',
-  ],
-
-  constants: ['true', 'false', 'nil', 'boolean', 'str'],
-
-  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'],
-
-      [/(?:\b(?:(def|defn|defmacro|defmulti|defonce|ns|ns-unmap|fn))\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' },
-    ],
-
-    comment: [
-      [/[^\(comment]+/, 'comment'],
-      [/\)/, 'comment', '@push'],
-      [/\(comment/, 'comment', '@pop'],
-      [/[\)]/, 'comment'],
-    ],
-
-    whitespace: [
-      [/[ \t\r\n]+/, 'white'],
-      [/\(comment/, 'comment', '@comment'],
-      [/;;.*$/, 'comment'],
-    ],
-
-    strings: [
-      [/"$/, 'string', '@popall'],
-      [/"(?=.)/, 'string', '@multiLineString'],
-    ],
-
-    multiLineString: [
-      [/\\./, 'string.escape'],
-      [/"/, 'string', '@popall'],
-      [/.(?=.*")/, 'string'],
-      [/.*\\$/, 'string'],
-      [/.*$/, 'string', '@popall'],
-    ],
-  },
+	defaultToken: '',
+	ignoreCase: true,
+	tokenPostfix: '.clj',
+
+	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',
+		'boolean',
+		'str',
+	],
+
+	constants: ['true', 'false', 'nil'],
+
+	operators: [
+		'=',
+		'not=',
+		'<',
+		'<=',
+		'>',
+		'>=',
+		'and',
+		'or',
+		'not',
+		'inc',
+		'dec',
+		'max',
+		'min',
+		'rem',
+		'bit-and',
+		'bit-or',
+		'bit-xor',
+		'bit-not',
+	],
+
+	tokenizer: {
+		root: [
+			[/0[xX][0-9a-fA-F]+/, 'number.hex'],
+			[/[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?/, 'number.float'],
+
+			[
+				/(?:\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',
+					},
+				},
+			],
+
+			[/\/#"(?:\.|(?:\")|[^""\n])*"\/g/, 'regexp'],
+
+			{ include: '@whitespace' },
+			{ include: '@strings' },
+		],
+
+		whitespace: [[/[ \t\r\n]+/, 'white'], [/;;.*$/, 'comment']],
+
+		strings: [
+			[/"$/, 'string', '@popall'],
+			[/"(?=.)/, 'string', '@multiLineString'],
+		],
+
+		multiLineString: [
+			[/\\./, 'string.escape'],
+			[/"/, 'string', '@popall'],
+			[/.(?=.*")/, 'string'],
+			[/.*\\$/, 'string'],
+			[/.*$/, 'string', '@popall'],
+		],
+	},
 };

+ 77 - 77
src/scheme/scheme.test.ts

@@ -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' }],
+		},
+	],
 ]);

+ 112 - 109
src/scheme/scheme.ts

@@ -9,116 +9,119 @@ import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration;
 import ILanguage = monaco.languages.IMonarchLanguage;
 
 export const conf: IRichLanguageConfiguration = {
-    comments: {
-        lineComment: ';',
-        blockComment: ['#|', '|#'],
-    },
-
-    brackets: [['(', ')'], ['{', '}'], ['[', ']']],
-
-    autoClosingPairs: [
-        { open: '{', close: '}' },
-        { open: '[', close: ']' },
-        { open: '(', close: ')' },
-        { open: '"', close: '"' },
-    ],
-
-    surroundingPairs: [
-        { open: '{', close: '}' },
-        { open: '[', close: ']' },
-        { open: '(', close: ')' },
-        { open: '"', close: '"' },
-    ],
+	comments: {
+		lineComment: ';',
+		blockComment: ['#|', '|#'],
+	},
+
+	brackets: [['(', ')'], ['{', '}'], ['[', ']']],
+
+	autoClosingPairs: [
+		{ 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',
-
-    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',
-    ],
-
-    constants: ['#t', '#f'],
-
-    operators: ['eq?', 'eqv?', 'equal?', 'and', 'or', 'not', 'null?'],
-
-    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']],
-
-            [
-                /[a-zA-Z_#][a-zA-Z0-9_\-\?\!\*]*/,
-                {
-                    cases: {
-                        '@keywords': 'keyword',
-                        '@constants': 'constant',
-                        '@operators': 'operators',
-                        '@default': 'identifier',
-                    },
-                },
-            ],
-
-            { include: '@whitespace' },
-            { include: '@strings' },
-        ],
-
-        comment: [
-            [/[^\|#]+/, 'comment'],
-            [/\|\#/, 'comment', '@push'],
-            [/#\|/, 'comment', '@pop'],
-            [/[\|#]/, 'comment'],
-        ],
-
-        whitespace: [
-            [/[ \t\r\n]+/, 'white'],
-            [/\|\#/, 'comment', '@comment'],
-            [/;.*$/, 'comment'],
-        ],
-
-        strings: [
-            [/"$/, 'string', '@popall'],
-            [/"(?=.)/, 'string', '@multiLineString'],
-        ],
-
-        multiLineString: [
-            [/\\./, 'string.escape'],
-            [/"/, 'string', '@popall'],
-            [/.(?=.*")/, 'string'],
-            [/.*\\$/, 'string'],
-            [/.*$/, 'string', '@popall'],
-        ],
-    },
+	defaultToken: '',
+	ignoreCase: true,
+	tokenPostfix: '.scheme',
+
+	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',
+	],
+
+	constants: ['#t', '#f'],
+
+	operators: ['eq?', 'eqv?', 'equal?', 'and', 'or', 'not', 'null?'],
+
+	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'],
+			],
+
+			{ 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'],
+		],
+
+		whitespace: [
+			[/[ \t\r\n]+/, 'white'],
+			[/#\|/, 'comment', '@comment'],
+			[/;.*$/, 'comment'],
+		],
+
+		strings: [
+			[/"$/, 'string', '@popall'],
+			[/"(?=.)/, 'string', '@multiLineString'],
+		],
+
+		multiLineString: [
+			[/\\./, 'string.escape'],
+			[/"/, 'string', '@popall'],
+			[/.(?=.*")/, 'string'],
+			[/.*\\$/, 'string'],
+			[/.*$/, 'string', '@popall'],
+		],
+	},
 };