mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 19:42:56 +01:00
Add prettier
This commit is contained in:
parent
1ca4a3a0aa
commit
3efc637414
156 changed files with 51562 additions and 37461 deletions
7
.prettierrc
Normal file
7
.prettierrc
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"arrowParens": "always",
|
||||
"singleQuote": true,
|
||||
"trailingComma": "none",
|
||||
"semi": true,
|
||||
"useTabs": true
|
||||
}
|
||||
54
.vscode/launch.json
vendored
54
.vscode/launch.json
vendored
|
|
@ -1,30 +1,28 @@
|
|||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Unit Tests",
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"program": "${workspaceRoot}/node_modules/.bin/tape",
|
||||
"stopOnEntry": false,
|
||||
"args": [
|
||||
"-r",
|
||||
"./test/all.js",
|
||||
// "--grep",
|
||||
// "typescript"
|
||||
],
|
||||
"cwd": "${workspaceRoot}",
|
||||
"preLaunchTask": null,
|
||||
"runtimeExecutable": null,
|
||||
"runtimeArgs": [
|
||||
"--nolazy"
|
||||
],
|
||||
"env": {
|
||||
"NODE_ENV": "development"
|
||||
},
|
||||
"console": "internalConsole",
|
||||
"sourceMaps": false,
|
||||
"outDir": null
|
||||
}
|
||||
]
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Unit Tests",
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"program": "${workspaceRoot}/node_modules/.bin/tape",
|
||||
"stopOnEntry": false,
|
||||
"args": [
|
||||
"-r",
|
||||
"./test/all.js"
|
||||
// "--grep",
|
||||
// "typescript"
|
||||
],
|
||||
"cwd": "${workspaceRoot}",
|
||||
"preLaunchTask": null,
|
||||
"runtimeExecutable": null,
|
||||
"runtimeArgs": ["--nolazy"],
|
||||
"env": {
|
||||
"NODE_ENV": "development"
|
||||
},
|
||||
"console": "internalConsole",
|
||||
"sourceMaps": false,
|
||||
"outDir": null
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
21
README.md
21
README.md
|
|
@ -14,25 +14,26 @@ This npm module is bundled and distributed in the [monaco-editor](https://www.np
|
|||
|
||||
## Dev: cheat sheet
|
||||
|
||||
* initial setup with `npm install .`
|
||||
* compile with `npm run watch`
|
||||
* test with `npm run test`
|
||||
* bundle with `npm run prepublishOnly`
|
||||
- initial setup with `npm install .`
|
||||
- compile with `npm run watch`
|
||||
- test with `npm run test`
|
||||
- bundle with `npm run prepublishOnly`
|
||||
|
||||
## Dev: Adding a new language
|
||||
|
||||
* create `$/src/myLang/myLang.contribution.ts`
|
||||
* create `$/src/myLang/myLang.ts`
|
||||
* create `$/src/myLang/myLang.test.ts`
|
||||
* edit `$/src/monaco.contribution.ts` and register your new language
|
||||
- create `$/src/myLang/myLang.contribution.ts`
|
||||
- create `$/src/myLang/myLang.ts`
|
||||
- create `$/src/myLang/myLang.test.ts`
|
||||
- edit `$/src/monaco.contribution.ts` and register your new language
|
||||
|
||||
```js
|
||||
import './myLang/myLang.contribution';
|
||||
import './myLang/myLang.contribution';
|
||||
```
|
||||
|
||||
## Code of Conduct
|
||||
|
||||
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
|
||||
|
||||
|
||||
## License
|
||||
|
||||
[MIT](https://github.com/Microsoft/monaco-languages/blob/master/LICENSE.md)
|
||||
|
|
|
|||
|
|
@ -4,25 +4,25 @@
|
|||
# https://docs.microsoft.com/azure/devops/pipelines/languages/javascript
|
||||
|
||||
trigger:
|
||||
- master
|
||||
- master
|
||||
|
||||
pool:
|
||||
vmImage: 'ubuntu-latest'
|
||||
|
||||
steps:
|
||||
- task: NodeTool@0
|
||||
inputs:
|
||||
versionSpec: '10.x'
|
||||
displayName: 'Install Node.js'
|
||||
- task: NodeTool@0
|
||||
inputs:
|
||||
versionSpec: '10.x'
|
||||
displayName: 'Install Node.js'
|
||||
|
||||
- script: |
|
||||
npm install
|
||||
displayName: 'npm install'
|
||||
- script: |
|
||||
npm install
|
||||
displayName: 'npm install'
|
||||
|
||||
- script: |
|
||||
npm run compile
|
||||
displayName: 'compile'
|
||||
- script: |
|
||||
npm run compile
|
||||
displayName: 'compile'
|
||||
|
||||
- script: |
|
||||
npm test
|
||||
displayName: 'test'
|
||||
- script: |
|
||||
npm test
|
||||
displayName: 'test'
|
||||
|
|
|
|||
3110
package-lock.json
generated
3110
package-lock.json
generated
File diff suppressed because it is too large
Load diff
69
package.json
69
package.json
|
|
@ -1,32 +1,41 @@
|
|||
{
|
||||
"name": "monaco-languages",
|
||||
"version": "1.10.0",
|
||||
"description": "Bundle of many languages for the Monaco Editor.",
|
||||
"scripts": {
|
||||
"compile": "mrmdir ./release && tsc -p ./src/tsconfig.json && tsc -p ./src/tsconfig.esm.json",
|
||||
"watch": "tsc -p ./src --watch",
|
||||
"watch-esm": "tsc -p ./src/tsconfig.esm.json --watch",
|
||||
"test": "tape -r ./test/all.js",
|
||||
"prepublishOnly": "npm run compile && node ./scripts/bundle"
|
||||
},
|
||||
"author": "Microsoft Corporation",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/Microsoft/monaco-languages"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/Microsoft/monaco-languages/issues"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/tape": "^4.2.34",
|
||||
"glob": "^7.1.6",
|
||||
"jsdom": "^16.4.0",
|
||||
"monaco-editor-core": "0.20.0",
|
||||
"monaco-plugin-helpers": "^1.0.2",
|
||||
"requirejs": "^2.3.6",
|
||||
"tape": "^4.13.2",
|
||||
"terser": "^4.6.6",
|
||||
"typescript": "3.7.5"
|
||||
}
|
||||
"name": "monaco-languages",
|
||||
"version": "1.10.0",
|
||||
"description": "Bundle of many languages for the Monaco Editor.",
|
||||
"scripts": {
|
||||
"compile": "mrmdir ./release && tsc -p ./src/tsconfig.json && tsc -p ./src/tsconfig.esm.json",
|
||||
"watch": "tsc -p ./src --watch",
|
||||
"watch-esm": "tsc -p ./src/tsconfig.esm.json --watch",
|
||||
"test": "tape -r ./test/all.js",
|
||||
"prepublishOnly": "npm run compile && node ./scripts/bundle",
|
||||
"prettier": "prettier --write ."
|
||||
},
|
||||
"author": "Microsoft Corporation",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/Microsoft/monaco-languages"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/Microsoft/monaco-languages/issues"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/tape": "^4.2.34",
|
||||
"glob": "^7.1.6",
|
||||
"husky": "^4.2.5",
|
||||
"jsdom": "^16.4.0",
|
||||
"monaco-editor-core": "0.20.0",
|
||||
"monaco-plugin-helpers": "^1.0.2",
|
||||
"prettier": "^2.1.1",
|
||||
"pretty-quick": "^3.0.0",
|
||||
"requirejs": "^2.3.6",
|
||||
"tape": "^4.13.2",
|
||||
"terser": "^4.6.6",
|
||||
"typescript": "3.7.5"
|
||||
},
|
||||
"husky": {
|
||||
"hooks": {
|
||||
"pre-commit": "pretty-quick --staged"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,35 +22,45 @@ const BUNDLED_FILE_HEADER = [
|
|||
].join('\n');
|
||||
|
||||
bundleOne('monaco.contribution');
|
||||
glob('release/dev/*/*.contribution.js', { cwd: path.dirname(__dirname) }, function (err, files) {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
return;
|
||||
glob(
|
||||
'release/dev/*/*.contribution.js',
|
||||
{ cwd: path.dirname(__dirname) },
|
||||
function (err, files) {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
return;
|
||||
}
|
||||
files.forEach(function (file) {
|
||||
file = file.replace(/\.contribution\.js$/, '');
|
||||
file = file.replace(/release[/\\]dev[/\\]/, '');
|
||||
bundleOne(file);
|
||||
});
|
||||
}
|
||||
files.forEach(function (file) {
|
||||
file = file.replace(/\.contribution\.js$/, '');
|
||||
file = file.replace(/release[/\\]dev[/\\]/, '');
|
||||
bundleOne(file);
|
||||
});
|
||||
});
|
||||
);
|
||||
|
||||
function bundleOne(moduleId, exclude) {
|
||||
requirejs.optimize({
|
||||
baseUrl: 'release/dev/',
|
||||
name: 'vs/basic-languages/' + moduleId,
|
||||
out: 'release/min/' + moduleId + '.js',
|
||||
exclude: exclude,
|
||||
paths: {
|
||||
'vs/basic-languages': REPO_ROOT + '/release/dev'
|
||||
requirejs.optimize(
|
||||
{
|
||||
baseUrl: 'release/dev/',
|
||||
name: 'vs/basic-languages/' + moduleId,
|
||||
out: 'release/min/' + moduleId + '.js',
|
||||
exclude: exclude,
|
||||
paths: {
|
||||
'vs/basic-languages': REPO_ROOT + '/release/dev'
|
||||
},
|
||||
optimize: 'none'
|
||||
},
|
||||
optimize: 'none'
|
||||
}, function (buildResponse) {
|
||||
const filePath = path.join(REPO_ROOT, 'release/min/' + moduleId + '.js');
|
||||
const fileContents = fs.readFileSync(filePath).toString();
|
||||
console.log();
|
||||
console.log(`Minifying ${filePath}...`);
|
||||
const result = terser.minify(fileContents);
|
||||
console.log(`Done.`);
|
||||
fs.writeFileSync(filePath, BUNDLED_FILE_HEADER + result.code);
|
||||
})
|
||||
function (buildResponse) {
|
||||
const filePath = path.join(
|
||||
REPO_ROOT,
|
||||
'release/min/' + moduleId + '.js'
|
||||
);
|
||||
const fileContents = fs.readFileSync(filePath).toString();
|
||||
console.log();
|
||||
console.log(`Minifying ${filePath}...`);
|
||||
const result = terser.minify(fileContents);
|
||||
console.log(`Done.`);
|
||||
fs.writeFileSync(filePath, BUNDLED_FILE_HEADER + result.code);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,8 @@
|
|||
'use strict';
|
||||
|
||||
// Allow for running under nodejs/requirejs in tests
|
||||
const _monaco: typeof monaco = (typeof monaco === 'undefined' ? (<any>self).monaco : monaco);
|
||||
const _monaco: typeof monaco =
|
||||
typeof monaco === 'undefined' ? (<any>self).monaco : monaco;
|
||||
|
||||
interface ILang extends monaco.languages.ILanguageExtensionPoint {
|
||||
loader: () => Promise<ILangImpl>;
|
||||
|
|
@ -16,14 +17,15 @@ interface ILangImpl {
|
|||
language: monaco.languages.IMonarchLanguage;
|
||||
}
|
||||
|
||||
const languageDefinitions: { [languageId: string]: ILang; } = {};
|
||||
const lazyLanguageLoaders: { [languageId: string]: LazyLanguageLoader; } = {};
|
||||
const languageDefinitions: { [languageId: string]: ILang } = {};
|
||||
const lazyLanguageLoaders: { [languageId: string]: LazyLanguageLoader } = {};
|
||||
|
||||
class LazyLanguageLoader {
|
||||
|
||||
public static getOrCreate(languageId: string): LazyLanguageLoader {
|
||||
if (!lazyLanguageLoaders[languageId]) {
|
||||
lazyLanguageLoaders[languageId] = new LazyLanguageLoader(languageId);
|
||||
lazyLanguageLoaders[languageId] = new LazyLanguageLoader(
|
||||
languageId
|
||||
);
|
||||
}
|
||||
return lazyLanguageLoaders[languageId];
|
||||
}
|
||||
|
|
@ -50,7 +52,10 @@ class LazyLanguageLoader {
|
|||
public load(): Promise<ILangImpl> {
|
||||
if (!this._loadingTriggered) {
|
||||
this._loadingTriggered = true;
|
||||
languageDefinitions[this._languageId].loader().then(mod => this._lazyLoadPromiseResolve(mod), err => this._lazyLoadPromiseReject(err));
|
||||
languageDefinitions[this._languageId].loader().then(
|
||||
(mod) => this._lazyLoadPromiseResolve(mod),
|
||||
(err) => this._lazyLoadPromiseReject(err)
|
||||
);
|
||||
}
|
||||
return this._lazyLoadPromise;
|
||||
}
|
||||
|
|
@ -67,9 +72,12 @@ export function registerLanguage(def: ILang): void {
|
|||
_monaco.languages.register(def);
|
||||
|
||||
const lazyLanguageLoader = LazyLanguageLoader.getOrCreate(languageId);
|
||||
_monaco.languages.setMonarchTokensProvider(languageId, lazyLanguageLoader.whenLoaded().then(mod => mod.language));
|
||||
_monaco.languages.setMonarchTokensProvider(
|
||||
languageId,
|
||||
lazyLanguageLoader.whenLoaded().then((mod) => mod.language)
|
||||
);
|
||||
_monaco.languages.onLanguage(languageId, () => {
|
||||
lazyLanguageLoader.load().then(mod => {
|
||||
lazyLanguageLoader.load().then((mod) => {
|
||||
_monaco.languages.setLanguageConfiguration(languageId, mod.conf);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -8,177 +8,201 @@
|
|||
import { testTokenization } from '../test/testRunner';
|
||||
|
||||
testTokenization('abap', [
|
||||
[{
|
||||
line: '* comment',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.abap' }
|
||||
]
|
||||
}],
|
||||
[{
|
||||
line: ' " comment',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 1, type: 'comment.abap' }
|
||||
]
|
||||
}],
|
||||
[{
|
||||
line: 'write hello.',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.abap' },
|
||||
{ startIndex: 5, type: '' },
|
||||
{ startIndex: 6, type: 'identifier.abap' },
|
||||
{ startIndex: 11, type: 'delimiter.abap' }
|
||||
]
|
||||
}],
|
||||
[{
|
||||
line: 'IF 2 = 3.',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.abap' },
|
||||
{ startIndex: 2, type: '' },
|
||||
{ startIndex: 3, type: 'number.abap' },
|
||||
{ startIndex: 4, type: '' },
|
||||
{ startIndex: 5, type: 'operator.abap' },
|
||||
{ startIndex: 6, type: '' },
|
||||
{ startIndex: 7, type: 'number.abap' },
|
||||
{ startIndex: 8, type: 'delimiter.abap' }
|
||||
]
|
||||
}],
|
||||
[{
|
||||
line: '\'hello\'',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'string.abap' },
|
||||
]
|
||||
}],
|
||||
[{
|
||||
line: '|hello|',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'string.abap' },
|
||||
]
|
||||
}],
|
||||
[{
|
||||
line: 'write: hello, world.',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.abap' },
|
||||
{ startIndex: 5, type: 'delimiter.abap' },
|
||||
{ startIndex: 6, type: '' },
|
||||
{ startIndex: 7, type: 'identifier.abap' },
|
||||
{ startIndex: 12, type: 'delimiter.abap' },
|
||||
{ startIndex: 13, type: '' },
|
||||
{ startIndex: 14, type: 'identifier.abap' },
|
||||
{ startIndex: 19, type: 'delimiter.abap' },
|
||||
]
|
||||
}],
|
||||
[{
|
||||
line: 'method_call( param ).',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'identifier.abap' },
|
||||
{ startIndex: 11, type: 'delimiter.parenthesis.abap' },
|
||||
{ startIndex: 12, type: '' },
|
||||
{ startIndex: 13, type: 'identifier.abap' },
|
||||
{ startIndex: 18, type: '' },
|
||||
{ startIndex: 19, type: 'delimiter.parenthesis.abap' },
|
||||
{ startIndex: 20, type: 'delimiter.abap' },
|
||||
]
|
||||
}],
|
||||
[{
|
||||
line: '\'he\'\' llo\'',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'string.abap' },
|
||||
]
|
||||
}],
|
||||
[{
|
||||
line: '|hel\\|lo|',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'string.abap' },
|
||||
]
|
||||
}],
|
||||
[{
|
||||
line: 'FIELD-SYMBOLS <foo>.',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.abap' },
|
||||
{ startIndex: 13, type: '' },
|
||||
{ startIndex: 14, type: 'identifier.abap' },
|
||||
{ startIndex: 19, type: 'delimiter.abap' },
|
||||
]
|
||||
}],
|
||||
[{
|
||||
line: 'IF foo IS NOT INITIAL.',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.abap' },
|
||||
{ startIndex: 2, type: '' },
|
||||
{ startIndex: 3, type: 'identifier.abap' },
|
||||
{ startIndex: 6, type: '' },
|
||||
{ startIndex: 7, type: 'keyword.abap' },
|
||||
{ startIndex: 9, type: '' },
|
||||
{ startIndex: 10, type: 'keyword.abap' },
|
||||
{ startIndex: 13, type: '' },
|
||||
{ startIndex: 14, type: 'keyword.abap' },
|
||||
{ startIndex: 21, type: 'delimiter.abap' },
|
||||
]
|
||||
}],
|
||||
[{
|
||||
line: 'WRITE `moo`.',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.abap' },
|
||||
{ startIndex: 5, type: '' },
|
||||
{ startIndex: 6, type: 'string.abap' },
|
||||
{ startIndex: 11, type: 'delimiter.abap' },
|
||||
]
|
||||
}],
|
||||
[{
|
||||
line: 'FORM foo.',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.abap' },
|
||||
{ startIndex: 4, type: '' },
|
||||
{ startIndex: 5, type: 'identifier.abap' },
|
||||
{ startIndex: 8, type: 'delimiter.abap' },
|
||||
]
|
||||
}],
|
||||
[{
|
||||
line: 'moo = CONV #( 1 ).',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'identifier.abap' },
|
||||
{ startIndex: 3, type: '' },
|
||||
{ startIndex: 4, type: 'operator.abap' },
|
||||
{ startIndex: 5, type: '' },
|
||||
{ startIndex: 6, type: 'keyword.abap' },
|
||||
{ startIndex: 10, type: '' },
|
||||
{ startIndex: 11, type: 'operator.abap' },
|
||||
{ startIndex: 12, type: "delimiter.parenthesis.abap" },
|
||||
{ startIndex: 13, type: "" },
|
||||
{ startIndex: 14, type: "number.abap" },
|
||||
{ startIndex: 15, type: "" },
|
||||
{ startIndex: 16, type: "delimiter.parenthesis.abap" },
|
||||
{ startIndex: 17, type: "delimiter.abap" }
|
||||
]
|
||||
}],
|
||||
[{
|
||||
line: 'WRITE foo ##pragma.',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.abap' },
|
||||
{ startIndex: 5, type: '' },
|
||||
{ startIndex: 6, type: 'identifier.abap' },
|
||||
{ startIndex: 9, type: '' },
|
||||
{ startIndex: 12, type: 'identifier.abap' },
|
||||
{ startIndex: 18, type: 'delimiter.abap' },
|
||||
]
|
||||
}],
|
||||
[{
|
||||
line: 'SELECT * FROM foo02 INTO @foo.',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.abap' },
|
||||
{ startIndex: 6, type: '' },
|
||||
{ startIndex: 7, type: 'operator.abap' },
|
||||
{ startIndex: 8, type: '' },
|
||||
{ startIndex: 9, type: 'keyword.abap' },
|
||||
{ startIndex: 13, type: '' },
|
||||
{ startIndex: 14, type: 'identifier.abap' },
|
||||
{ startIndex: 19, type: '' },
|
||||
{ startIndex: 20, type: 'keyword.abap' },
|
||||
{ startIndex: 24, type: '' },
|
||||
{ startIndex: 25, type: 'operator.abap' },
|
||||
{ startIndex: 26, type: 'identifier.abap' },
|
||||
{ startIndex: 29, type: 'delimiter.abap' },
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '* comment',
|
||||
tokens: [{ startIndex: 0, type: 'comment.abap' }]
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
line: ' " comment',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 1, type: 'comment.abap' }
|
||||
]
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
line: 'write hello.',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.abap' },
|
||||
{ startIndex: 5, type: '' },
|
||||
{ startIndex: 6, type: 'identifier.abap' },
|
||||
{ startIndex: 11, type: 'delimiter.abap' }
|
||||
]
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
line: 'IF 2 = 3.',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.abap' },
|
||||
{ startIndex: 2, type: '' },
|
||||
{ startIndex: 3, type: 'number.abap' },
|
||||
{ startIndex: 4, type: '' },
|
||||
{ startIndex: 5, type: 'operator.abap' },
|
||||
{ startIndex: 6, type: '' },
|
||||
{ startIndex: 7, type: 'number.abap' },
|
||||
{ startIndex: 8, type: 'delimiter.abap' }
|
||||
]
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
line: "'hello'",
|
||||
tokens: [{ startIndex: 0, type: 'string.abap' }]
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
line: '|hello|',
|
||||
tokens: [{ startIndex: 0, type: 'string.abap' }]
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
line: 'write: hello, world.',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.abap' },
|
||||
{ startIndex: 5, type: 'delimiter.abap' },
|
||||
{ startIndex: 6, type: '' },
|
||||
{ startIndex: 7, type: 'identifier.abap' },
|
||||
{ startIndex: 12, type: 'delimiter.abap' },
|
||||
{ startIndex: 13, type: '' },
|
||||
{ startIndex: 14, type: 'identifier.abap' },
|
||||
{ startIndex: 19, type: 'delimiter.abap' }
|
||||
]
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
line: 'method_call( param ).',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'identifier.abap' },
|
||||
{ startIndex: 11, type: 'delimiter.parenthesis.abap' },
|
||||
{ startIndex: 12, type: '' },
|
||||
{ startIndex: 13, type: 'identifier.abap' },
|
||||
{ startIndex: 18, type: '' },
|
||||
{ startIndex: 19, type: 'delimiter.parenthesis.abap' },
|
||||
{ startIndex: 20, type: 'delimiter.abap' }
|
||||
]
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
line: "'he'' llo'",
|
||||
tokens: [{ startIndex: 0, type: 'string.abap' }]
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
line: '|hel\\|lo|',
|
||||
tokens: [{ startIndex: 0, type: 'string.abap' }]
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
line: 'FIELD-SYMBOLS <foo>.',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.abap' },
|
||||
{ startIndex: 13, type: '' },
|
||||
{ startIndex: 14, type: 'identifier.abap' },
|
||||
{ startIndex: 19, type: 'delimiter.abap' }
|
||||
]
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
line: 'IF foo IS NOT INITIAL.',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.abap' },
|
||||
{ startIndex: 2, type: '' },
|
||||
{ startIndex: 3, type: 'identifier.abap' },
|
||||
{ startIndex: 6, type: '' },
|
||||
{ startIndex: 7, type: 'keyword.abap' },
|
||||
{ startIndex: 9, type: '' },
|
||||
{ startIndex: 10, type: 'keyword.abap' },
|
||||
{ startIndex: 13, type: '' },
|
||||
{ startIndex: 14, type: 'keyword.abap' },
|
||||
{ startIndex: 21, type: 'delimiter.abap' }
|
||||
]
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
line: 'WRITE `moo`.',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.abap' },
|
||||
{ startIndex: 5, type: '' },
|
||||
{ startIndex: 6, type: 'string.abap' },
|
||||
{ startIndex: 11, type: 'delimiter.abap' }
|
||||
]
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
line: 'FORM foo.',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.abap' },
|
||||
{ startIndex: 4, type: '' },
|
||||
{ startIndex: 5, type: 'identifier.abap' },
|
||||
{ startIndex: 8, type: 'delimiter.abap' }
|
||||
]
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
line: 'moo = CONV #( 1 ).',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'identifier.abap' },
|
||||
{ startIndex: 3, type: '' },
|
||||
{ startIndex: 4, type: 'operator.abap' },
|
||||
{ startIndex: 5, type: '' },
|
||||
{ startIndex: 6, type: 'keyword.abap' },
|
||||
{ startIndex: 10, type: '' },
|
||||
{ startIndex: 11, type: 'operator.abap' },
|
||||
{ startIndex: 12, type: 'delimiter.parenthesis.abap' },
|
||||
{ startIndex: 13, type: '' },
|
||||
{ startIndex: 14, type: 'number.abap' },
|
||||
{ startIndex: 15, type: '' },
|
||||
{ startIndex: 16, type: 'delimiter.parenthesis.abap' },
|
||||
{ startIndex: 17, type: 'delimiter.abap' }
|
||||
]
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
line: 'WRITE foo ##pragma.',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.abap' },
|
||||
{ startIndex: 5, type: '' },
|
||||
{ startIndex: 6, type: 'identifier.abap' },
|
||||
{ startIndex: 9, type: '' },
|
||||
{ startIndex: 12, type: 'identifier.abap' },
|
||||
{ startIndex: 18, type: 'delimiter.abap' }
|
||||
]
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
line: 'SELECT * FROM foo02 INTO @foo.',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.abap' },
|
||||
{ startIndex: 6, type: '' },
|
||||
{ startIndex: 7, type: 'operator.abap' },
|
||||
{ startIndex: 8, type: '' },
|
||||
{ startIndex: 9, type: 'keyword.abap' },
|
||||
{ startIndex: 13, type: '' },
|
||||
{ startIndex: 14, type: 'identifier.abap' },
|
||||
{ startIndex: 19, type: '' },
|
||||
{ startIndex: 20, type: 'keyword.abap' },
|
||||
{ startIndex: 24, type: '' },
|
||||
{ startIndex: 25, type: 'operator.abap' },
|
||||
{ startIndex: 26, type: 'identifier.abap' },
|
||||
{ startIndex: 29, type: 'delimiter.abap' }
|
||||
]
|
||||
}
|
||||
]
|
||||
]);
|
||||
|
|
|
|||
571
src/abap/abap.ts
571
src/abap/abap.ts
|
|
@ -10,114 +10,533 @@ import ILanguage = monaco.languages.IMonarchLanguage;
|
|||
|
||||
export const conf: IRichLanguageConfiguration = {
|
||||
comments: {
|
||||
lineComment: '*',
|
||||
lineComment: '*'
|
||||
},
|
||||
brackets: [
|
||||
['[', ']'],
|
||||
['(', ')']
|
||||
],
|
||||
]
|
||||
};
|
||||
|
||||
const abapKeywords = [
|
||||
'abstract','add','add-corresponding','adjacent','alias','aliases','all','append','appending','ascending','as','assert','assign','assigned','assigning','association','authority-check',
|
||||
'back','begin','binary','block','bound','break-point','by','byte',
|
||||
'class', 'call','cast','changing','check','class-data','class-method','class-methods','clear','close','cnt','collect','commit','cond','character',
|
||||
'corresponding','communication','component','compute','concatenate','condense','constants','conv','count',
|
||||
'controls','convert','create','currency',
|
||||
'data','descending','default','define','deferred','delete','describe','detail','display','divide','divide-corresponding','display-mode','duplicates',
|
||||
'abstract',
|
||||
'add',
|
||||
'add-corresponding',
|
||||
'adjacent',
|
||||
'alias',
|
||||
'aliases',
|
||||
'all',
|
||||
'append',
|
||||
'appending',
|
||||
'ascending',
|
||||
'as',
|
||||
'assert',
|
||||
'assign',
|
||||
'assigned',
|
||||
'assigning',
|
||||
'association',
|
||||
'authority-check',
|
||||
'back',
|
||||
'begin',
|
||||
'binary',
|
||||
'block',
|
||||
'bound',
|
||||
'break-point',
|
||||
'by',
|
||||
'byte',
|
||||
'class',
|
||||
'call',
|
||||
'cast',
|
||||
'changing',
|
||||
'check',
|
||||
'class-data',
|
||||
'class-method',
|
||||
'class-methods',
|
||||
'clear',
|
||||
'close',
|
||||
'cnt',
|
||||
'collect',
|
||||
'commit',
|
||||
'cond',
|
||||
'character',
|
||||
'corresponding',
|
||||
'communication',
|
||||
'component',
|
||||
'compute',
|
||||
'concatenate',
|
||||
'condense',
|
||||
'constants',
|
||||
'conv',
|
||||
'count',
|
||||
'controls',
|
||||
'convert',
|
||||
'create',
|
||||
'currency',
|
||||
'data',
|
||||
'descending',
|
||||
'default',
|
||||
'define',
|
||||
'deferred',
|
||||
'delete',
|
||||
'describe',
|
||||
'detail',
|
||||
'display',
|
||||
'divide',
|
||||
'divide-corresponding',
|
||||
'display-mode',
|
||||
'duplicates',
|
||||
'deleting',
|
||||
'editor-call','end','endexec','endfunction','ending','endmodule','end-of-definition','end-of-page','end-of-selection','end-test-injection','end-test-seam','exit-command','endclass','endmethod','endform','endinterface',
|
||||
'endprovide','endselect','endtry','endwhile','enum','event','events','exec','exit','export',
|
||||
'exporting','extract','exception','exceptions',
|
||||
'form','field-symbols','field-groups','field','first','fetch','fields','format','frame','free','from','function','find','for','found','function-pool',
|
||||
'generate','get',
|
||||
'handle','hide','hashed',
|
||||
'include','import','importing','index','infotypes','initial','initialization',
|
||||
'id','is','in','interface','interfaces','init','input','insert','instance','into','implemented',
|
||||
'editor-call',
|
||||
'end',
|
||||
'endexec',
|
||||
'endfunction',
|
||||
'ending',
|
||||
'endmodule',
|
||||
'end-of-definition',
|
||||
'end-of-page',
|
||||
'end-of-selection',
|
||||
'end-test-injection',
|
||||
'end-test-seam',
|
||||
'exit-command',
|
||||
'endclass',
|
||||
'endmethod',
|
||||
'endform',
|
||||
'endinterface',
|
||||
'endprovide',
|
||||
'endselect',
|
||||
'endtry',
|
||||
'endwhile',
|
||||
'enum',
|
||||
'event',
|
||||
'events',
|
||||
'exec',
|
||||
'exit',
|
||||
'export',
|
||||
'exporting',
|
||||
'extract',
|
||||
'exception',
|
||||
'exceptions',
|
||||
'form',
|
||||
'field-symbols',
|
||||
'field-groups',
|
||||
'field',
|
||||
'first',
|
||||
'fetch',
|
||||
'fields',
|
||||
'format',
|
||||
'frame',
|
||||
'free',
|
||||
'from',
|
||||
'function',
|
||||
'find',
|
||||
'for',
|
||||
'found',
|
||||
'function-pool',
|
||||
'generate',
|
||||
'get',
|
||||
'handle',
|
||||
'hide',
|
||||
'hashed',
|
||||
'include',
|
||||
'import',
|
||||
'importing',
|
||||
'index',
|
||||
'infotypes',
|
||||
'initial',
|
||||
'initialization',
|
||||
'id',
|
||||
'is',
|
||||
'in',
|
||||
'interface',
|
||||
'interfaces',
|
||||
'init',
|
||||
'input',
|
||||
'insert',
|
||||
'instance',
|
||||
'into',
|
||||
'implemented',
|
||||
'key',
|
||||
'left-justified','leave','like','line','line-count','line-size','load','local','log-point','length','left','leading','lower',
|
||||
'matchcode','method','mesh','message','message-id','methods','modify','module','move','move-corresponding','multiply','multiply-corresponding','match','mode',
|
||||
'not','new','new-line','new-page','new-section','next','no','no-gap','no-gaps','no-sign','no-zero','non-unique','number',
|
||||
'occurrence','object','obligatory','of','output','overlay','optional','others','occurrences','occurs','offset','options',
|
||||
'pack','parameters','perform','places','position','print-control','private','program','protected','provide','public','put','partially',
|
||||
'radiobutton','raising','ranges','receive','receiving','redefinition','reduce','reference','refresh','regex','reject','results','requested',
|
||||
'ref','replace','report','reserve','restore','result','return','returning','right-justified','rollback','read','read-only','rp-provide-from-last','run',
|
||||
'scan','screen','scroll','search','select','select-options','selection-screen','stamp','source','subkey','subscreen',
|
||||
'separated','set','shift','single','skip','sort','sorted','split','standard','stamp','starting','start-of-selection','sum','subtract-corresponding','statics','step','stop','structure','submatches','submit','subtract','summary','supplied','suppress','section','syntax-check','syntax-trace','system-call','switch',
|
||||
'tables','table','task','testing','test-seam','test-injection','then','time','times','title','titlebar','to','top-of-page','trailing','transfer','transformation','translate','transporting','types','type','type-pool','type-pools','tabbed',
|
||||
'unassign','unique','uline','unpack','update','upper','using','user-command',
|
||||
'left-justified',
|
||||
'leave',
|
||||
'like',
|
||||
'line',
|
||||
'line-count',
|
||||
'line-size',
|
||||
'load',
|
||||
'local',
|
||||
'log-point',
|
||||
'length',
|
||||
'left',
|
||||
'leading',
|
||||
'lower',
|
||||
'matchcode',
|
||||
'method',
|
||||
'mesh',
|
||||
'message',
|
||||
'message-id',
|
||||
'methods',
|
||||
'modify',
|
||||
'module',
|
||||
'move',
|
||||
'move-corresponding',
|
||||
'multiply',
|
||||
'multiply-corresponding',
|
||||
'match',
|
||||
'mode',
|
||||
'not',
|
||||
'new',
|
||||
'new-line',
|
||||
'new-page',
|
||||
'new-section',
|
||||
'next',
|
||||
'no',
|
||||
'no-gap',
|
||||
'no-gaps',
|
||||
'no-sign',
|
||||
'no-zero',
|
||||
'non-unique',
|
||||
'number',
|
||||
'occurrence',
|
||||
'object',
|
||||
'obligatory',
|
||||
'of',
|
||||
'output',
|
||||
'overlay',
|
||||
'optional',
|
||||
'others',
|
||||
'occurrences',
|
||||
'occurs',
|
||||
'offset',
|
||||
'options',
|
||||
'pack',
|
||||
'parameters',
|
||||
'perform',
|
||||
'places',
|
||||
'position',
|
||||
'print-control',
|
||||
'private',
|
||||
'program',
|
||||
'protected',
|
||||
'provide',
|
||||
'public',
|
||||
'put',
|
||||
'partially',
|
||||
'radiobutton',
|
||||
'raising',
|
||||
'ranges',
|
||||
'receive',
|
||||
'receiving',
|
||||
'redefinition',
|
||||
'reduce',
|
||||
'reference',
|
||||
'refresh',
|
||||
'regex',
|
||||
'reject',
|
||||
'results',
|
||||
'requested',
|
||||
'ref',
|
||||
'replace',
|
||||
'report',
|
||||
'reserve',
|
||||
'restore',
|
||||
'result',
|
||||
'return',
|
||||
'returning',
|
||||
'right-justified',
|
||||
'rollback',
|
||||
'read',
|
||||
'read-only',
|
||||
'rp-provide-from-last',
|
||||
'run',
|
||||
'scan',
|
||||
'screen',
|
||||
'scroll',
|
||||
'search',
|
||||
'select',
|
||||
'select-options',
|
||||
'selection-screen',
|
||||
'stamp',
|
||||
'source',
|
||||
'subkey',
|
||||
'subscreen',
|
||||
'separated',
|
||||
'set',
|
||||
'shift',
|
||||
'single',
|
||||
'skip',
|
||||
'sort',
|
||||
'sorted',
|
||||
'split',
|
||||
'standard',
|
||||
'stamp',
|
||||
'starting',
|
||||
'start-of-selection',
|
||||
'sum',
|
||||
'subtract-corresponding',
|
||||
'statics',
|
||||
'step',
|
||||
'stop',
|
||||
'structure',
|
||||
'submatches',
|
||||
'submit',
|
||||
'subtract',
|
||||
'summary',
|
||||
'supplied',
|
||||
'suppress',
|
||||
'section',
|
||||
'syntax-check',
|
||||
'syntax-trace',
|
||||
'system-call',
|
||||
'switch',
|
||||
'tables',
|
||||
'table',
|
||||
'task',
|
||||
'testing',
|
||||
'test-seam',
|
||||
'test-injection',
|
||||
'then',
|
||||
'time',
|
||||
'times',
|
||||
'title',
|
||||
'titlebar',
|
||||
'to',
|
||||
'top-of-page',
|
||||
'trailing',
|
||||
'transfer',
|
||||
'transformation',
|
||||
'translate',
|
||||
'transporting',
|
||||
'types',
|
||||
'type',
|
||||
'type-pool',
|
||||
'type-pools',
|
||||
'tabbed',
|
||||
'unassign',
|
||||
'unique',
|
||||
'uline',
|
||||
'unpack',
|
||||
'update',
|
||||
'upper',
|
||||
'using',
|
||||
'user-command',
|
||||
'value',
|
||||
'when','while','window','write','where','with','work',
|
||||
'at','case','catch','continue','do','elseif','else','endat','endcase','enddo','endif','endloop','endon','if','loop','on','raise','try',
|
||||
'when',
|
||||
'while',
|
||||
'window',
|
||||
'write',
|
||||
'where',
|
||||
'with',
|
||||
'work',
|
||||
'at',
|
||||
'case',
|
||||
'catch',
|
||||
'continue',
|
||||
'do',
|
||||
'elseif',
|
||||
'else',
|
||||
'endat',
|
||||
'endcase',
|
||||
'enddo',
|
||||
'endif',
|
||||
'endloop',
|
||||
'endon',
|
||||
'if',
|
||||
'loop',
|
||||
'on',
|
||||
'raise',
|
||||
'try',
|
||||
// built-in:
|
||||
'abs','sign','ceil','floor','trunc','frac','acos','asin','atan','cos','sin','tan','cosh','sinh','tanh','exp','log','log10','sqrt','strlen','xstrlen','charlen','lines','numofchar','dbmaxlen','round','rescale','nmax','nmin','cmax','cmin','boolc','boolx','xsdbool','contains','contains_any_of','contains_any_not_of','matches','line_exists','ipow','char_off','count','count_any_of','count_any_not_of','distance','condense','concat_lines_of','escape','find','find_end','find_any_of','find_any_not_of','insert','match','repeat','replace','reverse','segment','shift_left','shift_right','substring','substring_after','substring_from','substring_before','substring_to','to_upper','to_lower','to_mixed','from_mixed','translate','bit-set','line_index',
|
||||
'definition','implementation','public','inheriting','final'
|
||||
];
|
||||
'abs',
|
||||
'sign',
|
||||
'ceil',
|
||||
'floor',
|
||||
'trunc',
|
||||
'frac',
|
||||
'acos',
|
||||
'asin',
|
||||
'atan',
|
||||
'cos',
|
||||
'sin',
|
||||
'tan',
|
||||
'cosh',
|
||||
'sinh',
|
||||
'tanh',
|
||||
'exp',
|
||||
'log',
|
||||
'log10',
|
||||
'sqrt',
|
||||
'strlen',
|
||||
'xstrlen',
|
||||
'charlen',
|
||||
'lines',
|
||||
'numofchar',
|
||||
'dbmaxlen',
|
||||
'round',
|
||||
'rescale',
|
||||
'nmax',
|
||||
'nmin',
|
||||
'cmax',
|
||||
'cmin',
|
||||
'boolc',
|
||||
'boolx',
|
||||
'xsdbool',
|
||||
'contains',
|
||||
'contains_any_of',
|
||||
'contains_any_not_of',
|
||||
'matches',
|
||||
'line_exists',
|
||||
'ipow',
|
||||
'char_off',
|
||||
'count',
|
||||
'count_any_of',
|
||||
'count_any_not_of',
|
||||
'distance',
|
||||
'condense',
|
||||
'concat_lines_of',
|
||||
'escape',
|
||||
'find',
|
||||
'find_end',
|
||||
'find_any_of',
|
||||
'find_any_not_of',
|
||||
'insert',
|
||||
'match',
|
||||
'repeat',
|
||||
'replace',
|
||||
'reverse',
|
||||
'segment',
|
||||
'shift_left',
|
||||
'shift_right',
|
||||
'substring',
|
||||
'substring_after',
|
||||
'substring_from',
|
||||
'substring_before',
|
||||
'substring_to',
|
||||
'to_upper',
|
||||
'to_lower',
|
||||
'to_mixed',
|
||||
'from_mixed',
|
||||
'translate',
|
||||
'bit-set',
|
||||
'line_index',
|
||||
'definition',
|
||||
'implementation',
|
||||
'public',
|
||||
'inheriting',
|
||||
'final'
|
||||
];
|
||||
|
||||
export const language = <ILanguage> {
|
||||
export const language = <ILanguage>{
|
||||
defaultToken: 'invalid',
|
||||
ignoreCase: true,
|
||||
tokenPostfix: '.abap',
|
||||
keywords: abapKeywords,
|
||||
|
||||
typeKeywords: [
|
||||
'abap_bool','string','xstring','any','clike','csequence','numeric',
|
||||
'xsequence','c','n','i','p','f','d','t','x'
|
||||
'abap_bool',
|
||||
'string',
|
||||
'xstring',
|
||||
'any',
|
||||
'clike',
|
||||
'csequence',
|
||||
'numeric',
|
||||
'xsequence',
|
||||
'c',
|
||||
'n',
|
||||
'i',
|
||||
'p',
|
||||
'f',
|
||||
'd',
|
||||
't',
|
||||
'x'
|
||||
],
|
||||
|
||||
operators: [
|
||||
' +', ' -', '/', '*',
|
||||
'=', ' < ', ' > ', '<=', '>=', '<>', '><', '=<', '=>',
|
||||
'#', '@',
|
||||
'EQ', 'NE', 'GE', 'LE',
|
||||
'CS', 'CN', 'CA', 'CO', 'CP', 'NS', 'NA', 'NP',
|
||||
' +',
|
||||
' -',
|
||||
'/',
|
||||
'*',
|
||||
'=',
|
||||
' < ',
|
||||
' > ',
|
||||
'<=',
|
||||
'>=',
|
||||
'<>',
|
||||
'><',
|
||||
'=<',
|
||||
'=>',
|
||||
'#',
|
||||
'@',
|
||||
'EQ',
|
||||
'NE',
|
||||
'GE',
|
||||
'LE',
|
||||
'CS',
|
||||
'CN',
|
||||
'CA',
|
||||
'CO',
|
||||
'CP',
|
||||
'NS',
|
||||
'NA',
|
||||
'NP'
|
||||
],
|
||||
|
||||
symbols: /[=><!~?&+\-*\/\^%#@]+/,
|
||||
symbols: /[=><!~?&+\-*\/\^%#@]+/,
|
||||
|
||||
tokenizer: {
|
||||
root: [
|
||||
[/[a-z_$][\w-$]*/, { cases: { '@typeKeywords': 'keyword',
|
||||
'@keywords': 'keyword',
|
||||
'@default': 'identifier' } }],
|
||||
root: [
|
||||
[
|
||||
/[a-z_$][\w-$]*/,
|
||||
{
|
||||
cases: {
|
||||
'@typeKeywords': 'keyword',
|
||||
'@keywords': 'keyword',
|
||||
'@default': 'identifier'
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
[/<[\w]+>/, 'identifier'], // field symbols
|
||||
[/<[\w]+>/, 'identifier'], // field symbols
|
||||
|
||||
{ include: '@whitespace' },
|
||||
{ include: '@whitespace' },
|
||||
|
||||
[/[:,.]/, 'delimiter'],
|
||||
[/[:,.]/, 'delimiter'],
|
||||
|
||||
[/[{}()\[\]]/, '@brackets'],
|
||||
[/@symbols/, { cases: { '@operators': 'operator',
|
||||
'@default' : '' } } ],
|
||||
[/[{}()\[\]]/, '@brackets'],
|
||||
[
|
||||
/@symbols/,
|
||||
{ cases: { '@operators': 'operator', '@default': '' } }
|
||||
],
|
||||
|
||||
[/'/, { token: 'string', bracket: '@open', next: '@stringquote' } ],
|
||||
[/`/, { token: 'string', bracket: '@open', next: '@stringping' } ],
|
||||
[/\|/, { token: 'string', bracket: '@open', next: '@stringtemplate' } ],
|
||||
[/'/, { token: 'string', bracket: '@open', next: '@stringquote' }],
|
||||
[/`/, { token: 'string', bracket: '@open', next: '@stringping' }],
|
||||
[
|
||||
/\|/,
|
||||
{ token: 'string', bracket: '@open', next: '@stringtemplate' }
|
||||
],
|
||||
|
||||
[/\d+/, 'number'],
|
||||
],
|
||||
[/\d+/, 'number']
|
||||
],
|
||||
|
||||
stringtemplate: [
|
||||
[/[^\\\|]+/, 'string'],
|
||||
[/\\\|/, 'string'],
|
||||
[/\|/, { token: 'string', bracket: '@close', next: '@pop' } ]
|
||||
],
|
||||
stringtemplate: [
|
||||
[/[^\\\|]+/, 'string'],
|
||||
[/\\\|/, 'string'],
|
||||
[/\|/, { token: 'string', bracket: '@close', next: '@pop' }]
|
||||
],
|
||||
|
||||
stringping: [
|
||||
[/[^\\`]+/, 'string'],
|
||||
[/`/, { token: 'string', bracket: '@close', next: '@pop' } ]
|
||||
],
|
||||
stringping: [
|
||||
[/[^\\`]+/, 'string'],
|
||||
[/`/, { token: 'string', bracket: '@close', next: '@pop' }]
|
||||
],
|
||||
|
||||
stringquote: [
|
||||
[/[^\\']+/, 'string'],
|
||||
[/'/, { token: 'string', bracket: '@close', next: '@pop' } ]
|
||||
],
|
||||
stringquote: [
|
||||
[/[^\\']+/, 'string'],
|
||||
[/'/, { token: 'string', bracket: '@close', next: '@pop' }]
|
||||
],
|
||||
|
||||
whitespace: [
|
||||
[/[ \t\r\n]+/, ''],
|
||||
[/^\*.*$/, 'comment'],
|
||||
[/\".*$/, 'comment'],
|
||||
],
|
||||
},
|
||||
};
|
||||
whitespace: [
|
||||
[/[ \t\r\n]+/, ''],
|
||||
[/^\*.*$/, 'comment'],
|
||||
[/\".*$/, 'comment']
|
||||
]
|
||||
}
|
||||
};
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
139
src/apex/apex.ts
139
src/apex/apex.ts
|
|
@ -13,32 +13,36 @@ export const conf: IRichLanguageConfiguration = {
|
|||
wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g,
|
||||
comments: {
|
||||
lineComment: '//',
|
||||
blockComment: ['/*', '*/'],
|
||||
blockComment: ['/*', '*/']
|
||||
},
|
||||
brackets: [
|
||||
['{', '}'],
|
||||
['[', ']'],
|
||||
['(', ')'],
|
||||
['(', ')']
|
||||
],
|
||||
autoClosingPairs: [
|
||||
{ open: '{', close: '}' },
|
||||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '"', close: '"' },
|
||||
{ open: '\'', close: '\'' },
|
||||
{ open: "'", close: "'" }
|
||||
],
|
||||
surroundingPairs: [
|
||||
{ open: '{', close: '}' },
|
||||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '"', close: '"' },
|
||||
{ open: '\'', close: '\'' },
|
||||
{ open: '<', close: '>' },
|
||||
{ open: "'", close: "'" },
|
||||
{ open: '<', close: '>' }
|
||||
],
|
||||
folding: {
|
||||
markers: {
|
||||
start: new RegExp("^\\s*//\\s*(?:(?:#?region\\b)|(?:<editor-fold\\b))"),
|
||||
end: new RegExp("^\\s*//\\s*(?:(?:#?endregion\\b)|(?:</editor-fold>))")
|
||||
start: new RegExp(
|
||||
'^\\s*//\\s*(?:(?:#?region\\b)|(?:<editor-fold\\b))'
|
||||
),
|
||||
end: new RegExp(
|
||||
'^\\s*//\\s*(?:(?:#?endregion\\b)|(?:</editor-fold>))'
|
||||
)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -189,14 +193,15 @@ const keywords = [
|
|||
|
||||
// create case variations of the keywords - apex is case insensitive, but we can't make the highlighter case insensitive
|
||||
// because we use a heuristic to assume that identifiers starting with an upper case letter are types.
|
||||
const uppercaseFirstLetter = (lowercase: string) => lowercase.charAt(0).toUpperCase() + lowercase.substr(1);
|
||||
const uppercaseFirstLetter = (lowercase: string) =>
|
||||
lowercase.charAt(0).toUpperCase() + lowercase.substr(1);
|
||||
|
||||
let keywordsWithCaseVariations: string[] = [];
|
||||
keywords.forEach(lowercase => {
|
||||
keywords.forEach((lowercase) => {
|
||||
keywordsWithCaseVariations.push(lowercase);
|
||||
keywordsWithCaseVariations.push(lowercase.toUpperCase());
|
||||
keywordsWithCaseVariations.push(uppercaseFirstLetter(lowercase));
|
||||
})
|
||||
});
|
||||
|
||||
export const language = <ILanguage>{
|
||||
defaultToken: '',
|
||||
|
|
@ -205,11 +210,43 @@ export const language = <ILanguage>{
|
|||
keywords: keywordsWithCaseVariations,
|
||||
|
||||
operators: [
|
||||
'=', '>', '<', '!', '~', '?', ':',
|
||||
'==', '<=', '>=', '!=', '&&', '||', '++', '--',
|
||||
'+', '-', '*', '/', '&', '|', '^', '%', '<<',
|
||||
'>>', '>>>', '+=', '-=', '*=', '/=', '&=', '|=',
|
||||
'^=', '%=', '<<=', '>>=', '>>>='
|
||||
'=',
|
||||
'>',
|
||||
'<',
|
||||
'!',
|
||||
'~',
|
||||
'?',
|
||||
':',
|
||||
'==',
|
||||
'<=',
|
||||
'>=',
|
||||
'!=',
|
||||
'&&',
|
||||
'||',
|
||||
'++',
|
||||
'--',
|
||||
'+',
|
||||
'-',
|
||||
'*',
|
||||
'/',
|
||||
'&',
|
||||
'|',
|
||||
'^',
|
||||
'%',
|
||||
'<<',
|
||||
'>>',
|
||||
'>>>',
|
||||
'+=',
|
||||
'-=',
|
||||
'*=',
|
||||
'/=',
|
||||
'&=',
|
||||
'|=',
|
||||
'^=',
|
||||
'%=',
|
||||
'<<=',
|
||||
'>>=',
|
||||
'>>>='
|
||||
],
|
||||
|
||||
// we include these common regular expressions
|
||||
|
|
@ -224,20 +261,26 @@ export const language = <ILanguage>{
|
|||
tokenizer: {
|
||||
root: [
|
||||
// identifiers and keywords
|
||||
[/[a-z_$][\w$]*/, {
|
||||
cases: {
|
||||
'@keywords': { token: 'keyword.$0' },
|
||||
'@default': 'identifier'
|
||||
[
|
||||
/[a-z_$][\w$]*/,
|
||||
{
|
||||
cases: {
|
||||
'@keywords': { token: 'keyword.$0' },
|
||||
'@default': 'identifier'
|
||||
}
|
||||
}
|
||||
}],
|
||||
],
|
||||
|
||||
// assume that identifiers starting with an uppercase letter are types
|
||||
[/[A-Z][\w\$]*/, {
|
||||
cases: {
|
||||
'@keywords': { token: 'keyword.$0' },
|
||||
'@default': 'type.identifier'
|
||||
[
|
||||
/[A-Z][\w\$]*/,
|
||||
{
|
||||
cases: {
|
||||
'@keywords': { token: 'keyword.$0' },
|
||||
'@default': 'type.identifier'
|
||||
}
|
||||
}
|
||||
}],
|
||||
],
|
||||
|
||||
// whitespace
|
||||
{ include: '@whitespace' },
|
||||
|
|
@ -245,19 +288,25 @@ export const language = <ILanguage>{
|
|||
// delimiters and operators
|
||||
[/[{}()\[\]]/, '@brackets'],
|
||||
[/[<>](?!@symbols)/, '@brackets'],
|
||||
[/@symbols/, {
|
||||
cases: {
|
||||
'@operators': 'delimiter',
|
||||
'@default': ''
|
||||
[
|
||||
/@symbols/,
|
||||
{
|
||||
cases: {
|
||||
'@operators': 'delimiter',
|
||||
'@default': ''
|
||||
}
|
||||
}
|
||||
}],
|
||||
],
|
||||
|
||||
// @ annotations.
|
||||
[/@\s*[a-zA-Z_\$][\w\$]*/, 'annotation'],
|
||||
|
||||
// numbers
|
||||
[/(@digits)[eE]([\-+]?(@digits))?[fFdD]?/, 'number.float'],
|
||||
[/(@digits)\.(@digits)([eE][\-+]?(@digits))?[fFdD]?/, 'number.float'],
|
||||
[
|
||||
/(@digits)\.(@digits)([eE][\-+]?(@digits))?[fFdD]?/,
|
||||
'number.float'
|
||||
],
|
||||
[/(@digits)[fFdD]/, 'number.float'],
|
||||
[/(@digits)[lL]?/, 'number'],
|
||||
|
||||
|
|
@ -265,11 +314,10 @@ export const language = <ILanguage>{
|
|||
[/[;,.]/, 'delimiter'],
|
||||
|
||||
// strings
|
||||
[/"([^"\\]|\\.)*$/, 'string.invalid' ], // non-teminated string
|
||||
[/'([^'\\]|\\.)*$/, 'string.invalid' ], // non-teminated string
|
||||
[/"/, 'string', '@string."' ],
|
||||
[/'/, 'string', '@string.\'' ],
|
||||
|
||||
[/"([^"\\]|\\.)*$/, 'string.invalid'], // non-teminated string
|
||||
[/'([^'\\]|\\.)*$/, 'string.invalid'], // non-teminated string
|
||||
[/"/, 'string', '@string."'],
|
||||
[/'/, 'string', "@string.'"],
|
||||
|
||||
// characters
|
||||
[/'[^\\']'/, 'string'],
|
||||
|
|
@ -281,7 +329,7 @@ export const language = <ILanguage>{
|
|||
[/[ \t\r\n]+/, ''],
|
||||
[/\/\*\*(?!\/)/, 'comment.doc', '@apexdoc'],
|
||||
[/\/\*/, 'comment', '@comment'],
|
||||
[/\/\/.*$/, 'comment'],
|
||||
[/\/\/.*$/, 'comment']
|
||||
],
|
||||
|
||||
comment: [
|
||||
|
|
@ -302,9 +350,16 @@ export const language = <ILanguage>{
|
|||
string: [
|
||||
[/[^\\"']+/, 'string'],
|
||||
[/@escapes/, 'string.escape'],
|
||||
[/\\./, 'string.escape.invalid'],
|
||||
[/["']/, { cases: { '$#==$S2' : { token: 'string', next: '@pop' },
|
||||
'@default': 'string' }} ]
|
||||
],
|
||||
},
|
||||
[/\\./, 'string.escape.invalid'],
|
||||
[
|
||||
/["']/,
|
||||
{
|
||||
cases: {
|
||||
'$#==$S2': { token: 'string', next: '@pop' },
|
||||
'@default': 'string'
|
||||
}
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -5,11 +5,17 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
import { testTokenization as actualTestTokenization, ITestItem } from '../test/testRunner';
|
||||
import {
|
||||
testTokenization as actualTestTokenization,
|
||||
ITestItem
|
||||
} from '../test/testRunner';
|
||||
|
||||
function testTokenization(_language: string | string[], tests: ITestItem[][]): void {
|
||||
tests = tests.map(t => {
|
||||
return t.map(t => {
|
||||
function testTokenization(
|
||||
_language: string | string[],
|
||||
tests: ITestItem[][]
|
||||
): void {
|
||||
tests = tests.map((t) => {
|
||||
return t.map((t) => {
|
||||
return {
|
||||
line: t.line.replace(/\n/g, ' '),
|
||||
tokens: t.tokens
|
||||
|
|
@ -21,137 +27,155 @@ function testTokenization(_language: string | string[], tests: ITestItem[][]): v
|
|||
|
||||
testTokenization('azcli', [
|
||||
// Comment single line
|
||||
[{
|
||||
line: '#',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.azcli' }
|
||||
]
|
||||
}],
|
||||
[{
|
||||
line: '# az find -q secret',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.azcli' }
|
||||
]
|
||||
}],
|
||||
[{
|
||||
line: ' # az find -q secret',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.azcli' },
|
||||
{ startIndex: 4, type: 'comment.azcli' }
|
||||
]
|
||||
}],
|
||||
[{
|
||||
line: '#az find -q secret',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.azcli' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '#',
|
||||
tokens: [{ startIndex: 0, type: 'comment.azcli' }]
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
line: '# az find -q secret',
|
||||
tokens: [{ startIndex: 0, type: 'comment.azcli' }]
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
line: ' # az find -q secret',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.azcli' },
|
||||
{ startIndex: 4, type: 'comment.azcli' }
|
||||
]
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
line: '#az find -q secret',
|
||||
tokens: [{ startIndex: 0, type: 'comment.azcli' }]
|
||||
}
|
||||
],
|
||||
|
||||
// Other cases
|
||||
[{
|
||||
line: 'az find -q secret',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.azcli' },
|
||||
{ startIndex: 7, type: 'key.identifier.azcli' },
|
||||
{ startIndex: 11, type: 'string.azcli' }
|
||||
]
|
||||
}],
|
||||
[{
|
||||
line: '',
|
||||
tokens: [
|
||||
]
|
||||
}],
|
||||
[{
|
||||
line: ' ',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.azcli' }
|
||||
]
|
||||
}],
|
||||
[{
|
||||
line: '--assignee',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'key.identifier.azcli' }
|
||||
]
|
||||
}],
|
||||
[{
|
||||
line: ' --service-principal',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.azcli' },
|
||||
{ startIndex: 3, type: 'key.identifier.azcli' }
|
||||
]
|
||||
}],
|
||||
[{
|
||||
line: 'az ad sp create-for-rb --name ServicePrincipalName --password PASSWORD',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.azcli' },
|
||||
{ startIndex: 23, type: 'key.identifier.azcli' },
|
||||
{ startIndex: 31, type: 'string.azcli' },
|
||||
{ startIndex: 52, type: 'key.identifier.azcli' },
|
||||
{ startIndex: 63, type: 'string.azcli' }
|
||||
]
|
||||
}],
|
||||
[{
|
||||
line: '--name!~`\"$%^&*(|\/\.,-=+',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'key.identifier.azcli' }
|
||||
]
|
||||
}],
|
||||
[{
|
||||
line: '--name#some comment',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'key.identifier.azcli' },
|
||||
{ startIndex: 6, type: 'comment.azcli' }
|
||||
]
|
||||
}],
|
||||
[{
|
||||
line: '--query osPro ``````',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'key.identifier.azcli' },
|
||||
{ startIndex: 8, type: 'string.azcli' }
|
||||
]
|
||||
}],
|
||||
[{
|
||||
line: 'az ad sp create-for-rbac',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.azcli' }
|
||||
]
|
||||
}],
|
||||
[{
|
||||
line: '123456789',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.azcli' }
|
||||
]
|
||||
}],
|
||||
[{
|
||||
line: '- abc',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'key.identifier.azcli' },
|
||||
{ startIndex: 2, type: 'string.azcli' }
|
||||
]
|
||||
}],
|
||||
[{
|
||||
line: '- @!$()',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'key.identifier.azcli' },
|
||||
{ startIndex: 2, type: 'string.azcli' }
|
||||
]
|
||||
}],
|
||||
[{
|
||||
line: '""',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.azcli' }
|
||||
]
|
||||
}],
|
||||
[{
|
||||
line: '// some text',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.azcli' }
|
||||
]
|
||||
}],
|
||||
[{
|
||||
line: `'APP_ID'`,
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.azcli' }
|
||||
]
|
||||
}]
|
||||
[
|
||||
{
|
||||
line: 'az find -q secret',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.azcli' },
|
||||
{ startIndex: 7, type: 'key.identifier.azcli' },
|
||||
{ startIndex: 11, type: 'string.azcli' }
|
||||
]
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
line: '',
|
||||
tokens: []
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
line: ' ',
|
||||
tokens: [{ startIndex: 0, type: 'keyword.azcli' }]
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
line: '--assignee',
|
||||
tokens: [{ startIndex: 0, type: 'key.identifier.azcli' }]
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
line: ' --service-principal',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.azcli' },
|
||||
{ startIndex: 3, type: 'key.identifier.azcli' }
|
||||
]
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
line:
|
||||
'az ad sp create-for-rb --name ServicePrincipalName --password PASSWORD',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.azcli' },
|
||||
{ startIndex: 23, type: 'key.identifier.azcli' },
|
||||
{ startIndex: 31, type: 'string.azcli' },
|
||||
{ startIndex: 52, type: 'key.identifier.azcli' },
|
||||
{ startIndex: 63, type: 'string.azcli' }
|
||||
]
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
line: '--name!~`"$%^&*(|/.,-=+',
|
||||
tokens: [{ startIndex: 0, type: 'key.identifier.azcli' }]
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
line: '--name#some comment',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'key.identifier.azcli' },
|
||||
{ startIndex: 6, type: 'comment.azcli' }
|
||||
]
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
line: '--query osPro ``````',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'key.identifier.azcli' },
|
||||
{ startIndex: 8, type: 'string.azcli' }
|
||||
]
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
line: 'az ad sp create-for-rbac',
|
||||
tokens: [{ startIndex: 0, type: 'keyword.azcli' }]
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
line: '123456789',
|
||||
tokens: [{ startIndex: 0, type: 'keyword.azcli' }]
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
line: '- abc',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'key.identifier.azcli' },
|
||||
{ startIndex: 2, type: 'string.azcli' }
|
||||
]
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
line: '- @!$()',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'key.identifier.azcli' },
|
||||
{ startIndex: 2, type: 'string.azcli' }
|
||||
]
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
line: '""',
|
||||
tokens: [{ startIndex: 0, type: 'keyword.azcli' }]
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
line: '// some text',
|
||||
tokens: [{ startIndex: 0, type: 'keyword.azcli' }]
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
line: `'APP_ID'`,
|
||||
tokens: [{ startIndex: 0, type: 'keyword.azcli' }]
|
||||
}
|
||||
]
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import ILanguage = monaco.languages.IMonarchLanguage;
|
|||
|
||||
export const conf: IRichLanguageConfiguration = {
|
||||
comments: {
|
||||
lineComment: '#',
|
||||
lineComment: '#'
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -23,43 +23,58 @@ export const language = <ILanguage>{
|
|||
|
||||
tokenizer: {
|
||||
root: [
|
||||
{include: '@comment'},
|
||||
[/\s-+@str*\s*/, {
|
||||
cases: {
|
||||
'@eos': { token: 'key.identifier', next: '@popall' },
|
||||
'@default': { token: 'key.identifier', next: '@type' }
|
||||
{ include: '@comment' },
|
||||
[
|
||||
/\s-+@str*\s*/,
|
||||
{
|
||||
cases: {
|
||||
'@eos': { token: 'key.identifier', next: '@popall' },
|
||||
'@default': { token: 'key.identifier', next: '@type' }
|
||||
}
|
||||
}
|
||||
}],
|
||||
[/^-+@str*\s*/, {
|
||||
cases: {
|
||||
'@eos': { token: 'key.identifier', next: '@popall' },
|
||||
'@default': { token: 'key.identifier', next: '@type' }
|
||||
],
|
||||
[
|
||||
/^-+@str*\s*/,
|
||||
{
|
||||
cases: {
|
||||
'@eos': { token: 'key.identifier', next: '@popall' },
|
||||
'@default': { token: 'key.identifier', next: '@type' }
|
||||
}
|
||||
}
|
||||
}]
|
||||
]
|
||||
],
|
||||
|
||||
type: [
|
||||
{include: '@comment'},
|
||||
[/-+@str*\s*/, {
|
||||
cases: {
|
||||
'@eos': { token: 'key.identifier', next: '@popall' },
|
||||
'@default': 'key.identifier'
|
||||
{ include: '@comment' },
|
||||
[
|
||||
/-+@str*\s*/,
|
||||
{
|
||||
cases: {
|
||||
'@eos': { token: 'key.identifier', next: '@popall' },
|
||||
'@default': 'key.identifier'
|
||||
}
|
||||
}
|
||||
}],
|
||||
[/@str+\s*/, {
|
||||
cases: {
|
||||
'@eos': { token: 'string', next: '@popall' },
|
||||
'@default': 'string'
|
||||
}
|
||||
}]
|
||||
],
|
||||
[
|
||||
/@str+\s*/,
|
||||
{
|
||||
cases: {
|
||||
'@eos': { token: 'string', next: '@popall' },
|
||||
'@default': 'string'
|
||||
}
|
||||
}
|
||||
]
|
||||
],
|
||||
|
||||
comment: [
|
||||
[/#.*$/, {
|
||||
cases: {
|
||||
'@eos': { token: 'comment', next: '@popall' }
|
||||
[
|
||||
/#.*$/,
|
||||
{
|
||||
cases: {
|
||||
'@eos': { token: 'comment', next: '@popall' }
|
||||
}
|
||||
}
|
||||
}]
|
||||
]
|
||||
]
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -8,377 +8,391 @@ import { testTokenization } from '../test/testRunner';
|
|||
|
||||
testTokenization('bat', [
|
||||
// Keywords
|
||||
[{
|
||||
line: '@echo off title Selfhost',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.bat' },
|
||||
{ startIndex: 1, type: 'keyword.echo.bat' },
|
||||
{ startIndex: 5, type: '' },
|
||||
{ startIndex: 10, type: 'keyword.title.bat' },
|
||||
{ startIndex: 15, type: '' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '@echo off title Selfhost',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.bat' },
|
||||
{ startIndex: 1, type: 'keyword.echo.bat' },
|
||||
{ startIndex: 5, type: '' },
|
||||
{ startIndex: 10, type: 'keyword.title.bat' },
|
||||
{ startIndex: 15, type: '' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// Comments - single line
|
||||
[{
|
||||
line: 'REM',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.bat' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'REM',
|
||||
tokens: [{ startIndex: 0, type: 'comment.bat' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: ' REM a comment',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 4, type: 'comment.bat' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: ' REM a comment',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 4, type: 'comment.bat' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: 'REM a comment',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.bat' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'REM a comment',
|
||||
tokens: [{ startIndex: 0, type: 'comment.bat' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: 'REMnot a comment',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'REMnot a comment',
|
||||
tokens: [{ startIndex: 0, type: '' }]
|
||||
}
|
||||
],
|
||||
|
||||
// number
|
||||
[{
|
||||
line: '0',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.bat' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '0',
|
||||
tokens: [{ startIndex: 0, type: 'number.bat' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '0.0',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.float.bat' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '0.0',
|
||||
tokens: [{ startIndex: 0, type: 'number.float.bat' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '0x123',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.hex.bat' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '0x123',
|
||||
tokens: [{ startIndex: 0, type: 'number.hex.bat' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '23.5',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.float.bat' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '23.5',
|
||||
tokens: [{ startIndex: 0, type: 'number.float.bat' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '23.5e3',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.float.bat' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '23.5e3',
|
||||
tokens: [{ startIndex: 0, type: 'number.float.bat' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '23.5E3',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.float.bat' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '23.5E3',
|
||||
tokens: [{ startIndex: 0, type: 'number.float.bat' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '1.72e-3',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.float.bat' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '1.72e-3',
|
||||
tokens: [{ startIndex: 0, type: 'number.float.bat' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '0+0',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.bat' },
|
||||
{ startIndex: 1, type: 'delimiter.bat' },
|
||||
{ startIndex: 2, type: 'number.bat' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '0+0',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.bat' },
|
||||
{ startIndex: 1, type: 'delimiter.bat' },
|
||||
{ startIndex: 2, type: 'number.bat' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '100+10',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.bat' },
|
||||
{ startIndex: 3, type: 'delimiter.bat' },
|
||||
{ startIndex: 4, type: 'number.bat' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '100+10',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.bat' },
|
||||
{ startIndex: 3, type: 'delimiter.bat' },
|
||||
{ startIndex: 4, type: 'number.bat' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '0 + 0',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.bat' },
|
||||
{ startIndex: 1, type: '' },
|
||||
{ startIndex: 2, type: 'delimiter.bat' },
|
||||
{ startIndex: 3, type: '' },
|
||||
{ startIndex: 4, type: 'number.bat' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '0 + 0',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.bat' },
|
||||
{ startIndex: 1, type: '' },
|
||||
{ startIndex: 2, type: 'delimiter.bat' },
|
||||
{ startIndex: 3, type: '' },
|
||||
{ startIndex: 4, type: 'number.bat' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// Strings
|
||||
[{
|
||||
line: 'set s = "string"',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.set.bat' },
|
||||
{ startIndex: 3, type: '' },
|
||||
{ startIndex: 6, type: 'delimiter.bat' },
|
||||
{ startIndex: 7, type: '' },
|
||||
{ startIndex: 8, type: 'string.bat' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'set s = "string"',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.set.bat' },
|
||||
{ startIndex: 3, type: '' },
|
||||
{ startIndex: 6, type: 'delimiter.bat' },
|
||||
{ startIndex: 7, type: '' },
|
||||
{ startIndex: 8, type: 'string.bat' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '"use strict";',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'string.bat' },
|
||||
{ startIndex: 12, type: 'delimiter.bat' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '"use strict";',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'string.bat' },
|
||||
{ startIndex: 12, type: 'delimiter.bat' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// Tags
|
||||
[{
|
||||
line: 'setlocal endlocal',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.tag-setlocal.bat' },
|
||||
{ startIndex: 8, type: '' },
|
||||
{ startIndex: 9, type: 'keyword.tag-setlocal.bat' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'setlocal endlocal',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.tag-setlocal.bat' },
|
||||
{ startIndex: 8, type: '' },
|
||||
{ startIndex: 9, type: 'keyword.tag-setlocal.bat' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: 'setlocal ENDLOCAL',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.tag-setlocal.bat' },
|
||||
{ startIndex: 8, type: '' },
|
||||
{ startIndex: 9, type: 'keyword.tag-setlocal.bat' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'setlocal ENDLOCAL',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.tag-setlocal.bat' },
|
||||
{ startIndex: 8, type: '' },
|
||||
{ startIndex: 9, type: 'keyword.tag-setlocal.bat' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: 'SETLOCAL endlocal',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.tag-setlocal.bat' },
|
||||
{ startIndex: 8, type: '' },
|
||||
{ startIndex: 9, type: 'keyword.tag-setlocal.bat' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'SETLOCAL endlocal',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.tag-setlocal.bat' },
|
||||
{ startIndex: 8, type: '' },
|
||||
{ startIndex: 9, type: 'keyword.tag-setlocal.bat' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: 'setlocal setlocal endlocal',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.tag-setlocal.bat' },
|
||||
{ startIndex: 8, type: '' },
|
||||
{ startIndex: 9, type: 'keyword.tag-setlocal.bat' },
|
||||
{ startIndex: 17, type: '' },
|
||||
{ startIndex: 18, type: 'keyword.tag-setlocal.bat' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'setlocal setlocal endlocal',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.tag-setlocal.bat' },
|
||||
{ startIndex: 8, type: '' },
|
||||
{ startIndex: 9, type: 'keyword.tag-setlocal.bat' },
|
||||
{ startIndex: 17, type: '' },
|
||||
{ startIndex: 18, type: 'keyword.tag-setlocal.bat' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// Monarch generated
|
||||
[{
|
||||
line: 'rem asdf',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.bat' }
|
||||
]
|
||||
}, {
|
||||
line: '',
|
||||
tokens: [
|
||||
|
||||
]
|
||||
}, {
|
||||
line: 'REM',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.bat' }
|
||||
]
|
||||
}, {
|
||||
line: '',
|
||||
tokens: [
|
||||
|
||||
]
|
||||
}, {
|
||||
line: 'REMOVED not a comment really',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 8, type: 'keyword.not.bat' },
|
||||
{ startIndex: 11, type: '' }
|
||||
]
|
||||
}, {
|
||||
line: '',
|
||||
tokens: [
|
||||
|
||||
]
|
||||
}, {
|
||||
line: 'echo cool',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.echo.bat' },
|
||||
{ startIndex: 4, type: '' }
|
||||
]
|
||||
}, {
|
||||
line: '@echo off',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.bat' },
|
||||
{ startIndex: 1, type: 'keyword.echo.bat' },
|
||||
{ startIndex: 5, type: '' }
|
||||
]
|
||||
}, {
|
||||
line: '',
|
||||
tokens: [
|
||||
|
||||
]
|
||||
}, {
|
||||
line: 'setlocAL',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.tag-setlocal.bat' }
|
||||
]
|
||||
}, {
|
||||
line: ' asdf',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' }
|
||||
]
|
||||
}, {
|
||||
line: ' asdf',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' }
|
||||
]
|
||||
}, {
|
||||
line: 'endLocaL',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.tag-setlocal.bat' }
|
||||
]
|
||||
}, {
|
||||
line: '',
|
||||
tokens: [
|
||||
|
||||
]
|
||||
}, {
|
||||
line: 'call',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.call.bat' }
|
||||
]
|
||||
}, {
|
||||
line: '',
|
||||
tokens: [
|
||||
|
||||
]
|
||||
}, {
|
||||
line: ':MyLabel',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'metatag.bat' }
|
||||
]
|
||||
}, {
|
||||
line: 'some command',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' }
|
||||
]
|
||||
}, {
|
||||
line: '',
|
||||
tokens: [
|
||||
|
||||
]
|
||||
}, {
|
||||
line: '%sdfsdf% ',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'variable.bat' },
|
||||
{ startIndex: 8, type: '' }
|
||||
]
|
||||
}, {
|
||||
line: '',
|
||||
tokens: [
|
||||
|
||||
]
|
||||
}, {
|
||||
line: 'this is "a string %sdf% asdf"',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 8, type: 'string.bat' },
|
||||
{ startIndex: 18, type: 'variable.bat' },
|
||||
{ startIndex: 23, type: 'string.bat' }
|
||||
]
|
||||
}, {
|
||||
line: '',
|
||||
tokens: [
|
||||
|
||||
]
|
||||
}, {
|
||||
line: '',
|
||||
tokens: [
|
||||
|
||||
]
|
||||
}, {
|
||||
line: 'FOR %%A IN (1 2 3) DO (',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.for.bat' },
|
||||
{ startIndex: 3, type: '' },
|
||||
{ startIndex: 4, type: 'variable.bat' },
|
||||
{ startIndex: 7, type: '' },
|
||||
{ startIndex: 11, type: 'delimiter.parenthesis.bat' },
|
||||
{ startIndex: 12, type: 'number.bat' },
|
||||
{ startIndex: 13, type: '' },
|
||||
{ startIndex: 14, type: 'number.bat' },
|
||||
{ startIndex: 15, type: '' },
|
||||
{ startIndex: 16, type: 'number.bat' },
|
||||
{ startIndex: 17, type: 'delimiter.parenthesis.bat' },
|
||||
{ startIndex: 18, type: '' },
|
||||
{ startIndex: 22, type: 'delimiter.parenthesis.bat' }
|
||||
]
|
||||
}, {
|
||||
line: ' SET VAR1=%VAR1%%%A',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 1, type: 'keyword.set.bat' },
|
||||
{ startIndex: 4, type: '' },
|
||||
{ startIndex: 9, type: 'delimiter.bat' },
|
||||
{ startIndex: 10, type: 'variable.bat' }
|
||||
]
|
||||
}, {
|
||||
line: ' SET VAR2=%VAR2%%%A',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 1, type: 'keyword.set.bat' },
|
||||
{ startIndex: 4, type: '' },
|
||||
{ startIndex: 9, type: 'delimiter.bat' },
|
||||
{ startIndex: 10, type: 'variable.bat' }
|
||||
]
|
||||
}, {
|
||||
line: ' use \'string %%a asdf asdf\'',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 5, type: 'string.bat' },
|
||||
{ startIndex: 13, type: 'variable.bat' },
|
||||
{ startIndex: 16, type: 'string.bat' }
|
||||
]
|
||||
}, {
|
||||
line: ' non terminated "string %%aaa sdf',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 16, type: 'string.bat' },
|
||||
{ startIndex: 24, type: 'variable.bat' },
|
||||
{ startIndex: 29, type: 'string.bat' }
|
||||
]
|
||||
}, {
|
||||
line: ' this shold NOT BE red',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 12, type: 'keyword.not.bat' },
|
||||
{ startIndex: 15, type: '' }
|
||||
]
|
||||
}, {
|
||||
line: ')',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'delimiter.parenthesis.bat' }
|
||||
]
|
||||
}]
|
||||
[
|
||||
{
|
||||
line: 'rem asdf',
|
||||
tokens: [{ startIndex: 0, type: 'comment.bat' }]
|
||||
},
|
||||
{
|
||||
line: '',
|
||||
tokens: []
|
||||
},
|
||||
{
|
||||
line: 'REM',
|
||||
tokens: [{ startIndex: 0, type: 'comment.bat' }]
|
||||
},
|
||||
{
|
||||
line: '',
|
||||
tokens: []
|
||||
},
|
||||
{
|
||||
line: 'REMOVED not a comment really',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 8, type: 'keyword.not.bat' },
|
||||
{ startIndex: 11, type: '' }
|
||||
]
|
||||
},
|
||||
{
|
||||
line: '',
|
||||
tokens: []
|
||||
},
|
||||
{
|
||||
line: 'echo cool',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.echo.bat' },
|
||||
{ startIndex: 4, type: '' }
|
||||
]
|
||||
},
|
||||
{
|
||||
line: '@echo off',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.bat' },
|
||||
{ startIndex: 1, type: 'keyword.echo.bat' },
|
||||
{ startIndex: 5, type: '' }
|
||||
]
|
||||
},
|
||||
{
|
||||
line: '',
|
||||
tokens: []
|
||||
},
|
||||
{
|
||||
line: 'setlocAL',
|
||||
tokens: [{ startIndex: 0, type: 'keyword.tag-setlocal.bat' }]
|
||||
},
|
||||
{
|
||||
line: ' asdf',
|
||||
tokens: [{ startIndex: 0, type: '' }]
|
||||
},
|
||||
{
|
||||
line: ' asdf',
|
||||
tokens: [{ startIndex: 0, type: '' }]
|
||||
},
|
||||
{
|
||||
line: 'endLocaL',
|
||||
tokens: [{ startIndex: 0, type: 'keyword.tag-setlocal.bat' }]
|
||||
},
|
||||
{
|
||||
line: '',
|
||||
tokens: []
|
||||
},
|
||||
{
|
||||
line: 'call',
|
||||
tokens: [{ startIndex: 0, type: 'keyword.call.bat' }]
|
||||
},
|
||||
{
|
||||
line: '',
|
||||
tokens: []
|
||||
},
|
||||
{
|
||||
line: ':MyLabel',
|
||||
tokens: [{ startIndex: 0, type: 'metatag.bat' }]
|
||||
},
|
||||
{
|
||||
line: 'some command',
|
||||
tokens: [{ startIndex: 0, type: '' }]
|
||||
},
|
||||
{
|
||||
line: '',
|
||||
tokens: []
|
||||
},
|
||||
{
|
||||
line: '%sdfsdf% ',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'variable.bat' },
|
||||
{ startIndex: 8, type: '' }
|
||||
]
|
||||
},
|
||||
{
|
||||
line: '',
|
||||
tokens: []
|
||||
},
|
||||
{
|
||||
line: 'this is "a string %sdf% asdf"',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 8, type: 'string.bat' },
|
||||
{ startIndex: 18, type: 'variable.bat' },
|
||||
{ startIndex: 23, type: 'string.bat' }
|
||||
]
|
||||
},
|
||||
{
|
||||
line: '',
|
||||
tokens: []
|
||||
},
|
||||
{
|
||||
line: '',
|
||||
tokens: []
|
||||
},
|
||||
{
|
||||
line: 'FOR %%A IN (1 2 3) DO (',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.for.bat' },
|
||||
{ startIndex: 3, type: '' },
|
||||
{ startIndex: 4, type: 'variable.bat' },
|
||||
{ startIndex: 7, type: '' },
|
||||
{ startIndex: 11, type: 'delimiter.parenthesis.bat' },
|
||||
{ startIndex: 12, type: 'number.bat' },
|
||||
{ startIndex: 13, type: '' },
|
||||
{ startIndex: 14, type: 'number.bat' },
|
||||
{ startIndex: 15, type: '' },
|
||||
{ startIndex: 16, type: 'number.bat' },
|
||||
{ startIndex: 17, type: 'delimiter.parenthesis.bat' },
|
||||
{ startIndex: 18, type: '' },
|
||||
{ startIndex: 22, type: 'delimiter.parenthesis.bat' }
|
||||
]
|
||||
},
|
||||
{
|
||||
line: ' SET VAR1=%VAR1%%%A',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 1, type: 'keyword.set.bat' },
|
||||
{ startIndex: 4, type: '' },
|
||||
{ startIndex: 9, type: 'delimiter.bat' },
|
||||
{ startIndex: 10, type: 'variable.bat' }
|
||||
]
|
||||
},
|
||||
{
|
||||
line: ' SET VAR2=%VAR2%%%A',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 1, type: 'keyword.set.bat' },
|
||||
{ startIndex: 4, type: '' },
|
||||
{ startIndex: 9, type: 'delimiter.bat' },
|
||||
{ startIndex: 10, type: 'variable.bat' }
|
||||
]
|
||||
},
|
||||
{
|
||||
line: " use 'string %%a asdf asdf'",
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 5, type: 'string.bat' },
|
||||
{ startIndex: 13, type: 'variable.bat' },
|
||||
{ startIndex: 16, type: 'string.bat' }
|
||||
]
|
||||
},
|
||||
{
|
||||
line: ' non terminated "string %%aaa sdf',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 16, type: 'string.bat' },
|
||||
{ startIndex: 24, type: 'variable.bat' },
|
||||
{ startIndex: 29, type: 'string.bat' }
|
||||
]
|
||||
},
|
||||
{
|
||||
line: ' this shold NOT BE red',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 12, type: 'keyword.not.bat' },
|
||||
{ startIndex: 15, type: '' }
|
||||
]
|
||||
},
|
||||
{
|
||||
line: ')',
|
||||
tokens: [{ startIndex: 0, type: 'delimiter.parenthesis.bat' }]
|
||||
}
|
||||
]
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -21,17 +21,17 @@ export const conf: IRichLanguageConfiguration = {
|
|||
{ open: '{', close: '}' },
|
||||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '"', close: '"' },
|
||||
{ open: '"', close: '"' }
|
||||
],
|
||||
surroundingPairs: [
|
||||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '"', close: '"' },
|
||||
{ open: '"', close: '"' }
|
||||
],
|
||||
folding: {
|
||||
markers: {
|
||||
start: new RegExp("^\\s*(::\\s*|REM\\s+)#region"),
|
||||
end: new RegExp("^\\s*(::\\s*|REM\\s+)#endregion")
|
||||
start: new RegExp('^\\s*(::\\s*|REM\\s+)#region'),
|
||||
end: new RegExp('^\\s*(::\\s*|REM\\s+)#endregion')
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -56,10 +56,12 @@ export const language = <ILanguage>{
|
|||
// The main tokenizer for our languages
|
||||
tokenizer: {
|
||||
root: [
|
||||
|
||||
[/^(\s*)(rem(?:\s.*|))$/, ['', 'comment']],
|
||||
|
||||
[/(\@?)(@keywords)(?!\w)/, [{ token: 'keyword' }, { token: 'keyword.$2' }]],
|
||||
[
|
||||
/(\@?)(@keywords)(?!\w)/,
|
||||
[{ token: 'keyword' }, { token: 'keyword.$2' }]
|
||||
],
|
||||
|
||||
// whitespace
|
||||
[/[ \t\r\n]+/, ''],
|
||||
|
|
@ -92,28 +94,33 @@ export const language = <ILanguage>{
|
|||
|
||||
// strings:
|
||||
[/"/, 'string', '@string."'],
|
||||
[/'/, 'string', '@string.\''],
|
||||
[/'/, 'string', "@string.'"]
|
||||
],
|
||||
|
||||
string: [
|
||||
[/[^\\"'%]+/, {
|
||||
cases: {
|
||||
'@eos': { token: 'string', next: '@popall' },
|
||||
'@default': 'string'
|
||||
[
|
||||
/[^\\"'%]+/,
|
||||
{
|
||||
cases: {
|
||||
'@eos': { token: 'string', next: '@popall' },
|
||||
'@default': 'string'
|
||||
}
|
||||
}
|
||||
}],
|
||||
],
|
||||
[/@escapes/, 'string.escape'],
|
||||
[/\\./, 'string.escape.invalid'],
|
||||
[/%[\w ]+%/, 'variable'],
|
||||
[/%%[\w]+(?!\w)/, 'variable'],
|
||||
[/["']/, {
|
||||
cases: {
|
||||
'$#==$S2': { token: 'string', next: '@pop' },
|
||||
'@default': 'string'
|
||||
[
|
||||
/["']/,
|
||||
{
|
||||
cases: {
|
||||
'$#==$S2': { token: 'string', next: '@pop' },
|
||||
'@default': 'string'
|
||||
}
|
||||
}
|
||||
}],
|
||||
],
|
||||
[/$/, 'string', '@popall']
|
||||
],
|
||||
|
||||
]
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -8,133 +8,139 @@
|
|||
import { testTokenization } from '../test/testRunner';
|
||||
|
||||
testTokenization('cameligo', [
|
||||
|
||||
// Comments - single line
|
||||
[{
|
||||
line: '//',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.cameligo' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '//',
|
||||
tokens: [{ startIndex: 0, type: 'comment.cameligo' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: ' // a comment',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'white.cameligo' },
|
||||
{ startIndex: 4, type: 'comment.cameligo' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: ' // a comment',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'white.cameligo' },
|
||||
{ startIndex: 4, type: 'comment.cameligo' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '// a comment',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.cameligo' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '// a comment',
|
||||
tokens: [{ startIndex: 0, type: 'comment.cameligo' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '//sticky comment',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.cameligo' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '//sticky comment',
|
||||
tokens: [{ startIndex: 0, type: 'comment.cameligo' }]
|
||||
}
|
||||
],
|
||||
|
||||
// Comments - multi line (single line)
|
||||
[{
|
||||
line: '(**)',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.cameligo' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '(**)',
|
||||
tokens: [{ startIndex: 0, type: 'comment.cameligo' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: ' (* a comment *)',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'white.cameligo' },
|
||||
{ startIndex: 4, type: 'comment.cameligo' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: ' (* a comment *)',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'white.cameligo' },
|
||||
{ startIndex: 4, type: 'comment.cameligo' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '(* a comment *)',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.cameligo' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '(* a comment *)',
|
||||
tokens: [{ startIndex: 0, type: 'comment.cameligo' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '(*sticky comment*)',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.cameligo' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '(*sticky comment*)',
|
||||
tokens: [{ startIndex: 0, type: 'comment.cameligo' }]
|
||||
}
|
||||
],
|
||||
|
||||
// Comments - multi line (multi line)
|
||||
[{
|
||||
line: '(* start of multiline comment ',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.cameligo' }
|
||||
]
|
||||
}, {
|
||||
line: 'a comment between curly',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.cameligo'}
|
||||
]
|
||||
}, {
|
||||
line: 'end of multiline comment*)',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.cameligo'}
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '(* start of multiline comment ',
|
||||
tokens: [{ startIndex: 0, type: 'comment.cameligo' }]
|
||||
},
|
||||
{
|
||||
line: 'a comment between curly',
|
||||
tokens: [{ startIndex: 0, type: 'comment.cameligo' }]
|
||||
},
|
||||
{
|
||||
line: 'end of multiline comment*)',
|
||||
tokens: [{ startIndex: 0, type: 'comment.cameligo' }]
|
||||
}
|
||||
],
|
||||
|
||||
// Keywords
|
||||
[{
|
||||
line: 'let check if Current.amount',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.let.cameligo'},
|
||||
{ startIndex: 3, type: 'white.cameligo'},
|
||||
{ startIndex: 4, type: 'identifier.cameligo'},
|
||||
{ startIndex: 9, type: 'white.cameligo'},
|
||||
{ startIndex: 10, type: 'keyword.if.cameligo'},
|
||||
{ startIndex: 12, type: 'white.cameligo'},
|
||||
{ startIndex: 13, type: 'keyword.current.cameligo'},
|
||||
{ startIndex: 20, type: 'delimiter.cameligo'},
|
||||
{ startIndex: 21, type: 'identifier.cameligo'},
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'let check if Current.amount',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.let.cameligo' },
|
||||
{ startIndex: 3, type: 'white.cameligo' },
|
||||
{ startIndex: 4, type: 'identifier.cameligo' },
|
||||
{ startIndex: 9, type: 'white.cameligo' },
|
||||
{ startIndex: 10, type: 'keyword.if.cameligo' },
|
||||
{ startIndex: 12, type: 'white.cameligo' },
|
||||
{ startIndex: 13, type: 'keyword.current.cameligo' },
|
||||
{ startIndex: 20, type: 'delimiter.cameligo' },
|
||||
{ startIndex: 21, type: 'identifier.cameligo' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// Numbers
|
||||
[{
|
||||
line: '0',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.cameligo'}
|
||||
]
|
||||
}],
|
||||
[{
|
||||
line: '0;',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.cameligo'},
|
||||
{ startIndex: 1, type: 'delimiter.cameligo'}
|
||||
]
|
||||
}],
|
||||
[{
|
||||
line: '2.4',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.float.cameligo'}
|
||||
]
|
||||
}],
|
||||
[{
|
||||
line: '2.4;',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.float.cameligo'},
|
||||
{ startIndex: 3, type: 'delimiter.cameligo'}
|
||||
]
|
||||
}],
|
||||
[{
|
||||
line: '$123FF',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.hex.cameligo'}
|
||||
]
|
||||
}]
|
||||
|
||||
[
|
||||
{
|
||||
line: '0',
|
||||
tokens: [{ startIndex: 0, type: 'number.cameligo' }]
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
line: '0;',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.cameligo' },
|
||||
{ startIndex: 1, type: 'delimiter.cameligo' }
|
||||
]
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
line: '2.4',
|
||||
tokens: [{ startIndex: 0, type: 'number.float.cameligo' }]
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
line: '2.4;',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.float.cameligo' },
|
||||
{ startIndex: 3, type: 'delimiter.cameligo' }
|
||||
]
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
line: '$123FF',
|
||||
tokens: [{ startIndex: 0, type: 'number.hex.cameligo' }]
|
||||
}
|
||||
]
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -11,27 +11,27 @@ import ILanguage = monaco.languages.IMonarchLanguage;
|
|||
export const conf: IRichLanguageConfiguration = {
|
||||
comments: {
|
||||
lineComment: '//',
|
||||
blockComment: ['(*', '*)'],
|
||||
blockComment: ['(*', '*)']
|
||||
},
|
||||
brackets: [
|
||||
['{', '}'],
|
||||
['[', ']'],
|
||||
['(', ')'],
|
||||
['<', '>'],
|
||||
['<', '>']
|
||||
],
|
||||
autoClosingPairs: [
|
||||
{ open: '{', close: '}' },
|
||||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '<', close: '>' },
|
||||
{ open: '\'', close: '\'' },
|
||||
{ open: "'", close: "'" }
|
||||
],
|
||||
surroundingPairs: [
|
||||
{ open: '{', close: '}' },
|
||||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '<', close: '>' },
|
||||
{ open: '\'', close: '\'' },
|
||||
{ open: "'", close: "'" }
|
||||
]
|
||||
};
|
||||
|
||||
|
|
@ -48,19 +48,67 @@ export const language = <ILanguage>{
|
|||
],
|
||||
|
||||
keywords: [
|
||||
'abs', 'begin', 'Bytes', 'Crypto', 'Current', 'else', 'end', 'failwith',
|
||||
'false', 'fun', 'if', 'in', 'let', 'let%entry', 'let%init', 'List', 'list',
|
||||
'Map', 'map', 'match', 'match%nat', 'mod', 'not', 'operation', 'Operation', 'of',
|
||||
'Set', 'set', 'sender', 'source', 'String', 'then', 'true', 'type', 'with',
|
||||
'abs',
|
||||
'begin',
|
||||
'Bytes',
|
||||
'Crypto',
|
||||
'Current',
|
||||
'else',
|
||||
'end',
|
||||
'failwith',
|
||||
'false',
|
||||
'fun',
|
||||
'if',
|
||||
'in',
|
||||
'let',
|
||||
'let%entry',
|
||||
'let%init',
|
||||
'List',
|
||||
'list',
|
||||
'Map',
|
||||
'map',
|
||||
'match',
|
||||
'match%nat',
|
||||
'mod',
|
||||
'not',
|
||||
'operation',
|
||||
'Operation',
|
||||
'of',
|
||||
'Set',
|
||||
'set',
|
||||
'sender',
|
||||
'source',
|
||||
'String',
|
||||
'then',
|
||||
'true',
|
||||
'type',
|
||||
'with'
|
||||
],
|
||||
|
||||
typeKeywords: [
|
||||
'int', 'unit', 'string', 'tz',
|
||||
],
|
||||
typeKeywords: ['int', 'unit', 'string', 'tz'],
|
||||
|
||||
operators: [
|
||||
'=', '>', '<', '<=', '>=', '<>', ':', ':=', 'and', 'mod', 'or',
|
||||
'+', '-', '*', '/', '@', '&', '^', '%', '->', '<-'
|
||||
'=',
|
||||
'>',
|
||||
'<',
|
||||
'<=',
|
||||
'>=',
|
||||
'<>',
|
||||
':',
|
||||
':=',
|
||||
'and',
|
||||
'mod',
|
||||
'or',
|
||||
'+',
|
||||
'-',
|
||||
'*',
|
||||
'/',
|
||||
'@',
|
||||
'&',
|
||||
'^',
|
||||
'%',
|
||||
'->',
|
||||
'<-'
|
||||
],
|
||||
|
||||
// we include these common regular expressions
|
||||
|
|
@ -70,12 +118,15 @@ export const language = <ILanguage>{
|
|||
tokenizer: {
|
||||
root: [
|
||||
// identifiers and keywords
|
||||
[/[a-zA-Z_][\w]*/, {
|
||||
cases: {
|
||||
'@keywords': { token: 'keyword.$0' },
|
||||
'@default': 'identifier'
|
||||
[
|
||||
/[a-zA-Z_][\w]*/,
|
||||
{
|
||||
cases: {
|
||||
'@keywords': { token: 'keyword.$0' },
|
||||
'@default': 'identifier'
|
||||
}
|
||||
}
|
||||
}],
|
||||
],
|
||||
|
||||
// whitespace
|
||||
{ include: '@whitespace' },
|
||||
|
|
@ -83,12 +134,15 @@ export const language = <ILanguage>{
|
|||
// delimiters and operators
|
||||
[/[{}()\[\]]/, '@brackets'],
|
||||
[/[<>](?!@symbols)/, '@brackets'],
|
||||
[/@symbols/, {
|
||||
cases: {
|
||||
'@operators': 'delimiter',
|
||||
'@default': ''
|
||||
[
|
||||
/@symbols/,
|
||||
{
|
||||
cases: {
|
||||
'@operators': 'delimiter',
|
||||
'@default': ''
|
||||
}
|
||||
}
|
||||
}],
|
||||
],
|
||||
|
||||
// numbers
|
||||
[/\d*\.\d+([eE][\-+]?\d+)?/, 'number.float'],
|
||||
|
|
@ -99,33 +153,33 @@ export const language = <ILanguage>{
|
|||
[/[;,.]/, 'delimiter'],
|
||||
|
||||
// strings
|
||||
[/'([^'\\]|\\.)*$/, 'string.invalid'], // non-teminated string
|
||||
[/'([^'\\]|\\.)*$/, 'string.invalid'], // non-teminated string
|
||||
[/'/, 'string', '@string'],
|
||||
|
||||
// characters
|
||||
[/'[^\\']'/, 'string'],
|
||||
[/'/, 'string.invalid'],
|
||||
[/\#\d+/,'string']
|
||||
[/\#\d+/, 'string']
|
||||
],
|
||||
/* */
|
||||
|
||||
comment: [
|
||||
[/[^\(\*]+/, 'comment' ],
|
||||
[/[^\(\*]+/, 'comment'],
|
||||
//[/\(\*/, 'comment', '@push' ], // nested comment not allowed :-(
|
||||
[/\*\)/, 'comment', '@pop' ],
|
||||
[/\(\*/, 'comment' ]
|
||||
[/\*\)/, 'comment', '@pop'],
|
||||
[/\(\*/, 'comment']
|
||||
],
|
||||
|
||||
string: [
|
||||
[/[^\\']+/, 'string'],
|
||||
[/\\./, 'string.escape.invalid'],
|
||||
[/'/, { token: 'string.quote', bracket: '@close', next: '@pop' } ]
|
||||
[/[^\\']+/, 'string'],
|
||||
[/\\./, 'string.escape.invalid'],
|
||||
[/'/, { token: 'string.quote', bracket: '@close', next: '@pop' }]
|
||||
],
|
||||
|
||||
whitespace: [
|
||||
[/[ \t\r\n]+/, 'white'],
|
||||
[/\(\*/, 'comment', '@comment' ],
|
||||
[/\/\/.*$/, 'comment'],
|
||||
],
|
||||
},
|
||||
[/\(\*/, 'comment', '@comment'],
|
||||
[/\/\/.*$/, 'comment']
|
||||
]
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
import {ITestItem, testTokenization} from '../test/testRunner';
|
||||
import { ITestItem, testTokenization } from '../test/testRunner';
|
||||
|
||||
const specialForms = [
|
||||
'.',
|
||||
|
|
@ -21,12 +21,12 @@ const specialForms = [
|
|||
'set!',
|
||||
'throw',
|
||||
'try',
|
||||
'var',
|
||||
'var'
|
||||
];
|
||||
|
||||
const coreSymbols = [
|
||||
'*',
|
||||
'*\'',
|
||||
"*'",
|
||||
'*1',
|
||||
'*2',
|
||||
'*3',
|
||||
|
|
@ -64,9 +64,9 @@ const coreSymbols = [
|
|||
'*verbose-defrecords*',
|
||||
'*warn-on-reflection*',
|
||||
'+',
|
||||
'+\'',
|
||||
"+'",
|
||||
'-',
|
||||
'-\'',
|
||||
"-'",
|
||||
'->',
|
||||
'->>',
|
||||
'->ArrayChunk',
|
||||
|
|
@ -206,7 +206,7 @@ const coreSymbols = [
|
|||
'create-struct',
|
||||
'cycle',
|
||||
'dec',
|
||||
'dec\'',
|
||||
"dec'",
|
||||
'decimal?',
|
||||
'declare',
|
||||
'dedupe',
|
||||
|
|
@ -328,7 +328,7 @@ const coreSymbols = [
|
|||
'import',
|
||||
'in-ns',
|
||||
'inc',
|
||||
'inc\'',
|
||||
"inc'",
|
||||
'indexed?',
|
||||
'init-proxy',
|
||||
'inst-ms',
|
||||
|
|
@ -675,7 +675,7 @@ const coreSymbols = [
|
|||
'with-redefs-fn',
|
||||
'xml-seq',
|
||||
'zero?',
|
||||
'zipmap',
|
||||
'zipmap'
|
||||
];
|
||||
|
||||
function createTestCases(specialForms: string[], type: string): ITestItem[] {
|
||||
|
|
@ -684,9 +684,7 @@ function createTestCases(specialForms: string[], type: string): ITestItem[] {
|
|||
for (const specialForm of specialForms) {
|
||||
testCases.push({
|
||||
line: `${specialForm}`,
|
||||
tokens: [
|
||||
{startIndex: 0, type: `${type}.clj`},
|
||||
],
|
||||
tokens: [{ startIndex: 0, type: `${type}.clj` }]
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -707,68 +705,116 @@ testTokenization('clojure', [
|
|||
createTestCases([':foo', '::bar', ':foo/bar', ':foo.bar/baz'], 'constant'),
|
||||
|
||||
// numbers
|
||||
createTestCases([
|
||||
'42', '+42', '-421',
|
||||
'42N', '+42N', '-42N',
|
||||
'0.42', '+0.42', '-0.42',
|
||||
'42M', '+42M', '-42M',
|
||||
'42.42M', '+42.42M', '-42.42M',
|
||||
'1/42', '+1/42', '-1/42',
|
||||
'0x42af', '+0x42af', '-0x42af',
|
||||
'0x42AF', '+0x42AF', '-0x42AF',
|
||||
'1e2', '1e+2', '1e-2',
|
||||
'+1e2', '+1e+2', '+1e-2',
|
||||
'-1e2', '-1e+2', '-1e-2',
|
||||
'-1.0e2', '-0.1e+2', '-1.01e-2',
|
||||
'1E2', '1E+2', '1E-2',
|
||||
'+1E2', '+1E+2', '+1E-2',
|
||||
'-1E2', '-1E+2', '-1E-2',
|
||||
'-1.0E2', '-0.1E+2', '-1.01E-2',
|
||||
'2r101010', '+2r101010', '-2r101010',
|
||||
'2r101010', '+2r101010', '-2r101010',
|
||||
'8r52', '+8r52', '-8r52',
|
||||
'36rhello', '+36rhello', '-36rhello',
|
||||
'36rz', '+36rz', '-36rz',
|
||||
'36rZ', '+36rZ', '-36rZ',
|
||||
], 'number'),
|
||||
createTestCases(
|
||||
[
|
||||
'42',
|
||||
'+42',
|
||||
'-421',
|
||||
'42N',
|
||||
'+42N',
|
||||
'-42N',
|
||||
'0.42',
|
||||
'+0.42',
|
||||
'-0.42',
|
||||
'42M',
|
||||
'+42M',
|
||||
'-42M',
|
||||
'42.42M',
|
||||
'+42.42M',
|
||||
'-42.42M',
|
||||
'1/42',
|
||||
'+1/42',
|
||||
'-1/42',
|
||||
'0x42af',
|
||||
'+0x42af',
|
||||
'-0x42af',
|
||||
'0x42AF',
|
||||
'+0x42AF',
|
||||
'-0x42AF',
|
||||
'1e2',
|
||||
'1e+2',
|
||||
'1e-2',
|
||||
'+1e2',
|
||||
'+1e+2',
|
||||
'+1e-2',
|
||||
'-1e2',
|
||||
'-1e+2',
|
||||
'-1e-2',
|
||||
'-1.0e2',
|
||||
'-0.1e+2',
|
||||
'-1.01e-2',
|
||||
'1E2',
|
||||
'1E+2',
|
||||
'1E-2',
|
||||
'+1E2',
|
||||
'+1E+2',
|
||||
'+1E-2',
|
||||
'-1E2',
|
||||
'-1E+2',
|
||||
'-1E-2',
|
||||
'-1.0E2',
|
||||
'-0.1E+2',
|
||||
'-1.01E-2',
|
||||
'2r101010',
|
||||
'+2r101010',
|
||||
'-2r101010',
|
||||
'2r101010',
|
||||
'+2r101010',
|
||||
'-2r101010',
|
||||
'8r52',
|
||||
'+8r52',
|
||||
'-8r52',
|
||||
'36rhello',
|
||||
'+36rhello',
|
||||
'-36rhello',
|
||||
'36rz',
|
||||
'+36rz',
|
||||
'-36rz',
|
||||
'36rZ',
|
||||
'+36rZ',
|
||||
'-36rZ'
|
||||
],
|
||||
'number'
|
||||
),
|
||||
|
||||
// characters
|
||||
createTestCases([
|
||||
'\\1',
|
||||
'\\a',
|
||||
'\\#',
|
||||
'\\\\',
|
||||
'\\\"',
|
||||
'\\(',
|
||||
'\\A',
|
||||
'\\backspace',
|
||||
'\\formfeed',
|
||||
'\\newline',
|
||||
'\\space',
|
||||
'\\return',
|
||||
'\\tab',
|
||||
'\\o123',
|
||||
'\\u1000',
|
||||
'\\uAaAa',
|
||||
'\\u9F9F'
|
||||
], 'string'),
|
||||
createTestCases(
|
||||
[
|
||||
'\\1',
|
||||
'\\a',
|
||||
'\\#',
|
||||
'\\\\',
|
||||
'\\"',
|
||||
'\\(',
|
||||
'\\A',
|
||||
'\\backspace',
|
||||
'\\formfeed',
|
||||
'\\newline',
|
||||
'\\space',
|
||||
'\\return',
|
||||
'\\tab',
|
||||
'\\o123',
|
||||
'\\u1000',
|
||||
'\\uAaAa',
|
||||
'\\u9F9F'
|
||||
],
|
||||
'string'
|
||||
),
|
||||
|
||||
// strings
|
||||
[
|
||||
{
|
||||
line: '"I\'m a little teapot."',
|
||||
tokens: [
|
||||
{startIndex: 0, type: 'string.clj'},
|
||||
]
|
||||
tokens: [{ startIndex: 0, type: 'string.clj' }]
|
||||
},
|
||||
{
|
||||
line: '"I\'m a \\"little\\" teapot."',
|
||||
tokens: [
|
||||
{startIndex: 0, type: 'string.clj'},
|
||||
{startIndex: 7, type: 'string.escape.clj'},
|
||||
{startIndex: 9, type: 'string.clj'},
|
||||
{startIndex: 15, type: 'string.escape.clj'},
|
||||
{startIndex: 17, type: 'string.clj'},
|
||||
{ startIndex: 0, type: 'string.clj' },
|
||||
{ startIndex: 7, type: 'string.escape.clj' },
|
||||
{ startIndex: 9, type: 'string.clj' },
|
||||
{ startIndex: 15, type: 'string.escape.clj' },
|
||||
{ startIndex: 17, type: 'string.clj' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
|
@ -777,142 +823,125 @@ testTokenization('clojure', [
|
|||
[
|
||||
{
|
||||
line: '"I\'m',
|
||||
tokens: [
|
||||
{startIndex: 0, type: 'string.clj'},
|
||||
]
|
||||
tokens: [{ startIndex: 0, type: 'string.clj' }]
|
||||
},
|
||||
{
|
||||
line: '\\"a little\\"',
|
||||
tokens: [
|
||||
{startIndex: 0, type: 'string.escape.clj'},
|
||||
{startIndex: 2, type: 'string.clj'},
|
||||
{startIndex: 10, type: 'string.escape.clj'},
|
||||
{ startIndex: 0, type: 'string.escape.clj' },
|
||||
{ startIndex: 2, type: 'string.clj' },
|
||||
{ startIndex: 10, type: 'string.escape.clj' }
|
||||
]
|
||||
},
|
||||
{
|
||||
line: 'teapot."',
|
||||
tokens: [
|
||||
{startIndex: 0, type: 'string.clj'},
|
||||
]
|
||||
tokens: [{ startIndex: 0, type: 'string.clj' }]
|
||||
}
|
||||
],
|
||||
|
||||
// strings with other escapes in them (\" \' \\ \b \f \n \r \t)
|
||||
[{
|
||||
line: '"the escape \\" \\\' \\\\ \\b \\f \\n \\r \\t characters"',
|
||||
tokens: [
|
||||
{startIndex: 0, type: 'string.clj'},
|
||||
{startIndex: 12, type: 'string.escape.clj'},
|
||||
{startIndex: 14, type: 'string.clj'},
|
||||
{startIndex: 15, type: 'string.escape.clj'},
|
||||
{startIndex: 17, type: 'string.clj'},
|
||||
{startIndex: 18, type: 'string.escape.clj'},
|
||||
{startIndex: 20, type: 'string.clj'},
|
||||
{startIndex: 21, type: 'string.escape.clj'},
|
||||
{startIndex: 23, type: 'string.clj'},
|
||||
{startIndex: 24, type: 'string.escape.clj'},
|
||||
{startIndex: 26, type: 'string.clj'},
|
||||
{startIndex: 27, type: 'string.escape.clj'},
|
||||
{startIndex: 29, type: 'string.clj'},
|
||||
{startIndex: 30, type: 'string.escape.clj'},
|
||||
{startIndex: 32, type: 'string.clj'},
|
||||
{startIndex: 33, type: 'string.escape.clj'},
|
||||
{startIndex: 35, type: 'string.clj'},
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '"the escape \\" \\\' \\\\ \\b \\f \\n \\r \\t characters"',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'string.clj' },
|
||||
{ startIndex: 12, type: 'string.escape.clj' },
|
||||
{ startIndex: 14, type: 'string.clj' },
|
||||
{ startIndex: 15, type: 'string.escape.clj' },
|
||||
{ startIndex: 17, type: 'string.clj' },
|
||||
{ startIndex: 18, type: 'string.escape.clj' },
|
||||
{ startIndex: 20, type: 'string.clj' },
|
||||
{ startIndex: 21, type: 'string.escape.clj' },
|
||||
{ startIndex: 23, type: 'string.clj' },
|
||||
{ startIndex: 24, type: 'string.escape.clj' },
|
||||
{ startIndex: 26, type: 'string.clj' },
|
||||
{ startIndex: 27, type: 'string.escape.clj' },
|
||||
{ startIndex: 29, type: 'string.clj' },
|
||||
{ startIndex: 30, type: 'string.escape.clj' },
|
||||
{ startIndex: 32, type: 'string.clj' },
|
||||
{ startIndex: 33, type: 'string.escape.clj' },
|
||||
{ startIndex: 35, type: 'string.clj' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// comments
|
||||
createTestCases([
|
||||
'; this is an in-line comment.',
|
||||
';; this is a line comment.',
|
||||
], 'comment'),
|
||||
createTestCases(
|
||||
['; this is an in-line comment.', ';; this is a line comment.'],
|
||||
'comment'
|
||||
),
|
||||
|
||||
// `comment`
|
||||
[
|
||||
{
|
||||
line: '(comment)',
|
||||
tokens: [
|
||||
{startIndex: 0, type: 'comment.clj'},
|
||||
],
|
||||
tokens: [{ startIndex: 0, type: 'comment.clj' }]
|
||||
},
|
||||
{
|
||||
line: 'foo :bar 42',
|
||||
tokens: [
|
||||
{startIndex: 0, type: 'identifier.clj'},
|
||||
{startIndex: 3, type: 'white.clj'},
|
||||
{startIndex: 4, type: 'constant.clj'},
|
||||
{startIndex: 8, type: 'white.clj'},
|
||||
{startIndex: 9, type: 'number.clj'},
|
||||
],
|
||||
{ startIndex: 0, type: 'identifier.clj' },
|
||||
{ startIndex: 3, type: 'white.clj' },
|
||||
{ startIndex: 4, type: 'constant.clj' },
|
||||
{ startIndex: 8, type: 'white.clj' },
|
||||
{ startIndex: 9, type: 'number.clj' }
|
||||
]
|
||||
},
|
||||
{
|
||||
line: '(comment (foo [bar :baz 1 "qux"]))',
|
||||
tokens: [
|
||||
{startIndex: 0, type: 'comment.clj'},
|
||||
],
|
||||
tokens: [{ startIndex: 0, type: 'comment.clj' }]
|
||||
},
|
||||
{
|
||||
line: '(comments foo bar)',
|
||||
tokens: [
|
||||
{startIndex: 0, type: 'delimiter.parenthesis.clj'},
|
||||
{startIndex: 1, type: 'identifier.clj'},
|
||||
{startIndex: 9, type: 'white.clj'},
|
||||
{startIndex: 10, type: 'identifier.clj'},
|
||||
{startIndex: 13, type: 'white.clj'},
|
||||
{startIndex: 14, type: 'identifier.clj'},
|
||||
{startIndex: 17, type: 'delimiter.parenthesis.clj'},
|
||||
{ startIndex: 0, type: 'delimiter.parenthesis.clj' },
|
||||
{ startIndex: 1, type: 'identifier.clj' },
|
||||
{ startIndex: 9, type: 'white.clj' },
|
||||
{ startIndex: 10, type: 'identifier.clj' },
|
||||
{ startIndex: 13, type: 'white.clj' },
|
||||
{ startIndex: 14, type: 'identifier.clj' },
|
||||
{ startIndex: 17, type: 'delimiter.parenthesis.clj' }
|
||||
]
|
||||
},
|
||||
{
|
||||
line: '(comment6 foo bar)',
|
||||
tokens: [
|
||||
{startIndex: 0, type: 'delimiter.parenthesis.clj'},
|
||||
{startIndex: 1, type: 'identifier.clj'},
|
||||
{startIndex: 9, type: 'white.clj'},
|
||||
{startIndex: 10, type: 'identifier.clj'},
|
||||
{startIndex: 13, type: 'white.clj'},
|
||||
{startIndex: 14, type: 'identifier.clj'},
|
||||
{startIndex: 17, type: 'delimiter.parenthesis.clj'},
|
||||
{ startIndex: 0, type: 'delimiter.parenthesis.clj' },
|
||||
{ startIndex: 1, type: 'identifier.clj' },
|
||||
{ startIndex: 9, type: 'white.clj' },
|
||||
{ startIndex: 10, type: 'identifier.clj' },
|
||||
{ startIndex: 13, type: 'white.clj' },
|
||||
{ startIndex: 14, type: 'identifier.clj' },
|
||||
{ startIndex: 17, type: 'delimiter.parenthesis.clj' }
|
||||
]
|
||||
},
|
||||
{
|
||||
line: '(comment foo',
|
||||
tokens: [
|
||||
{startIndex: 0, type: 'comment.clj'},
|
||||
],
|
||||
tokens: [{ startIndex: 0, type: 'comment.clj' }]
|
||||
},
|
||||
{
|
||||
line: 'foo',
|
||||
tokens: [
|
||||
{startIndex: 0, type: 'comment.clj'},
|
||||
],
|
||||
},
|
||||
tokens: [{ startIndex: 0, type: 'comment.clj' }]
|
||||
}
|
||||
],
|
||||
|
||||
// reader macro characters
|
||||
createTestCases([
|
||||
'#',
|
||||
'@',
|
||||
'^',
|
||||
'`',
|
||||
'~',
|
||||
"'",
|
||||
], 'meta'),
|
||||
createTestCases(['#', '@', '^', '`', '~', "'"], 'meta'),
|
||||
|
||||
// treat comma as whitespace
|
||||
[
|
||||
{
|
||||
line: ', foo, :bar, "one", 2, ',
|
||||
tokens: [
|
||||
{startIndex: 0, type: 'white.clj'},
|
||||
{startIndex: 2, type: 'identifier.clj'},
|
||||
{startIndex: 5, type: 'white.clj'},
|
||||
{startIndex: 7, type: 'constant.clj'},
|
||||
{startIndex: 11, type: 'white.clj'},
|
||||
{startIndex: 13, type: 'string.clj'},
|
||||
{startIndex: 18, type: 'white.clj'},
|
||||
{startIndex: 20, type: 'number.clj'},
|
||||
{startIndex: 21, type: 'white.clj'}
|
||||
{ startIndex: 0, type: 'white.clj' },
|
||||
{ startIndex: 2, type: 'identifier.clj' },
|
||||
{ startIndex: 5, type: 'white.clj' },
|
||||
{ startIndex: 7, type: 'constant.clj' },
|
||||
{ startIndex: 11, type: 'white.clj' },
|
||||
{ startIndex: 13, type: 'string.clj' },
|
||||
{ startIndex: 18, type: 'white.clj' },
|
||||
{ startIndex: 20, type: 'number.clj' },
|
||||
{ startIndex: 21, type: 'white.clj' }
|
||||
]
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import ILanguage = monaco.languages.IMonarchLanguage;
|
|||
|
||||
export const conf: IRichLanguageConfiguration = {
|
||||
comments: {
|
||||
lineComment: ';;',
|
||||
lineComment: ';;'
|
||||
},
|
||||
|
||||
brackets: [
|
||||
|
|
@ -20,18 +20,18 @@ export const conf: IRichLanguageConfiguration = {
|
|||
],
|
||||
|
||||
autoClosingPairs: [
|
||||
{open: '[', close: ']'},
|
||||
{open: '"', close: '"'},
|
||||
{open: '(', close: ')'},
|
||||
{open: '{', close: '}'},
|
||||
{ open: '[', close: ']' },
|
||||
{ open: '"', close: '"' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '{', close: '}' }
|
||||
],
|
||||
|
||||
surroundingPairs: [
|
||||
{open: '[', close: ']'},
|
||||
{open: '"', close: '"'},
|
||||
{open: '(', close: ')'},
|
||||
{open: '{', close: '}'},
|
||||
],
|
||||
{ open: '[', close: ']' },
|
||||
{ open: '"', close: '"' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '{', close: '}' }
|
||||
]
|
||||
};
|
||||
|
||||
export const language = <ILanguage>{
|
||||
|
|
@ -40,9 +40,9 @@ export const language = <ILanguage>{
|
|||
tokenPostfix: '.clj',
|
||||
|
||||
brackets: [
|
||||
{open: '[', close: ']', token: 'delimiter.square'},
|
||||
{open: '(', close: ')', token: 'delimiter.parenthesis'},
|
||||
{open: '{', close: '}', token: 'delimiter.curly'},
|
||||
{ open: '[', close: ']', token: 'delimiter.square' },
|
||||
{ open: '(', close: ')', token: 'delimiter.parenthesis' },
|
||||
{ open: '{', close: '}', token: 'delimiter.curly' }
|
||||
],
|
||||
|
||||
constants: ['true', 'false', 'nil'],
|
||||
|
|
@ -74,12 +74,12 @@ export const language = <ILanguage>{
|
|||
'set!',
|
||||
'throw',
|
||||
'try',
|
||||
'var',
|
||||
'var'
|
||||
],
|
||||
|
||||
coreSymbols: [
|
||||
'*',
|
||||
'*\'',
|
||||
"*'",
|
||||
'*1',
|
||||
'*2',
|
||||
'*3',
|
||||
|
|
@ -117,9 +117,9 @@ export const language = <ILanguage>{
|
|||
'*verbose-defrecords*',
|
||||
'*warn-on-reflection*',
|
||||
'+',
|
||||
'+\'',
|
||||
"+'",
|
||||
'-',
|
||||
'-\'',
|
||||
"-'",
|
||||
'->',
|
||||
'->>',
|
||||
'->ArrayChunk',
|
||||
|
|
@ -259,7 +259,7 @@ export const language = <ILanguage>{
|
|||
'create-struct',
|
||||
'cycle',
|
||||
'dec',
|
||||
'dec\'',
|
||||
"dec'",
|
||||
'decimal?',
|
||||
'declare',
|
||||
'dedupe',
|
||||
|
|
@ -381,7 +381,7 @@ export const language = <ILanguage>{
|
|||
'import',
|
||||
'in-ns',
|
||||
'inc',
|
||||
'inc\'',
|
||||
"inc'",
|
||||
'indexed?',
|
||||
'init-proxy',
|
||||
'inst-ms',
|
||||
|
|
@ -728,13 +728,13 @@ export const language = <ILanguage>{
|
|||
'with-redefs-fn',
|
||||
'xml-seq',
|
||||
'zero?',
|
||||
'zipmap',
|
||||
'zipmap'
|
||||
],
|
||||
|
||||
tokenizer: {
|
||||
root: [
|
||||
// whitespaces and comments
|
||||
{include: '@whitespace'},
|
||||
{ include: '@whitespace' },
|
||||
|
||||
// numbers
|
||||
[/@numbers/, 'number'],
|
||||
|
|
@ -743,7 +743,7 @@ export const language = <ILanguage>{
|
|||
[/@characters/, 'string'],
|
||||
|
||||
// strings
|
||||
{include: '@string'},
|
||||
{ include: '@string' },
|
||||
|
||||
// brackets
|
||||
[/[()\[\]{}]/, '@brackets'],
|
||||
|
|
@ -755,38 +755,38 @@ export const language = <ILanguage>{
|
|||
[/[#'@^`~]/, 'meta'],
|
||||
|
||||
// symbols
|
||||
[/@qualifiedSymbols/, {
|
||||
[
|
||||
/@qualifiedSymbols/,
|
||||
{
|
||||
cases: {
|
||||
'^:.+$': 'constant', // Clojure keywords (e.g., `:foo/bar`)
|
||||
'^:.+$': 'constant', // Clojure keywords (e.g., `:foo/bar`)
|
||||
'@specialForms': 'keyword',
|
||||
'@coreSymbols': 'keyword',
|
||||
'@constants': 'constant',
|
||||
'@default': 'identifier',
|
||||
},
|
||||
},
|
||||
],
|
||||
'@default': 'identifier'
|
||||
}
|
||||
}
|
||||
]
|
||||
],
|
||||
|
||||
whitespace: [
|
||||
[/[\s,]+/, 'white'],
|
||||
[/;.*$/, 'comment'],
|
||||
[/\(comment\b/, 'comment', '@comment'],
|
||||
[/\(comment\b/, 'comment', '@comment']
|
||||
],
|
||||
|
||||
comment: [
|
||||
[/\(/, 'comment', '@push'],
|
||||
[/\)/, 'comment', '@pop'],
|
||||
[/[^()]/, 'comment'],
|
||||
[/[^()]/, 'comment']
|
||||
],
|
||||
|
||||
string: [
|
||||
[/"/, 'string', '@multiLineString'],
|
||||
],
|
||||
string: [[/"/, 'string', '@multiLineString']],
|
||||
|
||||
multiLineString: [
|
||||
[/"/, 'string', '@popall'],
|
||||
[/@escapes/, 'string.escape'],
|
||||
[/./, 'string']
|
||||
],
|
||||
},
|
||||
]
|
||||
}
|
||||
};
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -24,19 +24,19 @@ export const conf: IRichLanguageConfiguration = {
|
|||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '"', close: '"' },
|
||||
{ open: '\'', close: '\'' },
|
||||
{ open: "'", close: "'" }
|
||||
],
|
||||
surroundingPairs: [
|
||||
{ open: '{', close: '}' },
|
||||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '"', close: '"' },
|
||||
{ open: '\'', close: '\'' },
|
||||
{ open: "'", close: "'" }
|
||||
],
|
||||
folding: {
|
||||
markers: {
|
||||
start: new RegExp("^\\s*#region\\b"),
|
||||
end: new RegExp("^\\s*#endregion\\b")
|
||||
start: new RegExp('^\\s*#region\\b'),
|
||||
end: new RegExp('^\\s*#endregion\\b')
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -55,13 +55,50 @@ export const language = <ILanguage>{
|
|||
regEx: /\/(?!\/\/)(?:[^\/\\]|\\.)*\/[igm]*/,
|
||||
|
||||
keywords: [
|
||||
'and', 'or', 'is', 'isnt', 'not', 'on', 'yes', '@', 'no', 'off',
|
||||
'true', 'false', 'null', 'this',
|
||||
'new', 'delete', 'typeof', 'in', 'instanceof',
|
||||
'return', 'throw', 'break', 'continue', 'debugger',
|
||||
'if', 'else', 'switch', 'for', 'while', 'do', 'try', 'catch', 'finally',
|
||||
'class', 'extends', 'super',
|
||||
'undefined', 'then', 'unless', 'until', 'loop', 'of', 'by', 'when'
|
||||
'and',
|
||||
'or',
|
||||
'is',
|
||||
'isnt',
|
||||
'not',
|
||||
'on',
|
||||
'yes',
|
||||
'@',
|
||||
'no',
|
||||
'off',
|
||||
'true',
|
||||
'false',
|
||||
'null',
|
||||
'this',
|
||||
'new',
|
||||
'delete',
|
||||
'typeof',
|
||||
'in',
|
||||
'instanceof',
|
||||
'return',
|
||||
'throw',
|
||||
'break',
|
||||
'continue',
|
||||
'debugger',
|
||||
'if',
|
||||
'else',
|
||||
'switch',
|
||||
'for',
|
||||
'while',
|
||||
'do',
|
||||
'try',
|
||||
'catch',
|
||||
'finally',
|
||||
'class',
|
||||
'extends',
|
||||
'super',
|
||||
'undefined',
|
||||
'then',
|
||||
'unless',
|
||||
'until',
|
||||
'loop',
|
||||
'of',
|
||||
'by',
|
||||
'when'
|
||||
],
|
||||
|
||||
// we include these common regular expressions
|
||||
|
|
@ -71,16 +108,18 @@ export const language = <ILanguage>{
|
|||
// The main tokenizer for our languages
|
||||
tokenizer: {
|
||||
root: [
|
||||
|
||||
// identifiers and keywords
|
||||
[/\@[a-zA-Z_]\w*/, 'variable.predefined'],
|
||||
[/[a-zA-Z_]\w*/, {
|
||||
cases: {
|
||||
'this': 'variable.predefined',
|
||||
'@keywords': { token: 'keyword.$0' },
|
||||
'@default': ''
|
||||
[
|
||||
/[a-zA-Z_]\w*/,
|
||||
{
|
||||
cases: {
|
||||
this: 'variable.predefined',
|
||||
'@keywords': { token: 'keyword.$0' },
|
||||
'@default': ''
|
||||
}
|
||||
}
|
||||
}],
|
||||
],
|
||||
|
||||
// whitespace
|
||||
[/[ \t\r\n]+/, ''],
|
||||
|
|
@ -105,14 +144,19 @@ export const language = <ILanguage>{
|
|||
[/(\{)(\s*)(@regEx)/, ['@brackets', '', 'regexp']],
|
||||
[/(\;)(\s*)(@regEx)/, ['', '', 'regexp']],
|
||||
|
||||
|
||||
// delimiters
|
||||
[/}/, {
|
||||
cases: {
|
||||
'$S2==interpolatedstring': { token: 'string', next: '@pop' },
|
||||
'@default': '@brackets'
|
||||
[
|
||||
/}/,
|
||||
{
|
||||
cases: {
|
||||
'$S2==interpolatedstring': {
|
||||
token: 'string',
|
||||
next: '@pop'
|
||||
},
|
||||
'@default': '@brackets'
|
||||
}
|
||||
}
|
||||
}],
|
||||
],
|
||||
[/[{}()\[\]]/, '@brackets'],
|
||||
[/@symbols/, 'delimiter'],
|
||||
|
||||
|
|
@ -128,19 +172,25 @@ export const language = <ILanguage>{
|
|||
|
||||
// strings:
|
||||
[/"""/, 'string', '@herestring."""'],
|
||||
[/'''/, 'string', '@herestring.\'\'\''],
|
||||
[/"/, {
|
||||
cases: {
|
||||
'@eos': 'string',
|
||||
'@default': { token: 'string', next: '@string."' }
|
||||
[/'''/, 'string', "@herestring.'''"],
|
||||
[
|
||||
/"/,
|
||||
{
|
||||
cases: {
|
||||
'@eos': 'string',
|
||||
'@default': { token: 'string', next: '@string."' }
|
||||
}
|
||||
}
|
||||
}],
|
||||
[/'/, {
|
||||
cases: {
|
||||
'@eos': 'string',
|
||||
'@default': { token: 'string', next: '@string.\'' }
|
||||
],
|
||||
[
|
||||
/'/,
|
||||
{
|
||||
cases: {
|
||||
'@eos': 'string',
|
||||
'@default': { token: 'string', next: "@string.'" }
|
||||
}
|
||||
}
|
||||
}],
|
||||
]
|
||||
],
|
||||
|
||||
string: [
|
||||
|
|
@ -149,29 +199,41 @@ export const language = <ILanguage>{
|
|||
[/\./, 'string.escape.invalid'],
|
||||
[/\./, 'string.escape.invalid'],
|
||||
|
||||
[/#{/, {
|
||||
cases: {
|
||||
'$S2=="': { token: 'string', next: 'root.interpolatedstring' },
|
||||
'@default': 'string'
|
||||
[
|
||||
/#{/,
|
||||
{
|
||||
cases: {
|
||||
'$S2=="': {
|
||||
token: 'string',
|
||||
next: 'root.interpolatedstring'
|
||||
},
|
||||
'@default': 'string'
|
||||
}
|
||||
}
|
||||
}],
|
||||
],
|
||||
|
||||
[/["']/, {
|
||||
cases: {
|
||||
'$#==$S2': { token: 'string', next: '@pop' },
|
||||
'@default': 'string'
|
||||
[
|
||||
/["']/,
|
||||
{
|
||||
cases: {
|
||||
'$#==$S2': { token: 'string', next: '@pop' },
|
||||
'@default': 'string'
|
||||
}
|
||||
}
|
||||
}],
|
||||
],
|
||||
[/#/, 'string']
|
||||
],
|
||||
|
||||
herestring: [
|
||||
[/("""|''')/, {
|
||||
cases: {
|
||||
'$1==$S2': { token: 'string', next: '@pop' },
|
||||
'@default': 'string'
|
||||
[
|
||||
/("""|''')/,
|
||||
{
|
||||
cases: {
|
||||
'$1==$S2': { token: 'string', next: '@pop' },
|
||||
'@default': 'string'
|
||||
}
|
||||
}
|
||||
}],
|
||||
],
|
||||
[/[^#\\'"]+/, 'string'],
|
||||
[/['"]+/, 'string'],
|
||||
[/@escapes/, 'string.escape'],
|
||||
|
|
@ -182,9 +244,9 @@ export const language = <ILanguage>{
|
|||
],
|
||||
|
||||
comment: [
|
||||
[/[^#]+/, 'comment',],
|
||||
[/[^#]+/, 'comment'],
|
||||
[/###/, 'comment', '@pop'],
|
||||
[/#/, 'comment'],
|
||||
[/#/, 'comment']
|
||||
],
|
||||
|
||||
hereregexp: [
|
||||
|
|
@ -192,7 +254,7 @@ export const language = <ILanguage>{
|
|||
[/\\./, 'regexp'],
|
||||
[/#.*$/, 'comment'],
|
||||
['///[igm]*', { token: 'regexp', next: '@pop' }],
|
||||
[/\//, 'regexp'],
|
||||
],
|
||||
},
|
||||
[/\//, 'regexp']
|
||||
]
|
||||
}
|
||||
};
|
||||
|
|
|
|||
1504
src/cpp/cpp.test.ts
1504
src/cpp/cpp.test.ts
File diff suppressed because it is too large
Load diff
136
src/cpp/cpp.ts
136
src/cpp/cpp.ts
|
|
@ -11,7 +11,7 @@ import ILanguage = monaco.languages.IMonarchLanguage;
|
|||
export const conf: IRichLanguageConfiguration = {
|
||||
comments: {
|
||||
lineComment: '//',
|
||||
blockComment: ['/*', '*/'],
|
||||
blockComment: ['/*', '*/']
|
||||
},
|
||||
brackets: [
|
||||
['{', '}'],
|
||||
|
|
@ -22,20 +22,20 @@ export const conf: IRichLanguageConfiguration = {
|
|||
{ open: '[', close: ']' },
|
||||
{ open: '{', close: '}' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '\'', close: '\'', notIn: ['string', 'comment'] },
|
||||
{ open: '"', close: '"', notIn: ['string'] },
|
||||
{ open: "'", close: "'", notIn: ['string', 'comment'] },
|
||||
{ open: '"', close: '"', notIn: ['string'] }
|
||||
],
|
||||
surroundingPairs: [
|
||||
{ open: '{', close: '}' },
|
||||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '"', close: '"' },
|
||||
{ open: '\'', close: '\'' },
|
||||
{ open: "'", close: "'" }
|
||||
],
|
||||
folding: {
|
||||
markers: {
|
||||
start: new RegExp("^\\s*#pragma\\s+region\\b"),
|
||||
end: new RegExp("^\\s*#pragma\\s+endregion\\b")
|
||||
start: new RegExp('^\\s*#pragma\\s+region\\b'),
|
||||
end: new RegExp('^\\s*#pragma\\s+endregion\\b')
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -165,7 +165,7 @@ export const language = <ILanguage>{
|
|||
'_virtual_inheritance',
|
||||
'_w64',
|
||||
|
||||
'__abstract', // reserved word with two underscores
|
||||
'__abstract', // reserved word with two underscores
|
||||
'__alignof',
|
||||
'__asm',
|
||||
'__assume',
|
||||
|
|
@ -234,11 +234,43 @@ export const language = <ILanguage>{
|
|||
],
|
||||
|
||||
operators: [
|
||||
'=', '>', '<', '!', '~', '?', ':',
|
||||
'==', '<=', '>=', '!=', '&&', '||', '++', '--',
|
||||
'+', '-', '*', '/', '&', '|', '^', '%', '<<',
|
||||
'>>', '>>>', '+=', '-=', '*=', '/=', '&=', '|=',
|
||||
'^=', '%=', '<<=', '>>=', '>>>='
|
||||
'=',
|
||||
'>',
|
||||
'<',
|
||||
'!',
|
||||
'~',
|
||||
'?',
|
||||
':',
|
||||
'==',
|
||||
'<=',
|
||||
'>=',
|
||||
'!=',
|
||||
'&&',
|
||||
'||',
|
||||
'++',
|
||||
'--',
|
||||
'+',
|
||||
'-',
|
||||
'*',
|
||||
'/',
|
||||
'&',
|
||||
'|',
|
||||
'^',
|
||||
'%',
|
||||
'<<',
|
||||
'>>',
|
||||
'>>>',
|
||||
'+=',
|
||||
'-=',
|
||||
'*=',
|
||||
'/=',
|
||||
'&=',
|
||||
'|=',
|
||||
'^=',
|
||||
'%=',
|
||||
'<<=',
|
||||
'>>=',
|
||||
'>>>='
|
||||
],
|
||||
|
||||
// we include these common regular expressions
|
||||
|
|
@ -252,15 +284,21 @@ export const language = <ILanguage>{
|
|||
tokenizer: {
|
||||
root: [
|
||||
// C++ 11 Raw String
|
||||
[/@encoding?R\"(?:([^ ()\\\t]*))\(/, { token: 'string.raw.begin', next: '@raw.$1' }],
|
||||
[
|
||||
/@encoding?R\"(?:([^ ()\\\t]*))\(/,
|
||||
{ token: 'string.raw.begin', next: '@raw.$1' }
|
||||
],
|
||||
|
||||
// identifiers and keywords
|
||||
[/[a-zA-Z_]\w*/, {
|
||||
cases: {
|
||||
'@keywords': { token: 'keyword.$0' },
|
||||
'@default': 'identifier'
|
||||
[
|
||||
/[a-zA-Z_]\w*/,
|
||||
{
|
||||
cases: {
|
||||
'@keywords': { token: 'keyword.$0' },
|
||||
'@default': 'identifier'
|
||||
}
|
||||
}
|
||||
}],
|
||||
],
|
||||
|
||||
// whitespace
|
||||
{ include: '@whitespace' },
|
||||
|
|
@ -268,7 +306,10 @@ export const language = <ILanguage>{
|
|||
// [[ attributes ]].
|
||||
[/\[\[.*\]\]/, 'annotation'],
|
||||
|
||||
[/^\s*#include/, { token: 'keyword.directive.include', next: '@include' }],
|
||||
[
|
||||
/^\s*#include/,
|
||||
{ token: 'keyword.directive.include', next: '@include' }
|
||||
],
|
||||
|
||||
// Preprocessor directive
|
||||
[/^\s*#\s*\w+/, 'keyword'],
|
||||
|
|
@ -276,12 +317,15 @@ export const language = <ILanguage>{
|
|||
// delimiters and operators
|
||||
[/[{}()\[\]]/, '@brackets'],
|
||||
[/[<>](?!@symbols)/, '@brackets'],
|
||||
[/@symbols/, {
|
||||
cases: {
|
||||
'@operators': 'delimiter',
|
||||
'@default': ''
|
||||
[
|
||||
/@symbols/,
|
||||
{
|
||||
cases: {
|
||||
'@operators': 'delimiter',
|
||||
'@default': ''
|
||||
}
|
||||
}
|
||||
}],
|
||||
],
|
||||
|
||||
// numbers
|
||||
[/\d*\d+[eE]([\-+]?\d+)?(@floatsuffix)/, 'number.float'],
|
||||
|
|
@ -296,7 +340,7 @@ export const language = <ILanguage>{
|
|||
[/[;,.]/, 'delimiter'],
|
||||
|
||||
// strings
|
||||
[/"([^"\\]|\\.)*$/, 'string.invalid'], // non-teminated string
|
||||
[/"([^"\\]|\\.)*$/, 'string.invalid'], // non-teminated string
|
||||
[/"/, 'string', '@string'],
|
||||
|
||||
// characters
|
||||
|
|
@ -309,7 +353,7 @@ export const language = <ILanguage>{
|
|||
[/[ \t\r\n]+/, ''],
|
||||
[/\/\*\*(?!\/)/, 'comment.doc', '@doccomment'],
|
||||
[/\/\*/, 'comment', '@comment'],
|
||||
[/\/\/.*$/, 'comment'],
|
||||
[/\/\/.*$/, 'comment']
|
||||
],
|
||||
|
||||
comment: [
|
||||
|
|
@ -332,10 +376,22 @@ export const language = <ILanguage>{
|
|||
],
|
||||
|
||||
raw: [
|
||||
[/(.*)(\))(?:([^ ()\\\t]*))(\")/, {
|
||||
[
|
||||
/(.*)(\))(?:([^ ()\\\t]*))(\")/,
|
||||
{
|
||||
cases: {
|
||||
'$3==$S2': ['string.raw', 'string.raw.end', 'string.raw.end', { token: 'string.raw.end', next: '@pop' }],
|
||||
'@default': ['string.raw', 'string.raw', 'string.raw', 'string.raw']
|
||||
'$3==$S2': [
|
||||
'string.raw',
|
||||
'string.raw.end',
|
||||
'string.raw.end',
|
||||
{ token: 'string.raw.end', next: '@pop' }
|
||||
],
|
||||
'@default': [
|
||||
'string.raw',
|
||||
'string.raw',
|
||||
'string.raw',
|
||||
'string.raw'
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
|
|
@ -343,8 +399,24 @@ export const language = <ILanguage>{
|
|||
],
|
||||
|
||||
include: [
|
||||
[/(\s*)(<)([^<>]*)(>)/, ['', 'keyword.directive.include.begin', 'string.include.identifier', { token: 'keyword.directive.include.end', next: '@pop'}]],
|
||||
[/(\s*)(")([^"]*)(")/, ['', 'keyword.directive.include.begin', 'string.include.identifier', { token: 'keyword.directive.include.end', next: '@pop'}]]
|
||||
[
|
||||
/(\s*)(<)([^<>]*)(>)/,
|
||||
[
|
||||
'',
|
||||
'keyword.directive.include.begin',
|
||||
'string.include.identifier',
|
||||
{ token: 'keyword.directive.include.end', next: '@pop' }
|
||||
]
|
||||
],
|
||||
[
|
||||
/(\s*)(")([^"]*)(")/,
|
||||
[
|
||||
'',
|
||||
'keyword.directive.include.begin',
|
||||
'string.include.identifier',
|
||||
{ token: 'keyword.directive.include.end', next: '@pop' }
|
||||
]
|
||||
]
|
||||
]
|
||||
},
|
||||
}
|
||||
};
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -12,32 +12,32 @@ export const conf: IRichLanguageConfiguration = {
|
|||
wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\#\$\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g,
|
||||
comments: {
|
||||
lineComment: '//',
|
||||
blockComment: ['/*', '*/'],
|
||||
blockComment: ['/*', '*/']
|
||||
},
|
||||
brackets: [
|
||||
['{', '}'],
|
||||
['[', ']'],
|
||||
['(', ')'],
|
||||
['(', ')']
|
||||
],
|
||||
autoClosingPairs: [
|
||||
{ open: '{', close: '}' },
|
||||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '\'', close: '\'', notIn: ['string', 'comment'] },
|
||||
{ open: '"', close: '"', notIn: ['string', 'comment'] },
|
||||
{ open: "'", close: "'", notIn: ['string', 'comment'] },
|
||||
{ open: '"', close: '"', notIn: ['string', 'comment'] }
|
||||
],
|
||||
surroundingPairs: [
|
||||
{ open: '{', close: '}' },
|
||||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '<', close: '>' },
|
||||
{ open: '\'', close: '\'' },
|
||||
{ open: '"', close: '"' },
|
||||
{ open: "'", close: "'" },
|
||||
{ open: '"', close: '"' }
|
||||
],
|
||||
folding: {
|
||||
markers: {
|
||||
start: new RegExp("^\\s*#region\\b"),
|
||||
end: new RegExp("^\\s*#endregion\\b")
|
||||
start: new RegExp('^\\s*#region\\b'),
|
||||
end: new RegExp('^\\s*#endregion\\b')
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -54,35 +54,163 @@ export const language = <ILanguage>{
|
|||
],
|
||||
|
||||
keywords: [
|
||||
'extern', 'alias', 'using', 'bool', 'decimal', 'sbyte', 'byte', 'short',
|
||||
'ushort', 'int', 'uint', 'long', 'ulong', 'char', 'float', 'double',
|
||||
'object', 'dynamic', 'string', 'assembly', 'is', 'as', 'ref',
|
||||
'out', 'this', 'base', 'new', 'typeof', 'void', 'checked', 'unchecked',
|
||||
'default', 'delegate', 'var', 'const', 'if', 'else', 'switch', 'case',
|
||||
'while', 'do', 'for', 'foreach', 'in', 'break', 'continue', 'goto',
|
||||
'return', 'throw', 'try', 'catch', 'finally', 'lock', 'yield', 'from',
|
||||
'let', 'where', 'join', 'on', 'equals', 'into', 'orderby', 'ascending',
|
||||
'descending', 'select', 'group', 'by', 'namespace', 'partial', 'class',
|
||||
'field', 'event', 'method', 'param', 'property', 'public', 'protected',
|
||||
'internal', 'private', 'abstract', 'sealed', 'static', 'struct', 'readonly',
|
||||
'volatile', 'virtual', 'override', 'params', 'get', 'set', 'add', 'remove',
|
||||
'operator', 'true', 'false', 'implicit', 'explicit', 'interface', 'enum',
|
||||
'null', 'async', 'await', 'fixed', 'sizeof', 'stackalloc', 'unsafe', 'nameof',
|
||||
'extern',
|
||||
'alias',
|
||||
'using',
|
||||
'bool',
|
||||
'decimal',
|
||||
'sbyte',
|
||||
'byte',
|
||||
'short',
|
||||
'ushort',
|
||||
'int',
|
||||
'uint',
|
||||
'long',
|
||||
'ulong',
|
||||
'char',
|
||||
'float',
|
||||
'double',
|
||||
'object',
|
||||
'dynamic',
|
||||
'string',
|
||||
'assembly',
|
||||
'is',
|
||||
'as',
|
||||
'ref',
|
||||
'out',
|
||||
'this',
|
||||
'base',
|
||||
'new',
|
||||
'typeof',
|
||||
'void',
|
||||
'checked',
|
||||
'unchecked',
|
||||
'default',
|
||||
'delegate',
|
||||
'var',
|
||||
'const',
|
||||
'if',
|
||||
'else',
|
||||
'switch',
|
||||
'case',
|
||||
'while',
|
||||
'do',
|
||||
'for',
|
||||
'foreach',
|
||||
'in',
|
||||
'break',
|
||||
'continue',
|
||||
'goto',
|
||||
'return',
|
||||
'throw',
|
||||
'try',
|
||||
'catch',
|
||||
'finally',
|
||||
'lock',
|
||||
'yield',
|
||||
'from',
|
||||
'let',
|
||||
'where',
|
||||
'join',
|
||||
'on',
|
||||
'equals',
|
||||
'into',
|
||||
'orderby',
|
||||
'ascending',
|
||||
'descending',
|
||||
'select',
|
||||
'group',
|
||||
'by',
|
||||
'namespace',
|
||||
'partial',
|
||||
'class',
|
||||
'field',
|
||||
'event',
|
||||
'method',
|
||||
'param',
|
||||
'property',
|
||||
'public',
|
||||
'protected',
|
||||
'internal',
|
||||
'private',
|
||||
'abstract',
|
||||
'sealed',
|
||||
'static',
|
||||
'struct',
|
||||
'readonly',
|
||||
'volatile',
|
||||
'virtual',
|
||||
'override',
|
||||
'params',
|
||||
'get',
|
||||
'set',
|
||||
'add',
|
||||
'remove',
|
||||
'operator',
|
||||
'true',
|
||||
'false',
|
||||
'implicit',
|
||||
'explicit',
|
||||
'interface',
|
||||
'enum',
|
||||
'null',
|
||||
'async',
|
||||
'await',
|
||||
'fixed',
|
||||
'sizeof',
|
||||
'stackalloc',
|
||||
'unsafe',
|
||||
'nameof',
|
||||
'when'
|
||||
],
|
||||
|
||||
namespaceFollows: [
|
||||
'namespace', 'using',
|
||||
],
|
||||
namespaceFollows: ['namespace', 'using'],
|
||||
|
||||
parenFollows: [
|
||||
'if', 'for', 'while', 'switch', 'foreach', 'using', 'catch', 'when'
|
||||
'if',
|
||||
'for',
|
||||
'while',
|
||||
'switch',
|
||||
'foreach',
|
||||
'using',
|
||||
'catch',
|
||||
'when'
|
||||
],
|
||||
|
||||
operators: [
|
||||
'=', '??', '||', '&&', '|', '^', '&', '==', '!=', '<=', '>=', '<<',
|
||||
'+', '-', '*', '/', '%', '!', '~', '++', '--', '+=',
|
||||
'-=', '*=', '/=', '%=', '&=', '|=', '^=', '<<=', '>>=', '>>', '=>'
|
||||
'=',
|
||||
'??',
|
||||
'||',
|
||||
'&&',
|
||||
'|',
|
||||
'^',
|
||||
'&',
|
||||
'==',
|
||||
'!=',
|
||||
'<=',
|
||||
'>=',
|
||||
'<<',
|
||||
'+',
|
||||
'-',
|
||||
'*',
|
||||
'/',
|
||||
'%',
|
||||
'!',
|
||||
'~',
|
||||
'++',
|
||||
'--',
|
||||
'+=',
|
||||
'-=',
|
||||
'*=',
|
||||
'/=',
|
||||
'%=',
|
||||
'&=',
|
||||
'|=',
|
||||
'^=',
|
||||
'<<=',
|
||||
'>>=',
|
||||
'>>',
|
||||
'=>'
|
||||
],
|
||||
|
||||
symbols: /[=><!~?:&|+\-*\/\^%]+/,
|
||||
|
|
@ -93,36 +221,55 @@ export const language = <ILanguage>{
|
|||
// The main tokenizer for our languages
|
||||
tokenizer: {
|
||||
root: [
|
||||
|
||||
// identifiers and keywords
|
||||
[/\@?[a-zA-Z_]\w*/, {
|
||||
cases: {
|
||||
'@namespaceFollows': { token: 'keyword.$0', next: '@namespace' },
|
||||
'@keywords': { token: 'keyword.$0', next: '@qualified' },
|
||||
'@default': { token: 'identifier', next: '@qualified' }
|
||||
[
|
||||
/\@?[a-zA-Z_]\w*/,
|
||||
{
|
||||
cases: {
|
||||
'@namespaceFollows': {
|
||||
token: 'keyword.$0',
|
||||
next: '@namespace'
|
||||
},
|
||||
'@keywords': {
|
||||
token: 'keyword.$0',
|
||||
next: '@qualified'
|
||||
},
|
||||
'@default': { token: 'identifier', next: '@qualified' }
|
||||
}
|
||||
}
|
||||
}],
|
||||
],
|
||||
|
||||
// whitespace
|
||||
{ include: '@whitespace' },
|
||||
|
||||
// delimiters and operators
|
||||
[/}/, {
|
||||
cases: {
|
||||
'$S2==interpolatedstring': { token: 'string.quote', next: '@pop' },
|
||||
'$S2==litinterpstring': { token: 'string.quote', next: '@pop' },
|
||||
'@default': '@brackets'
|
||||
[
|
||||
/}/,
|
||||
{
|
||||
cases: {
|
||||
'$S2==interpolatedstring': {
|
||||
token: 'string.quote',
|
||||
next: '@pop'
|
||||
},
|
||||
'$S2==litinterpstring': {
|
||||
token: 'string.quote',
|
||||
next: '@pop'
|
||||
},
|
||||
'@default': '@brackets'
|
||||
}
|
||||
}
|
||||
}],
|
||||
],
|
||||
[/[{}()\[\]]/, '@brackets'],
|
||||
[/[<>](?!@symbols)/, '@brackets'],
|
||||
[/@symbols/, {
|
||||
cases: {
|
||||
'@operators': 'delimiter',
|
||||
'@default': ''
|
||||
[
|
||||
/@symbols/,
|
||||
{
|
||||
cases: {
|
||||
'@operators': 'delimiter',
|
||||
'@default': ''
|
||||
}
|
||||
}
|
||||
}],
|
||||
|
||||
],
|
||||
|
||||
// numbers
|
||||
[/[0-9_]*\.[0-9_]+([eE][\-+]?\d+)?[fFdD]?/, 'number.float'],
|
||||
|
|
@ -134,7 +281,7 @@ export const language = <ILanguage>{
|
|||
[/[;,.]/, 'delimiter'],
|
||||
|
||||
// strings
|
||||
[/"([^"\\]|\\.)*$/, 'string.invalid'], // non-teminated string
|
||||
[/"([^"\\]|\\.)*$/, 'string.invalid'], // non-teminated string
|
||||
[/"/, { token: 'string.quote', next: '@string' }],
|
||||
[/\$\@"/, { token: 'string.quote', next: '@litinterpstring' }],
|
||||
[/\@"/, { token: 'string.quote', next: '@litstring' }],
|
||||
|
|
@ -147,21 +294,24 @@ export const language = <ILanguage>{
|
|||
],
|
||||
|
||||
qualified: [
|
||||
[/[a-zA-Z_][\w]*/, {
|
||||
cases: {
|
||||
'@keywords': { token: 'keyword.$0' },
|
||||
'@default': 'identifier'
|
||||
[
|
||||
/[a-zA-Z_][\w]*/,
|
||||
{
|
||||
cases: {
|
||||
'@keywords': { token: 'keyword.$0' },
|
||||
'@default': 'identifier'
|
||||
}
|
||||
}
|
||||
}],
|
||||
],
|
||||
[/\./, 'delimiter'],
|
||||
['', '', '@pop'],
|
||||
['', '', '@pop']
|
||||
],
|
||||
|
||||
namespace: [
|
||||
{ include: '@whitespace' },
|
||||
[/[A-Z]\w*/, 'namespace'],
|
||||
[/[\.=]/, 'delimiter'],
|
||||
['', '', '@pop'],
|
||||
['', '', '@pop']
|
||||
],
|
||||
|
||||
comment: [
|
||||
|
|
@ -208,7 +358,7 @@ export const language = <ILanguage>{
|
|||
[/^[ \t\v\f]*#\w.*$/, 'namespace.cpp'],
|
||||
[/[ \t\v\f\r\n]+/, ''],
|
||||
[/\/\*/, 'comment', '@comment'],
|
||||
[/\/\/.*$/, 'comment'],
|
||||
],
|
||||
},
|
||||
[/\/\/.*$/, 'comment']
|
||||
]
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -21,41 +21,41 @@ export const language = <ILanguage>{
|
|||
typeKeywords: [],
|
||||
tokenPostfix: '.csp',
|
||||
operators: [],
|
||||
symbols: /[=><!~?:&|+\-*\/\^%]+/,
|
||||
symbols: /[=><!~?:&|+\-*\/\^%]+/,
|
||||
escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
|
||||
tokenizer: {
|
||||
root: [
|
||||
[/child-src/, 'string.quote'],
|
||||
[/connect-src/, 'string.quote'],
|
||||
[/default-src/, 'string.quote'],
|
||||
[/font-src/, 'string.quote'],
|
||||
[/frame-src/, 'string.quote'],
|
||||
[/img-src/, 'string.quote'],
|
||||
[/manifest-src/, 'string.quote'],
|
||||
[/media-src/, 'string.quote'],
|
||||
[/object-src/, 'string.quote'],
|
||||
[/script-src/, 'string.quote'],
|
||||
[/style-src/, 'string.quote'],
|
||||
[/worker-src/, 'string.quote'],
|
||||
[/base-uri/, 'string.quote'],
|
||||
[/plugin-types/, 'string.quote'],
|
||||
[/sandbox/, 'string.quote'],
|
||||
[/disown-opener/, 'string.quote'],
|
||||
[/form-action/, 'string.quote'],
|
||||
[/frame-ancestors/, 'string.quote'],
|
||||
[/report-uri/, 'string.quote'],
|
||||
[/report-to/, 'string.quote'],
|
||||
[/upgrade-insecure-requests/, 'string.quote'],
|
||||
[/block-all-mixed-content/, 'string.quote'],
|
||||
[/require-sri-for/, 'string.quote'],
|
||||
[/reflected-xss/, 'string.quote'],
|
||||
[/referrer/, 'string.quote'],
|
||||
[/policy-uri/, 'string.quote'],
|
||||
[/'self'/, 'string.quote'],
|
||||
[/'unsafe-inline'/, 'string.quote'],
|
||||
[/'unsafe-eval'/, 'string.quote'],
|
||||
[/'strict-dynamic'/, 'string.quote'],
|
||||
[/'unsafe-hashed-attributes'/, 'string.quote']
|
||||
[/child-src/, 'string.quote'],
|
||||
[/connect-src/, 'string.quote'],
|
||||
[/default-src/, 'string.quote'],
|
||||
[/font-src/, 'string.quote'],
|
||||
[/frame-src/, 'string.quote'],
|
||||
[/img-src/, 'string.quote'],
|
||||
[/manifest-src/, 'string.quote'],
|
||||
[/media-src/, 'string.quote'],
|
||||
[/object-src/, 'string.quote'],
|
||||
[/script-src/, 'string.quote'],
|
||||
[/style-src/, 'string.quote'],
|
||||
[/worker-src/, 'string.quote'],
|
||||
[/base-uri/, 'string.quote'],
|
||||
[/plugin-types/, 'string.quote'],
|
||||
[/sandbox/, 'string.quote'],
|
||||
[/disown-opener/, 'string.quote'],
|
||||
[/form-action/, 'string.quote'],
|
||||
[/frame-ancestors/, 'string.quote'],
|
||||
[/report-uri/, 'string.quote'],
|
||||
[/report-to/, 'string.quote'],
|
||||
[/upgrade-insecure-requests/, 'string.quote'],
|
||||
[/block-all-mixed-content/, 'string.quote'],
|
||||
[/require-sri-for/, 'string.quote'],
|
||||
[/reflected-xss/, 'string.quote'],
|
||||
[/referrer/, 'string.quote'],
|
||||
[/policy-uri/, 'string.quote'],
|
||||
[/'self'/, 'string.quote'],
|
||||
[/'unsafe-inline'/, 'string.quote'],
|
||||
[/'unsafe-eval'/, 'string.quote'],
|
||||
[/'strict-dynamic'/, 'string.quote'],
|
||||
[/'unsafe-hashed-attributes'/, 'string.quote']
|
||||
]
|
||||
}
|
||||
};
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -26,7 +26,7 @@ export const conf: LanguageConfiguration = {
|
|||
{ open: '[', close: ']', notIn: ['string', 'comment'] },
|
||||
{ open: '(', close: ')', notIn: ['string', 'comment'] },
|
||||
{ open: '"', close: '"', notIn: ['string', 'comment'] },
|
||||
{ open: '\'', close: '\'', notIn: ['string', 'comment'] }
|
||||
{ open: "'", close: "'", notIn: ['string', 'comment'] }
|
||||
],
|
||||
|
||||
surroundingPairs: [
|
||||
|
|
@ -34,13 +34,13 @@ export const conf: LanguageConfiguration = {
|
|||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '"', close: '"' },
|
||||
{ open: '\'', close: '\'' }
|
||||
{ open: "'", close: "'" }
|
||||
],
|
||||
|
||||
folding: {
|
||||
markers: {
|
||||
start: new RegExp("^\\s*\\/\\*\\s*#region\\b\\s*(.*?)\\s*\\*\\/"),
|
||||
end: new RegExp("^\\s*\\/\\*\\s*#endregion\\b.*\\*\\/")
|
||||
start: new RegExp('^\\s*\\/\\*\\s*#region\\b\\s*(.*?)\\s*\\*\\/'),
|
||||
end: new RegExp('^\\s*\\/\\*\\s*#endregion\\b.*\\*\\/')
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -50,7 +50,8 @@ export const language = <IMonarchLanguage>{
|
|||
tokenPostfix: '.css',
|
||||
|
||||
ws: '[ \t\n\r\f]*', // whitespaces (referenced in several rules)
|
||||
identifier: '-?-?([a-zA-Z]|(\\\\(([0-9a-fA-F]{1,6}\\s?)|[^[0-9a-fA-F])))([\\w\\-]|(\\\\(([0-9a-fA-F]{1,6}\\s?)|[^[0-9a-fA-F])))*',
|
||||
identifier:
|
||||
'-?-?([a-zA-Z]|(\\\\(([0-9a-fA-F]{1,6}\\s?)|[^[0-9a-fA-F])))([\\w\\-]|(\\\\(([0-9a-fA-F]{1,6}\\s?)|[^[0-9a-fA-F])))*',
|
||||
|
||||
brackets: [
|
||||
{ open: '{', close: '}', token: 'delimiter.bracket' },
|
||||
|
|
@ -60,19 +61,35 @@ export const language = <IMonarchLanguage>{
|
|||
],
|
||||
|
||||
tokenizer: {
|
||||
root: [
|
||||
{ include: '@selector' },
|
||||
],
|
||||
root: [{ include: '@selector' }],
|
||||
|
||||
selector: [
|
||||
{ include: '@comments' },
|
||||
{ include: '@import' },
|
||||
{ include: '@strings' },
|
||||
['[@](keyframes|-webkit-keyframes|-moz-keyframes|-o-keyframes)', { token: 'keyword', next: '@keyframedeclaration' }],
|
||||
[
|
||||
'[@](keyframes|-webkit-keyframes|-moz-keyframes|-o-keyframes)',
|
||||
{ token: 'keyword', next: '@keyframedeclaration' }
|
||||
],
|
||||
['[@](page|content|font-face|-moz-document)', { token: 'keyword' }],
|
||||
['[@](charset|namespace)', { token: 'keyword', next: '@declarationbody' }],
|
||||
['(url-prefix)(\\()', ['attribute.value', { token: 'delimiter.parenthesis', next: '@urldeclaration' }]],
|
||||
['(url)(\\()', ['attribute.value', { token: 'delimiter.parenthesis', next: '@urldeclaration' }]],
|
||||
[
|
||||
'[@](charset|namespace)',
|
||||
{ token: 'keyword', next: '@declarationbody' }
|
||||
],
|
||||
[
|
||||
'(url-prefix)(\\()',
|
||||
[
|
||||
'attribute.value',
|
||||
{ token: 'delimiter.parenthesis', next: '@urldeclaration' }
|
||||
]
|
||||
],
|
||||
[
|
||||
'(url)(\\()',
|
||||
[
|
||||
'attribute.value',
|
||||
{ token: 'delimiter.parenthesis', next: '@urldeclaration' }
|
||||
]
|
||||
],
|
||||
{ include: '@selectorname' },
|
||||
['[\\*]', 'tag'], // selector symbols
|
||||
['[>\\+,]', 'delimiter'], // selector operators
|
||||
|
|
@ -82,23 +99,39 @@ export const language = <IMonarchLanguage>{
|
|||
|
||||
selectorbody: [
|
||||
{ include: '@comments' },
|
||||
['[*_]?@identifier@ws:(?=(\\s|\\d|[^{;}]*[;}]))', 'attribute.name', '@rulevalue'], // rule definition: to distinguish from a nested selector check for whitespace, number or a semicolon
|
||||
[
|
||||
'[*_]?@identifier@ws:(?=(\\s|\\d|[^{;}]*[;}]))',
|
||||
'attribute.name',
|
||||
'@rulevalue'
|
||||
], // rule definition: to distinguish from a nested selector check for whitespace, number or a semicolon
|
||||
['}', { token: 'delimiter.bracket', next: '@pop' }]
|
||||
],
|
||||
|
||||
selectorname: [
|
||||
['(\\.|#(?=[^{])|%|(@identifier)|:)+', 'tag'], // selector (.foo, div, ...)
|
||||
['(\\.|#(?=[^{])|%|(@identifier)|:)+', 'tag'] // selector (.foo, div, ...)
|
||||
],
|
||||
|
||||
selectorattribute: [
|
||||
{ include: '@term' },
|
||||
[']', { token: 'delimiter.bracket', next: '@pop' }],
|
||||
[']', { token: 'delimiter.bracket', next: '@pop' }]
|
||||
],
|
||||
|
||||
term: [
|
||||
{ include: '@comments' },
|
||||
['(url-prefix)(\\()', ['attribute.value', { token: 'delimiter.parenthesis', next: '@urldeclaration' }]],
|
||||
['(url)(\\()', ['attribute.value', { token: 'delimiter.parenthesis', next: '@urldeclaration' }]],
|
||||
[
|
||||
'(url-prefix)(\\()',
|
||||
[
|
||||
'attribute.value',
|
||||
{ token: 'delimiter.parenthesis', next: '@urldeclaration' }
|
||||
]
|
||||
],
|
||||
[
|
||||
'(url)(\\()',
|
||||
[
|
||||
'attribute.value',
|
||||
{ token: 'delimiter.parenthesis', next: '@urldeclaration' }
|
||||
]
|
||||
],
|
||||
{ include: '@functioninvocation' },
|
||||
{ include: '@numbers' },
|
||||
{ include: '@name' },
|
||||
|
|
@ -148,47 +181,55 @@ export const language = <IMonarchLanguage>{
|
|||
comment: [
|
||||
['\\*\\/', 'comment', '@pop'],
|
||||
[/[^*/]+/, 'comment'],
|
||||
[/./, 'comment'],
|
||||
[/./, 'comment']
|
||||
],
|
||||
|
||||
name: [
|
||||
['@identifier', 'attribute.value']
|
||||
],
|
||||
name: [['@identifier', 'attribute.value']],
|
||||
|
||||
numbers: [
|
||||
['-?(\\d*\\.)?\\d+([eE][\\-+]?\\d+)?', { token: 'attribute.value.number', next: '@units' }],
|
||||
[
|
||||
'-?(\\d*\\.)?\\d+([eE][\\-+]?\\d+)?',
|
||||
{ token: 'attribute.value.number', next: '@units' }
|
||||
],
|
||||
['#[0-9a-fA-F_]+(?!\\w)', 'attribute.value.hex']
|
||||
],
|
||||
|
||||
units: [
|
||||
['(em|ex|ch|rem|vmin|vmax|vw|vh|vm|cm|mm|in|px|pt|pc|deg|grad|rad|turn|s|ms|Hz|kHz|%)?', 'attribute.value.unit', '@pop']
|
||||
[
|
||||
'(em|ex|ch|rem|vmin|vmax|vw|vh|vm|cm|mm|in|px|pt|pc|deg|grad|rad|turn|s|ms|Hz|kHz|%)?',
|
||||
'attribute.value.unit',
|
||||
'@pop'
|
||||
]
|
||||
],
|
||||
|
||||
keyframedeclaration: [
|
||||
['@identifier', 'attribute.value'],
|
||||
['{', { token: 'delimiter.bracket', switchTo: '@keyframebody' }],
|
||||
['{', { token: 'delimiter.bracket', switchTo: '@keyframebody' }]
|
||||
],
|
||||
|
||||
keyframebody: [
|
||||
{ include: '@term' },
|
||||
['{', { token: 'delimiter.bracket', next: '@selectorbody' }],
|
||||
['}', { token: 'delimiter.bracket', next: '@pop' }],
|
||||
['}', { token: 'delimiter.bracket', next: '@pop' }]
|
||||
],
|
||||
|
||||
functioninvocation: [
|
||||
['@identifier\\(', { token: 'attribute.value', next: '@functionarguments' }],
|
||||
[
|
||||
'@identifier\\(',
|
||||
{ token: 'attribute.value', next: '@functionarguments' }
|
||||
]
|
||||
],
|
||||
|
||||
functionarguments: [
|
||||
['\\$@identifier@ws:', 'attribute.name'],
|
||||
['[,]', 'delimiter'],
|
||||
{ include: '@term' },
|
||||
['\\)', { token: 'attribute.value', next: '@pop' }],
|
||||
['\\)', { token: 'attribute.value', next: '@pop' }]
|
||||
],
|
||||
|
||||
strings: [
|
||||
['~?"', { token: 'string', next: '@stringenddoublequote' }],
|
||||
['~?\'', { token: 'string', next: '@stringendquote' }]
|
||||
["~?'", { token: 'string', next: '@stringendquote' }]
|
||||
],
|
||||
|
||||
stringenddoublequote: [
|
||||
|
|
@ -200,7 +241,7 @@ export const language = <IMonarchLanguage>{
|
|||
|
||||
stringendquote: [
|
||||
['\\\\.', 'string'],
|
||||
['\'', { token: 'string', next: '@pop' }],
|
||||
["'", { token: 'string', next: '@pop' }],
|
||||
[/[^\\']+/, 'string'],
|
||||
['.', 'string']
|
||||
]
|
||||
|
|
|
|||
|
|
@ -2,25 +2,25 @@
|
|||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
"use strict";
|
||||
'use strict';
|
||||
|
||||
import { testTokenization } from "../test/testRunner";
|
||||
import { testTokenization } from '../test/testRunner';
|
||||
|
||||
testTokenization("dart", [
|
||||
testTokenization('dart', [
|
||||
// Comments - single line
|
||||
[
|
||||
{
|
||||
line: "//",
|
||||
tokens: [{ startIndex: 0, type: "comment.dart" }]
|
||||
line: '//',
|
||||
tokens: [{ startIndex: 0, type: 'comment.dart' }]
|
||||
}
|
||||
],
|
||||
|
||||
[
|
||||
{
|
||||
line: " // a comment",
|
||||
line: ' // a comment',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: "" },
|
||||
{ startIndex: 4, type: "comment.dart" }
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 4, type: 'comment.dart' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
|
@ -28,73 +28,73 @@ testTokenization("dart", [
|
|||
// Broken nested tokens due to invalid comment tokenization
|
||||
[
|
||||
{
|
||||
line: "/* //*/ a",
|
||||
line: '/* //*/ a',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: "comment.dart" },
|
||||
{ startIndex: 7, type: "" },
|
||||
{ startIndex: 8, type: "identifier.dart" }
|
||||
{ startIndex: 0, type: 'comment.dart' },
|
||||
{ startIndex: 7, type: '' },
|
||||
{ startIndex: 8, type: 'identifier.dart' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[
|
||||
{
|
||||
line: "// a comment",
|
||||
tokens: [{ startIndex: 0, type: "comment.dart" }]
|
||||
line: '// a comment',
|
||||
tokens: [{ startIndex: 0, type: 'comment.dart' }]
|
||||
}
|
||||
],
|
||||
|
||||
[
|
||||
{
|
||||
line: "//sticky comment",
|
||||
tokens: [{ startIndex: 0, type: "comment.dart" }]
|
||||
line: '//sticky comment',
|
||||
tokens: [{ startIndex: 0, type: 'comment.dart' }]
|
||||
}
|
||||
],
|
||||
|
||||
[
|
||||
{
|
||||
line: "/almost a comment",
|
||||
line: '/almost a comment',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: "delimiter.dart" },
|
||||
{ startIndex: 1, type: "identifier.dart" },
|
||||
{ startIndex: 7, type: "" },
|
||||
{ startIndex: 8, type: "identifier.dart" },
|
||||
{ startIndex: 9, type: "" },
|
||||
{ startIndex: 10, type: "identifier.dart" }
|
||||
{ startIndex: 0, type: 'delimiter.dart' },
|
||||
{ startIndex: 1, type: 'identifier.dart' },
|
||||
{ startIndex: 7, type: '' },
|
||||
{ startIndex: 8, type: 'identifier.dart' },
|
||||
{ startIndex: 9, type: '' },
|
||||
{ startIndex: 10, type: 'identifier.dart' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[
|
||||
{
|
||||
line: "1 / 2; /* comment",
|
||||
line: '1 / 2; /* comment',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: "number.dart" },
|
||||
{ startIndex: 1, type: "" },
|
||||
{ startIndex: 2, type: "delimiter.dart" },
|
||||
{ startIndex: 3, type: "" },
|
||||
{ startIndex: 4, type: "number.dart" },
|
||||
{ startIndex: 5, type: "delimiter.dart" },
|
||||
{ startIndex: 6, type: "" },
|
||||
{ startIndex: 7, type: "comment.dart" }
|
||||
{ startIndex: 0, type: 'number.dart' },
|
||||
{ startIndex: 1, type: '' },
|
||||
{ startIndex: 2, type: 'delimiter.dart' },
|
||||
{ startIndex: 3, type: '' },
|
||||
{ startIndex: 4, type: 'number.dart' },
|
||||
{ startIndex: 5, type: 'delimiter.dart' },
|
||||
{ startIndex: 6, type: '' },
|
||||
{ startIndex: 7, type: 'comment.dart' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[
|
||||
{
|
||||
line: "var x = 1; // my comment // is a nice one",
|
||||
line: 'var x = 1; // my comment // is a nice one',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: "keyword.dart" },
|
||||
{ startIndex: 3, type: "" },
|
||||
{ startIndex: 4, type: "identifier.dart" },
|
||||
{ startIndex: 5, type: "" },
|
||||
{ startIndex: 6, type: "delimiter.dart" },
|
||||
{ startIndex: 7, type: "" },
|
||||
{ startIndex: 8, type: "number.dart" },
|
||||
{ startIndex: 9, type: "delimiter.dart" },
|
||||
{ startIndex: 10, type: "" },
|
||||
{ startIndex: 11, type: "comment.dart" }
|
||||
{ startIndex: 0, type: 'keyword.dart' },
|
||||
{ startIndex: 3, type: '' },
|
||||
{ startIndex: 4, type: 'identifier.dart' },
|
||||
{ startIndex: 5, type: '' },
|
||||
{ startIndex: 6, type: 'delimiter.dart' },
|
||||
{ startIndex: 7, type: '' },
|
||||
{ startIndex: 8, type: 'number.dart' },
|
||||
{ startIndex: 9, type: 'delimiter.dart' },
|
||||
{ startIndex: 10, type: '' },
|
||||
{ startIndex: 11, type: 'comment.dart' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
|
@ -102,71 +102,71 @@ testTokenization("dart", [
|
|||
// Comments - range comment, single line
|
||||
[
|
||||
{
|
||||
line: "/* a simple comment */",
|
||||
tokens: [{ startIndex: 0, type: "comment.dart" }]
|
||||
line: '/* a simple comment */',
|
||||
tokens: [{ startIndex: 0, type: 'comment.dart' }]
|
||||
}
|
||||
],
|
||||
|
||||
[
|
||||
{
|
||||
line: "var x = /* a simple comment */ 1;",
|
||||
line: 'var x = /* a simple comment */ 1;',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: "keyword.dart" },
|
||||
{ startIndex: 3, type: "" },
|
||||
{ startIndex: 4, type: "identifier.dart" },
|
||||
{ startIndex: 5, type: "" },
|
||||
{ startIndex: 6, type: "delimiter.dart" },
|
||||
{ startIndex: 7, type: "" },
|
||||
{ startIndex: 8, type: "comment.dart" },
|
||||
{ startIndex: 30, type: "" },
|
||||
{ startIndex: 31, type: "number.dart" },
|
||||
{ startIndex: 32, type: "delimiter.dart" }
|
||||
{ startIndex: 0, type: 'keyword.dart' },
|
||||
{ startIndex: 3, type: '' },
|
||||
{ startIndex: 4, type: 'identifier.dart' },
|
||||
{ startIndex: 5, type: '' },
|
||||
{ startIndex: 6, type: 'delimiter.dart' },
|
||||
{ startIndex: 7, type: '' },
|
||||
{ startIndex: 8, type: 'comment.dart' },
|
||||
{ startIndex: 30, type: '' },
|
||||
{ startIndex: 31, type: 'number.dart' },
|
||||
{ startIndex: 32, type: 'delimiter.dart' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[
|
||||
{
|
||||
line: "var x = /* comment */ 1; */",
|
||||
line: 'var x = /* comment */ 1; */',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: "keyword.dart" },
|
||||
{ startIndex: 3, type: "" },
|
||||
{ startIndex: 4, type: "identifier.dart" },
|
||||
{ startIndex: 5, type: "" },
|
||||
{ startIndex: 6, type: "delimiter.dart" },
|
||||
{ startIndex: 7, type: "" },
|
||||
{ startIndex: 8, type: "comment.dart" },
|
||||
{ startIndex: 21, type: "" },
|
||||
{ startIndex: 22, type: "number.dart" },
|
||||
{ startIndex: 23, type: "delimiter.dart" },
|
||||
{ startIndex: 24, type: "" }
|
||||
{ startIndex: 0, type: 'keyword.dart' },
|
||||
{ startIndex: 3, type: '' },
|
||||
{ startIndex: 4, type: 'identifier.dart' },
|
||||
{ startIndex: 5, type: '' },
|
||||
{ startIndex: 6, type: 'delimiter.dart' },
|
||||
{ startIndex: 7, type: '' },
|
||||
{ startIndex: 8, type: 'comment.dart' },
|
||||
{ startIndex: 21, type: '' },
|
||||
{ startIndex: 22, type: 'number.dart' },
|
||||
{ startIndex: 23, type: 'delimiter.dart' },
|
||||
{ startIndex: 24, type: '' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[
|
||||
{
|
||||
line: "x = /**/;",
|
||||
line: 'x = /**/;',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: "identifier.dart" },
|
||||
{ startIndex: 1, type: "" },
|
||||
{ startIndex: 2, type: "delimiter.dart" },
|
||||
{ startIndex: 3, type: "" },
|
||||
{ startIndex: 4, type: "comment.dart" },
|
||||
{ startIndex: 8, type: "delimiter.dart" }
|
||||
{ startIndex: 0, type: 'identifier.dart' },
|
||||
{ startIndex: 1, type: '' },
|
||||
{ startIndex: 2, type: 'delimiter.dart' },
|
||||
{ startIndex: 3, type: '' },
|
||||
{ startIndex: 4, type: 'comment.dart' },
|
||||
{ startIndex: 8, type: 'delimiter.dart' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[
|
||||
{
|
||||
line: "x = /*/;",
|
||||
line: 'x = /*/;',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: "identifier.dart" },
|
||||
{ startIndex: 1, type: "" },
|
||||
{ startIndex: 2, type: "delimiter.dart" },
|
||||
{ startIndex: 3, type: "" },
|
||||
{ startIndex: 4, type: "comment.dart" }
|
||||
{ startIndex: 0, type: 'identifier.dart' },
|
||||
{ startIndex: 1, type: '' },
|
||||
{ startIndex: 2, type: 'delimiter.dart' },
|
||||
{ startIndex: 3, type: '' },
|
||||
{ startIndex: 4, type: 'comment.dart' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
|
@ -174,43 +174,43 @@ testTokenization("dart", [
|
|||
// Comments - range comment, multiple lines
|
||||
[
|
||||
{
|
||||
line: "/* start of multiline comment",
|
||||
tokens: [{ startIndex: 0, type: "comment.dart" }]
|
||||
line: '/* start of multiline comment',
|
||||
tokens: [{ startIndex: 0, type: 'comment.dart' }]
|
||||
},
|
||||
{
|
||||
line: "a comment between without a star",
|
||||
tokens: [{ startIndex: 0, type: "comment.dart" }]
|
||||
line: 'a comment between without a star',
|
||||
tokens: [{ startIndex: 0, type: 'comment.dart' }]
|
||||
},
|
||||
{
|
||||
line: "end of multiline comment*/",
|
||||
tokens: [{ startIndex: 0, type: "comment.dart" }]
|
||||
line: 'end of multiline comment*/',
|
||||
tokens: [{ startIndex: 0, type: 'comment.dart' }]
|
||||
}
|
||||
],
|
||||
|
||||
[
|
||||
{
|
||||
line: "var x = /* start a comment",
|
||||
line: 'var x = /* start a comment',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: "keyword.dart" },
|
||||
{ startIndex: 3, type: "" },
|
||||
{ startIndex: 4, type: "identifier.dart" },
|
||||
{ startIndex: 5, type: "" },
|
||||
{ startIndex: 6, type: "delimiter.dart" },
|
||||
{ startIndex: 7, type: "" },
|
||||
{ startIndex: 8, type: "comment.dart" }
|
||||
{ startIndex: 0, type: 'keyword.dart' },
|
||||
{ startIndex: 3, type: '' },
|
||||
{ startIndex: 4, type: 'identifier.dart' },
|
||||
{ startIndex: 5, type: '' },
|
||||
{ startIndex: 6, type: 'delimiter.dart' },
|
||||
{ startIndex: 7, type: '' },
|
||||
{ startIndex: 8, type: 'comment.dart' }
|
||||
]
|
||||
},
|
||||
{
|
||||
line: " a ",
|
||||
tokens: [{ startIndex: 0, type: "comment.dart" }]
|
||||
line: ' a ',
|
||||
tokens: [{ startIndex: 0, type: 'comment.dart' }]
|
||||
},
|
||||
{
|
||||
line: "and end it */ 2;",
|
||||
line: 'and end it */ 2;',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: "comment.dart" },
|
||||
{ startIndex: 13, type: "" },
|
||||
{ startIndex: 14, type: "number.dart" },
|
||||
{ startIndex: 15, type: "delimiter.dart" }
|
||||
{ startIndex: 0, type: 'comment.dart' },
|
||||
{ startIndex: 13, type: '' },
|
||||
{ startIndex: 14, type: 'number.dart' },
|
||||
{ startIndex: 15, type: 'delimiter.dart' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
|
@ -218,32 +218,32 @@ testTokenization("dart", [
|
|||
// Keywords
|
||||
[
|
||||
{
|
||||
line: "var x = function() { };",
|
||||
line: 'var x = function() { };',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: "keyword.dart" },
|
||||
{ startIndex: 3, type: "" },
|
||||
{ startIndex: 4, type: "identifier.dart" },
|
||||
{ startIndex: 5, type: "" },
|
||||
{ startIndex: 6, type: "delimiter.dart" },
|
||||
{ startIndex: 7, type: "" },
|
||||
{ startIndex: 8, type: "identifier.dart" },
|
||||
{ startIndex: 16, type: "delimiter.parenthesis.dart" },
|
||||
{ startIndex: 18, type: "" },
|
||||
{ startIndex: 19, type: "delimiter.bracket.dart" },
|
||||
{ startIndex: 20, type: "" },
|
||||
{ startIndex: 21, type: "delimiter.bracket.dart" },
|
||||
{ startIndex: 22, type: "delimiter.dart" }
|
||||
{ startIndex: 0, type: 'keyword.dart' },
|
||||
{ startIndex: 3, type: '' },
|
||||
{ startIndex: 4, type: 'identifier.dart' },
|
||||
{ startIndex: 5, type: '' },
|
||||
{ startIndex: 6, type: 'delimiter.dart' },
|
||||
{ startIndex: 7, type: '' },
|
||||
{ startIndex: 8, type: 'identifier.dart' },
|
||||
{ startIndex: 16, type: 'delimiter.parenthesis.dart' },
|
||||
{ startIndex: 18, type: '' },
|
||||
{ startIndex: 19, type: 'delimiter.bracket.dart' },
|
||||
{ startIndex: 20, type: '' },
|
||||
{ startIndex: 21, type: 'delimiter.bracket.dart' },
|
||||
{ startIndex: 22, type: 'delimiter.dart' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[
|
||||
{
|
||||
line: " var ",
|
||||
line: ' var ',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: "" },
|
||||
{ startIndex: 4, type: "keyword.dart" },
|
||||
{ startIndex: 7, type: "" }
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 4, type: 'keyword.dart' },
|
||||
{ startIndex: 7, type: '' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
|
@ -251,228 +251,228 @@ testTokenization("dart", [
|
|||
// Numbers
|
||||
[
|
||||
{
|
||||
line: "0",
|
||||
tokens: [{ startIndex: 0, type: "number.dart" }]
|
||||
line: '0',
|
||||
tokens: [{ startIndex: 0, type: 'number.dart' }]
|
||||
}
|
||||
],
|
||||
|
||||
[
|
||||
{
|
||||
line: "0.10",
|
||||
tokens: [{ startIndex: 0, type: "number.float.dart" }]
|
||||
line: '0.10',
|
||||
tokens: [{ startIndex: 0, type: 'number.float.dart' }]
|
||||
}
|
||||
],
|
||||
|
||||
[
|
||||
{
|
||||
line: "0x",
|
||||
line: '0x',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: "number.dart" },
|
||||
{ startIndex: 1, type: "identifier.dart" }
|
||||
{ startIndex: 0, type: 'number.dart' },
|
||||
{ startIndex: 1, type: 'identifier.dart' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[
|
||||
{
|
||||
line: "0x123",
|
||||
tokens: [{ startIndex: 0, type: "number.hex.dart" }]
|
||||
line: '0x123',
|
||||
tokens: [{ startIndex: 0, type: 'number.hex.dart' }]
|
||||
}
|
||||
],
|
||||
|
||||
[
|
||||
{
|
||||
line: "0x5_2",
|
||||
tokens: [{ startIndex: 0, type: "number.hex.dart" }]
|
||||
line: '0x5_2',
|
||||
tokens: [{ startIndex: 0, type: 'number.hex.dart' }]
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
line: "0b1010_0101",
|
||||
tokens: [{ startIndex: 0, type: "number.binary.dart" }]
|
||||
line: '0b1010_0101',
|
||||
tokens: [{ startIndex: 0, type: 'number.binary.dart' }]
|
||||
}
|
||||
],
|
||||
|
||||
[
|
||||
{
|
||||
line: "0B001",
|
||||
tokens: [{ startIndex: 0, type: "number.binary.dart" }]
|
||||
line: '0B001',
|
||||
tokens: [{ startIndex: 0, type: 'number.binary.dart' }]
|
||||
}
|
||||
],
|
||||
|
||||
[
|
||||
{
|
||||
line: "10e3",
|
||||
tokens: [{ startIndex: 0, type: "number.float.dart" }]
|
||||
line: '10e3',
|
||||
tokens: [{ startIndex: 0, type: 'number.float.dart' }]
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
line: "23.5",
|
||||
tokens: [{ startIndex: 0, type: "number.float.dart" }]
|
||||
line: '23.5',
|
||||
tokens: [{ startIndex: 0, type: 'number.float.dart' }]
|
||||
}
|
||||
],
|
||||
|
||||
[
|
||||
{
|
||||
line: "23.5e3",
|
||||
tokens: [{ startIndex: 0, type: "number.float.dart" }]
|
||||
line: '23.5e3',
|
||||
tokens: [{ startIndex: 0, type: 'number.float.dart' }]
|
||||
}
|
||||
],
|
||||
|
||||
[
|
||||
{
|
||||
line: "23.5e-3",
|
||||
tokens: [{ startIndex: 0, type: "number.float.dart" }]
|
||||
line: '23.5e-3',
|
||||
tokens: [{ startIndex: 0, type: 'number.float.dart' }]
|
||||
}
|
||||
],
|
||||
|
||||
[
|
||||
{
|
||||
line: "23.5E3",
|
||||
tokens: [{ startIndex: 0, type: "number.float.dart" }]
|
||||
line: '23.5E3',
|
||||
tokens: [{ startIndex: 0, type: 'number.float.dart' }]
|
||||
}
|
||||
],
|
||||
|
||||
[
|
||||
{
|
||||
line: "23.5E-3",
|
||||
tokens: [{ startIndex: 0, type: "number.float.dart" }]
|
||||
line: '23.5E-3',
|
||||
tokens: [{ startIndex: 0, type: 'number.float.dart' }]
|
||||
}
|
||||
],
|
||||
|
||||
[
|
||||
{
|
||||
line: "0_52",
|
||||
tokens: [{ startIndex: 0, type: "number.dart" }]
|
||||
line: '0_52',
|
||||
tokens: [{ startIndex: 0, type: 'number.dart' }]
|
||||
}
|
||||
],
|
||||
|
||||
[
|
||||
{
|
||||
line: "5_2",
|
||||
tokens: [{ startIndex: 0, type: "number.dart" }]
|
||||
line: '5_2',
|
||||
tokens: [{ startIndex: 0, type: 'number.dart' }]
|
||||
}
|
||||
],
|
||||
|
||||
[
|
||||
{
|
||||
line: "5_______2",
|
||||
tokens: [{ startIndex: 0, type: "number.dart" }]
|
||||
line: '5_______2',
|
||||
tokens: [{ startIndex: 0, type: 'number.dart' }]
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
line: "3._1415F",
|
||||
line: '3._1415F',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: "number.dart" },
|
||||
{ startIndex: 1, type: "delimiter.dart" },
|
||||
{ startIndex: 2, type: "identifier.dart" }
|
||||
{ startIndex: 0, type: 'number.dart' },
|
||||
{ startIndex: 1, type: 'delimiter.dart' },
|
||||
{ startIndex: 2, type: 'identifier.dart' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[
|
||||
{
|
||||
line: "999_99_9999_L",
|
||||
line: '999_99_9999_L',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: "number.dart" },
|
||||
{ startIndex: 11, type: "identifier.dart" }
|
||||
{ startIndex: 0, type: 'number.dart' },
|
||||
{ startIndex: 11, type: 'identifier.dart' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[
|
||||
{
|
||||
line: "52_",
|
||||
line: '52_',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: "number.dart" },
|
||||
{ startIndex: 2, type: "identifier.dart" }
|
||||
{ startIndex: 0, type: 'number.dart' },
|
||||
{ startIndex: 2, type: 'identifier.dart' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[
|
||||
{
|
||||
line: "0_x52",
|
||||
line: '0_x52',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: "number.dart" },
|
||||
{ startIndex: 1, type: "identifier.dart" }
|
||||
{ startIndex: 0, type: 'number.dart' },
|
||||
{ startIndex: 1, type: 'identifier.dart' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[
|
||||
{
|
||||
line: "0x_52",
|
||||
line: '0x_52',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: "number.dart" },
|
||||
{ startIndex: 1, type: "identifier.dart" }
|
||||
{ startIndex: 0, type: 'number.dart' },
|
||||
{ startIndex: 1, type: 'identifier.dart' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[
|
||||
{
|
||||
line: "0x52_",
|
||||
line: '0x52_',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: "number.hex.dart" },
|
||||
{ startIndex: 4, type: "identifier.dart" }
|
||||
{ startIndex: 0, type: 'number.hex.dart' },
|
||||
{ startIndex: 4, type: 'identifier.dart' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[
|
||||
{
|
||||
line: "052_",
|
||||
line: '052_',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: "number.octal.dart" },
|
||||
{ startIndex: 3, type: "identifier.dart" }
|
||||
{ startIndex: 0, type: 'number.octal.dart' },
|
||||
{ startIndex: 3, type: 'identifier.dart' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[
|
||||
{
|
||||
line: "23.5L",
|
||||
line: '23.5L',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: "number.float.dart" },
|
||||
{ startIndex: 4, type: "type.identifier.dart" }
|
||||
{ startIndex: 0, type: 'number.float.dart' },
|
||||
{ startIndex: 4, type: 'type.identifier.dart' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[
|
||||
{
|
||||
line: "0+0",
|
||||
line: '0+0',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: "number.dart" },
|
||||
{ startIndex: 1, type: "delimiter.dart" },
|
||||
{ startIndex: 2, type: "number.dart" }
|
||||
{ startIndex: 0, type: 'number.dart' },
|
||||
{ startIndex: 1, type: 'delimiter.dart' },
|
||||
{ startIndex: 2, type: 'number.dart' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[
|
||||
{
|
||||
line: "100+10",
|
||||
line: '100+10',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: "number.dart" },
|
||||
{ startIndex: 3, type: "delimiter.dart" },
|
||||
{ startIndex: 4, type: "number.dart" }
|
||||
{ startIndex: 0, type: 'number.dart' },
|
||||
{ startIndex: 3, type: 'delimiter.dart' },
|
||||
{ startIndex: 4, type: 'number.dart' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[
|
||||
{
|
||||
line: "0 + 0",
|
||||
line: '0 + 0',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: "number.dart" },
|
||||
{ startIndex: 1, type: "" },
|
||||
{ startIndex: 2, type: "delimiter.dart" },
|
||||
{ startIndex: 3, type: "" },
|
||||
{ startIndex: 4, type: "number.dart" }
|
||||
{ startIndex: 0, type: 'number.dart' },
|
||||
{ startIndex: 1, type: '' },
|
||||
{ startIndex: 2, type: 'delimiter.dart' },
|
||||
{ startIndex: 3, type: '' },
|
||||
{ startIndex: 4, type: 'number.dart' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
|
@ -482,14 +482,14 @@ testTokenization("dart", [
|
|||
{
|
||||
line: "var s = 's';",
|
||||
tokens: [
|
||||
{ startIndex: 0, type: "keyword.dart" },
|
||||
{ startIndex: 3, type: "" },
|
||||
{ startIndex: 4, type: "identifier.dart" },
|
||||
{ startIndex: 5, type: "" },
|
||||
{ startIndex: 6, type: "delimiter.dart" },
|
||||
{ startIndex: 7, type: "" },
|
||||
{ startIndex: 8, type: "string.dart" },
|
||||
{ startIndex: 11, type: "delimiter.dart" }
|
||||
{ startIndex: 0, type: 'keyword.dart' },
|
||||
{ startIndex: 3, type: '' },
|
||||
{ startIndex: 4, type: 'identifier.dart' },
|
||||
{ startIndex: 5, type: '' },
|
||||
{ startIndex: 6, type: 'delimiter.dart' },
|
||||
{ startIndex: 7, type: '' },
|
||||
{ startIndex: 8, type: 'string.dart' },
|
||||
{ startIndex: 11, type: 'delimiter.dart' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
|
@ -498,19 +498,19 @@ testTokenization("dart", [
|
|||
{
|
||||
line: 'String s = "concatenated" + " String" ;',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: "type.identifier.dart" },
|
||||
{ startIndex: 6, type: "" },
|
||||
{ startIndex: 7, type: "identifier.dart" },
|
||||
{ startIndex: 8, type: "" },
|
||||
{ startIndex: 9, type: "delimiter.dart" },
|
||||
{ startIndex: 10, type: "" },
|
||||
{ startIndex: 11, type: "string.dart" },
|
||||
{ startIndex: 25, type: "" },
|
||||
{ startIndex: 26, type: "delimiter.dart" },
|
||||
{ startIndex: 27, type: "" },
|
||||
{ startIndex: 28, type: "string.dart" },
|
||||
{ startIndex: 37, type: "" },
|
||||
{ startIndex: 38, type: "delimiter.dart" }
|
||||
{ startIndex: 0, type: 'type.identifier.dart' },
|
||||
{ startIndex: 6, type: '' },
|
||||
{ startIndex: 7, type: 'identifier.dart' },
|
||||
{ startIndex: 8, type: '' },
|
||||
{ startIndex: 9, type: 'delimiter.dart' },
|
||||
{ startIndex: 10, type: '' },
|
||||
{ startIndex: 11, type: 'string.dart' },
|
||||
{ startIndex: 25, type: '' },
|
||||
{ startIndex: 26, type: 'delimiter.dart' },
|
||||
{ startIndex: 27, type: '' },
|
||||
{ startIndex: 28, type: 'string.dart' },
|
||||
{ startIndex: 37, type: '' },
|
||||
{ startIndex: 38, type: 'delimiter.dart' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
|
@ -518,7 +518,7 @@ testTokenization("dart", [
|
|||
[
|
||||
{
|
||||
line: '"quote in a string"',
|
||||
tokens: [{ startIndex: 0, type: "string.dart" }]
|
||||
tokens: [{ startIndex: 0, type: 'string.dart' }]
|
||||
}
|
||||
],
|
||||
|
||||
|
|
@ -526,11 +526,11 @@ testTokenization("dart", [
|
|||
{
|
||||
line: '"escaping \\"quotes\\" is cool"',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: "string.dart" },
|
||||
{ startIndex: 10, type: "string.escape.dart" },
|
||||
{ startIndex: 12, type: "string.dart" },
|
||||
{ startIndex: 18, type: "string.escape.dart" },
|
||||
{ startIndex: 20, type: "string.dart" }
|
||||
{ startIndex: 0, type: 'string.dart' },
|
||||
{ startIndex: 10, type: 'string.escape.dart' },
|
||||
{ startIndex: 12, type: 'string.dart' },
|
||||
{ startIndex: 18, type: 'string.escape.dart' },
|
||||
{ startIndex: 20, type: 'string.dart' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
|
@ -538,22 +538,22 @@ testTokenization("dart", [
|
|||
[
|
||||
{
|
||||
line: '"\\"',
|
||||
tokens: [{ startIndex: 0, type: "string.invalid.dart" }]
|
||||
tokens: [{ startIndex: 0, type: 'string.invalid.dart' }]
|
||||
}
|
||||
],
|
||||
|
||||
// Annotations
|
||||
[
|
||||
{
|
||||
line: "@",
|
||||
tokens: [{ startIndex: 0, type: "invalid.dart" }]
|
||||
line: '@',
|
||||
tokens: [{ startIndex: 0, type: 'invalid.dart' }]
|
||||
}
|
||||
],
|
||||
|
||||
[
|
||||
{
|
||||
line: "@Override",
|
||||
tokens: [{ startIndex: 0, type: "annotation.dart" }]
|
||||
line: '@Override',
|
||||
tokens: [{ startIndex: 0, type: 'annotation.dart' }]
|
||||
}
|
||||
]
|
||||
]);
|
||||
|
|
|
|||
376
src/dart/dart.ts
376
src/dart/dart.ts
|
|
@ -3,40 +3,40 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
"use strict";
|
||||
'use strict';
|
||||
|
||||
import LanguageConfiguration = monaco.languages.LanguageConfiguration;
|
||||
import IMonarchLanguage = monaco.languages.IMonarchLanguage;
|
||||
|
||||
export const conf: LanguageConfiguration = {
|
||||
comments: {
|
||||
lineComment: "//",
|
||||
blockComment: ["/*", "*/"]
|
||||
lineComment: '//',
|
||||
blockComment: ['/*', '*/']
|
||||
},
|
||||
brackets: [
|
||||
["{", "}"],
|
||||
["[", "]"],
|
||||
["(", ")"]
|
||||
['{', '}'],
|
||||
['[', ']'],
|
||||
['(', ')']
|
||||
],
|
||||
autoClosingPairs: [
|
||||
{ open: "{", close: "}" },
|
||||
{ open: "[", close: "]" },
|
||||
{ open: "(", close: ")" },
|
||||
{ open: "'", close: "'", notIn: ["string", "comment"] },
|
||||
{ open: '"', close: '"', notIn: ["string"] },
|
||||
{ open: "`", close: "`", notIn: ["string", "comment"] },
|
||||
{ open: "/**", close: " */", notIn: ["string"] }
|
||||
{ open: '{', close: '}' },
|
||||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: "'", close: "'", notIn: ['string', 'comment'] },
|
||||
{ open: '"', close: '"', notIn: ['string'] },
|
||||
{ open: '`', close: '`', notIn: ['string', 'comment'] },
|
||||
{ open: '/**', close: ' */', notIn: ['string'] }
|
||||
],
|
||||
surroundingPairs: [
|
||||
{ open: "{", close: "}" },
|
||||
{ open: "[", close: "]" },
|
||||
{ open: "(", close: ")" },
|
||||
{ open: '{', close: '}' },
|
||||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
|
||||
{ open: "<", close: ">" },
|
||||
{ open: '<', close: '>' },
|
||||
{ open: "'", close: "'" },
|
||||
{ open: "(", close: ")" },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '"', close: '"' },
|
||||
{ open: "`", close: "`" }
|
||||
{ open: '`', close: '`' }
|
||||
],
|
||||
folding: {
|
||||
markers: {
|
||||
|
|
@ -47,114 +47,114 @@ export const conf: LanguageConfiguration = {
|
|||
};
|
||||
|
||||
export const language = <IMonarchLanguage>{
|
||||
defaultToken: "invalid",
|
||||
tokenPostfix: ".dart",
|
||||
defaultToken: 'invalid',
|
||||
tokenPostfix: '.dart',
|
||||
|
||||
keywords: [
|
||||
"abstract",
|
||||
"dynamic",
|
||||
"implements",
|
||||
"show",
|
||||
"as",
|
||||
"else",
|
||||
"import",
|
||||
"static",
|
||||
"assert",
|
||||
"enum",
|
||||
"in",
|
||||
"super",
|
||||
"async",
|
||||
"export",
|
||||
"interface",
|
||||
"switch",
|
||||
"await",
|
||||
"extends",
|
||||
"is",
|
||||
"sync",
|
||||
"break",
|
||||
"external",
|
||||
"library",
|
||||
"this",
|
||||
"case",
|
||||
"factory",
|
||||
"mixin",
|
||||
"throw",
|
||||
"catch",
|
||||
"false",
|
||||
"new",
|
||||
"true",
|
||||
"class",
|
||||
"final",
|
||||
"null",
|
||||
"try",
|
||||
"const",
|
||||
"finally",
|
||||
"on",
|
||||
"typedef",
|
||||
"continue",
|
||||
"for",
|
||||
"operator",
|
||||
"var",
|
||||
"covariant",
|
||||
"Function",
|
||||
"part",
|
||||
"void",
|
||||
"default",
|
||||
"get",
|
||||
"rethrow",
|
||||
"while",
|
||||
"deferred",
|
||||
"hide",
|
||||
"return",
|
||||
"with",
|
||||
"do",
|
||||
"if",
|
||||
"set",
|
||||
"yield"
|
||||
'abstract',
|
||||
'dynamic',
|
||||
'implements',
|
||||
'show',
|
||||
'as',
|
||||
'else',
|
||||
'import',
|
||||
'static',
|
||||
'assert',
|
||||
'enum',
|
||||
'in',
|
||||
'super',
|
||||
'async',
|
||||
'export',
|
||||
'interface',
|
||||
'switch',
|
||||
'await',
|
||||
'extends',
|
||||
'is',
|
||||
'sync',
|
||||
'break',
|
||||
'external',
|
||||
'library',
|
||||
'this',
|
||||
'case',
|
||||
'factory',
|
||||
'mixin',
|
||||
'throw',
|
||||
'catch',
|
||||
'false',
|
||||
'new',
|
||||
'true',
|
||||
'class',
|
||||
'final',
|
||||
'null',
|
||||
'try',
|
||||
'const',
|
||||
'finally',
|
||||
'on',
|
||||
'typedef',
|
||||
'continue',
|
||||
'for',
|
||||
'operator',
|
||||
'var',
|
||||
'covariant',
|
||||
'Function',
|
||||
'part',
|
||||
'void',
|
||||
'default',
|
||||
'get',
|
||||
'rethrow',
|
||||
'while',
|
||||
'deferred',
|
||||
'hide',
|
||||
'return',
|
||||
'with',
|
||||
'do',
|
||||
'if',
|
||||
'set',
|
||||
'yield'
|
||||
],
|
||||
typeKeywords: ["int", "double", "String", "bool"],
|
||||
typeKeywords: ['int', 'double', 'String', 'bool'],
|
||||
|
||||
operators: [
|
||||
"+",
|
||||
"-",
|
||||
"*",
|
||||
"/",
|
||||
"~/",
|
||||
"%",
|
||||
"++",
|
||||
"--",
|
||||
"==",
|
||||
"!=",
|
||||
">",
|
||||
"<",
|
||||
">=",
|
||||
"<=",
|
||||
"=",
|
||||
"-=",
|
||||
"/=",
|
||||
"%=",
|
||||
">>=",
|
||||
"^=",
|
||||
"+=",
|
||||
"*=",
|
||||
"~/=",
|
||||
"<<=",
|
||||
"&=",
|
||||
"!=",
|
||||
"||",
|
||||
"&&",
|
||||
"&",
|
||||
"|",
|
||||
"^",
|
||||
"~",
|
||||
"<<",
|
||||
">>",
|
||||
"!",
|
||||
">>>",
|
||||
"??",
|
||||
"?",
|
||||
":",
|
||||
"|="
|
||||
'+',
|
||||
'-',
|
||||
'*',
|
||||
'/',
|
||||
'~/',
|
||||
'%',
|
||||
'++',
|
||||
'--',
|
||||
'==',
|
||||
'!=',
|
||||
'>',
|
||||
'<',
|
||||
'>=',
|
||||
'<=',
|
||||
'=',
|
||||
'-=',
|
||||
'/=',
|
||||
'%=',
|
||||
'>>=',
|
||||
'^=',
|
||||
'+=',
|
||||
'*=',
|
||||
'~/=',
|
||||
'<<=',
|
||||
'&=',
|
||||
'!=',
|
||||
'||',
|
||||
'&&',
|
||||
'&',
|
||||
'|',
|
||||
'^',
|
||||
'~',
|
||||
'<<',
|
||||
'>>',
|
||||
'!',
|
||||
'>>>',
|
||||
'??',
|
||||
'?',
|
||||
':',
|
||||
'|='
|
||||
],
|
||||
|
||||
// we include these common regular expressions
|
||||
|
|
@ -170,7 +170,7 @@ export const language = <IMonarchLanguage>{
|
|||
|
||||
// The main tokenizer for our languages
|
||||
tokenizer: {
|
||||
root: [[/[{}]/, "delimiter.bracket"], { include: "common" }],
|
||||
root: [[/[{}]/, 'delimiter.bracket'], { include: 'common' }],
|
||||
|
||||
common: [
|
||||
// identifiers and keywords
|
||||
|
|
@ -178,83 +178,80 @@ export const language = <IMonarchLanguage>{
|
|||
/[a-z_$][\w$]*/,
|
||||
{
|
||||
cases: {
|
||||
"@typeKeywords": "type.identifier",
|
||||
"@keywords": "keyword",
|
||||
"@default": "identifier"
|
||||
'@typeKeywords': 'type.identifier',
|
||||
'@keywords': 'keyword',
|
||||
'@default': 'identifier'
|
||||
}
|
||||
}
|
||||
],
|
||||
[
|
||||
/(?<![a-zA-Z0-9_$])([_$]*[A-Z][a-zA-Z0-9_$]*)/,
|
||||
"type.identifier"
|
||||
], // to show class names nicely
|
||||
[/(?<![a-zA-Z0-9_$])([_$]*[A-Z][a-zA-Z0-9_$]*)/, 'type.identifier'], // to show class names nicely
|
||||
// [/[A-Z][\w\$]*/, 'identifier'],
|
||||
|
||||
// whitespace
|
||||
{ include: "@whitespace" },
|
||||
{ include: '@whitespace' },
|
||||
|
||||
// regular expression: ensure it is terminated before beginning (otherwise it is an opeator)
|
||||
[
|
||||
/\/(?=([^\\\/]|\\.)+\/([gimsuy]*)(\s*)(\.|;|,|\)|\]|\}|$))/,
|
||||
{ token: "regexp", bracket: "@open", next: "@regexp" }
|
||||
{ token: 'regexp', bracket: '@open', next: '@regexp' }
|
||||
],
|
||||
|
||||
// @ annotations.
|
||||
[/@[a-zA-Z]+/, "annotation"],
|
||||
[/@[a-zA-Z]+/, 'annotation'],
|
||||
// variable
|
||||
|
||||
// delimiters and operators
|
||||
[/[()\[\]]/, "@brackets"],
|
||||
[/[<>](?!@symbols)/, "@brackets"],
|
||||
[/!(?=([^=]|$))/, "delimiter"],
|
||||
[/[()\[\]]/, '@brackets'],
|
||||
[/[<>](?!@symbols)/, '@brackets'],
|
||||
[/!(?=([^=]|$))/, 'delimiter'],
|
||||
[
|
||||
/@symbols/,
|
||||
{
|
||||
cases: {
|
||||
"@operators": "delimiter",
|
||||
"@default": ""
|
||||
'@operators': 'delimiter',
|
||||
'@default': ''
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
// numbers
|
||||
[/(@digits)[eE]([\-+]?(@digits))?/, "number.float"],
|
||||
[/(@digits)\.(@digits)([eE][\-+]?(@digits))?/, "number.float"],
|
||||
[/0[xX](@hexdigits)n?/, "number.hex"],
|
||||
[/0[oO]?(@octaldigits)n?/, "number.octal"],
|
||||
[/0[bB](@binarydigits)n?/, "number.binary"],
|
||||
[/(@digits)n?/, "number"],
|
||||
[/(@digits)[eE]([\-+]?(@digits))?/, 'number.float'],
|
||||
[/(@digits)\.(@digits)([eE][\-+]?(@digits))?/, 'number.float'],
|
||||
[/0[xX](@hexdigits)n?/, 'number.hex'],
|
||||
[/0[oO]?(@octaldigits)n?/, 'number.octal'],
|
||||
[/0[bB](@binarydigits)n?/, 'number.binary'],
|
||||
[/(@digits)n?/, 'number'],
|
||||
|
||||
// delimiter: after number because of .\d floats
|
||||
[/[;,.]/, "delimiter"],
|
||||
[/[;,.]/, 'delimiter'],
|
||||
|
||||
// strings
|
||||
[/"([^"\\]|\\.)*$/, "string.invalid"], // non-teminated string
|
||||
[/'([^'\\]|\\.)*$/, "string.invalid"], // non-teminated string
|
||||
[/"/, "string", "@string_double"],
|
||||
[/'/, "string", "@string_single"]
|
||||
[/"([^"\\]|\\.)*$/, 'string.invalid'], // non-teminated string
|
||||
[/'([^'\\]|\\.)*$/, 'string.invalid'], // non-teminated string
|
||||
[/"/, 'string', '@string_double'],
|
||||
[/'/, 'string', '@string_single']
|
||||
|
||||
// [/[a-zA-Z]+/, "variable"]
|
||||
],
|
||||
|
||||
whitespace: [
|
||||
[/[ \t\r\n]+/, ""],
|
||||
[/\/\*\*(?!\/)/, "comment.doc", "@jsdoc"],
|
||||
[/\/\*/, "comment", "@comment"],
|
||||
[/\/\/\/.*$/, "comment.doc"],
|
||||
[/\/\/.*$/, "comment"]
|
||||
[/[ \t\r\n]+/, ''],
|
||||
[/\/\*\*(?!\/)/, 'comment.doc', '@jsdoc'],
|
||||
[/\/\*/, 'comment', '@comment'],
|
||||
[/\/\/\/.*$/, 'comment.doc'],
|
||||
[/\/\/.*$/, 'comment']
|
||||
],
|
||||
|
||||
comment: [
|
||||
[/[^\/*]+/, "comment"],
|
||||
[/\*\//, "comment", "@pop"],
|
||||
[/[\/*]/, "comment"]
|
||||
[/[^\/*]+/, 'comment'],
|
||||
[/\*\//, 'comment', '@pop'],
|
||||
[/[\/*]/, 'comment']
|
||||
],
|
||||
|
||||
jsdoc: [
|
||||
[/[^\/*]+/, "comment.doc"],
|
||||
[/\*\//, "comment.doc", "@pop"],
|
||||
[/[\/*]/, "comment.doc"]
|
||||
[/[^\/*]+/, 'comment.doc'],
|
||||
[/\*\//, 'comment.doc', '@pop'],
|
||||
[/[\/*]/, 'comment.doc']
|
||||
],
|
||||
|
||||
// We match regular expression quite precisely
|
||||
|
|
@ -262,65 +259,66 @@ export const language = <IMonarchLanguage>{
|
|||
[
|
||||
/(\{)(\d+(?:,\d*)?)(\})/,
|
||||
[
|
||||
"regexp.escape.control",
|
||||
"regexp.escape.control",
|
||||
"regexp.escape.control"
|
||||
'regexp.escape.control',
|
||||
'regexp.escape.control',
|
||||
'regexp.escape.control'
|
||||
]
|
||||
],
|
||||
[
|
||||
/(\[)(\^?)(?=(?:[^\]\\\/]|\\.)+)/,
|
||||
[
|
||||
"regexp.escape.control",
|
||||
{ token: "regexp.escape.control", next: "@regexrange" }
|
||||
'regexp.escape.control',
|
||||
{ token: 'regexp.escape.control', next: '@regexrange' }
|
||||
]
|
||||
],
|
||||
[
|
||||
/(\()(\?:|\?=|\?!)/,
|
||||
["regexp.escape.control", "regexp.escape.control"]
|
||||
['regexp.escape.control', 'regexp.escape.control']
|
||||
],
|
||||
[/[()]/, "regexp.escape.control"],
|
||||
[/@regexpctl/, "regexp.escape.control"],
|
||||
[/[^\\\/]/, "regexp"],
|
||||
[/@regexpesc/, "regexp.escape"],
|
||||
[/\\\./, "regexp.invalid"],
|
||||
[/[()]/, 'regexp.escape.control'],
|
||||
[/@regexpctl/, 'regexp.escape.control'],
|
||||
[/[^\\\/]/, 'regexp'],
|
||||
[/@regexpesc/, 'regexp.escape'],
|
||||
[/\\\./, 'regexp.invalid'],
|
||||
[
|
||||
/(\/)([gimsuy]*)/,
|
||||
[
|
||||
{ token: "regexp", bracket: "@close", next: "@pop" },
|
||||
"keyword.other"
|
||||
{ token: 'regexp', bracket: '@close', next: '@pop' },
|
||||
'keyword.other'
|
||||
]
|
||||
]
|
||||
],
|
||||
|
||||
regexrange: [
|
||||
[/-/, "regexp.escape.control"],
|
||||
[/\^/, "regexp.invalid"],
|
||||
[/@regexpesc/, "regexp.escape"],
|
||||
[/[^\]]/, "regexp"],
|
||||
[/-/, 'regexp.escape.control'],
|
||||
[/\^/, 'regexp.invalid'],
|
||||
[/@regexpesc/, 'regexp.escape'],
|
||||
[/[^\]]/, 'regexp'],
|
||||
[
|
||||
/\]/,
|
||||
{
|
||||
token: "regexp.escape.control",
|
||||
next: "@pop",
|
||||
bracket: "@close"
|
||||
token: 'regexp.escape.control',
|
||||
next: '@pop',
|
||||
bracket: '@close'
|
||||
}
|
||||
]
|
||||
],
|
||||
|
||||
string_double: [
|
||||
[/[^\\"\$]+/, "string"], [/[^\\"]+/, "string"],
|
||||
[/@escapes/, "string.escape"],
|
||||
[/\\./, "string.escape.invalid"],
|
||||
[/"/, "string", "@pop"],
|
||||
[/[^\\"\$]+/, 'string'],
|
||||
[/[^\\"]+/, 'string'],
|
||||
[/@escapes/, 'string.escape'],
|
||||
[/\\./, 'string.escape.invalid'],
|
||||
[/"/, 'string', '@pop'],
|
||||
[/\$\w+/, 'identifier']
|
||||
],
|
||||
|
||||
string_single: [
|
||||
[/[^\\'\$]+/, "string"],
|
||||
[/@escapes/, "string.escape"],
|
||||
[/\\./, "string.escape.invalid"],
|
||||
[/'/, "string", "@pop"],
|
||||
[/[^\\'\$]+/, 'string'],
|
||||
[/@escapes/, 'string.escape'],
|
||||
[/\\./, 'string.escape.invalid'],
|
||||
[/'/, 'string', '@pop'],
|
||||
[/\$\w+/, 'identifier']
|
||||
],
|
||||
]
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -9,213 +9,221 @@ import { testTokenization } from '../test/testRunner';
|
|||
|
||||
testTokenization('dockerfile', [
|
||||
// All
|
||||
[{
|
||||
line: 'FROM mono:3.12',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.dockerfile' },
|
||||
{ startIndex: 4, type: '' }
|
||||
]
|
||||
}, {
|
||||
line: '',
|
||||
tokens: [
|
||||
|
||||
]
|
||||
}, {
|
||||
line: 'ENV KRE_FEED https://www.myget.org/F/aspnetvnext/api/v2',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.dockerfile' },
|
||||
{ startIndex: 3, type: '' },
|
||||
{ startIndex: 4, type: 'variable.dockerfile' },
|
||||
{ startIndex: 12, type: '' }
|
||||
]
|
||||
}, {
|
||||
line: 'ENV KRE_USER_HOME /opt/kre',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.dockerfile' },
|
||||
{ startIndex: 3, type: '' },
|
||||
{ startIndex: 4, type: 'variable.dockerfile' },
|
||||
{ startIndex: 17, type: '' }
|
||||
]
|
||||
}, {
|
||||
line: '',
|
||||
tokens: [
|
||||
|
||||
]
|
||||
}, {
|
||||
line: 'RUN apt-get -qq update && apt-get -qqy install unzip ',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.dockerfile' },
|
||||
{ startIndex: 3, type: '' }
|
||||
]
|
||||
}, {
|
||||
line: '',
|
||||
tokens: [
|
||||
|
||||
]
|
||||
}, {
|
||||
line: 'ONBUILD RUN curl -sSL https://raw.githubusercontent.com/aspnet/Home/dev/kvminstall.sh | sh',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.dockerfile' },
|
||||
{ startIndex: 7, type: '' },
|
||||
{ startIndex: 8, type: 'keyword.dockerfile' },
|
||||
{ startIndex: 11, type: '' }
|
||||
]
|
||||
}, {
|
||||
line: 'ONBUILD RUN bash -c "source $KRE_USER_HOME/kvm/kvm.sh \\',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.dockerfile' },
|
||||
{ startIndex: 7, type: '' },
|
||||
{ startIndex: 8, type: 'keyword.dockerfile' },
|
||||
{ startIndex: 11, type: '' },
|
||||
{ startIndex: 20, type: 'string.dockerfile' },
|
||||
{ startIndex: 28, type: 'variable.dockerfile' },
|
||||
{ startIndex: 42, type: 'string.dockerfile' }
|
||||
]
|
||||
}, {
|
||||
line: ' && kvm install latest -a default \\',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'string.dockerfile' }
|
||||
]
|
||||
}, {
|
||||
line: ' && kvm alias default | xargs -i ln -s $KRE_USER_HOME/packages/{} $KRE_USER_HOME/packages/default"',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'string.dockerfile' },
|
||||
{ startIndex: 42, type: 'variable.dockerfile' },
|
||||
{ startIndex: 56, type: 'string.dockerfile' },
|
||||
{ startIndex: 69, type: 'variable.dockerfile' },
|
||||
{ startIndex: 83, type: 'string.dockerfile' }
|
||||
]
|
||||
}, {
|
||||
line: '',
|
||||
tokens: [
|
||||
|
||||
]
|
||||
}, {
|
||||
line: '# Install libuv for Kestrel from source code (binary is not in wheezy and one in jessie is still too old)',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.dockerfile' }
|
||||
]
|
||||
}, {
|
||||
line: 'RUN apt-get -qqy install \\',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.dockerfile' },
|
||||
{ startIndex: 3, type: '' }
|
||||
]
|
||||
}, {
|
||||
line: ' autoconf \\',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' }
|
||||
]
|
||||
}, {
|
||||
line: ' automake \\',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' }
|
||||
]
|
||||
}, {
|
||||
line: ' build-essential \\',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' }
|
||||
]
|
||||
}, {
|
||||
line: ' libtool ',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' }
|
||||
]
|
||||
}, {
|
||||
line: 'RUN LIBUV_VERSION=1.0.0-rc2 \\',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.dockerfile' },
|
||||
{ startIndex: 3, type: '' }
|
||||
]
|
||||
}, {
|
||||
line: ' && curl -sSL https://github.com/joyent/libuv/archive/v${LIBUV_VERSION}.tar.gz | tar zxfv - -C /usr/local/src \\',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 58, type: 'variable.dockerfile' },
|
||||
{ startIndex: 74, type: '' }
|
||||
]
|
||||
}, {
|
||||
line: ' && cd /usr/local/src/libuv-$LIBUV_VERSION \\',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 31, type: 'variable.dockerfile' },
|
||||
{ startIndex: 45, type: '' }
|
||||
]
|
||||
}, {
|
||||
line: ' && sh autogen.sh && ./configure && make && make install \\',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' }
|
||||
]
|
||||
}, {
|
||||
line: ' && rm -rf /usr/local/src/libuv-$LIBUV_VERSION \\',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 35, type: 'variable.dockerfile' },
|
||||
{ startIndex: 49, type: '' }
|
||||
]
|
||||
}, {
|
||||
line: ' && ldconfig',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' }
|
||||
]
|
||||
}, {
|
||||
line: '',
|
||||
tokens: [
|
||||
|
||||
]
|
||||
}, {
|
||||
line: 'ENV PATH $PATH:$KRE_USER_HOME/packages/default/bin',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.dockerfile' },
|
||||
{ startIndex: 3, type: '' },
|
||||
{ startIndex: 4, type: 'variable.dockerfile' },
|
||||
{ startIndex: 8, type: '' },
|
||||
{ startIndex: 9, type: 'variable.dockerfile' },
|
||||
{ startIndex: 14, type: '' },
|
||||
{ startIndex: 15, type: 'variable.dockerfile' },
|
||||
{ startIndex: 29, type: '' }
|
||||
]
|
||||
}, {
|
||||
line: '',
|
||||
tokens: [
|
||||
|
||||
]
|
||||
}, {
|
||||
line: '# Extra things to test',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.dockerfile' }
|
||||
]
|
||||
}, {
|
||||
line: 'RUN echo "string at end"',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.dockerfile' },
|
||||
{ startIndex: 3, type: '' },
|
||||
{ startIndex: 9, type: 'string.dockerfile' }
|
||||
]
|
||||
}, {
|
||||
line: 'RUN echo must work \'some str\' and some more',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.dockerfile' },
|
||||
{ startIndex: 3, type: '' },
|
||||
{ startIndex: 19, type: 'string.dockerfile' },
|
||||
{ startIndex: 29, type: '' }
|
||||
]
|
||||
}, {
|
||||
line: 'RUN echo hi this is # not a comment',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.dockerfile' },
|
||||
{ startIndex: 3, type: '' }
|
||||
]
|
||||
}, {
|
||||
line: 'RUN echo \'String with ${VAR} and another $one here\'',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.dockerfile' },
|
||||
{ startIndex: 3, type: '' },
|
||||
{ startIndex: 9, type: 'string.dockerfile' },
|
||||
{ startIndex: 22, type: 'variable.dockerfile' },
|
||||
{ startIndex: 28, type: 'string.dockerfile' },
|
||||
{ startIndex: 41, type: 'variable.dockerfile' },
|
||||
{ startIndex: 45, type: 'string.dockerfile' }
|
||||
]
|
||||
}]
|
||||
[
|
||||
{
|
||||
line: 'FROM mono:3.12',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.dockerfile' },
|
||||
{ startIndex: 4, type: '' }
|
||||
]
|
||||
},
|
||||
{
|
||||
line: '',
|
||||
tokens: []
|
||||
},
|
||||
{
|
||||
line: 'ENV KRE_FEED https://www.myget.org/F/aspnetvnext/api/v2',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.dockerfile' },
|
||||
{ startIndex: 3, type: '' },
|
||||
{ startIndex: 4, type: 'variable.dockerfile' },
|
||||
{ startIndex: 12, type: '' }
|
||||
]
|
||||
},
|
||||
{
|
||||
line: 'ENV KRE_USER_HOME /opt/kre',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.dockerfile' },
|
||||
{ startIndex: 3, type: '' },
|
||||
{ startIndex: 4, type: 'variable.dockerfile' },
|
||||
{ startIndex: 17, type: '' }
|
||||
]
|
||||
},
|
||||
{
|
||||
line: '',
|
||||
tokens: []
|
||||
},
|
||||
{
|
||||
line: 'RUN apt-get -qq update && apt-get -qqy install unzip ',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.dockerfile' },
|
||||
{ startIndex: 3, type: '' }
|
||||
]
|
||||
},
|
||||
{
|
||||
line: '',
|
||||
tokens: []
|
||||
},
|
||||
{
|
||||
line:
|
||||
'ONBUILD RUN curl -sSL https://raw.githubusercontent.com/aspnet/Home/dev/kvminstall.sh | sh',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.dockerfile' },
|
||||
{ startIndex: 7, type: '' },
|
||||
{ startIndex: 8, type: 'keyword.dockerfile' },
|
||||
{ startIndex: 11, type: '' }
|
||||
]
|
||||
},
|
||||
{
|
||||
line: 'ONBUILD RUN bash -c "source $KRE_USER_HOME/kvm/kvm.sh \\',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.dockerfile' },
|
||||
{ startIndex: 7, type: '' },
|
||||
{ startIndex: 8, type: 'keyword.dockerfile' },
|
||||
{ startIndex: 11, type: '' },
|
||||
{ startIndex: 20, type: 'string.dockerfile' },
|
||||
{ startIndex: 28, type: 'variable.dockerfile' },
|
||||
{ startIndex: 42, type: 'string.dockerfile' }
|
||||
]
|
||||
},
|
||||
{
|
||||
line: ' && kvm install latest -a default \\',
|
||||
tokens: [{ startIndex: 0, type: 'string.dockerfile' }]
|
||||
},
|
||||
{
|
||||
line:
|
||||
' && kvm alias default | xargs -i ln -s $KRE_USER_HOME/packages/{} $KRE_USER_HOME/packages/default"',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'string.dockerfile' },
|
||||
{ startIndex: 42, type: 'variable.dockerfile' },
|
||||
{ startIndex: 56, type: 'string.dockerfile' },
|
||||
{ startIndex: 69, type: 'variable.dockerfile' },
|
||||
{ startIndex: 83, type: 'string.dockerfile' }
|
||||
]
|
||||
},
|
||||
{
|
||||
line: '',
|
||||
tokens: []
|
||||
},
|
||||
{
|
||||
line:
|
||||
'# Install libuv for Kestrel from source code (binary is not in wheezy and one in jessie is still too old)',
|
||||
tokens: [{ startIndex: 0, type: 'comment.dockerfile' }]
|
||||
},
|
||||
{
|
||||
line: 'RUN apt-get -qqy install \\',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.dockerfile' },
|
||||
{ startIndex: 3, type: '' }
|
||||
]
|
||||
},
|
||||
{
|
||||
line: ' autoconf \\',
|
||||
tokens: [{ startIndex: 0, type: '' }]
|
||||
},
|
||||
{
|
||||
line: ' automake \\',
|
||||
tokens: [{ startIndex: 0, type: '' }]
|
||||
},
|
||||
{
|
||||
line: ' build-essential \\',
|
||||
tokens: [{ startIndex: 0, type: '' }]
|
||||
},
|
||||
{
|
||||
line: ' libtool ',
|
||||
tokens: [{ startIndex: 0, type: '' }]
|
||||
},
|
||||
{
|
||||
line: 'RUN LIBUV_VERSION=1.0.0-rc2 \\',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.dockerfile' },
|
||||
{ startIndex: 3, type: '' }
|
||||
]
|
||||
},
|
||||
{
|
||||
line:
|
||||
' && curl -sSL https://github.com/joyent/libuv/archive/v${LIBUV_VERSION}.tar.gz | tar zxfv - -C /usr/local/src \\',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 58, type: 'variable.dockerfile' },
|
||||
{ startIndex: 74, type: '' }
|
||||
]
|
||||
},
|
||||
{
|
||||
line: ' && cd /usr/local/src/libuv-$LIBUV_VERSION \\',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 31, type: 'variable.dockerfile' },
|
||||
{ startIndex: 45, type: '' }
|
||||
]
|
||||
},
|
||||
{
|
||||
line:
|
||||
' && sh autogen.sh && ./configure && make && make install \\',
|
||||
tokens: [{ startIndex: 0, type: '' }]
|
||||
},
|
||||
{
|
||||
line: ' && rm -rf /usr/local/src/libuv-$LIBUV_VERSION \\',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 35, type: 'variable.dockerfile' },
|
||||
{ startIndex: 49, type: '' }
|
||||
]
|
||||
},
|
||||
{
|
||||
line: ' && ldconfig',
|
||||
tokens: [{ startIndex: 0, type: '' }]
|
||||
},
|
||||
{
|
||||
line: '',
|
||||
tokens: []
|
||||
},
|
||||
{
|
||||
line: 'ENV PATH $PATH:$KRE_USER_HOME/packages/default/bin',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.dockerfile' },
|
||||
{ startIndex: 3, type: '' },
|
||||
{ startIndex: 4, type: 'variable.dockerfile' },
|
||||
{ startIndex: 8, type: '' },
|
||||
{ startIndex: 9, type: 'variable.dockerfile' },
|
||||
{ startIndex: 14, type: '' },
|
||||
{ startIndex: 15, type: 'variable.dockerfile' },
|
||||
{ startIndex: 29, type: '' }
|
||||
]
|
||||
},
|
||||
{
|
||||
line: '',
|
||||
tokens: []
|
||||
},
|
||||
{
|
||||
line: '# Extra things to test',
|
||||
tokens: [{ startIndex: 0, type: 'comment.dockerfile' }]
|
||||
},
|
||||
{
|
||||
line: 'RUN echo "string at end"',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.dockerfile' },
|
||||
{ startIndex: 3, type: '' },
|
||||
{ startIndex: 9, type: 'string.dockerfile' }
|
||||
]
|
||||
},
|
||||
{
|
||||
line: "RUN echo must work 'some str' and some more",
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.dockerfile' },
|
||||
{ startIndex: 3, type: '' },
|
||||
{ startIndex: 19, type: 'string.dockerfile' },
|
||||
{ startIndex: 29, type: '' }
|
||||
]
|
||||
},
|
||||
{
|
||||
line: 'RUN echo hi this is # not a comment',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.dockerfile' },
|
||||
{ startIndex: 3, type: '' }
|
||||
]
|
||||
},
|
||||
{
|
||||
line: "RUN echo 'String with ${VAR} and another $one here'",
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.dockerfile' },
|
||||
{ startIndex: 3, type: '' },
|
||||
{ startIndex: 9, type: 'string.dockerfile' },
|
||||
{ startIndex: 22, type: 'variable.dockerfile' },
|
||||
{ startIndex: 28, type: 'string.dockerfile' },
|
||||
{ startIndex: 41, type: 'variable.dockerfile' },
|
||||
{ startIndex: 45, type: 'string.dockerfile' }
|
||||
]
|
||||
}
|
||||
]
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -19,14 +19,14 @@ export const conf: IRichLanguageConfiguration = {
|
|||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '"', close: '"' },
|
||||
{ open: '\'', close: '\'' },
|
||||
{ open: "'", close: "'" }
|
||||
],
|
||||
surroundingPairs: [
|
||||
{ open: '{', close: '}' },
|
||||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '"', close: '"' },
|
||||
{ open: '\'', close: '\'' },
|
||||
{ open: "'", close: "'" }
|
||||
]
|
||||
};
|
||||
|
||||
|
|
@ -42,47 +42,63 @@ export const language = <ILanguage>{
|
|||
{ include: '@comment' },
|
||||
|
||||
[/(ONBUILD)(\s+)/, ['keyword', '']],
|
||||
[/(ENV)(\s+)([\w]+)/, ['keyword', '', { token: 'variable', next: '@arguments' }]],
|
||||
[/(FROM|MAINTAINER|RUN|EXPOSE|ENV|ADD|ARG|VOLUME|LABEL|USER|WORKDIR|COPY|CMD|STOPSIGNAL|SHELL|HEALTHCHECK|ENTRYPOINT)/, { token: 'keyword', next: '@arguments' }]
|
||||
[
|
||||
/(ENV)(\s+)([\w]+)/,
|
||||
['keyword', '', { token: 'variable', next: '@arguments' }]
|
||||
],
|
||||
[
|
||||
/(FROM|MAINTAINER|RUN|EXPOSE|ENV|ADD|ARG|VOLUME|LABEL|USER|WORKDIR|COPY|CMD|STOPSIGNAL|SHELL|HEALTHCHECK|ENTRYPOINT)/,
|
||||
{ token: 'keyword', next: '@arguments' }
|
||||
]
|
||||
],
|
||||
|
||||
arguments: [
|
||||
{ include: '@whitespace' },
|
||||
{ include: '@strings' },
|
||||
|
||||
[/(@variable)/, {
|
||||
cases: {
|
||||
'@eos': { token: 'variable', next: '@popall' },
|
||||
'@default': 'variable'
|
||||
[
|
||||
/(@variable)/,
|
||||
{
|
||||
cases: {
|
||||
'@eos': { token: 'variable', next: '@popall' },
|
||||
'@default': 'variable'
|
||||
}
|
||||
}
|
||||
}],
|
||||
[/\\/, {
|
||||
cases: {
|
||||
'@eos': '',
|
||||
'@default': ''
|
||||
],
|
||||
[
|
||||
/\\/,
|
||||
{
|
||||
cases: {
|
||||
'@eos': '',
|
||||
'@default': ''
|
||||
}
|
||||
}
|
||||
}],
|
||||
[/./, {
|
||||
cases: {
|
||||
'@eos': { token: '', next: '@popall' },
|
||||
'@default': ''
|
||||
],
|
||||
[
|
||||
/./,
|
||||
{
|
||||
cases: {
|
||||
'@eos': { token: '', next: '@popall' },
|
||||
'@default': ''
|
||||
}
|
||||
}
|
||||
}],
|
||||
]
|
||||
],
|
||||
|
||||
// Deal with white space, including comments
|
||||
whitespace: [
|
||||
[/\s+/, {
|
||||
cases: {
|
||||
'@eos': { token: '', next: '@popall' },
|
||||
'@default': ''
|
||||
[
|
||||
/\s+/,
|
||||
{
|
||||
cases: {
|
||||
'@eos': { token: '', next: '@popall' },
|
||||
'@default': ''
|
||||
}
|
||||
}
|
||||
}],
|
||||
]
|
||||
],
|
||||
|
||||
comment: [
|
||||
[/(^#.*$)/, 'comment', '@popall']
|
||||
],
|
||||
comment: [[/(^#.*$)/, 'comment', '@popall']],
|
||||
|
||||
// Recognize strings, including those broken across lines with \ (but not without)
|
||||
strings: [
|
||||
|
|
@ -92,12 +108,15 @@ export const language = <ILanguage>{
|
|||
[/"/, 'string', '@dblStringBody']
|
||||
],
|
||||
stringBody: [
|
||||
[/[^\\\$']/, {
|
||||
cases: {
|
||||
'@eos': { token: 'string', next: '@popall' },
|
||||
'@default': 'string'
|
||||
[
|
||||
/[^\\\$']/,
|
||||
{
|
||||
cases: {
|
||||
'@eos': { token: 'string', next: '@popall' },
|
||||
'@default': 'string'
|
||||
}
|
||||
}
|
||||
}],
|
||||
],
|
||||
|
||||
[/\\./, 'string.escape'],
|
||||
[/'$/, 'string', '@popall'],
|
||||
|
|
@ -108,12 +127,15 @@ export const language = <ILanguage>{
|
|||
[/$/, 'string', '@popall']
|
||||
],
|
||||
dblStringBody: [
|
||||
[/[^\\\$"]/, {
|
||||
cases: {
|
||||
'@eos': { token: 'string', next: '@popall' },
|
||||
'@default': 'string'
|
||||
[
|
||||
/[^\\\$"]/,
|
||||
{
|
||||
cases: {
|
||||
'@eos': { token: 'string', next: '@popall' },
|
||||
'@default': 'string'
|
||||
}
|
||||
}
|
||||
}],
|
||||
],
|
||||
|
||||
[/\\./, 'string.escape'],
|
||||
[/"$/, 'string', '@popall'],
|
||||
|
|
|
|||
|
|
@ -9,453 +9,485 @@ import { testTokenization } from '../test/testRunner';
|
|||
|
||||
testTokenization('fsharp', [
|
||||
// comments - single line
|
||||
[{
|
||||
line: '// one line comment',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.fs' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '// one line comment',
|
||||
tokens: [{ startIndex: 0, type: 'comment.fs' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '//',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.fs' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '//',
|
||||
tokens: [{ startIndex: 0, type: 'comment.fs' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: ' // a comment',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 4, type: 'comment.fs' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: ' // a comment',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 4, type: 'comment.fs' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '// a comment',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.fs' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '// a comment',
|
||||
tokens: [{ startIndex: 0, type: 'comment.fs' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '//sticky comment',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.fs' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '//sticky comment',
|
||||
tokens: [{ startIndex: 0, type: 'comment.fs' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '/almost a comment',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'delimiter.fs' },
|
||||
{ startIndex: 1, type: 'identifier.fs' },
|
||||
{ startIndex: 7, type: '' },
|
||||
{ startIndex: 8, type: 'identifier.fs' },
|
||||
{ startIndex: 9, type: '' },
|
||||
{ startIndex: 10, type: 'identifier.fs' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '/almost a comment',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'delimiter.fs' },
|
||||
{ startIndex: 1, type: 'identifier.fs' },
|
||||
{ startIndex: 7, type: '' },
|
||||
{ startIndex: 8, type: 'identifier.fs' },
|
||||
{ startIndex: 9, type: '' },
|
||||
{ startIndex: 10, type: 'identifier.fs' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '(/*almost a comment',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'delimiter.parenthesis.fs' },
|
||||
{ startIndex: 1, type: 'delimiter.fs' },
|
||||
{ startIndex: 3, type: 'identifier.fs' },
|
||||
{ startIndex: 9, type: '' },
|
||||
{ startIndex: 10, type: 'identifier.fs' },
|
||||
{ startIndex: 11, type: '' },
|
||||
{ startIndex: 12, type: 'identifier.fs' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '(/*almost a comment',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'delimiter.parenthesis.fs' },
|
||||
{ startIndex: 1, type: 'delimiter.fs' },
|
||||
{ startIndex: 3, type: 'identifier.fs' },
|
||||
{ startIndex: 9, type: '' },
|
||||
{ startIndex: 10, type: 'identifier.fs' },
|
||||
{ startIndex: 11, type: '' },
|
||||
{ startIndex: 12, type: 'identifier.fs' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '1 / 2; (* comment',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.fs' },
|
||||
{ startIndex: 1, type: '' },
|
||||
{ startIndex: 2, type: 'delimiter.fs' },
|
||||
{ startIndex: 3, type: '' },
|
||||
{ startIndex: 4, type: 'number.fs' },
|
||||
{ startIndex: 5, type: 'delimiter.fs' },
|
||||
{ startIndex: 6, type: '' },
|
||||
{ startIndex: 7, type: 'comment.fs' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '1 / 2; (* comment',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.fs' },
|
||||
{ startIndex: 1, type: '' },
|
||||
{ startIndex: 2, type: 'delimiter.fs' },
|
||||
{ startIndex: 3, type: '' },
|
||||
{ startIndex: 4, type: 'number.fs' },
|
||||
{ startIndex: 5, type: 'delimiter.fs' },
|
||||
{ startIndex: 6, type: '' },
|
||||
{ startIndex: 7, type: 'comment.fs' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: 'let x = 1; // my comment // is a nice one',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.let.fs' },
|
||||
{ startIndex: 3, type: '' },
|
||||
{ startIndex: 4, type: 'identifier.fs' },
|
||||
{ startIndex: 5, type: '' },
|
||||
{ startIndex: 6, type: 'delimiter.fs' },
|
||||
{ startIndex: 7, type: '' },
|
||||
{ startIndex: 8, type: 'number.fs' },
|
||||
{ startIndex: 9, type: 'delimiter.fs' },
|
||||
{ startIndex: 10, type: '' },
|
||||
{ startIndex: 11, type: 'comment.fs' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'let x = 1; // my comment // is a nice one',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.let.fs' },
|
||||
{ startIndex: 3, type: '' },
|
||||
{ startIndex: 4, type: 'identifier.fs' },
|
||||
{ startIndex: 5, type: '' },
|
||||
{ startIndex: 6, type: 'delimiter.fs' },
|
||||
{ startIndex: 7, type: '' },
|
||||
{ startIndex: 8, type: 'number.fs' },
|
||||
{ startIndex: 9, type: 'delimiter.fs' },
|
||||
{ startIndex: 10, type: '' },
|
||||
{ startIndex: 11, type: 'comment.fs' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// Keywords
|
||||
[{
|
||||
line: 'namespace Application1',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.namespace.fs' },
|
||||
{ startIndex: 9, type: '' },
|
||||
{ startIndex: 10, type: 'identifier.fs' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'namespace Application1',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.namespace.fs' },
|
||||
{ startIndex: 9, type: '' },
|
||||
{ startIndex: 10, type: 'identifier.fs' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: 'type MyType',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.type.fs' },
|
||||
{ startIndex: 4, type: '' },
|
||||
{ startIndex: 5, type: 'identifier.fs' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'type MyType',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.type.fs' },
|
||||
{ startIndex: 4, type: '' },
|
||||
{ startIndex: 5, type: 'identifier.fs' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: 'module App =',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.module.fs' },
|
||||
{ startIndex: 6, type: '' },
|
||||
{ startIndex: 7, type: 'identifier.fs' },
|
||||
{ startIndex: 10, type: '' },
|
||||
{ startIndex: 11, type: 'delimiter.fs' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'module App =',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.module.fs' },
|
||||
{ startIndex: 6, type: '' },
|
||||
{ startIndex: 7, type: 'identifier.fs' },
|
||||
{ startIndex: 10, type: '' },
|
||||
{ startIndex: 11, type: 'delimiter.fs' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: 'let AppName = "App1"',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.let.fs' },
|
||||
{ startIndex: 3, type: '' },
|
||||
{ startIndex: 4, type: 'identifier.fs' },
|
||||
{ startIndex: 11, type: '' },
|
||||
{ startIndex: 12, type: 'delimiter.fs' },
|
||||
{ startIndex: 13, type: '' },
|
||||
{ startIndex: 14, type: 'string.fs' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'let AppName = "App1"',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.let.fs' },
|
||||
{ startIndex: 3, type: '' },
|
||||
{ startIndex: 4, type: 'identifier.fs' },
|
||||
{ startIndex: 11, type: '' },
|
||||
{ startIndex: 12, type: 'delimiter.fs' },
|
||||
{ startIndex: 13, type: '' },
|
||||
{ startIndex: 14, type: 'string.fs' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// Comments - range comment
|
||||
[{
|
||||
line: '(* a simple comment *)',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.fs' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '(* a simple comment *)',
|
||||
tokens: [{ startIndex: 0, type: 'comment.fs' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: 'let x = (* a simple comment *) 1',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.let.fs' },
|
||||
{ startIndex: 3, type: '' },
|
||||
{ startIndex: 4, type: 'identifier.fs' },
|
||||
{ startIndex: 5, type: '' },
|
||||
{ startIndex: 6, type: 'delimiter.fs' },
|
||||
{ startIndex: 7, type: '' },
|
||||
{ startIndex: 8, type: 'comment.fs' },
|
||||
{ startIndex: 30, type: '' },
|
||||
{ startIndex: 31, type: 'number.fs' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'let x = (* a simple comment *) 1',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.let.fs' },
|
||||
{ startIndex: 3, type: '' },
|
||||
{ startIndex: 4, type: 'identifier.fs' },
|
||||
{ startIndex: 5, type: '' },
|
||||
{ startIndex: 6, type: 'delimiter.fs' },
|
||||
{ startIndex: 7, type: '' },
|
||||
{ startIndex: 8, type: 'comment.fs' },
|
||||
{ startIndex: 30, type: '' },
|
||||
{ startIndex: 31, type: 'number.fs' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: 'x = (**)',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'identifier.fs' },
|
||||
{ startIndex: 1, type: '' },
|
||||
{ startIndex: 2, type: 'delimiter.fs' },
|
||||
{ startIndex: 3, type: '' },
|
||||
{ startIndex: 4, type: 'comment.fs' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'x = (**)',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'identifier.fs' },
|
||||
{ startIndex: 1, type: '' },
|
||||
{ startIndex: 2, type: 'delimiter.fs' },
|
||||
{ startIndex: 3, type: '' },
|
||||
{ startIndex: 4, type: 'comment.fs' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: 'x = (*)',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'identifier.fs' },
|
||||
{ startIndex: 1, type: '' },
|
||||
{ startIndex: 2, type: 'delimiter.fs' },
|
||||
{ startIndex: 3, type: '' },
|
||||
{ startIndex: 4, type: 'delimiter.parenthesis.fs' },
|
||||
{ startIndex: 5, type: 'delimiter.fs' },
|
||||
{ startIndex: 6, type: 'delimiter.parenthesis.fs' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'x = (*)',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'identifier.fs' },
|
||||
{ startIndex: 1, type: '' },
|
||||
{ startIndex: 2, type: 'delimiter.fs' },
|
||||
{ startIndex: 3, type: '' },
|
||||
{ startIndex: 4, type: 'delimiter.parenthesis.fs' },
|
||||
{ startIndex: 5, type: 'delimiter.fs' },
|
||||
{ startIndex: 6, type: 'delimiter.parenthesis.fs' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// Numbers
|
||||
[{
|
||||
line: '0',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.fs' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '0',
|
||||
tokens: [{ startIndex: 0, type: 'number.fs' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '0x123',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.hex.fs' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '0x123',
|
||||
tokens: [{ startIndex: 0, type: 'number.hex.fs' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '23.5',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.float.fs' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '23.5',
|
||||
tokens: [{ startIndex: 0, type: 'number.float.fs' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '23.5e3',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.float.fs' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '23.5e3',
|
||||
tokens: [{ startIndex: 0, type: 'number.float.fs' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '23.5E3',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.float.fs' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '23.5E3',
|
||||
tokens: [{ startIndex: 0, type: 'number.float.fs' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '23.5F',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.float.fs' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '23.5F',
|
||||
tokens: [{ startIndex: 0, type: 'number.float.fs' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '23.5f',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.float.fs' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '23.5f',
|
||||
tokens: [{ startIndex: 0, type: 'number.float.fs' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '1.72E3F',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.float.fs' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '1.72E3F',
|
||||
tokens: [{ startIndex: 0, type: 'number.float.fs' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '1.72E3f',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.float.fs' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '1.72E3f',
|
||||
tokens: [{ startIndex: 0, type: 'number.float.fs' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '1.72e3F',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.float.fs' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '1.72e3F',
|
||||
tokens: [{ startIndex: 0, type: 'number.float.fs' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '1.72e3f',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.float.fs' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '1.72e3f',
|
||||
tokens: [{ startIndex: 0, type: 'number.float.fs' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '23.5M',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.float.fs' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '23.5M',
|
||||
tokens: [{ startIndex: 0, type: 'number.float.fs' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '23.5m',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.float.fs' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '23.5m',
|
||||
tokens: [{ startIndex: 0, type: 'number.float.fs' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '1.72E3M',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.float.fs' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '1.72E3M',
|
||||
tokens: [{ startIndex: 0, type: 'number.float.fs' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '1.72E3m',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.float.fs' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '1.72E3m',
|
||||
tokens: [{ startIndex: 0, type: 'number.float.fs' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '1.72e3M',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.float.fs' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '1.72e3M',
|
||||
tokens: [{ startIndex: 0, type: 'number.float.fs' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '1.72e3m',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.float.fs' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '1.72e3m',
|
||||
tokens: [{ startIndex: 0, type: 'number.float.fs' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '0+0',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.fs' },
|
||||
{ startIndex: 1, type: 'delimiter.fs' },
|
||||
{ startIndex: 2, type: 'number.fs' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '0+0',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.fs' },
|
||||
{ startIndex: 1, type: 'delimiter.fs' },
|
||||
{ startIndex: 2, type: 'number.fs' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '100+10',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.fs' },
|
||||
{ startIndex: 3, type: 'delimiter.fs' },
|
||||
{ startIndex: 4, type: 'number.fs' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '100+10',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.fs' },
|
||||
{ startIndex: 3, type: 'delimiter.fs' },
|
||||
{ startIndex: 4, type: 'number.fs' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '0 + 0',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.fs' },
|
||||
{ startIndex: 1, type: '' },
|
||||
{ startIndex: 2, type: 'delimiter.fs' },
|
||||
{ startIndex: 3, type: '' },
|
||||
{ startIndex: 4, type: 'number.fs' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '0 + 0',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.fs' },
|
||||
{ startIndex: 1, type: '' },
|
||||
{ startIndex: 2, type: 'delimiter.fs' },
|
||||
{ startIndex: 3, type: '' },
|
||||
{ startIndex: 4, type: 'number.fs' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '0b00000101',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.bin.fs' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '0b00000101',
|
||||
tokens: [{ startIndex: 0, type: 'number.bin.fs' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '86y',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.fs' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '86y',
|
||||
tokens: [{ startIndex: 0, type: 'number.fs' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '0b00000101y',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.bin.fs' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '0b00000101y',
|
||||
tokens: [{ startIndex: 0, type: 'number.bin.fs' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '86s',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.fs' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '86s',
|
||||
tokens: [{ startIndex: 0, type: 'number.fs' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '86us',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.fs' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '86us',
|
||||
tokens: [{ startIndex: 0, type: 'number.fs' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '86',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.fs' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '86',
|
||||
tokens: [{ startIndex: 0, type: 'number.fs' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '86l',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.fs' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '86l',
|
||||
tokens: [{ startIndex: 0, type: 'number.fs' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '86u',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.fs' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '86u',
|
||||
tokens: [{ startIndex: 0, type: 'number.fs' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '86ul',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.fs' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '86ul',
|
||||
tokens: [{ startIndex: 0, type: 'number.fs' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '0x00002D3Fn',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.hex.fs' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '0x00002D3Fn',
|
||||
tokens: [{ startIndex: 0, type: 'number.hex.fs' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '0x00002D3Fun',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.hex.fs' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '0x00002D3Fun',
|
||||
tokens: [{ startIndex: 0, type: 'number.hex.fs' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '86L',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.fs' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '86L',
|
||||
tokens: [{ startIndex: 0, type: 'number.fs' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '86UL',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.fs' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '86UL',
|
||||
tokens: [{ startIndex: 0, type: 'number.fs' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '9999999999999999999999999999I',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.fs' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '9999999999999999999999999999I',
|
||||
tokens: [{ startIndex: 0, type: 'number.fs' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '0x00002D3FLF',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.float.fs' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '0x00002D3FLF',
|
||||
tokens: [{ startIndex: 0, type: 'number.float.fs' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '(* This operator -> (*) should be ignored *) let i = 0',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.fs' },
|
||||
{ startIndex: 44, type: '' },
|
||||
{ startIndex: 45, type: 'keyword.let.fs' },
|
||||
{ startIndex: 48, type: '' },
|
||||
{ startIndex: 49, type: 'identifier.fs' },
|
||||
{ startIndex: 50, type: '' },
|
||||
{ startIndex: 51, type: 'delimiter.fs' },
|
||||
{ startIndex: 52, type: '' },
|
||||
{ startIndex: 53, type: 'number.fs' }
|
||||
]
|
||||
}]
|
||||
[
|
||||
{
|
||||
line: '(* This operator -> (*) should be ignored *) let i = 0',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.fs' },
|
||||
{ startIndex: 44, type: '' },
|
||||
{ startIndex: 45, type: 'keyword.let.fs' },
|
||||
{ startIndex: 48, type: '' },
|
||||
{ startIndex: 49, type: 'identifier.fs' },
|
||||
{ startIndex: 50, type: '' },
|
||||
{ startIndex: 51, type: 'delimiter.fs' },
|
||||
{ startIndex: 52, type: '' },
|
||||
{ startIndex: 53, type: 'number.fs' }
|
||||
]
|
||||
}
|
||||
]
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import ILanguage = monaco.languages.IMonarchLanguage;
|
|||
export const conf: IRichLanguageConfiguration = {
|
||||
comments: {
|
||||
lineComment: '//',
|
||||
blockComment: ['(*', '*)'],
|
||||
blockComment: ['(*', '*)']
|
||||
},
|
||||
brackets: [
|
||||
['{', '}'],
|
||||
|
|
@ -29,12 +29,16 @@ export const conf: IRichLanguageConfiguration = {
|
|||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '"', close: '"' },
|
||||
{ open: '\'', close: '\'' }
|
||||
{ open: "'", close: "'" }
|
||||
],
|
||||
folding: {
|
||||
markers: {
|
||||
start: new RegExp("^\\s*//\\s*#region\\b|^\\s*\\(\\*\\s*#region(.*)\\*\\)"),
|
||||
end: new RegExp("^\\s*//\\s*#endregion\\b|^\\s*\\(\\*\\s*#endregion\\s*\\*\\)")
|
||||
start: new RegExp(
|
||||
'^\\s*//\\s*#region\\b|^\\s*\\(\\*\\s*#region(.*)\\*\\)'
|
||||
),
|
||||
end: new RegExp(
|
||||
'^\\s*//\\s*#endregion\\b|^\\s*\\(\\*\\s*#endregion\\s*\\*\\)'
|
||||
)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -44,29 +48,103 @@ export const language = <ILanguage>{
|
|||
tokenPostfix: '.fs',
|
||||
|
||||
keywords: [
|
||||
'abstract', 'and', 'atomic', 'as',
|
||||
'assert', 'asr', 'base', 'begin',
|
||||
'break', 'checked', 'component',
|
||||
'const', 'constraint', 'constructor',
|
||||
'continue', 'class', 'default',
|
||||
'delegate', 'do', 'done', 'downcast',
|
||||
'downto', 'elif', 'else', 'end',
|
||||
'exception', 'eager', 'event', 'external',
|
||||
'extern', 'false', 'finally', 'for',
|
||||
'fun', 'function', 'fixed', 'functor',
|
||||
'global', 'if', 'in', 'include', 'inherit',
|
||||
'inline', 'interface', 'internal', 'land',
|
||||
'lor', 'lsl', 'lsr', 'lxor', 'lazy', 'let',
|
||||
'match', 'member', 'mod', 'module', 'mutable',
|
||||
'namespace', 'method', 'mixin', 'new', 'not',
|
||||
'null', 'of', 'open', 'or', 'object',
|
||||
'override', 'private', 'parallel', 'process',
|
||||
'protected', 'pure', 'public', 'rec', 'return',
|
||||
'static', 'sealed', 'struct', 'sig', 'then',
|
||||
'to', 'true', 'tailcall', 'trait',
|
||||
'try', 'type', 'upcast', 'use',
|
||||
'val', 'void', 'virtual', 'volatile',
|
||||
'when', 'while', 'with', 'yield'
|
||||
'abstract',
|
||||
'and',
|
||||
'atomic',
|
||||
'as',
|
||||
'assert',
|
||||
'asr',
|
||||
'base',
|
||||
'begin',
|
||||
'break',
|
||||
'checked',
|
||||
'component',
|
||||
'const',
|
||||
'constraint',
|
||||
'constructor',
|
||||
'continue',
|
||||
'class',
|
||||
'default',
|
||||
'delegate',
|
||||
'do',
|
||||
'done',
|
||||
'downcast',
|
||||
'downto',
|
||||
'elif',
|
||||
'else',
|
||||
'end',
|
||||
'exception',
|
||||
'eager',
|
||||
'event',
|
||||
'external',
|
||||
'extern',
|
||||
'false',
|
||||
'finally',
|
||||
'for',
|
||||
'fun',
|
||||
'function',
|
||||
'fixed',
|
||||
'functor',
|
||||
'global',
|
||||
'if',
|
||||
'in',
|
||||
'include',
|
||||
'inherit',
|
||||
'inline',
|
||||
'interface',
|
||||
'internal',
|
||||
'land',
|
||||
'lor',
|
||||
'lsl',
|
||||
'lsr',
|
||||
'lxor',
|
||||
'lazy',
|
||||
'let',
|
||||
'match',
|
||||
'member',
|
||||
'mod',
|
||||
'module',
|
||||
'mutable',
|
||||
'namespace',
|
||||
'method',
|
||||
'mixin',
|
||||
'new',
|
||||
'not',
|
||||
'null',
|
||||
'of',
|
||||
'open',
|
||||
'or',
|
||||
'object',
|
||||
'override',
|
||||
'private',
|
||||
'parallel',
|
||||
'process',
|
||||
'protected',
|
||||
'pure',
|
||||
'public',
|
||||
'rec',
|
||||
'return',
|
||||
'static',
|
||||
'sealed',
|
||||
'struct',
|
||||
'sig',
|
||||
'then',
|
||||
'to',
|
||||
'true',
|
||||
'tailcall',
|
||||
'trait',
|
||||
'try',
|
||||
'type',
|
||||
'upcast',
|
||||
'use',
|
||||
'val',
|
||||
'void',
|
||||
'virtual',
|
||||
'volatile',
|
||||
'when',
|
||||
'while',
|
||||
'with',
|
||||
'yield'
|
||||
],
|
||||
|
||||
// we include these common regular expressions
|
||||
|
|
@ -79,12 +157,15 @@ export const language = <ILanguage>{
|
|||
tokenizer: {
|
||||
root: [
|
||||
// identifiers and keywords
|
||||
[/[a-zA-Z_]\w*/, {
|
||||
cases: {
|
||||
'@keywords': { token: 'keyword.$0' },
|
||||
'@default': 'identifier'
|
||||
[
|
||||
/[a-zA-Z_]\w*/,
|
||||
{
|
||||
cases: {
|
||||
'@keywords': { token: 'keyword.$0' },
|
||||
'@default': 'identifier'
|
||||
}
|
||||
}
|
||||
}],
|
||||
],
|
||||
|
||||
// whitespace
|
||||
{ include: '@whitespace' },
|
||||
|
|
@ -112,7 +193,7 @@ export const language = <ILanguage>{
|
|||
[/[;,.]/, 'delimiter'],
|
||||
|
||||
// strings
|
||||
[/"([^"\\]|\\.)*$/, 'string.invalid'], // non-teminated string
|
||||
[/"([^"\\]|\\.)*$/, 'string.invalid'], // non-teminated string
|
||||
[/"""/, 'string', '@string."""'],
|
||||
[/"/, 'string', '@string."'],
|
||||
|
||||
|
|
@ -128,7 +209,7 @@ export const language = <ILanguage>{
|
|||
whitespace: [
|
||||
[/[ \t\r\n]+/, ''],
|
||||
[/\(\*(?!\))/, 'comment', '@comment'],
|
||||
[/\/\/.*$/, 'comment'],
|
||||
[/\/\/.*$/, 'comment']
|
||||
],
|
||||
|
||||
comment: [
|
||||
|
|
@ -143,18 +224,21 @@ export const language = <ILanguage>{
|
|||
[/[^\\"]+/, 'string'],
|
||||
[/@escapes/, 'string.escape'],
|
||||
[/\\./, 'string.escape.invalid'],
|
||||
[/("""|"B?)/, {
|
||||
cases: {
|
||||
'$#==$S2': { token: 'string', next: '@pop' },
|
||||
'@default': 'string'
|
||||
[
|
||||
/("""|"B?)/,
|
||||
{
|
||||
cases: {
|
||||
'$#==$S2': { token: 'string', next: '@pop' },
|
||||
'@default': 'string'
|
||||
}
|
||||
}
|
||||
}]
|
||||
]
|
||||
],
|
||||
|
||||
litstring: [
|
||||
[/[^"]+/, 'string'],
|
||||
[/""/, 'string.escape'],
|
||||
[/"/, { token: 'string.quote', next: '@pop' }]
|
||||
],
|
||||
},
|
||||
]
|
||||
}
|
||||
};
|
||||
|
|
|
|||
2762
src/go/go.test.ts
2762
src/go/go.test.ts
File diff suppressed because it is too large
Load diff
101
src/go/go.ts
101
src/go/go.ts
|
|
@ -11,7 +11,7 @@ import ILanguage = monaco.languages.IMonarchLanguage;
|
|||
export const conf: IRichLanguageConfiguration = {
|
||||
comments: {
|
||||
lineComment: '//',
|
||||
blockComment: ['/*', '*/'],
|
||||
blockComment: ['/*', '*/']
|
||||
},
|
||||
brackets: [
|
||||
['{', '}'],
|
||||
|
|
@ -24,7 +24,7 @@ export const conf: IRichLanguageConfiguration = {
|
|||
{ open: '(', close: ')' },
|
||||
{ open: '`', close: '`', notIn: ['string'] },
|
||||
{ open: '"', close: '"', notIn: ['string'] },
|
||||
{ open: '\'', close: '\'', notIn: ['string', 'comment'] },
|
||||
{ open: "'", close: "'", notIn: ['string', 'comment'] }
|
||||
],
|
||||
surroundingPairs: [
|
||||
{ open: '{', close: '}' },
|
||||
|
|
@ -32,12 +32,11 @@ export const conf: IRichLanguageConfiguration = {
|
|||
{ open: '(', close: ')' },
|
||||
{ open: '`', close: '`' },
|
||||
{ open: '"', close: '"' },
|
||||
{ open: '\'', close: '\'' },
|
||||
{ open: "'", close: "'" }
|
||||
]
|
||||
};
|
||||
|
||||
export const language = <ILanguage>{
|
||||
|
||||
defaultToken: '',
|
||||
tokenPostfix: '.go',
|
||||
|
||||
|
|
@ -88,31 +87,76 @@ export const language = <ILanguage>{
|
|||
'int',
|
||||
'uintptr',
|
||||
'string',
|
||||
'nil',
|
||||
'nil'
|
||||
],
|
||||
|
||||
operators: [
|
||||
'+', '-', '*', '/', '%', '&', '|', '^', '<<', '>>', '&^',
|
||||
'+=', '-=', '*=', '/=', '%=', '&=', '|=', '^=', '<<=', '>>=', '&^=',
|
||||
'&&', '||', '<-', '++', '--', '==', '<', '>', '=', '!', '!=', '<=', '>=', ':=', '...',
|
||||
'(', ')', '', ']', '{', '}', ',', ';', '.', ':'
|
||||
'+',
|
||||
'-',
|
||||
'*',
|
||||
'/',
|
||||
'%',
|
||||
'&',
|
||||
'|',
|
||||
'^',
|
||||
'<<',
|
||||
'>>',
|
||||
'&^',
|
||||
'+=',
|
||||
'-=',
|
||||
'*=',
|
||||
'/=',
|
||||
'%=',
|
||||
'&=',
|
||||
'|=',
|
||||
'^=',
|
||||
'<<=',
|
||||
'>>=',
|
||||
'&^=',
|
||||
'&&',
|
||||
'||',
|
||||
'<-',
|
||||
'++',
|
||||
'--',
|
||||
'==',
|
||||
'<',
|
||||
'>',
|
||||
'=',
|
||||
'!',
|
||||
'!=',
|
||||
'<=',
|
||||
'>=',
|
||||
':=',
|
||||
'...',
|
||||
'(',
|
||||
')',
|
||||
'',
|
||||
']',
|
||||
'{',
|
||||
'}',
|
||||
',',
|
||||
';',
|
||||
'.',
|
||||
':'
|
||||
],
|
||||
|
||||
// we include these common regular expressions
|
||||
symbols: /[=><!~?:&|+\-*\/\^%]+/,
|
||||
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.$0' },
|
||||
'@default': 'identifier'
|
||||
[
|
||||
/[a-zA-Z_]\w*/,
|
||||
{
|
||||
cases: {
|
||||
'@keywords': { token: 'keyword.$0' },
|
||||
'@default': 'identifier'
|
||||
}
|
||||
}
|
||||
}],
|
||||
],
|
||||
|
||||
// whitespace
|
||||
{ include: '@whitespace' },
|
||||
|
|
@ -126,12 +170,15 @@ export const language = <ILanguage>{
|
|||
// delimiters and operators
|
||||
[/[{}()\[\]]/, '@brackets'],
|
||||
[/[<>](?!@symbols)/, '@brackets'],
|
||||
[/@symbols/, {
|
||||
cases: {
|
||||
'@operators': 'delimiter',
|
||||
'@default': ''
|
||||
[
|
||||
/@symbols/,
|
||||
{
|
||||
cases: {
|
||||
'@operators': 'delimiter',
|
||||
'@default': ''
|
||||
}
|
||||
}
|
||||
}],
|
||||
],
|
||||
|
||||
// numbers
|
||||
[/\d*\d+[eE]([\-+]?\d+)?/, 'number.float'],
|
||||
|
|
@ -146,9 +193,9 @@ export const language = <ILanguage>{
|
|||
[/[;,.]/, 'delimiter'],
|
||||
|
||||
// strings
|
||||
[/"([^"\\]|\\.)*$/, 'string.invalid'], // non-teminated string
|
||||
[/"([^"\\]|\\.)*$/, 'string.invalid'], // non-teminated string
|
||||
[/"/, 'string', '@string'],
|
||||
[/`/, "string", "@rawstring"],
|
||||
[/`/, 'string', '@rawstring'],
|
||||
|
||||
// characters
|
||||
[/'[^\\']'/, 'string'],
|
||||
|
|
@ -160,7 +207,7 @@ export const language = <ILanguage>{
|
|||
[/[ \t\r\n]+/, ''],
|
||||
[/\/\*\*(?!\/)/, 'comment.doc', '@doccomment'],
|
||||
[/\/\*/, 'comment', '@comment'],
|
||||
[/\/\/.*$/, 'comment'],
|
||||
[/\/\/.*$/, 'comment']
|
||||
],
|
||||
|
||||
comment: [
|
||||
|
|
@ -187,8 +234,8 @@ export const language = <ILanguage>{
|
|||
],
|
||||
|
||||
rawstring: [
|
||||
[/[^\`]/, "string"],
|
||||
[/`/, "string", "@pop"]
|
||||
],
|
||||
},
|
||||
[/[^\`]/, 'string'],
|
||||
[/`/, 'string', '@pop']
|
||||
]
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -9,80 +9,87 @@ import { testTokenization } from '../test/testRunner';
|
|||
|
||||
testTokenization('graphql', [
|
||||
// Keywords
|
||||
[{
|
||||
line: 'scalar Date',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.gql' },
|
||||
{ startIndex: 6, type: '' },
|
||||
{ startIndex: 7, type: 'type.identifier.gql' },
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'scalar Date',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.gql' },
|
||||
{ startIndex: 6, type: '' },
|
||||
{ startIndex: 7, type: 'type.identifier.gql' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// Root schema definition
|
||||
[{
|
||||
line: 'schema { query: Query, mutation: Mutation subscription: Subscription }',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: "keyword.gql" },
|
||||
{ startIndex: 6, type: "" },
|
||||
{ startIndex: 7, type: "delimiter.curly.gql" },
|
||||
{ startIndex: 8, type: "" },
|
||||
{ startIndex: 9, type: "keyword.gql" }, // this should be identifier
|
||||
{ startIndex: 14, type: "operator.gql" },
|
||||
{ startIndex: 15, type: "" },
|
||||
{ startIndex: 16, type: "type.identifier.gql" },
|
||||
{ startIndex: 21, type: "delimiter.gql" },
|
||||
{ startIndex: 22, type: "" },
|
||||
{ startIndex: 23, type: "keyword.gql" }, // this should be identifier
|
||||
{ startIndex: 31, type: "operator.gql" },
|
||||
{ startIndex: 32, type: "" },
|
||||
{ startIndex: 33, type: "type.identifier.gql" },
|
||||
{ startIndex: 41, type: "" },
|
||||
{ startIndex: 42, type: "keyword.gql" }, // this should be identifier
|
||||
{ startIndex: 54, type: "operator.gql" },
|
||||
{ startIndex: 55, type: "" },
|
||||
{ startIndex: 56, type: "type.identifier.gql" },
|
||||
{ startIndex: 68, type: "" },
|
||||
{ startIndex: 69, type: "delimiter.curly.gql" },
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line:
|
||||
'schema { query: Query, mutation: Mutation subscription: Subscription }',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.gql' },
|
||||
{ startIndex: 6, type: '' },
|
||||
{ startIndex: 7, type: 'delimiter.curly.gql' },
|
||||
{ startIndex: 8, type: '' },
|
||||
{ startIndex: 9, type: 'keyword.gql' }, // this should be identifier
|
||||
{ startIndex: 14, type: 'operator.gql' },
|
||||
{ startIndex: 15, type: '' },
|
||||
{ startIndex: 16, type: 'type.identifier.gql' },
|
||||
{ startIndex: 21, type: 'delimiter.gql' },
|
||||
{ startIndex: 22, type: '' },
|
||||
{ startIndex: 23, type: 'keyword.gql' }, // this should be identifier
|
||||
{ startIndex: 31, type: 'operator.gql' },
|
||||
{ startIndex: 32, type: '' },
|
||||
{ startIndex: 33, type: 'type.identifier.gql' },
|
||||
{ startIndex: 41, type: '' },
|
||||
{ startIndex: 42, type: 'keyword.gql' }, // this should be identifier
|
||||
{ startIndex: 54, type: 'operator.gql' },
|
||||
{ startIndex: 55, type: '' },
|
||||
{ startIndex: 56, type: 'type.identifier.gql' },
|
||||
{ startIndex: 68, type: '' },
|
||||
{ startIndex: 69, type: 'delimiter.curly.gql' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: `query testQuery($intValue:Int=3){value(arg:{string:"string" int:$intValue}){field1 field2}}`,
|
||||
tokens: [
|
||||
{ startIndex: 0, type: "keyword.gql" }, // 'query'
|
||||
{ startIndex: 5, type: "" }, // ' '
|
||||
{ startIndex: 6, type: "key.identifier.gql" }, // 'testQuery'
|
||||
{ startIndex: 15, type: "delimiter.parenthesis.gql" }, // '('
|
||||
{ startIndex: 16, type: "argument.identifier.gql" }, // '$intValue'
|
||||
{ startIndex: 25, type: "operator.gql" }, // ':'
|
||||
{ startIndex: 26, type: "keyword.gql" }, // 'Int'
|
||||
{ startIndex: 29, type: "operator.gql" }, // '='
|
||||
{ startIndex: 30, type: "number.gql" }, // '3'
|
||||
{ startIndex: 31, type: "delimiter.parenthesis.gql" }, // ')'
|
||||
{ startIndex: 32, type: "delimiter.curly.gql" }, // '{'
|
||||
{ startIndex: 33, type: "key.identifier.gql" }, // 'value'
|
||||
{ startIndex: 38, type: "delimiter.parenthesis.gql" }, // '('
|
||||
{ startIndex: 39, type: "key.identifier.gql" }, // 'arg'
|
||||
{ startIndex: 42, type: "operator.gql" }, // ':'
|
||||
{ startIndex: 43, type: "delimiter.curly.gql" }, // '{'
|
||||
{ startIndex: 44, type: "key.identifier.gql" }, // 'string'
|
||||
{ startIndex: 50, type: "operator.gql" }, // ':'
|
||||
{ startIndex: 51, type: "string.quote.gql" }, // '"'
|
||||
{ startIndex: 52, type: "string.gql" }, // 'string'
|
||||
{ startIndex: 58, type: "string.quote.gql" }, // '"'
|
||||
{ startIndex: 59, type: "" }, // ' '
|
||||
{ startIndex: 60, type: "key.identifier.gql" }, // 'int'
|
||||
{ startIndex: 63, type: "operator.gql" }, // ':'
|
||||
{ startIndex: 64, type: "argument.identifier.gql" }, // '$intValue'
|
||||
{ startIndex: 73, type: "delimiter.curly.gql" }, // '}'
|
||||
{ startIndex: 74, type: "delimiter.parenthesis.gql" }, // ')'
|
||||
{ startIndex: 75, type: "delimiter.curly.gql" }, // '{'
|
||||
{ startIndex: 76, type: "key.identifier.gql" }, // 'field1'
|
||||
{ startIndex: 82, type: "" }, // ' '
|
||||
{ startIndex: 83, type: "key.identifier.gql" }, // 'field2'
|
||||
{ startIndex: 89, type: "delimiter.curly.gql" }, // '}}'
|
||||
],
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: `query testQuery($intValue:Int=3){value(arg:{string:"string" int:$intValue}){field1 field2}}`,
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.gql' }, // 'query'
|
||||
{ startIndex: 5, type: '' }, // ' '
|
||||
{ startIndex: 6, type: 'key.identifier.gql' }, // 'testQuery'
|
||||
{ startIndex: 15, type: 'delimiter.parenthesis.gql' }, // '('
|
||||
{ startIndex: 16, type: 'argument.identifier.gql' }, // '$intValue'
|
||||
{ startIndex: 25, type: 'operator.gql' }, // ':'
|
||||
{ startIndex: 26, type: 'keyword.gql' }, // 'Int'
|
||||
{ startIndex: 29, type: 'operator.gql' }, // '='
|
||||
{ startIndex: 30, type: 'number.gql' }, // '3'
|
||||
{ startIndex: 31, type: 'delimiter.parenthesis.gql' }, // ')'
|
||||
{ startIndex: 32, type: 'delimiter.curly.gql' }, // '{'
|
||||
{ startIndex: 33, type: 'key.identifier.gql' }, // 'value'
|
||||
{ startIndex: 38, type: 'delimiter.parenthesis.gql' }, // '('
|
||||
{ startIndex: 39, type: 'key.identifier.gql' }, // 'arg'
|
||||
{ startIndex: 42, type: 'operator.gql' }, // ':'
|
||||
{ startIndex: 43, type: 'delimiter.curly.gql' }, // '{'
|
||||
{ startIndex: 44, type: 'key.identifier.gql' }, // 'string'
|
||||
{ startIndex: 50, type: 'operator.gql' }, // ':'
|
||||
{ startIndex: 51, type: 'string.quote.gql' }, // '"'
|
||||
{ startIndex: 52, type: 'string.gql' }, // 'string'
|
||||
{ startIndex: 58, type: 'string.quote.gql' }, // '"'
|
||||
{ startIndex: 59, type: '' }, // ' '
|
||||
{ startIndex: 60, type: 'key.identifier.gql' }, // 'int'
|
||||
{ startIndex: 63, type: 'operator.gql' }, // ':'
|
||||
{ startIndex: 64, type: 'argument.identifier.gql' }, // '$intValue'
|
||||
{ startIndex: 73, type: 'delimiter.curly.gql' }, // '}'
|
||||
{ startIndex: 74, type: 'delimiter.parenthesis.gql' }, // ')'
|
||||
{ startIndex: 75, type: 'delimiter.curly.gql' }, // '{'
|
||||
{ startIndex: 76, type: 'key.identifier.gql' }, // 'field1'
|
||||
{ startIndex: 82, type: '' }, // ' '
|
||||
{ startIndex: 83, type: 'key.identifier.gql' }, // 'field2'
|
||||
{ startIndex: 89, type: 'delimiter.curly.gql' } // '}}'
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// More complex test:
|
||||
// """
|
||||
|
|
@ -95,49 +102,40 @@ testTokenization('graphql', [
|
|||
[
|
||||
{
|
||||
line: '"""',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: "string.gql" }
|
||||
],
|
||||
tokens: [{ startIndex: 0, type: 'string.gql' }]
|
||||
},
|
||||
{
|
||||
line: 'This is MarkDown',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: "" }
|
||||
],
|
||||
tokens: [{ startIndex: 0, type: '' }]
|
||||
},
|
||||
{
|
||||
line: '"""',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: "string.gql" }
|
||||
],
|
||||
tokens: [{ startIndex: 0, type: 'string.gql' }]
|
||||
},
|
||||
{
|
||||
line: 'interface Node {',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: "keyword.gql" },
|
||||
{ startIndex: 9, type: "" },
|
||||
{ startIndex: 10, type: "type.identifier.gql" },
|
||||
{ startIndex: 14, type: "" },
|
||||
{ startIndex: 15, type: "delimiter.curly.gql" },
|
||||
],
|
||||
{ startIndex: 0, type: 'keyword.gql' },
|
||||
{ startIndex: 9, type: '' },
|
||||
{ startIndex: 10, type: 'type.identifier.gql' },
|
||||
{ startIndex: 14, type: '' },
|
||||
{ startIndex: 15, type: 'delimiter.curly.gql' }
|
||||
]
|
||||
},
|
||||
{
|
||||
line: ' id: ID!',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: "" },
|
||||
{ startIndex: 2, type: "key.identifier.gql" },
|
||||
{ startIndex: 4, type: "operator.gql" },
|
||||
{ startIndex: 5, type: "" },
|
||||
{ startIndex: 6, type: "keyword.gql" },
|
||||
{ startIndex: 8, type: "operator.gql" },
|
||||
],
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 2, type: 'key.identifier.gql' },
|
||||
{ startIndex: 4, type: 'operator.gql' },
|
||||
{ startIndex: 5, type: '' },
|
||||
{ startIndex: 6, type: 'keyword.gql' },
|
||||
{ startIndex: 8, type: 'operator.gql' }
|
||||
]
|
||||
},
|
||||
{
|
||||
line: '}',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: "delimiter.curly.gql", },
|
||||
],
|
||||
},
|
||||
tokens: [{ startIndex: 0, type: 'delimiter.curly.gql' }]
|
||||
}
|
||||
]
|
||||
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -22,14 +22,14 @@ export const conf: IRichLanguageConfiguration = {
|
|||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '"""', close: '"""', notIn: ['string', 'comment'] },
|
||||
{ open: '"', close: '"', notIn: ['string', 'comment'] },
|
||||
{ open: '"', close: '"', notIn: ['string', 'comment'] }
|
||||
],
|
||||
surroundingPairs: [
|
||||
{ open: '{', close: '}' },
|
||||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '"""', close: '"""' },
|
||||
{ open: '"', close: '"' },
|
||||
{ open: '"', close: '"' }
|
||||
],
|
||||
folding: {
|
||||
offSide: true
|
||||
|
|
@ -42,20 +42,48 @@ export const language = <ILanguage>{
|
|||
tokenPostfix: '.gql',
|
||||
|
||||
keywords: [
|
||||
'null', 'true', 'false',
|
||||
'query', 'mutation', 'subscription',
|
||||
'extend', 'schema', 'directive',
|
||||
'scalar', 'type', 'interface', 'union', 'enum', 'input', 'implements',
|
||||
'fragment', 'on',
|
||||
'null',
|
||||
'true',
|
||||
'false',
|
||||
'query',
|
||||
'mutation',
|
||||
'subscription',
|
||||
'extend',
|
||||
'schema',
|
||||
'directive',
|
||||
'scalar',
|
||||
'type',
|
||||
'interface',
|
||||
'union',
|
||||
'enum',
|
||||
'input',
|
||||
'implements',
|
||||
'fragment',
|
||||
'on'
|
||||
],
|
||||
|
||||
typeKeywords: ['Int', 'Float', 'String', 'Boolean', 'ID'],
|
||||
|
||||
directiveLocations: [
|
||||
'SCHEMA', 'SCALAR', 'OBJECT', 'FIELD_DEFINITION', 'ARGUMENT_DEFINITION',
|
||||
'INTERFACE', 'UNION', 'ENUM', 'ENUM_VALUE', 'INPUT_OBJECT', 'INPUT_FIELD_DEFINITION',
|
||||
'QUERY', 'MUTATION', 'SUBSCRIPTION', 'FIELD', 'FRAGMENT_DEFINITION',
|
||||
'FRAGMENT_SPREAD', 'INLINE_FRAGMENT', 'VARIABLE_DEFINITION',
|
||||
'SCHEMA',
|
||||
'SCALAR',
|
||||
'OBJECT',
|
||||
'FIELD_DEFINITION',
|
||||
'ARGUMENT_DEFINITION',
|
||||
'INTERFACE',
|
||||
'UNION',
|
||||
'ENUM',
|
||||
'ENUM_VALUE',
|
||||
'INPUT_OBJECT',
|
||||
'INPUT_FIELD_DEFINITION',
|
||||
'QUERY',
|
||||
'MUTATION',
|
||||
'SUBSCRIPTION',
|
||||
'FIELD',
|
||||
'FRAGMENT_DEFINITION',
|
||||
'FRAGMENT_SPREAD',
|
||||
'INLINE_FRAGMENT',
|
||||
'VARIABLE_DEFINITION'
|
||||
],
|
||||
|
||||
operators: ['=', '!', '?', ':', '&', '|'],
|
||||
|
|
@ -69,16 +97,15 @@ export const language = <ILanguage>{
|
|||
// The main tokenizer for our languages
|
||||
tokenizer: {
|
||||
root: [
|
||||
|
||||
// fields and argument names
|
||||
[
|
||||
/[a-z_][\w$]*/,
|
||||
{
|
||||
cases: {
|
||||
'@keywords': 'keyword',
|
||||
'@default': 'key.identifier',
|
||||
},
|
||||
},
|
||||
'@default': 'key.identifier'
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
// identify typed input variables
|
||||
|
|
@ -87,9 +114,9 @@ export const language = <ILanguage>{
|
|||
{
|
||||
cases: {
|
||||
'@keywords': 'keyword',
|
||||
'@default': 'argument.identifier',
|
||||
},
|
||||
},
|
||||
'@default': 'argument.identifier'
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
// to show class names nicely
|
||||
|
|
@ -98,9 +125,9 @@ export const language = <ILanguage>{
|
|||
{
|
||||
cases: {
|
||||
'@typeKeywords': 'keyword',
|
||||
'@default': 'type.identifier',
|
||||
},
|
||||
},
|
||||
'@default': 'type.identifier'
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
// whitespace
|
||||
|
|
@ -110,7 +137,7 @@ export const language = <ILanguage>{
|
|||
[/[{}()\[\]]/, '@brackets'],
|
||||
[
|
||||
/@symbols/,
|
||||
{ cases: { '@operators': 'operator', '@default': '' } },
|
||||
{ cases: { '@operators': 'operator', '@default': '' } }
|
||||
],
|
||||
|
||||
// @ annotations.
|
||||
|
|
@ -118,7 +145,7 @@ export const language = <ILanguage>{
|
|||
// Note: message are supressed during the first load -- change some lines to see them.
|
||||
[
|
||||
/@\s*[a-zA-Z_\$][\w\$]*/,
|
||||
{ token: 'annotation', log: 'annotation token: $0' },
|
||||
{ token: 'annotation', log: 'annotation token: $0' }
|
||||
],
|
||||
|
||||
// numbers
|
||||
|
|
@ -129,13 +156,14 @@ export const language = <ILanguage>{
|
|||
// delimiter: after number because of .\d floats
|
||||
[/[;,.]/, 'delimiter'],
|
||||
|
||||
[/"""/,
|
||||
[
|
||||
/"""/,
|
||||
{ token: 'string', next: '@mlstring', nextEmbedded: 'markdown' }
|
||||
],
|
||||
|
||||
// strings
|
||||
[/"([^"\\]|\\.)*$/, 'string.invalid'], // non-teminated string
|
||||
[/"/, { token: 'string.quote', bracket: '@open', next: '@string' }],
|
||||
[/"/, { token: 'string.quote', bracket: '@open', next: '@string' }]
|
||||
],
|
||||
|
||||
mlstring: [
|
||||
|
|
@ -147,9 +175,12 @@ export const language = <ILanguage>{
|
|||
[/[^\\"]+/, 'string'],
|
||||
[/@escapes/, 'string.escape'],
|
||||
[/\\./, 'string.escape.invalid'],
|
||||
[/"/, { token: 'string.quote', bracket: '@close', next: '@pop' }],
|
||||
[/"/, { token: 'string.quote', bracket: '@close', next: '@pop' }]
|
||||
],
|
||||
|
||||
whitespace: [[/[ \t\r\n]+/, ''], [/#.*$/, 'comment']],
|
||||
},
|
||||
whitespace: [
|
||||
[/[ \t\r\n]+/, ''],
|
||||
[/#.*$/, 'comment']
|
||||
]
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -7,309 +7,351 @@
|
|||
|
||||
import { testTokenization } from '../test/testRunner';
|
||||
|
||||
testTokenization(['handlebars', 'css'], [
|
||||
testTokenization(
|
||||
['handlebars', 'css'],
|
||||
[
|
||||
// Just HTML
|
||||
[
|
||||
{
|
||||
line: '<h1>handlebars!</h1>',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'delimiter.html' },
|
||||
{ startIndex: 1, type: 'tag.html' },
|
||||
{ startIndex: 3, type: 'delimiter.html' },
|
||||
{ startIndex: 4, type: '' },
|
||||
{ startIndex: 15, type: 'delimiter.html' },
|
||||
{ startIndex: 17, type: 'tag.html' },
|
||||
{ startIndex: 19, type: 'delimiter.html' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// Just HTML
|
||||
[{
|
||||
line: '<h1>handlebars!</h1>',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'delimiter.html' },
|
||||
{ startIndex: 1, type: 'tag.html' },
|
||||
{ startIndex: 3, type: 'delimiter.html' },
|
||||
{ startIndex: 4, type: '' },
|
||||
{ startIndex: 15, type: 'delimiter.html' },
|
||||
{ startIndex: 17, type: 'tag.html' },
|
||||
{ startIndex: 19, type: 'delimiter.html' }
|
||||
]
|
||||
}],
|
||||
// Expressions
|
||||
[
|
||||
{
|
||||
line: '<h1>{{ title }}</h1>',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'delimiter.html' },
|
||||
{ startIndex: 1, type: 'tag.html' },
|
||||
{ startIndex: 3, type: 'delimiter.html' },
|
||||
{ startIndex: 4, type: 'delimiter.handlebars' },
|
||||
{ startIndex: 6, type: '' },
|
||||
{ startIndex: 7, type: 'variable.parameter.handlebars' },
|
||||
{ startIndex: 12, type: '' },
|
||||
{ startIndex: 13, type: 'delimiter.handlebars' },
|
||||
{ startIndex: 15, type: 'delimiter.html' },
|
||||
{ startIndex: 17, type: 'tag.html' },
|
||||
{ startIndex: 19, type: 'delimiter.html' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// Expressions
|
||||
[{
|
||||
line: '<h1>{{ title }}</h1>',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'delimiter.html' },
|
||||
{ startIndex: 1, type: 'tag.html' },
|
||||
{ startIndex: 3, type: 'delimiter.html' },
|
||||
{ startIndex: 4, type: 'delimiter.handlebars' },
|
||||
{ startIndex: 6, type: '' },
|
||||
{ startIndex: 7, type: 'variable.parameter.handlebars' },
|
||||
{ startIndex: 12, type: '' },
|
||||
{ startIndex: 13, type: 'delimiter.handlebars' },
|
||||
{ startIndex: 15, type: 'delimiter.html' },
|
||||
{ startIndex: 17, type: 'tag.html' },
|
||||
{ startIndex: 19, type: 'delimiter.html' }
|
||||
]
|
||||
}],
|
||||
// Expressions Sans Whitespace
|
||||
[
|
||||
{
|
||||
line: '<h1>{{title}}</h1>',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'delimiter.html' },
|
||||
{ startIndex: 1, type: 'tag.html' },
|
||||
{ startIndex: 3, type: 'delimiter.html' },
|
||||
{ startIndex: 4, type: 'delimiter.handlebars' },
|
||||
{ startIndex: 6, type: 'variable.parameter.handlebars' },
|
||||
{ startIndex: 11, type: 'delimiter.handlebars' },
|
||||
{ startIndex: 13, type: 'delimiter.html' },
|
||||
{ startIndex: 15, type: 'tag.html' },
|
||||
{ startIndex: 17, type: 'delimiter.html' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// Expressions Sans Whitespace
|
||||
[{
|
||||
line: '<h1>{{title}}</h1>',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'delimiter.html' },
|
||||
{ startIndex: 1, type: 'tag.html' },
|
||||
{ startIndex: 3, type: 'delimiter.html' },
|
||||
{ startIndex: 4, type: 'delimiter.handlebars' },
|
||||
{ startIndex: 6, type: 'variable.parameter.handlebars' },
|
||||
{ startIndex: 11, type: 'delimiter.handlebars' },
|
||||
{ startIndex: 13, type: 'delimiter.html' },
|
||||
{ startIndex: 15, type: 'tag.html' },
|
||||
{ startIndex: 17, type: 'delimiter.html' }
|
||||
]
|
||||
}],
|
||||
// Unescaped Expressions
|
||||
[
|
||||
{
|
||||
line: '<h1>{{{ title }}}</h1>',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'delimiter.html' },
|
||||
{ startIndex: 1, type: 'tag.html' },
|
||||
{ startIndex: 3, type: 'delimiter.html' },
|
||||
{ startIndex: 4, type: 'delimiter.handlebars' },
|
||||
{ startIndex: 7, type: '' },
|
||||
{ startIndex: 8, type: 'variable.parameter.handlebars' },
|
||||
{ startIndex: 13, type: '' },
|
||||
{ startIndex: 14, type: 'delimiter.handlebars' },
|
||||
{ startIndex: 17, type: 'delimiter.html' },
|
||||
{ startIndex: 19, type: 'tag.html' },
|
||||
{ startIndex: 21, type: 'delimiter.html' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// Unescaped Expressions
|
||||
[{
|
||||
line: '<h1>{{{ title }}}</h1>',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'delimiter.html' },
|
||||
{ startIndex: 1, type: 'tag.html' },
|
||||
{ startIndex: 3, type: 'delimiter.html' },
|
||||
{ startIndex: 4, type: 'delimiter.handlebars' },
|
||||
{ startIndex: 7, type: '' },
|
||||
{ startIndex: 8, type: 'variable.parameter.handlebars' },
|
||||
{ startIndex: 13, type: '' },
|
||||
{ startIndex: 14, type: 'delimiter.handlebars' },
|
||||
{ startIndex: 17, type: 'delimiter.html' },
|
||||
{ startIndex: 19, type: 'tag.html' },
|
||||
{ startIndex: 21, type: 'delimiter.html' }
|
||||
]
|
||||
}],
|
||||
// Blocks
|
||||
[
|
||||
{
|
||||
line: '<ul>{{#each items}}<li>{{item}}</li>{{/each}}</ul>',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'delimiter.html' },
|
||||
{ startIndex: 1, type: 'tag.html' },
|
||||
{ startIndex: 3, type: 'delimiter.html' },
|
||||
{ startIndex: 4, type: 'delimiter.handlebars' },
|
||||
{ startIndex: 6, type: 'keyword.helper.handlebars' },
|
||||
{ startIndex: 11, type: '' },
|
||||
{ startIndex: 12, type: 'variable.parameter.handlebars' },
|
||||
{ startIndex: 17, type: 'delimiter.handlebars' },
|
||||
{ startIndex: 19, type: 'delimiter.html' },
|
||||
{ startIndex: 20, type: 'tag.html' },
|
||||
{ startIndex: 22, type: 'delimiter.html' },
|
||||
{ startIndex: 23, type: 'delimiter.handlebars' },
|
||||
{ startIndex: 25, type: 'variable.parameter.handlebars' },
|
||||
{ startIndex: 29, type: 'delimiter.handlebars' },
|
||||
{ startIndex: 31, type: 'delimiter.html' },
|
||||
{ startIndex: 33, type: 'tag.html' },
|
||||
{ startIndex: 35, type: 'delimiter.html' },
|
||||
{ startIndex: 36, type: 'delimiter.handlebars' },
|
||||
{ startIndex: 38, type: 'keyword.helper.handlebars' },
|
||||
{ startIndex: 43, type: 'delimiter.handlebars' },
|
||||
{ startIndex: 45, type: 'delimiter.html' },
|
||||
{ startIndex: 47, type: 'tag.html' },
|
||||
{ startIndex: 49, type: 'delimiter.html' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// Blocks
|
||||
[{
|
||||
line: '<ul>{{#each items}}<li>{{item}}</li>{{/each}}</ul>',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'delimiter.html' },
|
||||
{ startIndex: 1, type: 'tag.html' },
|
||||
{ startIndex: 3, type: 'delimiter.html' },
|
||||
{ startIndex: 4, type: 'delimiter.handlebars' },
|
||||
{ startIndex: 6, type: 'keyword.helper.handlebars' },
|
||||
{ startIndex: 11, type: '' },
|
||||
{ startIndex: 12, type: 'variable.parameter.handlebars' },
|
||||
{ startIndex: 17, type: 'delimiter.handlebars' },
|
||||
{ startIndex: 19, type: 'delimiter.html' },
|
||||
{ startIndex: 20, type: 'tag.html' },
|
||||
{ startIndex: 22, type: 'delimiter.html' },
|
||||
{ startIndex: 23, type: 'delimiter.handlebars' },
|
||||
{ startIndex: 25, type: 'variable.parameter.handlebars' },
|
||||
{ startIndex: 29, type: 'delimiter.handlebars' },
|
||||
{ startIndex: 31, type: 'delimiter.html' },
|
||||
{ startIndex: 33, type: 'tag.html' },
|
||||
{ startIndex: 35, type: 'delimiter.html' },
|
||||
{ startIndex: 36, type: 'delimiter.handlebars' },
|
||||
{ startIndex: 38, type: 'keyword.helper.handlebars' },
|
||||
{ startIndex: 43, type: 'delimiter.handlebars' },
|
||||
{ startIndex: 45, type: 'delimiter.html' },
|
||||
{ startIndex: 47, type: 'tag.html' },
|
||||
{ startIndex: 49, type: 'delimiter.html' }
|
||||
]
|
||||
}],
|
||||
// Multiline
|
||||
[
|
||||
{
|
||||
line: '<div>',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'delimiter.html' },
|
||||
{ startIndex: 1, type: 'tag.html' },
|
||||
{ startIndex: 4, type: 'delimiter.html' }
|
||||
]
|
||||
},
|
||||
{
|
||||
line: '{{#if foo}}',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'delimiter.handlebars' },
|
||||
{ startIndex: 2, type: 'keyword.helper.handlebars' },
|
||||
{ startIndex: 5, type: '' },
|
||||
{ startIndex: 6, type: 'variable.parameter.handlebars' },
|
||||
{ startIndex: 9, type: 'delimiter.handlebars' }
|
||||
]
|
||||
},
|
||||
{
|
||||
line: '<span>{{bar}}</span>',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'delimiter.html' },
|
||||
{ startIndex: 1, type: 'tag.html' },
|
||||
{ startIndex: 5, type: 'delimiter.html' },
|
||||
{ startIndex: 6, type: 'delimiter.handlebars' },
|
||||
{ startIndex: 8, type: 'variable.parameter.handlebars' },
|
||||
{ startIndex: 11, type: 'delimiter.handlebars' },
|
||||
{ startIndex: 13, type: 'delimiter.html' },
|
||||
{ startIndex: 15, type: 'tag.html' },
|
||||
{ startIndex: 19, type: 'delimiter.html' }
|
||||
]
|
||||
},
|
||||
{
|
||||
line: '{{/if}}',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'delimiter.handlebars' },
|
||||
{ startIndex: 2, type: 'keyword.helper.handlebars' },
|
||||
{ startIndex: 5, type: 'delimiter.handlebars' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// Multiline
|
||||
[{
|
||||
line: '<div>',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'delimiter.html' },
|
||||
{ startIndex: 1, type: 'tag.html' },
|
||||
{ startIndex: 4, type: 'delimiter.html' }
|
||||
]
|
||||
}, {
|
||||
line: '{{#if foo}}',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'delimiter.handlebars' },
|
||||
{ startIndex: 2, type: 'keyword.helper.handlebars' },
|
||||
{ startIndex: 5, type: '' },
|
||||
{ startIndex: 6, type: 'variable.parameter.handlebars' },
|
||||
{ startIndex: 9, type: 'delimiter.handlebars' }
|
||||
]
|
||||
}, {
|
||||
line: '<span>{{bar}}</span>',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'delimiter.html' },
|
||||
{ startIndex: 1, type: 'tag.html' },
|
||||
{ startIndex: 5, type: 'delimiter.html' },
|
||||
{ startIndex: 6, type: 'delimiter.handlebars' },
|
||||
{ startIndex: 8, type: 'variable.parameter.handlebars' },
|
||||
{ startIndex: 11, type: 'delimiter.handlebars' },
|
||||
{ startIndex: 13, type: 'delimiter.html' },
|
||||
{ startIndex: 15, type: 'tag.html' },
|
||||
{ startIndex: 19, type: 'delimiter.html' }
|
||||
]
|
||||
}, {
|
||||
line: '{{/if}}',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'delimiter.handlebars' },
|
||||
{ startIndex: 2, type: 'keyword.helper.handlebars' },
|
||||
{ startIndex: 5, type: 'delimiter.handlebars' }
|
||||
]
|
||||
}],
|
||||
// Div end
|
||||
[
|
||||
{
|
||||
line: '</div>',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'delimiter.html' },
|
||||
{ startIndex: 2, type: 'tag.html' },
|
||||
{ startIndex: 5, type: 'delimiter.html' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// Div end
|
||||
[{
|
||||
line: '</div>',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'delimiter.html' },
|
||||
{ startIndex: 2, type: 'tag.html' },
|
||||
{ startIndex: 5, type: 'delimiter.html' }
|
||||
]
|
||||
}],
|
||||
// HTML Expressions
|
||||
[
|
||||
{
|
||||
line:
|
||||
'<script type="text/x-handlebars-template"><h1>{{ title }}</h1></script>',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'delimiter.html' },
|
||||
{ startIndex: 1, type: 'tag.html' },
|
||||
{ startIndex: 7, type: '' },
|
||||
{ startIndex: 8, type: 'attribute.name' },
|
||||
{ startIndex: 12, type: 'delimiter' },
|
||||
{ startIndex: 13, type: 'attribute.value' },
|
||||
{ startIndex: 41, type: 'delimiter.html' },
|
||||
{ startIndex: 42, type: 'delimiter.html' },
|
||||
{ startIndex: 43, type: 'tag.html' },
|
||||
{ startIndex: 45, type: 'delimiter.html' },
|
||||
{ startIndex: 46, type: 'delimiter.handlebars' },
|
||||
{ startIndex: 48, type: '' },
|
||||
{ startIndex: 49, type: 'variable.parameter.handlebars' },
|
||||
{ startIndex: 54, type: '' },
|
||||
{ startIndex: 55, type: 'delimiter.handlebars' },
|
||||
{ startIndex: 57, type: 'delimiter.html' },
|
||||
{ startIndex: 59, type: 'tag.html' },
|
||||
{ startIndex: 61, type: 'delimiter.html' },
|
||||
{ startIndex: 62, type: 'delimiter.html' },
|
||||
{ startIndex: 64, type: 'tag.html' },
|
||||
{ startIndex: 70, type: 'delimiter.html' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// HTML Expressions
|
||||
[{
|
||||
line: '<script type="text/x-handlebars-template"><h1>{{ title }}</h1></script>',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'delimiter.html' },
|
||||
{ startIndex: 1, type: 'tag.html' },
|
||||
{ startIndex: 7, type: '' },
|
||||
{ startIndex: 8, type: 'attribute.name' },
|
||||
{ startIndex: 12, type: 'delimiter' },
|
||||
{ startIndex: 13, type: 'attribute.value' },
|
||||
{ startIndex: 41, type: 'delimiter.html' },
|
||||
{ startIndex: 42, type: 'delimiter.html' },
|
||||
{ startIndex: 43, type: 'tag.html' },
|
||||
{ startIndex: 45, type: 'delimiter.html' },
|
||||
{ startIndex: 46, type: 'delimiter.handlebars' },
|
||||
{ startIndex: 48, type: '' },
|
||||
{ startIndex: 49, type: 'variable.parameter.handlebars' },
|
||||
{ startIndex: 54, type: '' },
|
||||
{ startIndex: 55, type: 'delimiter.handlebars' },
|
||||
{ startIndex: 57, type: 'delimiter.html' },
|
||||
{ startIndex: 59, type: 'tag.html' },
|
||||
{ startIndex: 61, type: 'delimiter.html' },
|
||||
{ startIndex: 62, type: 'delimiter.html' },
|
||||
{ startIndex: 64, type: 'tag.html' },
|
||||
{ startIndex: 70, type: 'delimiter.html' }
|
||||
]
|
||||
}],
|
||||
// Multi-line HTML Expressions
|
||||
[
|
||||
{
|
||||
line: '<script type="text/x-handlebars-template">',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'delimiter.html' },
|
||||
{ startIndex: 1, type: 'tag.html' },
|
||||
{ startIndex: 7, type: '' },
|
||||
{ startIndex: 8, type: 'attribute.name' },
|
||||
{ startIndex: 12, type: 'delimiter' },
|
||||
{ startIndex: 13, type: 'attribute.value' },
|
||||
{ startIndex: 41, type: 'delimiter.html' }
|
||||
]
|
||||
},
|
||||
{
|
||||
line: '<h1>{{ title }}</h1>',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'delimiter.html' },
|
||||
{ startIndex: 1, type: 'tag.html' },
|
||||
{ startIndex: 3, type: 'delimiter.html' },
|
||||
{ startIndex: 4, type: 'delimiter.handlebars' },
|
||||
{ startIndex: 6, type: '' },
|
||||
{ startIndex: 7, type: 'variable.parameter.handlebars' },
|
||||
{ startIndex: 12, type: '' },
|
||||
{ startIndex: 13, type: 'delimiter.handlebars' },
|
||||
{ startIndex: 15, type: 'delimiter.html' },
|
||||
{ startIndex: 17, type: 'tag.html' },
|
||||
{ startIndex: 19, type: 'delimiter.html' }
|
||||
]
|
||||
},
|
||||
{
|
||||
line: '</script>',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'delimiter.html' },
|
||||
{ startIndex: 2, type: 'tag.html' },
|
||||
{ startIndex: 8, type: 'delimiter.html' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// Multi-line HTML Expressions
|
||||
[{
|
||||
line: '<script type="text/x-handlebars-template">',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'delimiter.html' },
|
||||
{ startIndex: 1, type: 'tag.html' },
|
||||
{ startIndex: 7, type: '' },
|
||||
{ startIndex: 8, type: 'attribute.name' },
|
||||
{ startIndex: 12, type: 'delimiter' },
|
||||
{ startIndex: 13, type: 'attribute.value' },
|
||||
{ startIndex: 41, type: 'delimiter.html' }
|
||||
]
|
||||
}, {
|
||||
line: '<h1>{{ title }}</h1>',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'delimiter.html' },
|
||||
{ startIndex: 1, type: 'tag.html' },
|
||||
{ startIndex: 3, type: 'delimiter.html' },
|
||||
{ startIndex: 4, type: 'delimiter.handlebars' },
|
||||
{ startIndex: 6, type: '' },
|
||||
{ startIndex: 7, type: 'variable.parameter.handlebars' },
|
||||
{ startIndex: 12, type: '' },
|
||||
{ startIndex: 13, type: 'delimiter.handlebars' },
|
||||
{ startIndex: 15, type: 'delimiter.html' },
|
||||
{ startIndex: 17, type: 'tag.html' },
|
||||
{ startIndex: 19, type: 'delimiter.html' }
|
||||
]
|
||||
}, {
|
||||
line: '</script>',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'delimiter.html' },
|
||||
{ startIndex: 2, type: 'tag.html' },
|
||||
{ startIndex: 8, type: 'delimiter.html' }
|
||||
]
|
||||
}],
|
||||
// HTML Nested Modes
|
||||
[
|
||||
{
|
||||
line: '{{foo}}<script></script>{{bar}}',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'delimiter.handlebars' },
|
||||
{ startIndex: 2, type: 'variable.parameter.handlebars' },
|
||||
{ startIndex: 5, type: 'delimiter.handlebars' },
|
||||
{ startIndex: 7, type: 'delimiter.html' },
|
||||
{ startIndex: 8, type: 'tag.html' },
|
||||
{ startIndex: 14, type: 'delimiter.html' },
|
||||
// { startIndex:15, type: 'delimiter.html' },
|
||||
{ startIndex: 17, type: 'tag.html' },
|
||||
{ startIndex: 23, type: 'delimiter.html' },
|
||||
{ startIndex: 24, type: 'delimiter.handlebars' },
|
||||
{ startIndex: 26, type: 'variable.parameter.handlebars' },
|
||||
{ startIndex: 29, type: 'delimiter.handlebars' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// HTML Nested Modes
|
||||
[{
|
||||
line: '{{foo}}<script></script>{{bar}}',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'delimiter.handlebars' },
|
||||
{ startIndex: 2, type: 'variable.parameter.handlebars' },
|
||||
{ startIndex: 5, type: 'delimiter.handlebars' },
|
||||
{ startIndex: 7, type: 'delimiter.html' },
|
||||
{ startIndex: 8, type: 'tag.html' },
|
||||
{ startIndex: 14, type: 'delimiter.html' },
|
||||
// { startIndex:15, type: 'delimiter.html' },
|
||||
{ startIndex: 17, type: 'tag.html' },
|
||||
{ startIndex: 23, type: 'delimiter.html' },
|
||||
{ startIndex: 24, type: 'delimiter.handlebars' },
|
||||
{ startIndex: 26, type: 'variable.parameter.handlebars' },
|
||||
{ startIndex: 29, type: 'delimiter.handlebars' }
|
||||
]
|
||||
}],
|
||||
// else keyword
|
||||
[
|
||||
{
|
||||
line: '{{else}}',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'delimiter.handlebars' },
|
||||
{ startIndex: 2, type: 'keyword.helper.handlebars' },
|
||||
{ startIndex: 6, type: 'delimiter.handlebars' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// else keyword
|
||||
[{
|
||||
line: '{{else}}',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'delimiter.handlebars' },
|
||||
{ startIndex: 2, type: 'keyword.helper.handlebars' },
|
||||
{ startIndex: 6, type: 'delimiter.handlebars' }
|
||||
]
|
||||
}],
|
||||
// else keyword #2
|
||||
[
|
||||
{
|
||||
line: '{{elseFoo}}',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'delimiter.handlebars' },
|
||||
{ startIndex: 2, type: 'variable.parameter.handlebars' },
|
||||
{ startIndex: 9, type: 'delimiter.handlebars' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// else keyword #2
|
||||
[{
|
||||
line: '{{elseFoo}}',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'delimiter.handlebars' },
|
||||
{ startIndex: 2, type: 'variable.parameter.handlebars' },
|
||||
{ startIndex: 9, type: 'delimiter.handlebars' }
|
||||
]
|
||||
}],
|
||||
// Token inside attribute
|
||||
[
|
||||
{
|
||||
line: '<a href="/posts/{{permalink}}">',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'delimiter.html' },
|
||||
{ startIndex: 1, type: 'tag.html' },
|
||||
{ startIndex: 2, type: '' },
|
||||
{ startIndex: 3, type: 'attribute.name' },
|
||||
{ startIndex: 7, type: 'delimiter' },
|
||||
{ startIndex: 8, type: 'attribute.value' },
|
||||
{ startIndex: 30, type: 'delimiter.html' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// Token inside attribute
|
||||
[{
|
||||
line: '<a href="/posts/{{permalink}}">',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'delimiter.html' },
|
||||
{ startIndex: 1, type: 'tag.html' },
|
||||
{ startIndex: 2, type: '' },
|
||||
{ startIndex: 3, type: 'attribute.name' },
|
||||
{ startIndex: 7, type: 'delimiter' },
|
||||
{ startIndex: 8, type: 'attribute.value' },
|
||||
{ startIndex: 30, type: 'delimiter.html' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '{{test "coloring/looks broken"}}">',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'delimiter.handlebars' },
|
||||
{ startIndex: 2, type: 'variable.parameter.handlebars' },
|
||||
{ startIndex: 6, type: '' },
|
||||
{ startIndex: 7, type: 'string.handlebars' },
|
||||
{ startIndex: 30, type: 'delimiter.handlebars' },
|
||||
{ startIndex: 32, type: '' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '{{test "coloring/looks broken"}}">',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'delimiter.handlebars' },
|
||||
{ startIndex: 2, type: 'variable.parameter.handlebars' },
|
||||
{ startIndex: 6, type: '' },
|
||||
{ startIndex: 7, type: 'string.handlebars' },
|
||||
{ startIndex: 30, type: 'delimiter.handlebars' },
|
||||
{ startIndex: 32, type: '' }
|
||||
]
|
||||
}],
|
||||
// Block comment
|
||||
[
|
||||
{
|
||||
line: '{{!-- block comment --}}',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.block.start.handlebars' },
|
||||
{ startIndex: 5, type: 'comment.content.handlebars' },
|
||||
{ startIndex: 20, type: 'comment.block.end.handlebars' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// Block comment
|
||||
[{
|
||||
line: '{{!-- block comment --}}',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.block.start.handlebars' },
|
||||
{ startIndex: 5, type: 'comment.content.handlebars' },
|
||||
{ startIndex: 20, type: 'comment.block.end.handlebars' }
|
||||
]
|
||||
}],
|
||||
// Block comment with mustache
|
||||
[
|
||||
{
|
||||
line: '{{!-- block comment }} with mustache --}}',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.block.start.handlebars' },
|
||||
{ startIndex: 5, type: 'comment.content.handlebars' },
|
||||
{ startIndex: 37, type: 'comment.block.end.handlebars' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// Block comment with mustache
|
||||
[{
|
||||
line: '{{!-- block comment }} with mustache --}}',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.block.start.handlebars' },
|
||||
{ startIndex: 5, type: 'comment.content.handlebars' },
|
||||
{ startIndex: 37, type: 'comment.block.end.handlebars' }
|
||||
// Handlebars comment
|
||||
[
|
||||
{
|
||||
line: '{{! comment }}',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.start.handlebars' },
|
||||
{ startIndex: 3, type: 'comment.content.handlebars' },
|
||||
{ startIndex: 12, type: 'comment.end.handlebars' }
|
||||
]
|
||||
}
|
||||
]
|
||||
}],
|
||||
|
||||
// Handlebars comment
|
||||
[{
|
||||
line: '{{! comment }}',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.start.handlebars' },
|
||||
{ startIndex: 3, type: 'comment.content.handlebars' },
|
||||
{ startIndex: 12, type: 'comment.end.handlebars' }
|
||||
]
|
||||
}],
|
||||
]);
|
||||
]
|
||||
);
|
||||
|
|
|
|||
|
|
@ -9,9 +9,27 @@ import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration;
|
|||
import ILanguage = monaco.languages.IMonarchLanguage;
|
||||
|
||||
// Allow for running under nodejs/requirejs in tests
|
||||
const _monaco: typeof monaco = (typeof monaco === 'undefined' ? (<any>self).monaco : monaco);
|
||||
const _monaco: typeof monaco =
|
||||
typeof monaco === 'undefined' ? (<any>self).monaco : monaco;
|
||||
|
||||
const EMPTY_ELEMENTS: string[] = ['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'menuitem', 'meta', 'param', 'source', 'track', 'wbr'];
|
||||
const EMPTY_ELEMENTS: string[] = [
|
||||
'area',
|
||||
'base',
|
||||
'br',
|
||||
'col',
|
||||
'embed',
|
||||
'hr',
|
||||
'img',
|
||||
'input',
|
||||
'keygen',
|
||||
'link',
|
||||
'menuitem',
|
||||
'meta',
|
||||
'param',
|
||||
'source',
|
||||
'track',
|
||||
'wbr'
|
||||
];
|
||||
|
||||
export const conf: IRichLanguageConfiguration = {
|
||||
wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\@\$\^\&\*\(\)\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\s]+)/g,
|
||||
|
|
@ -33,27 +51,39 @@ export const conf: IRichLanguageConfiguration = {
|
|||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '"', close: '"' },
|
||||
{ open: '\'', close: '\'' }
|
||||
{ open: "'", close: "'" }
|
||||
],
|
||||
|
||||
surroundingPairs: [
|
||||
{ open: '<', close: '>' },
|
||||
{ open: '"', close: '"' },
|
||||
{ open: '\'', close: '\'' }
|
||||
{ open: "'", close: "'" }
|
||||
],
|
||||
|
||||
onEnterRules: [
|
||||
{
|
||||
beforeText: new RegExp(`<(?!(?:${EMPTY_ELEMENTS.join('|')}))(\\w[\\w\\d]*)([^/>]*(?!/)>)[^<]*$`, 'i'),
|
||||
beforeText: new RegExp(
|
||||
`<(?!(?:${EMPTY_ELEMENTS.join(
|
||||
'|'
|
||||
)}))(\\w[\\w\\d]*)([^/>]*(?!/)>)[^<]*$`,
|
||||
'i'
|
||||
),
|
||||
afterText: /^<\/(\w[\w\d]*)\s*>$/i,
|
||||
action: { indentAction: _monaco.languages.IndentAction.IndentOutdent }
|
||||
action: {
|
||||
indentAction: _monaco.languages.IndentAction.IndentOutdent
|
||||
}
|
||||
},
|
||||
{
|
||||
beforeText: new RegExp(`<(?!(?:${EMPTY_ELEMENTS.join('|')}))(\\w[\\w\\d]*)([^/>]*(?!/)>)[^<]*$`, 'i'),
|
||||
beforeText: new RegExp(
|
||||
`<(?!(?:${EMPTY_ELEMENTS.join(
|
||||
'|'
|
||||
)}))(\\w[\\w\\d]*)([^/>]*(?!/)>)[^<]*$`,
|
||||
'i'
|
||||
),
|
||||
action: { indentAction: _monaco.languages.IndentAction.Indent }
|
||||
}
|
||||
],
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
export const language = <ILanguage>{
|
||||
defaultToken: '',
|
||||
|
|
@ -65,23 +95,44 @@ export const language = <ILanguage>{
|
|||
root: [
|
||||
[/\{\{!--/, 'comment.block.start.handlebars', '@commentBlock'],
|
||||
[/\{\{!/, 'comment.start.handlebars', '@comment'],
|
||||
[/\{\{/, { token: '@rematch', switchTo: '@handlebarsInSimpleState.root' }],
|
||||
[
|
||||
/\{\{/,
|
||||
{ token: '@rematch', switchTo: '@handlebarsInSimpleState.root' }
|
||||
],
|
||||
[/<!DOCTYPE/, 'metatag.html', '@doctype'],
|
||||
[/<!--/, 'comment.html', '@commentHtml'],
|
||||
[/(<)(\w+)(\/>)/, ['delimiter.html', 'tag.html', 'delimiter.html']],
|
||||
[/(<)(script)/, ['delimiter.html', { token: 'tag.html', next: '@script' }]],
|
||||
[/(<)(style)/, ['delimiter.html', { token: 'tag.html', next: '@style' }]],
|
||||
[/(<)([:\w]+)/, ['delimiter.html', { token: 'tag.html', next: '@otherTag' }]],
|
||||
[/(<\/)(\w+)/, ['delimiter.html', { token: 'tag.html', next: '@otherTag' }]],
|
||||
[
|
||||
/(<)(script)/,
|
||||
['delimiter.html', { token: 'tag.html', next: '@script' }]
|
||||
],
|
||||
[
|
||||
/(<)(style)/,
|
||||
['delimiter.html', { token: 'tag.html', next: '@style' }]
|
||||
],
|
||||
[
|
||||
/(<)([:\w]+)/,
|
||||
['delimiter.html', { token: 'tag.html', next: '@otherTag' }]
|
||||
],
|
||||
[
|
||||
/(<\/)(\w+)/,
|
||||
['delimiter.html', { token: 'tag.html', next: '@otherTag' }]
|
||||
],
|
||||
[/</, 'delimiter.html'],
|
||||
[/\{/, 'delimiter.html'],
|
||||
[/[^<{]+/] // text
|
||||
],
|
||||
|
||||
doctype: [
|
||||
[/\{\{/, { token: '@rematch', switchTo: '@handlebarsInSimpleState.comment' }],
|
||||
[
|
||||
/\{\{/,
|
||||
{
|
||||
token: '@rematch',
|
||||
switchTo: '@handlebarsInSimpleState.comment'
|
||||
}
|
||||
],
|
||||
[/[^>]+/, 'metatag.content.html'],
|
||||
[/>/, 'metatag.html', '@pop'],
|
||||
[/>/, 'metatag.html', '@pop']
|
||||
],
|
||||
|
||||
comment: [
|
||||
|
|
@ -95,60 +146,144 @@ export const language = <ILanguage>{
|
|||
],
|
||||
|
||||
commentHtml: [
|
||||
[/\{\{/, { token: '@rematch', switchTo: '@handlebarsInSimpleState.comment' }],
|
||||
[
|
||||
/\{\{/,
|
||||
{
|
||||
token: '@rematch',
|
||||
switchTo: '@handlebarsInSimpleState.comment'
|
||||
}
|
||||
],
|
||||
[/-->/, 'comment.html', '@pop'],
|
||||
[/[^-]+/, 'comment.content.html'],
|
||||
[/./, 'comment.content.html']
|
||||
],
|
||||
|
||||
otherTag: [
|
||||
[/\{\{/, { token: '@rematch', switchTo: '@handlebarsInSimpleState.otherTag' }],
|
||||
[
|
||||
/\{\{/,
|
||||
{
|
||||
token: '@rematch',
|
||||
switchTo: '@handlebarsInSimpleState.otherTag'
|
||||
}
|
||||
],
|
||||
[/\/?>/, 'delimiter.html', '@pop'],
|
||||
[/"([^"]*)"/, 'attribute.value'],
|
||||
[/'([^']*)'/, 'attribute.value'],
|
||||
[/[\w\-]+/, 'attribute.name'],
|
||||
[/=/, 'delimiter'],
|
||||
[/[ \t\r\n]+/], // whitespace
|
||||
[/[ \t\r\n]+/] // whitespace
|
||||
],
|
||||
|
||||
// -- BEGIN <script> tags handling
|
||||
|
||||
// After <script
|
||||
script: [
|
||||
[/\{\{/, { token: '@rematch', switchTo: '@handlebarsInSimpleState.script' }],
|
||||
[
|
||||
/\{\{/,
|
||||
{
|
||||
token: '@rematch',
|
||||
switchTo: '@handlebarsInSimpleState.script'
|
||||
}
|
||||
],
|
||||
[/type/, 'attribute.name', '@scriptAfterType'],
|
||||
[/"([^"]*)"/, 'attribute.value'],
|
||||
[/'([^']*)'/, 'attribute.value'],
|
||||
[/[\w\-]+/, 'attribute.name'],
|
||||
[/=/, 'delimiter'],
|
||||
[/>/, { token: 'delimiter.html', next: '@scriptEmbedded.text/javascript', nextEmbedded: 'text/javascript' }],
|
||||
[
|
||||
/>/,
|
||||
{
|
||||
token: 'delimiter.html',
|
||||
next: '@scriptEmbedded.text/javascript',
|
||||
nextEmbedded: 'text/javascript'
|
||||
}
|
||||
],
|
||||
[/[ \t\r\n]+/], // whitespace
|
||||
[/(<\/)(script\s*)(>)/, ['delimiter.html', 'tag.html', { token: 'delimiter.html', next: '@pop' }]]
|
||||
[
|
||||
/(<\/)(script\s*)(>)/,
|
||||
[
|
||||
'delimiter.html',
|
||||
'tag.html',
|
||||
{ token: 'delimiter.html', next: '@pop' }
|
||||
]
|
||||
]
|
||||
],
|
||||
|
||||
// After <script ... type
|
||||
scriptAfterType: [
|
||||
[/\{\{/, { token: '@rematch', switchTo: '@handlebarsInSimpleState.scriptAfterType' }],
|
||||
[
|
||||
/\{\{/,
|
||||
{
|
||||
token: '@rematch',
|
||||
switchTo: '@handlebarsInSimpleState.scriptAfterType'
|
||||
}
|
||||
],
|
||||
[/=/, 'delimiter', '@scriptAfterTypeEquals'],
|
||||
[/>/, { token: 'delimiter.html', next: '@scriptEmbedded.text/javascript', nextEmbedded: 'text/javascript' }], // cover invalid e.g. <script type>
|
||||
[
|
||||
/>/,
|
||||
{
|
||||
token: 'delimiter.html',
|
||||
next: '@scriptEmbedded.text/javascript',
|
||||
nextEmbedded: 'text/javascript'
|
||||
}
|
||||
], // cover invalid e.g. <script type>
|
||||
[/[ \t\r\n]+/], // whitespace
|
||||
[/<\/script\s*>/, { token: '@rematch', next: '@pop' }]
|
||||
],
|
||||
|
||||
// After <script ... type =
|
||||
scriptAfterTypeEquals: [
|
||||
[/\{\{/, { token: '@rematch', switchTo: '@handlebarsInSimpleState.scriptAfterTypeEquals' }],
|
||||
[/"([^"]*)"/, { token: 'attribute.value', switchTo: '@scriptWithCustomType.$1' }],
|
||||
[/'([^']*)'/, { token: 'attribute.value', switchTo: '@scriptWithCustomType.$1' }],
|
||||
[/>/, { token: 'delimiter.html', next: '@scriptEmbedded.text/javascript', nextEmbedded: 'text/javascript' }], // cover invalid e.g. <script type=>
|
||||
[
|
||||
/\{\{/,
|
||||
{
|
||||
token: '@rematch',
|
||||
switchTo: '@handlebarsInSimpleState.scriptAfterTypeEquals'
|
||||
}
|
||||
],
|
||||
[
|
||||
/"([^"]*)"/,
|
||||
{
|
||||
token: 'attribute.value',
|
||||
switchTo: '@scriptWithCustomType.$1'
|
||||
}
|
||||
],
|
||||
[
|
||||
/'([^']*)'/,
|
||||
{
|
||||
token: 'attribute.value',
|
||||
switchTo: '@scriptWithCustomType.$1'
|
||||
}
|
||||
],
|
||||
[
|
||||
/>/,
|
||||
{
|
||||
token: 'delimiter.html',
|
||||
next: '@scriptEmbedded.text/javascript',
|
||||
nextEmbedded: 'text/javascript'
|
||||
}
|
||||
], // cover invalid e.g. <script type=>
|
||||
[/[ \t\r\n]+/], // whitespace
|
||||
[/<\/script\s*>/, { token: '@rematch', next: '@pop' }]
|
||||
],
|
||||
|
||||
// After <script ... type = $S2
|
||||
scriptWithCustomType: [
|
||||
[/\{\{/, { token: '@rematch', switchTo: '@handlebarsInSimpleState.scriptWithCustomType.$S2' }],
|
||||
[/>/, { token: 'delimiter.html', next: '@scriptEmbedded.$S2', nextEmbedded: '$S2' }],
|
||||
[
|
||||
/\{\{/,
|
||||
{
|
||||
token: '@rematch',
|
||||
switchTo:
|
||||
'@handlebarsInSimpleState.scriptWithCustomType.$S2'
|
||||
}
|
||||
],
|
||||
[
|
||||
/>/,
|
||||
{
|
||||
token: 'delimiter.html',
|
||||
next: '@scriptEmbedded.$S2',
|
||||
nextEmbedded: '$S2'
|
||||
}
|
||||
],
|
||||
[/"([^"]*)"/, 'attribute.value'],
|
||||
[/'([^']*)'/, 'attribute.value'],
|
||||
[/[\w\-]+/, 'attribute.name'],
|
||||
|
|
@ -158,51 +293,131 @@ export const language = <ILanguage>{
|
|||
],
|
||||
|
||||
scriptEmbedded: [
|
||||
[/\{\{/, { token: '@rematch', switchTo: '@handlebarsInEmbeddedState.scriptEmbedded.$S2', nextEmbedded: '@pop' }],
|
||||
[/<\/script/, { token: '@rematch', next: '@pop', nextEmbedded: '@pop' }]
|
||||
[
|
||||
/\{\{/,
|
||||
{
|
||||
token: '@rematch',
|
||||
switchTo: '@handlebarsInEmbeddedState.scriptEmbedded.$S2',
|
||||
nextEmbedded: '@pop'
|
||||
}
|
||||
],
|
||||
[
|
||||
/<\/script/,
|
||||
{ token: '@rematch', next: '@pop', nextEmbedded: '@pop' }
|
||||
]
|
||||
],
|
||||
|
||||
// -- END <script> tags handling
|
||||
|
||||
|
||||
// -- BEGIN <style> tags handling
|
||||
|
||||
// After <style
|
||||
style: [
|
||||
[/\{\{/, { token: '@rematch', switchTo: '@handlebarsInSimpleState.style' }],
|
||||
[
|
||||
/\{\{/,
|
||||
{
|
||||
token: '@rematch',
|
||||
switchTo: '@handlebarsInSimpleState.style'
|
||||
}
|
||||
],
|
||||
[/type/, 'attribute.name', '@styleAfterType'],
|
||||
[/"([^"]*)"/, 'attribute.value'],
|
||||
[/'([^']*)'/, 'attribute.value'],
|
||||
[/[\w\-]+/, 'attribute.name'],
|
||||
[/=/, 'delimiter'],
|
||||
[/>/, { token: 'delimiter.html', next: '@styleEmbedded.text/css', nextEmbedded: 'text/css' }],
|
||||
[
|
||||
/>/,
|
||||
{
|
||||
token: 'delimiter.html',
|
||||
next: '@styleEmbedded.text/css',
|
||||
nextEmbedded: 'text/css'
|
||||
}
|
||||
],
|
||||
[/[ \t\r\n]+/], // whitespace
|
||||
[/(<\/)(style\s*)(>)/, ['delimiter.html', 'tag.html', { token: 'delimiter.html', next: '@pop' }]]
|
||||
[
|
||||
/(<\/)(style\s*)(>)/,
|
||||
[
|
||||
'delimiter.html',
|
||||
'tag.html',
|
||||
{ token: 'delimiter.html', next: '@pop' }
|
||||
]
|
||||
]
|
||||
],
|
||||
|
||||
// After <style ... type
|
||||
styleAfterType: [
|
||||
[/\{\{/, { token: '@rematch', switchTo: '@handlebarsInSimpleState.styleAfterType' }],
|
||||
[
|
||||
/\{\{/,
|
||||
{
|
||||
token: '@rematch',
|
||||
switchTo: '@handlebarsInSimpleState.styleAfterType'
|
||||
}
|
||||
],
|
||||
[/=/, 'delimiter', '@styleAfterTypeEquals'],
|
||||
[/>/, { token: 'delimiter.html', next: '@styleEmbedded.text/css', nextEmbedded: 'text/css' }], // cover invalid e.g. <style type>
|
||||
[
|
||||
/>/,
|
||||
{
|
||||
token: 'delimiter.html',
|
||||
next: '@styleEmbedded.text/css',
|
||||
nextEmbedded: 'text/css'
|
||||
}
|
||||
], // cover invalid e.g. <style type>
|
||||
[/[ \t\r\n]+/], // whitespace
|
||||
[/<\/style\s*>/, { token: '@rematch', next: '@pop' }]
|
||||
],
|
||||
|
||||
// After <style ... type =
|
||||
styleAfterTypeEquals: [
|
||||
[/\{\{/, { token: '@rematch', switchTo: '@handlebarsInSimpleState.styleAfterTypeEquals' }],
|
||||
[/"([^"]*)"/, { token: 'attribute.value', switchTo: '@styleWithCustomType.$1' }],
|
||||
[/'([^']*)'/, { token: 'attribute.value', switchTo: '@styleWithCustomType.$1' }],
|
||||
[/>/, { token: 'delimiter.html', next: '@styleEmbedded.text/css', nextEmbedded: 'text/css' }], // cover invalid e.g. <style type=>
|
||||
[
|
||||
/\{\{/,
|
||||
{
|
||||
token: '@rematch',
|
||||
switchTo: '@handlebarsInSimpleState.styleAfterTypeEquals'
|
||||
}
|
||||
],
|
||||
[
|
||||
/"([^"]*)"/,
|
||||
{
|
||||
token: 'attribute.value',
|
||||
switchTo: '@styleWithCustomType.$1'
|
||||
}
|
||||
],
|
||||
[
|
||||
/'([^']*)'/,
|
||||
{
|
||||
token: 'attribute.value',
|
||||
switchTo: '@styleWithCustomType.$1'
|
||||
}
|
||||
],
|
||||
[
|
||||
/>/,
|
||||
{
|
||||
token: 'delimiter.html',
|
||||
next: '@styleEmbedded.text/css',
|
||||
nextEmbedded: 'text/css'
|
||||
}
|
||||
], // cover invalid e.g. <style type=>
|
||||
[/[ \t\r\n]+/], // whitespace
|
||||
[/<\/style\s*>/, { token: '@rematch', next: '@pop' }]
|
||||
],
|
||||
|
||||
// After <style ... type = $S2
|
||||
styleWithCustomType: [
|
||||
[/\{\{/, { token: '@rematch', switchTo: '@handlebarsInSimpleState.styleWithCustomType.$S2' }],
|
||||
[/>/, { token: 'delimiter.html', next: '@styleEmbedded.$S2', nextEmbedded: '$S2' }],
|
||||
[
|
||||
/\{\{/,
|
||||
{
|
||||
token: '@rematch',
|
||||
switchTo: '@handlebarsInSimpleState.styleWithCustomType.$S2'
|
||||
}
|
||||
],
|
||||
[
|
||||
/>/,
|
||||
{
|
||||
token: 'delimiter.html',
|
||||
next: '@styleEmbedded.$S2',
|
||||
nextEmbedded: '$S2'
|
||||
}
|
||||
],
|
||||
[/"([^"]*)"/, 'attribute.value'],
|
||||
[/'([^']*)'/, 'attribute.value'],
|
||||
[/[\w\-]+/, 'attribute.name'],
|
||||
|
|
@ -212,22 +427,41 @@ export const language = <ILanguage>{
|
|||
],
|
||||
|
||||
styleEmbedded: [
|
||||
[/\{\{/, { token: '@rematch', switchTo: '@handlebarsInEmbeddedState.styleEmbedded.$S2', nextEmbedded: '@pop' }],
|
||||
[/<\/style/, { token: '@rematch', next: '@pop', nextEmbedded: '@pop' }]
|
||||
[
|
||||
/\{\{/,
|
||||
{
|
||||
token: '@rematch',
|
||||
switchTo: '@handlebarsInEmbeddedState.styleEmbedded.$S2',
|
||||
nextEmbedded: '@pop'
|
||||
}
|
||||
],
|
||||
[
|
||||
/<\/style/,
|
||||
{ token: '@rematch', next: '@pop', nextEmbedded: '@pop' }
|
||||
]
|
||||
],
|
||||
|
||||
// -- END <style> tags handling
|
||||
|
||||
|
||||
handlebarsInSimpleState: [
|
||||
[/\{\{\{?/, 'delimiter.handlebars'],
|
||||
[/\}\}\}?/, { token: 'delimiter.handlebars', switchTo: '@$S2.$S3' }],
|
||||
[
|
||||
/\}\}\}?/,
|
||||
{ token: 'delimiter.handlebars', switchTo: '@$S2.$S3' }
|
||||
],
|
||||
{ include: 'handlebarsRoot' }
|
||||
],
|
||||
|
||||
handlebarsInEmbeddedState: [
|
||||
[/\{\{\{?/, 'delimiter.handlebars'],
|
||||
[/\}\}\}?/, { token: 'delimiter.handlebars', switchTo: '@$S2.$S3', nextEmbedded: '$S3' }],
|
||||
[
|
||||
/\}\}\}?/,
|
||||
{
|
||||
token: 'delimiter.handlebars',
|
||||
switchTo: '@$S2.$S3',
|
||||
nextEmbedded: '$S3'
|
||||
}
|
||||
],
|
||||
{ include: 'handlebarsRoot' }
|
||||
],
|
||||
|
||||
|
|
@ -236,7 +470,7 @@ export const language = <ILanguage>{
|
|||
[/[#/][^\s}]+/, 'keyword.helper.handlebars'],
|
||||
[/else\b/, 'keyword.helper.handlebars'],
|
||||
[/[\s]+/],
|
||||
[/[^}]/, 'variable.parameter.handlebars'],
|
||||
],
|
||||
},
|
||||
[/[^}]/, 'variable.parameter.handlebars']
|
||||
]
|
||||
}
|
||||
};
|
||||
|
|
|
|||
186
src/hcl/hcl.ts
186
src/hcl/hcl.ts
|
|
@ -11,7 +11,7 @@ import ILanguage = monaco.languages.IMonarchLanguage;
|
|||
export const conf: IRichLanguageConfiguration = {
|
||||
comments: {
|
||||
lineComment: '//',
|
||||
blockComment: ['/*', '*/'],
|
||||
blockComment: ['/*', '*/']
|
||||
},
|
||||
brackets: [
|
||||
['{', '}'],
|
||||
|
|
@ -23,14 +23,14 @@ export const conf: IRichLanguageConfiguration = {
|
|||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '"', close: '"', notIn: ['string'] },
|
||||
{ open: '\'', close: '\'', notIn: ['string', 'comment'] },
|
||||
{ open: "'", close: "'", notIn: ['string', 'comment'] }
|
||||
],
|
||||
surroundingPairs: [
|
||||
{ open: '{', close: '}' },
|
||||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '"', close: '"' },
|
||||
{ open: '\'', close: '\'' },
|
||||
{ open: "'", close: "'" }
|
||||
]
|
||||
};
|
||||
|
||||
|
|
@ -39,16 +39,146 @@ export const language = <ILanguage>{
|
|||
tokenPostfix: '.tf',
|
||||
|
||||
keywords: [
|
||||
'var', 'local', 'module', 'data', 'path', 'terraform',
|
||||
'resource', 'provider', 'variable', 'output', 'locals',
|
||||
'any', 'string', 'number', 'bool',
|
||||
'abs', 'ceil', 'floor', 'log', 'max', 'min', 'pow', 'signum', 'chomp', 'format', 'formatlist', 'indent', 'join', 'lower', 'regex', 'regexall', 'replace', 'split', 'strrev', 'substr', 'title', 'trimspace', 'upper', 'chunklist', 'coalesce', 'coalescelist', 'compact', 'concat', 'contains', 'distinct', 'element', 'flatten', 'index', 'keys', 'length', 'list', 'lookup', 'map', 'matchkeys', 'merge', 'range', 'reverse', 'setintersection', 'setproduct', 'setunion', 'slice', 'sort', 'transpose', 'values', 'zipmap', 'base64decode', 'base64encode', 'base64gzip', 'csvdecode', 'jsondecode', 'jsonencode', 'urlencode', 'yamldecode', 'yamlencode', 'abspath', 'dirname', 'pathexpand', 'basename', 'file', 'fileexists', 'fileset', 'filebase64', 'templatefile', 'formatdate', 'timeadd', 'timestamp', 'base64sha256', 'base64sha512', 'bcrypt', 'filebase64sha256', 'filebase64sha512', 'filemd5', 'filemd1', 'filesha256', 'filesha512', 'md5', 'rsadecrypt', 'sha1', 'sha256', 'sha512', 'uuid', 'uuidv5', 'cidrhost', 'cidrnetmask', 'cidrsubnet', 'tobool', 'tolist', 'tomap', 'tonumber', 'toset', 'tostring',
|
||||
'true', 'false', 'null',
|
||||
'if ', 'else ', 'endif ', 'for ', 'in', 'endfor'
|
||||
'var',
|
||||
'local',
|
||||
'module',
|
||||
'data',
|
||||
'path',
|
||||
'terraform',
|
||||
'resource',
|
||||
'provider',
|
||||
'variable',
|
||||
'output',
|
||||
'locals',
|
||||
'any',
|
||||
'string',
|
||||
'number',
|
||||
'bool',
|
||||
'abs',
|
||||
'ceil',
|
||||
'floor',
|
||||
'log',
|
||||
'max',
|
||||
'min',
|
||||
'pow',
|
||||
'signum',
|
||||
'chomp',
|
||||
'format',
|
||||
'formatlist',
|
||||
'indent',
|
||||
'join',
|
||||
'lower',
|
||||
'regex',
|
||||
'regexall',
|
||||
'replace',
|
||||
'split',
|
||||
'strrev',
|
||||
'substr',
|
||||
'title',
|
||||
'trimspace',
|
||||
'upper',
|
||||
'chunklist',
|
||||
'coalesce',
|
||||
'coalescelist',
|
||||
'compact',
|
||||
'concat',
|
||||
'contains',
|
||||
'distinct',
|
||||
'element',
|
||||
'flatten',
|
||||
'index',
|
||||
'keys',
|
||||
'length',
|
||||
'list',
|
||||
'lookup',
|
||||
'map',
|
||||
'matchkeys',
|
||||
'merge',
|
||||
'range',
|
||||
'reverse',
|
||||
'setintersection',
|
||||
'setproduct',
|
||||
'setunion',
|
||||
'slice',
|
||||
'sort',
|
||||
'transpose',
|
||||
'values',
|
||||
'zipmap',
|
||||
'base64decode',
|
||||
'base64encode',
|
||||
'base64gzip',
|
||||
'csvdecode',
|
||||
'jsondecode',
|
||||
'jsonencode',
|
||||
'urlencode',
|
||||
'yamldecode',
|
||||
'yamlencode',
|
||||
'abspath',
|
||||
'dirname',
|
||||
'pathexpand',
|
||||
'basename',
|
||||
'file',
|
||||
'fileexists',
|
||||
'fileset',
|
||||
'filebase64',
|
||||
'templatefile',
|
||||
'formatdate',
|
||||
'timeadd',
|
||||
'timestamp',
|
||||
'base64sha256',
|
||||
'base64sha512',
|
||||
'bcrypt',
|
||||
'filebase64sha256',
|
||||
'filebase64sha512',
|
||||
'filemd5',
|
||||
'filemd1',
|
||||
'filesha256',
|
||||
'filesha512',
|
||||
'md5',
|
||||
'rsadecrypt',
|
||||
'sha1',
|
||||
'sha256',
|
||||
'sha512',
|
||||
'uuid',
|
||||
'uuidv5',
|
||||
'cidrhost',
|
||||
'cidrnetmask',
|
||||
'cidrsubnet',
|
||||
'tobool',
|
||||
'tolist',
|
||||
'tomap',
|
||||
'tonumber',
|
||||
'toset',
|
||||
'tostring',
|
||||
'true',
|
||||
'false',
|
||||
'null',
|
||||
'if ',
|
||||
'else ',
|
||||
'endif ',
|
||||
'for ',
|
||||
'in',
|
||||
'endfor'
|
||||
],
|
||||
|
||||
operators: [
|
||||
'>=', '<=', '==', '!=', '+', '-', '*', '/', '%', '&&', '||', '!', '<', '>', '?', '...', ':',
|
||||
'>=',
|
||||
'<=',
|
||||
'==',
|
||||
'!=',
|
||||
'+',
|
||||
'-',
|
||||
'*',
|
||||
'/',
|
||||
'%',
|
||||
'&&',
|
||||
'||',
|
||||
'!',
|
||||
'<',
|
||||
'>',
|
||||
'?',
|
||||
'...',
|
||||
':'
|
||||
],
|
||||
|
||||
// we include these common regular expressions
|
||||
|
|
@ -60,12 +190,15 @@ export const language = <ILanguage>{
|
|||
tokenizer: {
|
||||
root: [
|
||||
// identifiers and keywords
|
||||
[/[a-zA-Z_]\w*/, {
|
||||
cases: {
|
||||
'@keywords': { token: 'keyword.$0' },
|
||||
'@default': 'identifier'
|
||||
[
|
||||
/[a-zA-Z_]\w*/,
|
||||
{
|
||||
cases: {
|
||||
'@keywords': { token: 'keyword.$0' },
|
||||
'@default': 'identifier'
|
||||
}
|
||||
}
|
||||
}],
|
||||
],
|
||||
|
||||
// whitespace
|
||||
{ include: '@whitespace' },
|
||||
|
|
@ -73,12 +206,15 @@ export const language = <ILanguage>{
|
|||
// delimiters and operators
|
||||
[/[{}()\[\]]/, '@brackets'],
|
||||
[/[<>](?!@symbols)/, '@brackets'],
|
||||
[/@symbols/, {
|
||||
cases: {
|
||||
'@operators': 'delimiter',
|
||||
'@default': ''
|
||||
[
|
||||
/@symbols/,
|
||||
{
|
||||
cases: {
|
||||
'@operators': 'delimiter',
|
||||
'@default': ''
|
||||
}
|
||||
}
|
||||
}],
|
||||
],
|
||||
|
||||
// numbers
|
||||
[/\d*\d+[eE]([\-+]?\d+)?/, 'number.float'],
|
||||
|
|
@ -90,15 +226,15 @@ export const language = <ILanguage>{
|
|||
[/[;,.]/, 'delimiter'],
|
||||
|
||||
// strings
|
||||
[/"([^"\\]|\\.)*$/, 'string.invalid'], // non-teminated string
|
||||
[/"/, 'string', '@string'],
|
||||
[/"([^"\\]|\\.)*$/, 'string.invalid'], // non-teminated string
|
||||
[/"/, 'string', '@string']
|
||||
],
|
||||
|
||||
whitespace: [
|
||||
[/[ \t\r\n]+/, ''],
|
||||
[/\/\*/, 'comment', '@comment'],
|
||||
[/\/\/.*$/, 'comment'],
|
||||
[/#.*$/, 'comment'],
|
||||
[/#.*$/, 'comment']
|
||||
],
|
||||
|
||||
comment: [
|
||||
|
|
@ -112,6 +248,6 @@ export const language = <ILanguage>{
|
|||
[/@escapes/, 'string.escape'],
|
||||
[/\\./, 'string.escape.invalid'],
|
||||
[/"/, 'string', '@pop']
|
||||
],
|
||||
},
|
||||
]
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -8,8 +8,23 @@ import { registerLanguage } from '../_.contribution';
|
|||
|
||||
registerLanguage({
|
||||
id: 'html',
|
||||
extensions: ['.html', '.htm', '.shtml', '.xhtml', '.mdoc', '.jsp', '.asp', '.aspx', '.jshtm'],
|
||||
extensions: [
|
||||
'.html',
|
||||
'.htm',
|
||||
'.shtml',
|
||||
'.xhtml',
|
||||
'.mdoc',
|
||||
'.jsp',
|
||||
'.asp',
|
||||
'.aspx',
|
||||
'.jshtm'
|
||||
],
|
||||
aliases: ['HTML', 'htm', 'html', 'xhtml'],
|
||||
mimetypes: ['text/html', 'text/x-jshtm', 'text/template', 'text/ng-template'],
|
||||
mimetypes: [
|
||||
'text/html',
|
||||
'text/x-jshtm',
|
||||
'text/template',
|
||||
'text/ng-template'
|
||||
],
|
||||
loader: () => import('./html')
|
||||
});
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
200
src/html/html.ts
200
src/html/html.ts
|
|
@ -9,9 +9,27 @@ import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration;
|
|||
import ILanguage = monaco.languages.IMonarchLanguage;
|
||||
|
||||
// Allow for running under nodejs/requirejs in tests
|
||||
const _monaco: typeof monaco = (typeof monaco === 'undefined' ? (<any>self).monaco : monaco);
|
||||
const _monaco: typeof monaco =
|
||||
typeof monaco === 'undefined' ? (<any>self).monaco : monaco;
|
||||
|
||||
const EMPTY_ELEMENTS: string[] = ['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'menuitem', 'meta', 'param', 'source', 'track', 'wbr'];
|
||||
const EMPTY_ELEMENTS: string[] = [
|
||||
'area',
|
||||
'base',
|
||||
'br',
|
||||
'col',
|
||||
'embed',
|
||||
'hr',
|
||||
'img',
|
||||
'input',
|
||||
'keygen',
|
||||
'link',
|
||||
'menuitem',
|
||||
'meta',
|
||||
'param',
|
||||
'source',
|
||||
'track',
|
||||
'wbr'
|
||||
];
|
||||
|
||||
export const conf: IRichLanguageConfiguration = {
|
||||
wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\@\$\^\&\*\(\)\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\s]+)/g,
|
||||
|
|
@ -32,34 +50,46 @@ export const conf: IRichLanguageConfiguration = {
|
|||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '"', close: '"' },
|
||||
{ open: '\'', close: '\'' }
|
||||
{ open: "'", close: "'" }
|
||||
],
|
||||
|
||||
surroundingPairs: [
|
||||
{ open: '"', close: '"' },
|
||||
{ open: '\'', close: '\'' },
|
||||
{ open: "'", close: "'" },
|
||||
{ open: '{', close: '}' },
|
||||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '<', close: '>' },
|
||||
{ open: '<', close: '>' }
|
||||
],
|
||||
|
||||
onEnterRules: [
|
||||
{
|
||||
beforeText: new RegExp(`<(?!(?:${EMPTY_ELEMENTS.join('|')}))([_:\\w][_:\\w-.\\d]*)([^/>]*(?!/)>)[^<]*$`, 'i'),
|
||||
beforeText: new RegExp(
|
||||
`<(?!(?:${EMPTY_ELEMENTS.join(
|
||||
'|'
|
||||
)}))([_:\\w][_:\\w-.\\d]*)([^/>]*(?!/)>)[^<]*$`,
|
||||
'i'
|
||||
),
|
||||
afterText: /^<\/([_:\w][_:\w-.\d]*)\s*>$/i,
|
||||
action: { indentAction: _monaco.languages.IndentAction.IndentOutdent }
|
||||
action: {
|
||||
indentAction: _monaco.languages.IndentAction.IndentOutdent
|
||||
}
|
||||
},
|
||||
{
|
||||
beforeText: new RegExp(`<(?!(?:${EMPTY_ELEMENTS.join('|')}))(\\w[\\w\\d]*)([^/>]*(?!/)>)[^<]*$`, 'i'),
|
||||
beforeText: new RegExp(
|
||||
`<(?!(?:${EMPTY_ELEMENTS.join(
|
||||
'|'
|
||||
)}))(\\w[\\w\\d]*)([^/>]*(?!/)>)[^<]*$`,
|
||||
'i'
|
||||
),
|
||||
action: { indentAction: _monaco.languages.IndentAction.Indent }
|
||||
}
|
||||
],
|
||||
|
||||
folding: {
|
||||
markers: {
|
||||
start: new RegExp("^\\s*<!--\\s*#region\\b.*-->"),
|
||||
end: new RegExp("^\\s*<!--\\s*#endregion\\b.*-->")
|
||||
start: new RegExp('^\\s*<!--\\s*#region\\b.*-->'),
|
||||
end: new RegExp('^\\s*<!--\\s*#endregion\\b.*-->')
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -74,18 +104,27 @@ export const language = <ILanguage>{
|
|||
root: [
|
||||
[/<!DOCTYPE/, 'metatag', '@doctype'],
|
||||
[/<!--/, 'comment', '@comment'],
|
||||
[/(<)((?:[\w\-]+:)?[\w\-]+)(\s*)(\/>)/, ['delimiter', 'tag', '', 'delimiter']],
|
||||
[
|
||||
/(<)((?:[\w\-]+:)?[\w\-]+)(\s*)(\/>)/,
|
||||
['delimiter', 'tag', '', 'delimiter']
|
||||
],
|
||||
[/(<)(script)/, ['delimiter', { token: 'tag', next: '@script' }]],
|
||||
[/(<)(style)/, ['delimiter', { token: 'tag', next: '@style' }]],
|
||||
[/(<)((?:[\w\-]+:)?[\w\-]+)/, ['delimiter', { token: 'tag', next: '@otherTag' }]],
|
||||
[/(<\/)((?:[\w\-]+:)?[\w\-]+)/, ['delimiter', { token: 'tag', next: '@otherTag' }]],
|
||||
[
|
||||
/(<)((?:[\w\-]+:)?[\w\-]+)/,
|
||||
['delimiter', { token: 'tag', next: '@otherTag' }]
|
||||
],
|
||||
[
|
||||
/(<\/)((?:[\w\-]+:)?[\w\-]+)/,
|
||||
['delimiter', { token: 'tag', next: '@otherTag' }]
|
||||
],
|
||||
[/</, 'delimiter'],
|
||||
[/[^<]+/], // text
|
||||
[/[^<]+/] // text
|
||||
],
|
||||
|
||||
doctype: [
|
||||
[/[^>]+/, 'metatag.content'],
|
||||
[/>/, 'metatag', '@pop'],
|
||||
[/>/, 'metatag', '@pop']
|
||||
],
|
||||
|
||||
comment: [
|
||||
|
|
@ -100,7 +139,7 @@ export const language = <ILanguage>{
|
|||
[/'([^']*)'/, 'attribute.value'],
|
||||
[/[\w\-]+/, 'attribute.name'],
|
||||
[/=/, 'delimiter'],
|
||||
[/[ \t\r\n]+/], // whitespace
|
||||
[/[ \t\r\n]+/] // whitespace
|
||||
],
|
||||
|
||||
// -- BEGIN <script> tags handling
|
||||
|
|
@ -112,31 +151,74 @@ export const language = <ILanguage>{
|
|||
[/'([^']*)'/, 'attribute.value'],
|
||||
[/[\w\-]+/, 'attribute.name'],
|
||||
[/=/, 'delimiter'],
|
||||
[/>/, { token: 'delimiter', next: '@scriptEmbedded', nextEmbedded: 'text/javascript' }],
|
||||
[
|
||||
/>/,
|
||||
{
|
||||
token: 'delimiter',
|
||||
next: '@scriptEmbedded',
|
||||
nextEmbedded: 'text/javascript'
|
||||
}
|
||||
],
|
||||
[/[ \t\r\n]+/], // whitespace
|
||||
[/(<\/)(script\s*)(>)/, ['delimiter', 'tag', { token: 'delimiter', next: '@pop' }]]
|
||||
[
|
||||
/(<\/)(script\s*)(>)/,
|
||||
['delimiter', 'tag', { token: 'delimiter', next: '@pop' }]
|
||||
]
|
||||
],
|
||||
|
||||
// After <script ... type
|
||||
scriptAfterType: [
|
||||
[/=/, 'delimiter', '@scriptAfterTypeEquals'],
|
||||
[/>/, { token: 'delimiter', next: '@scriptEmbedded', nextEmbedded: 'text/javascript' }], // cover invalid e.g. <script type>
|
||||
[
|
||||
/>/,
|
||||
{
|
||||
token: 'delimiter',
|
||||
next: '@scriptEmbedded',
|
||||
nextEmbedded: 'text/javascript'
|
||||
}
|
||||
], // cover invalid e.g. <script type>
|
||||
[/[ \t\r\n]+/], // whitespace
|
||||
[/<\/script\s*>/, { token: '@rematch', next: '@pop' }]
|
||||
],
|
||||
|
||||
// After <script ... type =
|
||||
scriptAfterTypeEquals: [
|
||||
[/"([^"]*)"/, { token: 'attribute.value', switchTo: '@scriptWithCustomType.$1' }],
|
||||
[/'([^']*)'/, { token: 'attribute.value', switchTo: '@scriptWithCustomType.$1' }],
|
||||
[/>/, { token: 'delimiter', next: '@scriptEmbedded', nextEmbedded: 'text/javascript' }], // cover invalid e.g. <script type=>
|
||||
[
|
||||
/"([^"]*)"/,
|
||||
{
|
||||
token: 'attribute.value',
|
||||
switchTo: '@scriptWithCustomType.$1'
|
||||
}
|
||||
],
|
||||
[
|
||||
/'([^']*)'/,
|
||||
{
|
||||
token: 'attribute.value',
|
||||
switchTo: '@scriptWithCustomType.$1'
|
||||
}
|
||||
],
|
||||
[
|
||||
/>/,
|
||||
{
|
||||
token: 'delimiter',
|
||||
next: '@scriptEmbedded',
|
||||
nextEmbedded: 'text/javascript'
|
||||
}
|
||||
], // cover invalid e.g. <script type=>
|
||||
[/[ \t\r\n]+/], // whitespace
|
||||
[/<\/script\s*>/, { token: '@rematch', next: '@pop' }]
|
||||
],
|
||||
|
||||
// After <script ... type = $S2
|
||||
scriptWithCustomType: [
|
||||
[/>/, { token: 'delimiter', next: '@scriptEmbedded.$S2', nextEmbedded: '$S2' }],
|
||||
[
|
||||
/>/,
|
||||
{
|
||||
token: 'delimiter',
|
||||
next: '@scriptEmbedded.$S2',
|
||||
nextEmbedded: '$S2'
|
||||
}
|
||||
],
|
||||
[/"([^"]*)"/, 'attribute.value'],
|
||||
[/'([^']*)'/, 'attribute.value'],
|
||||
[/[\w\-]+/, 'attribute.name'],
|
||||
|
|
@ -146,13 +228,15 @@ export const language = <ILanguage>{
|
|||
],
|
||||
|
||||
scriptEmbedded: [
|
||||
[/<\/script/, { token: '@rematch', next: '@pop', nextEmbedded: '@pop' }],
|
||||
[
|
||||
/<\/script/,
|
||||
{ token: '@rematch', next: '@pop', nextEmbedded: '@pop' }
|
||||
],
|
||||
[/[^<]+/, '']
|
||||
],
|
||||
|
||||
// -- END <script> tags handling
|
||||
|
||||
|
||||
// -- BEGIN <style> tags handling
|
||||
|
||||
// After <style
|
||||
|
|
@ -162,31 +246,74 @@ export const language = <ILanguage>{
|
|||
[/'([^']*)'/, 'attribute.value'],
|
||||
[/[\w\-]+/, 'attribute.name'],
|
||||
[/=/, 'delimiter'],
|
||||
[/>/, { token: 'delimiter', next: '@styleEmbedded', nextEmbedded: 'text/css' }],
|
||||
[
|
||||
/>/,
|
||||
{
|
||||
token: 'delimiter',
|
||||
next: '@styleEmbedded',
|
||||
nextEmbedded: 'text/css'
|
||||
}
|
||||
],
|
||||
[/[ \t\r\n]+/], // whitespace
|
||||
[/(<\/)(style\s*)(>)/, ['delimiter', 'tag', { token: 'delimiter', next: '@pop' }]]
|
||||
[
|
||||
/(<\/)(style\s*)(>)/,
|
||||
['delimiter', 'tag', { token: 'delimiter', next: '@pop' }]
|
||||
]
|
||||
],
|
||||
|
||||
// After <style ... type
|
||||
styleAfterType: [
|
||||
[/=/, 'delimiter', '@styleAfterTypeEquals'],
|
||||
[/>/, { token: 'delimiter', next: '@styleEmbedded', nextEmbedded: 'text/css' }], // cover invalid e.g. <style type>
|
||||
[
|
||||
/>/,
|
||||
{
|
||||
token: 'delimiter',
|
||||
next: '@styleEmbedded',
|
||||
nextEmbedded: 'text/css'
|
||||
}
|
||||
], // cover invalid e.g. <style type>
|
||||
[/[ \t\r\n]+/], // whitespace
|
||||
[/<\/style\s*>/, { token: '@rematch', next: '@pop' }]
|
||||
],
|
||||
|
||||
// After <style ... type =
|
||||
styleAfterTypeEquals: [
|
||||
[/"([^"]*)"/, { token: 'attribute.value', switchTo: '@styleWithCustomType.$1' }],
|
||||
[/'([^']*)'/, { token: 'attribute.value', switchTo: '@styleWithCustomType.$1' }],
|
||||
[/>/, { token: 'delimiter', next: '@styleEmbedded', nextEmbedded: 'text/css' }], // cover invalid e.g. <style type=>
|
||||
[
|
||||
/"([^"]*)"/,
|
||||
{
|
||||
token: 'attribute.value',
|
||||
switchTo: '@styleWithCustomType.$1'
|
||||
}
|
||||
],
|
||||
[
|
||||
/'([^']*)'/,
|
||||
{
|
||||
token: 'attribute.value',
|
||||
switchTo: '@styleWithCustomType.$1'
|
||||
}
|
||||
],
|
||||
[
|
||||
/>/,
|
||||
{
|
||||
token: 'delimiter',
|
||||
next: '@styleEmbedded',
|
||||
nextEmbedded: 'text/css'
|
||||
}
|
||||
], // cover invalid e.g. <style type=>
|
||||
[/[ \t\r\n]+/], // whitespace
|
||||
[/<\/style\s*>/, { token: '@rematch', next: '@pop' }]
|
||||
],
|
||||
|
||||
// After <style ... type = $S2
|
||||
styleWithCustomType: [
|
||||
[/>/, { token: 'delimiter', next: '@styleEmbedded.$S2', nextEmbedded: '$S2' }],
|
||||
[
|
||||
/>/,
|
||||
{
|
||||
token: 'delimiter',
|
||||
next: '@styleEmbedded.$S2',
|
||||
nextEmbedded: '$S2'
|
||||
}
|
||||
],
|
||||
[/"([^"]*)"/, 'attribute.value'],
|
||||
[/'([^']*)'/, 'attribute.value'],
|
||||
[/[\w\-]+/, 'attribute.name'],
|
||||
|
|
@ -196,12 +323,15 @@ export const language = <ILanguage>{
|
|||
],
|
||||
|
||||
styleEmbedded: [
|
||||
[/<\/style/, { token: '@rematch', next: '@pop', nextEmbedded: '@pop' }],
|
||||
[
|
||||
/<\/style/,
|
||||
{ token: '@rematch', next: '@pop', nextEmbedded: '@pop' }
|
||||
],
|
||||
[/[^<]+/, '']
|
||||
],
|
||||
]
|
||||
|
||||
// -- END <style> tags handling
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
// TESTED WITH:
|
||||
|
|
|
|||
|
|
@ -15,21 +15,21 @@ export const conf: IRichLanguageConfiguration = {
|
|||
brackets: [
|
||||
['{', '}'],
|
||||
['[', ']'],
|
||||
['(', ')'],
|
||||
['(', ')']
|
||||
],
|
||||
autoClosingPairs: [
|
||||
{ open: '{', close: '}' },
|
||||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '"', close: '"' },
|
||||
{ open: '\'', close: '\'' },
|
||||
{ open: "'", close: "'" }
|
||||
],
|
||||
surroundingPairs: [
|
||||
{ open: '{', close: '}' },
|
||||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '"', close: '"' },
|
||||
{ open: '\'', close: '\'' },
|
||||
{ open: "'", close: "'" }
|
||||
]
|
||||
};
|
||||
|
||||
|
|
@ -43,7 +43,6 @@ export const language = <ILanguage>{
|
|||
// The main tokenizer for our languages
|
||||
tokenizer: {
|
||||
root: [
|
||||
|
||||
// sections
|
||||
[/^\[[^\]]*\]/, 'metatag'],
|
||||
|
||||
|
|
@ -57,27 +56,30 @@ export const language = <ILanguage>{
|
|||
[/\d+/, 'number'],
|
||||
|
||||
// strings: recover on non-terminated strings
|
||||
[/"([^"\\]|\\.)*$/, 'string.invalid'], // non-teminated string
|
||||
[/'([^'\\]|\\.)*$/, 'string.invalid'], // non-teminated string
|
||||
[/"([^"\\]|\\.)*$/, 'string.invalid'], // non-teminated string
|
||||
[/'([^'\\]|\\.)*$/, 'string.invalid'], // non-teminated string
|
||||
[/"/, 'string', '@string."'],
|
||||
[/'/, 'string', '@string.\''],
|
||||
[/'/, 'string', "@string.'"]
|
||||
],
|
||||
|
||||
whitespace: [
|
||||
[/[ \t\r\n]+/, ''],
|
||||
[/^\s*[#;].*$/, 'comment'],
|
||||
[/^\s*[#;].*$/, 'comment']
|
||||
],
|
||||
|
||||
string: [
|
||||
[/[^\\"']+/, 'string'],
|
||||
[/@escapes/, 'string.escape'],
|
||||
[/\\./, 'string.escape.invalid'],
|
||||
[/["']/, {
|
||||
cases: {
|
||||
'$#==$S2': { token: 'string', next: '@pop' },
|
||||
'@default': 'string'
|
||||
[
|
||||
/["']/,
|
||||
{
|
||||
cases: {
|
||||
'$#==$S2': { token: 'string', next: '@pop' },
|
||||
'@default': 'string'
|
||||
}
|
||||
}
|
||||
}]
|
||||
],
|
||||
},
|
||||
]
|
||||
]
|
||||
}
|
||||
};
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
158
src/java/java.ts
158
src/java/java.ts
|
|
@ -13,32 +13,36 @@ export const conf: IRichLanguageConfiguration = {
|
|||
wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g,
|
||||
comments: {
|
||||
lineComment: '//',
|
||||
blockComment: ['/*', '*/'],
|
||||
blockComment: ['/*', '*/']
|
||||
},
|
||||
brackets: [
|
||||
['{', '}'],
|
||||
['[', ']'],
|
||||
['(', ')'],
|
||||
['(', ')']
|
||||
],
|
||||
autoClosingPairs: [
|
||||
{ open: '{', close: '}' },
|
||||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '"', close: '"' },
|
||||
{ open: '\'', close: '\'' },
|
||||
{ open: "'", close: "'" }
|
||||
],
|
||||
surroundingPairs: [
|
||||
{ open: '{', close: '}' },
|
||||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '"', close: '"' },
|
||||
{ open: '\'', close: '\'' },
|
||||
{ open: '<', close: '>' },
|
||||
{ open: "'", close: "'" },
|
||||
{ open: '<', close: '>' }
|
||||
],
|
||||
folding: {
|
||||
markers: {
|
||||
start: new RegExp("^\\s*//\\s*(?:(?:#?region\\b)|(?:<editor-fold\\b))"),
|
||||
end: new RegExp("^\\s*//\\s*(?:(?:#?endregion\\b)|(?:</editor-fold>))")
|
||||
start: new RegExp(
|
||||
'^\\s*//\\s*(?:(?:#?region\\b)|(?:<editor-fold\\b))'
|
||||
),
|
||||
end: new RegExp(
|
||||
'^\\s*//\\s*(?:(?:#?endregion\\b)|(?:</editor-fold>))'
|
||||
)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -48,21 +52,98 @@ export const language = <ILanguage>{
|
|||
tokenPostfix: '.java',
|
||||
|
||||
keywords: [
|
||||
'abstract', 'continue', 'for', 'new', 'switch', 'assert', 'default',
|
||||
'goto', 'package', 'synchronized', 'boolean', 'do', 'if', 'private',
|
||||
'this', 'break', 'double', 'implements', 'protected', 'throw', 'byte',
|
||||
'else', 'import', 'public', 'throws', 'case', 'enum', 'instanceof', 'return',
|
||||
'transient', 'catch', 'extends', 'int', 'short', 'try', 'char', 'final',
|
||||
'interface', 'static', 'void', 'class', 'finally', 'long', 'strictfp',
|
||||
'volatile', 'const', 'float', 'native', 'super', 'while', 'true', 'false'
|
||||
'abstract',
|
||||
'continue',
|
||||
'for',
|
||||
'new',
|
||||
'switch',
|
||||
'assert',
|
||||
'default',
|
||||
'goto',
|
||||
'package',
|
||||
'synchronized',
|
||||
'boolean',
|
||||
'do',
|
||||
'if',
|
||||
'private',
|
||||
'this',
|
||||
'break',
|
||||
'double',
|
||||
'implements',
|
||||
'protected',
|
||||
'throw',
|
||||
'byte',
|
||||
'else',
|
||||
'import',
|
||||
'public',
|
||||
'throws',
|
||||
'case',
|
||||
'enum',
|
||||
'instanceof',
|
||||
'return',
|
||||
'transient',
|
||||
'catch',
|
||||
'extends',
|
||||
'int',
|
||||
'short',
|
||||
'try',
|
||||
'char',
|
||||
'final',
|
||||
'interface',
|
||||
'static',
|
||||
'void',
|
||||
'class',
|
||||
'finally',
|
||||
'long',
|
||||
'strictfp',
|
||||
'volatile',
|
||||
'const',
|
||||
'float',
|
||||
'native',
|
||||
'super',
|
||||
'while',
|
||||
'true',
|
||||
'false'
|
||||
],
|
||||
|
||||
operators: [
|
||||
'=', '>', '<', '!', '~', '?', ':',
|
||||
'==', '<=', '>=', '!=', '&&', '||', '++', '--',
|
||||
'+', '-', '*', '/', '&', '|', '^', '%', '<<',
|
||||
'>>', '>>>', '+=', '-=', '*=', '/=', '&=', '|=',
|
||||
'^=', '%=', '<<=', '>>=', '>>>='
|
||||
'=',
|
||||
'>',
|
||||
'<',
|
||||
'!',
|
||||
'~',
|
||||
'?',
|
||||
':',
|
||||
'==',
|
||||
'<=',
|
||||
'>=',
|
||||
'!=',
|
||||
'&&',
|
||||
'||',
|
||||
'++',
|
||||
'--',
|
||||
'+',
|
||||
'-',
|
||||
'*',
|
||||
'/',
|
||||
'&',
|
||||
'|',
|
||||
'^',
|
||||
'%',
|
||||
'<<',
|
||||
'>>',
|
||||
'>>>',
|
||||
'+=',
|
||||
'-=',
|
||||
'*=',
|
||||
'/=',
|
||||
'&=',
|
||||
'|=',
|
||||
'^=',
|
||||
'%=',
|
||||
'<<=',
|
||||
'>>=',
|
||||
'>>>='
|
||||
],
|
||||
|
||||
// we include these common regular expressions
|
||||
|
|
@ -77,12 +158,15 @@ export const language = <ILanguage>{
|
|||
tokenizer: {
|
||||
root: [
|
||||
// identifiers and keywords
|
||||
[/[a-zA-Z_$][\w$]*/, {
|
||||
cases: {
|
||||
'@keywords': { token: 'keyword.$0' },
|
||||
'@default': 'identifier'
|
||||
[
|
||||
/[a-zA-Z_$][\w$]*/,
|
||||
{
|
||||
cases: {
|
||||
'@keywords': { token: 'keyword.$0' },
|
||||
'@default': 'identifier'
|
||||
}
|
||||
}
|
||||
}],
|
||||
],
|
||||
|
||||
// whitespace
|
||||
{ include: '@whitespace' },
|
||||
|
|
@ -90,19 +174,25 @@ export const language = <ILanguage>{
|
|||
// delimiters and operators
|
||||
[/[{}()\[\]]/, '@brackets'],
|
||||
[/[<>](?!@symbols)/, '@brackets'],
|
||||
[/@symbols/, {
|
||||
cases: {
|
||||
'@operators': 'delimiter',
|
||||
'@default': ''
|
||||
[
|
||||
/@symbols/,
|
||||
{
|
||||
cases: {
|
||||
'@operators': 'delimiter',
|
||||
'@default': ''
|
||||
}
|
||||
}
|
||||
}],
|
||||
],
|
||||
|
||||
// @ annotations.
|
||||
[/@\s*[a-zA-Z_\$][\w\$]*/, 'annotation'],
|
||||
|
||||
// numbers
|
||||
[/(@digits)[eE]([\-+]?(@digits))?[fFdD]?/, 'number.float'],
|
||||
[/(@digits)\.(@digits)([eE][\-+]?(@digits))?[fFdD]?/, 'number.float'],
|
||||
[
|
||||
/(@digits)\.(@digits)([eE][\-+]?(@digits))?[fFdD]?/,
|
||||
'number.float'
|
||||
],
|
||||
[/0[xX](@hexdigits)[Ll]?/, 'number.hex'],
|
||||
[/0(@octaldigits)[Ll]?/, 'number.octal'],
|
||||
[/0[bB](@binarydigits)[Ll]?/, 'number.binary'],
|
||||
|
|
@ -113,7 +203,7 @@ export const language = <ILanguage>{
|
|||
[/[;,.]/, 'delimiter'],
|
||||
|
||||
// strings
|
||||
[/"([^"\\]|\\.)*$/, 'string.invalid'], // non-teminated string
|
||||
[/"([^"\\]|\\.)*$/, 'string.invalid'], // non-teminated string
|
||||
[/"/, 'string', '@string'],
|
||||
|
||||
// characters
|
||||
|
|
@ -126,7 +216,7 @@ export const language = <ILanguage>{
|
|||
[/[ \t\r\n]+/, ''],
|
||||
[/\/\*\*(?!\/)/, 'comment.doc', '@javadoc'],
|
||||
[/\/\*/, 'comment', '@comment'],
|
||||
[/\/\/.*$/, 'comment'],
|
||||
[/\/\/.*$/, 'comment']
|
||||
],
|
||||
|
||||
comment: [
|
||||
|
|
@ -150,6 +240,6 @@ export const language = <ILanguage>{
|
|||
[/@escapes/, 'string.escape'],
|
||||
[/\\./, 'string.escape.invalid'],
|
||||
[/"/, 'string', '@pop']
|
||||
],
|
||||
},
|
||||
]
|
||||
}
|
||||
};
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -5,12 +5,16 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
import { conf as tsConf, language as tsLanguage } from '../typescript/typescript';
|
||||
import {
|
||||
conf as tsConf,
|
||||
language as tsLanguage
|
||||
} from '../typescript/typescript';
|
||||
import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration;
|
||||
import ILanguage = monaco.languages.IMonarchLanguage;
|
||||
|
||||
// Allow for running under nodejs/requirejs in tests
|
||||
const _monaco: typeof monaco = (typeof monaco === 'undefined' ? (<any>self).monaco : monaco);
|
||||
const _monaco: typeof monaco =
|
||||
typeof monaco === 'undefined' ? (<any>self).monaco : monaco;
|
||||
|
||||
export const conf: IRichLanguageConfiguration = tsConf;
|
||||
|
||||
|
|
@ -20,13 +24,52 @@ export const language = <ILanguage>{
|
|||
tokenPostfix: '.js',
|
||||
|
||||
keywords: [
|
||||
'break', 'case', 'catch', 'class', 'continue', 'const',
|
||||
'constructor', 'debugger', 'default', 'delete', 'do', 'else',
|
||||
'export', 'extends', 'false', 'finally', 'for', 'from', 'function',
|
||||
'get', 'if', 'import', 'in', 'instanceof', 'let', 'new', 'null',
|
||||
'return', 'set', 'super', 'switch', 'symbol', 'this', 'throw', 'true',
|
||||
'try', 'typeof', 'undefined', 'var', 'void', 'while', 'with', 'yield',
|
||||
'async', 'await', 'of'
|
||||
'break',
|
||||
'case',
|
||||
'catch',
|
||||
'class',
|
||||
'continue',
|
||||
'const',
|
||||
'constructor',
|
||||
'debugger',
|
||||
'default',
|
||||
'delete',
|
||||
'do',
|
||||
'else',
|
||||
'export',
|
||||
'extends',
|
||||
'false',
|
||||
'finally',
|
||||
'for',
|
||||
'from',
|
||||
'function',
|
||||
'get',
|
||||
'if',
|
||||
'import',
|
||||
'in',
|
||||
'instanceof',
|
||||
'let',
|
||||
'new',
|
||||
'null',
|
||||
'return',
|
||||
'set',
|
||||
'super',
|
||||
'switch',
|
||||
'symbol',
|
||||
'this',
|
||||
'throw',
|
||||
'true',
|
||||
'try',
|
||||
'typeof',
|
||||
'undefined',
|
||||
'var',
|
||||
'void',
|
||||
'while',
|
||||
'with',
|
||||
'yield',
|
||||
'async',
|
||||
'await',
|
||||
'of'
|
||||
],
|
||||
typeKeywords: [],
|
||||
|
||||
|
|
@ -39,5 +82,5 @@ export const language = <ILanguage>{
|
|||
hexdigits: tsLanguage.hexdigits,
|
||||
regexpctl: tsLanguage.regexpctl,
|
||||
regexpesc: tsLanguage.regexpesc,
|
||||
tokenizer: tsLanguage.tokenizer,
|
||||
tokenizer: tsLanguage.tokenizer
|
||||
};
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import {registerLanguage} from '../_.contribution';
|
||||
import { registerLanguage } from '../_.contribution';
|
||||
|
||||
registerLanguage({
|
||||
id: 'julia',
|
||||
|
|
|
|||
|
|
@ -5,32 +5,36 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
import {testTokenization} from '../test/testRunner';
|
||||
import { testTokenization } from '../test/testRunner';
|
||||
|
||||
testTokenization('julia', [
|
||||
[{
|
||||
line: "a = 1",
|
||||
tokens: [
|
||||
{startIndex: 0, type: "identifier.julia"},
|
||||
{startIndex: 1, type: ""},
|
||||
{startIndex: 2, type: "source.julia"},
|
||||
{startIndex: 3, type: ""},
|
||||
{startIndex: 4, type: "number.julia"}
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'a = 1',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'identifier.julia' },
|
||||
{ startIndex: 1, type: '' },
|
||||
{ startIndex: 2, type: 'source.julia' },
|
||||
{ startIndex: 3, type: '' },
|
||||
{ startIndex: 4, type: 'number.julia' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: "b(c) = 2c",
|
||||
tokens: [
|
||||
{startIndex: 0, type: "keyword.flow.julia"},
|
||||
{startIndex: 1, type: "delimiter.parenthesis.julia"},
|
||||
{startIndex: 2, type: "identifier.julia"},
|
||||
{startIndex: 3, type: "delimiter.parenthesis.julia"},
|
||||
{startIndex: 4, type: ""},
|
||||
{startIndex: 5, type: "source.julia"},
|
||||
{startIndex: 6, type: ""},
|
||||
{startIndex: 7, type: "number.julia"},
|
||||
{startIndex: 8, type: "identifier.julia"}
|
||||
]
|
||||
}]
|
||||
[
|
||||
{
|
||||
line: 'b(c) = 2c',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.flow.julia' },
|
||||
{ startIndex: 1, type: 'delimiter.parenthesis.julia' },
|
||||
{ startIndex: 2, type: 'identifier.julia' },
|
||||
{ startIndex: 3, type: 'delimiter.parenthesis.julia' },
|
||||
{ startIndex: 4, type: '' },
|
||||
{ startIndex: 5, type: 'source.julia' },
|
||||
{ startIndex: 6, type: '' },
|
||||
{ startIndex: 7, type: 'number.julia' },
|
||||
{ startIndex: 8, type: 'identifier.julia' }
|
||||
]
|
||||
}
|
||||
]
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -15,18 +15,18 @@ export const conf: IRichLanguageConfiguration = {
|
|||
['(', ')']
|
||||
],
|
||||
autoClosingPairs: [
|
||||
{open: '{', close: '}'},
|
||||
{open: '[', close: ']'},
|
||||
{open: '(', close: ')'},
|
||||
{open: '"', close: '"'},
|
||||
{open: '\'', close: '\''},
|
||||
{ open: '{', close: '}' },
|
||||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '"', close: '"' },
|
||||
{ open: "'", close: "'" }
|
||||
],
|
||||
surroundingPairs: [
|
||||
{open: '{', close: '}'},
|
||||
{open: '[', close: ']'},
|
||||
{open: '(', close: ')'},
|
||||
{open: '"', close: '"'},
|
||||
{open: '\'', close: '\''},
|
||||
{ open: '{', close: '}' },
|
||||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '"', close: '"' },
|
||||
{ open: "'", close: "'" }
|
||||
]
|
||||
};
|
||||
|
||||
|
|
@ -34,56 +34,304 @@ export const language = <ILanguage>{
|
|||
tokenPostfix: '.julia',
|
||||
|
||||
keywords: [
|
||||
'begin', 'while', 'if', 'for', 'try', 'return', 'break', 'continue',
|
||||
'function', 'macro', 'quote', 'let', 'local', 'global', 'const', 'do',
|
||||
'struct', 'module', 'baremodule', 'using', 'import', 'export',
|
||||
'end', 'else', 'elseif', 'catch', 'finally',
|
||||
'mutable', 'primitive', 'abstract', 'type',
|
||||
'in', 'isa', 'where', 'new'
|
||||
'begin',
|
||||
'while',
|
||||
'if',
|
||||
'for',
|
||||
'try',
|
||||
'return',
|
||||
'break',
|
||||
'continue',
|
||||
'function',
|
||||
'macro',
|
||||
'quote',
|
||||
'let',
|
||||
'local',
|
||||
'global',
|
||||
'const',
|
||||
'do',
|
||||
'struct',
|
||||
'module',
|
||||
'baremodule',
|
||||
'using',
|
||||
'import',
|
||||
'export',
|
||||
'end',
|
||||
'else',
|
||||
'elseif',
|
||||
'catch',
|
||||
'finally',
|
||||
'mutable',
|
||||
'primitive',
|
||||
'abstract',
|
||||
'type',
|
||||
'in',
|
||||
'isa',
|
||||
'where',
|
||||
'new'
|
||||
],
|
||||
|
||||
types: [
|
||||
'LinRange', 'LineNumberNode', 'LinearIndices', 'LoadError', 'MIME', 'Matrix', 'Method', 'MethodError',
|
||||
'Missing', 'MissingException', 'Module', 'NTuple', 'NamedTuple', 'Nothing', 'Number', 'OrdinalRange',
|
||||
'OutOfMemoryError', 'OverflowError', 'Pair', 'PartialQuickSort', 'PermutedDimsArray', 'Pipe', 'Ptr',
|
||||
'QuoteNode', 'Rational', 'RawFD', 'ReadOnlyMemoryError', 'Real', 'ReentrantLock', 'Ref', 'Regex', 'RegexMatch',
|
||||
'RoundingMode', 'SegmentationFault', 'Set', 'Signed', 'Some', 'StackOverflowError', 'StepRange', 'StepRangeLen',
|
||||
'StridedArray', 'StridedMatrix', 'StridedVecOrMat', 'StridedVector', 'String', 'StringIndexError', 'SubArray',
|
||||
'SubString', 'SubstitutionString', 'Symbol', 'SystemError', 'Task', 'Text', 'TextDisplay', 'Timer', 'Tuple', 'Type',
|
||||
'TypeError', 'TypeVar', 'UInt', 'UInt128', 'UInt16', 'UInt32', 'UInt64', 'UInt8', 'UndefInitializer', 'AbstractArray',
|
||||
'UndefKeywordError', 'AbstractChannel', 'UndefRefError', 'AbstractChar', 'UndefVarError', 'AbstractDict', 'Union',
|
||||
'AbstractDisplay', 'UnionAll', 'AbstractFloat', 'UnitRange', 'AbstractIrrational', 'Unsigned', 'AbstractMatrix',
|
||||
'AbstractRange', 'Val', 'AbstractSet', 'Vararg', 'AbstractString', 'VecElement', 'AbstractUnitRange', 'VecOrMat',
|
||||
'AbstractVecOrMat', 'Vector', 'AbstractVector', 'VersionNumber', 'Any', 'WeakKeyDict', 'ArgumentError', 'WeakRef',
|
||||
'Array', 'AssertionError', 'BigFloat', 'BigInt', 'BitArray', 'BitMatrix', 'BitSet', 'BitVector', 'Bool', 'BoundsError',
|
||||
'CapturedException', 'CartesianIndex', 'CartesianIndices', 'Cchar', 'Cdouble', 'Cfloat', 'Channel', 'Char', 'Cint',
|
||||
'Cintmax_t', 'Clong', 'Clonglong', 'Cmd', 'Colon', 'Complex', 'ComplexF16', 'ComplexF32', 'ComplexF64',
|
||||
'CompositeException', 'Condition', 'Cptrdiff_t', 'Cshort', 'Csize_t', 'Cssize_t', 'Cstring', 'Cuchar', 'Cuint',
|
||||
'Cuintmax_t', 'Culong', 'Culonglong', 'Cushort', 'Cvoid', 'Cwchar_t', 'Cwstring', 'DataType', 'DenseArray',
|
||||
'DenseMatrix', 'DenseVecOrMat', 'DenseVector', 'Dict', 'DimensionMismatch', 'Dims', 'DivideError', 'DomainError',
|
||||
'EOFError', 'Enum', 'ErrorException', 'Exception', 'ExponentialBackOff', 'Expr', 'Float16', 'Float32', 'Float64',
|
||||
'Function', 'GlobalRef', 'HTML', 'IO', 'IOBuffer', 'IOContext', 'IOStream', 'IdDict', 'IndexCartesian', 'IndexLinear',
|
||||
'IndexStyle', 'InexactError', 'InitError', 'Int', 'Int128', 'Int16', 'Int32', 'Int64', 'Int8', 'Integer',
|
||||
'InterruptException', 'InvalidStateException', 'Irrational', 'KeyError'
|
||||
'LinRange',
|
||||
'LineNumberNode',
|
||||
'LinearIndices',
|
||||
'LoadError',
|
||||
'MIME',
|
||||
'Matrix',
|
||||
'Method',
|
||||
'MethodError',
|
||||
'Missing',
|
||||
'MissingException',
|
||||
'Module',
|
||||
'NTuple',
|
||||
'NamedTuple',
|
||||
'Nothing',
|
||||
'Number',
|
||||
'OrdinalRange',
|
||||
'OutOfMemoryError',
|
||||
'OverflowError',
|
||||
'Pair',
|
||||
'PartialQuickSort',
|
||||
'PermutedDimsArray',
|
||||
'Pipe',
|
||||
'Ptr',
|
||||
'QuoteNode',
|
||||
'Rational',
|
||||
'RawFD',
|
||||
'ReadOnlyMemoryError',
|
||||
'Real',
|
||||
'ReentrantLock',
|
||||
'Ref',
|
||||
'Regex',
|
||||
'RegexMatch',
|
||||
'RoundingMode',
|
||||
'SegmentationFault',
|
||||
'Set',
|
||||
'Signed',
|
||||
'Some',
|
||||
'StackOverflowError',
|
||||
'StepRange',
|
||||
'StepRangeLen',
|
||||
'StridedArray',
|
||||
'StridedMatrix',
|
||||
'StridedVecOrMat',
|
||||
'StridedVector',
|
||||
'String',
|
||||
'StringIndexError',
|
||||
'SubArray',
|
||||
'SubString',
|
||||
'SubstitutionString',
|
||||
'Symbol',
|
||||
'SystemError',
|
||||
'Task',
|
||||
'Text',
|
||||
'TextDisplay',
|
||||
'Timer',
|
||||
'Tuple',
|
||||
'Type',
|
||||
'TypeError',
|
||||
'TypeVar',
|
||||
'UInt',
|
||||
'UInt128',
|
||||
'UInt16',
|
||||
'UInt32',
|
||||
'UInt64',
|
||||
'UInt8',
|
||||
'UndefInitializer',
|
||||
'AbstractArray',
|
||||
'UndefKeywordError',
|
||||
'AbstractChannel',
|
||||
'UndefRefError',
|
||||
'AbstractChar',
|
||||
'UndefVarError',
|
||||
'AbstractDict',
|
||||
'Union',
|
||||
'AbstractDisplay',
|
||||
'UnionAll',
|
||||
'AbstractFloat',
|
||||
'UnitRange',
|
||||
'AbstractIrrational',
|
||||
'Unsigned',
|
||||
'AbstractMatrix',
|
||||
'AbstractRange',
|
||||
'Val',
|
||||
'AbstractSet',
|
||||
'Vararg',
|
||||
'AbstractString',
|
||||
'VecElement',
|
||||
'AbstractUnitRange',
|
||||
'VecOrMat',
|
||||
'AbstractVecOrMat',
|
||||
'Vector',
|
||||
'AbstractVector',
|
||||
'VersionNumber',
|
||||
'Any',
|
||||
'WeakKeyDict',
|
||||
'ArgumentError',
|
||||
'WeakRef',
|
||||
'Array',
|
||||
'AssertionError',
|
||||
'BigFloat',
|
||||
'BigInt',
|
||||
'BitArray',
|
||||
'BitMatrix',
|
||||
'BitSet',
|
||||
'BitVector',
|
||||
'Bool',
|
||||
'BoundsError',
|
||||
'CapturedException',
|
||||
'CartesianIndex',
|
||||
'CartesianIndices',
|
||||
'Cchar',
|
||||
'Cdouble',
|
||||
'Cfloat',
|
||||
'Channel',
|
||||
'Char',
|
||||
'Cint',
|
||||
'Cintmax_t',
|
||||
'Clong',
|
||||
'Clonglong',
|
||||
'Cmd',
|
||||
'Colon',
|
||||
'Complex',
|
||||
'ComplexF16',
|
||||
'ComplexF32',
|
||||
'ComplexF64',
|
||||
'CompositeException',
|
||||
'Condition',
|
||||
'Cptrdiff_t',
|
||||
'Cshort',
|
||||
'Csize_t',
|
||||
'Cssize_t',
|
||||
'Cstring',
|
||||
'Cuchar',
|
||||
'Cuint',
|
||||
'Cuintmax_t',
|
||||
'Culong',
|
||||
'Culonglong',
|
||||
'Cushort',
|
||||
'Cvoid',
|
||||
'Cwchar_t',
|
||||
'Cwstring',
|
||||
'DataType',
|
||||
'DenseArray',
|
||||
'DenseMatrix',
|
||||
'DenseVecOrMat',
|
||||
'DenseVector',
|
||||
'Dict',
|
||||
'DimensionMismatch',
|
||||
'Dims',
|
||||
'DivideError',
|
||||
'DomainError',
|
||||
'EOFError',
|
||||
'Enum',
|
||||
'ErrorException',
|
||||
'Exception',
|
||||
'ExponentialBackOff',
|
||||
'Expr',
|
||||
'Float16',
|
||||
'Float32',
|
||||
'Float64',
|
||||
'Function',
|
||||
'GlobalRef',
|
||||
'HTML',
|
||||
'IO',
|
||||
'IOBuffer',
|
||||
'IOContext',
|
||||
'IOStream',
|
||||
'IdDict',
|
||||
'IndexCartesian',
|
||||
'IndexLinear',
|
||||
'IndexStyle',
|
||||
'InexactError',
|
||||
'InitError',
|
||||
'Int',
|
||||
'Int128',
|
||||
'Int16',
|
||||
'Int32',
|
||||
'Int64',
|
||||
'Int8',
|
||||
'Integer',
|
||||
'InterruptException',
|
||||
'InvalidStateException',
|
||||
'Irrational',
|
||||
'KeyError'
|
||||
],
|
||||
|
||||
keywordops: [
|
||||
'<:', '>:', ':', '=>', '...', '.', '->', '?'
|
||||
],
|
||||
keywordops: ['<:', '>:', ':', '=>', '...', '.', '->', '?'],
|
||||
|
||||
allops: /[^\w\d\s()\[\]{}"'#]+/,
|
||||
|
||||
constants: [
|
||||
'true', 'false', 'nothing', 'missing', 'undef',
|
||||
'Inf', 'pi', 'NaN', 'π', 'ℯ',
|
||||
'true',
|
||||
'false',
|
||||
'nothing',
|
||||
'missing',
|
||||
'undef',
|
||||
'Inf',
|
||||
'pi',
|
||||
'NaN',
|
||||
'π',
|
||||
'ℯ',
|
||||
'ans',
|
||||
'PROGRAM_FILE', 'ARGS', 'C_NULL', 'VERSION', 'DEPOT_PATH', 'LOAD_PATH'
|
||||
'PROGRAM_FILE',
|
||||
'ARGS',
|
||||
'C_NULL',
|
||||
'VERSION',
|
||||
'DEPOT_PATH',
|
||||
'LOAD_PATH'
|
||||
],
|
||||
|
||||
operators: [
|
||||
'!', '!=', '!==', '%', '&', '*', '+', '-', '/', '//', '<', '<<', '<=', '==', '===',
|
||||
'=>', '>', '>=', '>>', '>>>', '\\', '^', '|', '|>', '~', '÷', '∈', '∉', '∋', '∌', '∘',
|
||||
'√', '∛', '∩', '∪', '≈', '≉', '≠', '≡', '≢', '≤', '≥', '⊆', '⊇', '⊈', '⊉', '⊊', '⊋', '⊻'
|
||||
'!',
|
||||
'!=',
|
||||
'!==',
|
||||
'%',
|
||||
'&',
|
||||
'*',
|
||||
'+',
|
||||
'-',
|
||||
'/',
|
||||
'//',
|
||||
'<',
|
||||
'<<',
|
||||
'<=',
|
||||
'==',
|
||||
'===',
|
||||
'=>',
|
||||
'>',
|
||||
'>=',
|
||||
'>>',
|
||||
'>>>',
|
||||
'\\',
|
||||
'^',
|
||||
'|',
|
||||
'|>',
|
||||
'~',
|
||||
'÷',
|
||||
'∈',
|
||||
'∉',
|
||||
'∋',
|
||||
'∌',
|
||||
'∘',
|
||||
'√',
|
||||
'∛',
|
||||
'∩',
|
||||
'∪',
|
||||
'≈',
|
||||
'≉',
|
||||
'≠',
|
||||
'≡',
|
||||
'≢',
|
||||
'≤',
|
||||
'≥',
|
||||
'⊆',
|
||||
'⊇',
|
||||
'⊈',
|
||||
'⊉',
|
||||
'⊊',
|
||||
'⊋',
|
||||
'⊻'
|
||||
],
|
||||
|
||||
brackets: [
|
||||
|
|
@ -102,7 +350,10 @@ export const language = <ILanguage>{
|
|||
tokenizer: {
|
||||
root: [
|
||||
[/(::)\s*|\b(isa)\s+/, 'keyword', '@typeanno'],
|
||||
[/\b(isa)(\s*\(@ident\s*,\s*)/, ['keyword', {token: '', next: '@typeanno'}]],
|
||||
[
|
||||
/\b(isa)(\s*\(@ident\s*,\s*)/,
|
||||
['keyword', { token: '', next: '@typeanno' }]
|
||||
],
|
||||
[/\b(type|struct)[ \t]+/, 'keyword', '@typeanno'],
|
||||
|
||||
// symbols
|
||||
|
|
@ -122,30 +373,39 @@ export const language = <ILanguage>{
|
|||
[/raw"/, 'string.delim', '@rsstring'],
|
||||
[/[bv]?"/, 'string.delim', '@dsstring'],
|
||||
|
||||
[/(@ident)\{/, {
|
||||
cases: {
|
||||
'$1@types': {token: 'type', next: '@gen'},
|
||||
'@default': {token: 'type', next: '@gen'}
|
||||
[
|
||||
/(@ident)\{/,
|
||||
{
|
||||
cases: {
|
||||
'$1@types': { token: 'type', next: '@gen' },
|
||||
'@default': { token: 'type', next: '@gen' }
|
||||
}
|
||||
}
|
||||
}],
|
||||
],
|
||||
|
||||
[/@ident[!?'']?(?=\.?\()/, {
|
||||
cases: {
|
||||
'@types': 'type',
|
||||
'@keywords': 'keyword',
|
||||
'@constants': 'variable',
|
||||
'@default': 'keyword.flow'
|
||||
[
|
||||
/@ident[!?'']?(?=\.?\()/,
|
||||
{
|
||||
cases: {
|
||||
'@types': 'type',
|
||||
'@keywords': 'keyword',
|
||||
'@constants': 'variable',
|
||||
'@default': 'keyword.flow'
|
||||
}
|
||||
}
|
||||
}],
|
||||
],
|
||||
|
||||
[/@ident[!?']?/, {
|
||||
cases: {
|
||||
'@types': 'type',
|
||||
'@keywords': 'keyword',
|
||||
'@constants': 'variable',
|
||||
'@default': 'identifier'
|
||||
[
|
||||
/@ident[!?']?/,
|
||||
{
|
||||
cases: {
|
||||
'@types': 'type',
|
||||
'@keywords': 'keyword',
|
||||
'@constants': 'variable',
|
||||
'@default': 'identifier'
|
||||
}
|
||||
}
|
||||
}],
|
||||
],
|
||||
|
||||
[/\$\w+/, 'key'],
|
||||
[/\$\(/, 'key', '@paste'],
|
||||
|
|
@ -153,22 +413,24 @@ export const language = <ILanguage>{
|
|||
[/@@ident/, 'annotation'],
|
||||
|
||||
// whitespace
|
||||
{include: '@whitespace'},
|
||||
{ include: '@whitespace' },
|
||||
|
||||
// characters
|
||||
[/'(?:@escapes|.)'/, 'string.character'],
|
||||
|
||||
// delimiters and operators
|
||||
[/[()\[\]{}]/, '@brackets'],
|
||||
[/@allops/, {
|
||||
cases: {
|
||||
'@keywordops': 'keyword',
|
||||
'@operators': 'operator',
|
||||
[
|
||||
/@allops/,
|
||||
{
|
||||
cases: {
|
||||
'@keywordops': 'keyword',
|
||||
'@operators': 'operator'
|
||||
}
|
||||
}
|
||||
}],
|
||||
],
|
||||
[/[;,]/, 'delimiter'],
|
||||
|
||||
|
||||
// numbers
|
||||
[/0[xX][0-9a-fA-F](_?[0-9a-fA-F])*/, 'number.hex'],
|
||||
[/0[_oO][0-7](_?[0-7])*/, 'number.octal'],
|
||||
|
|
@ -179,7 +441,10 @@ export const language = <ILanguage>{
|
|||
// type
|
||||
typeanno: [
|
||||
[/[a-zA-Z_]\w*(?:\.[a-zA-Z_]\w*)*\{/, 'type', '@gen'],
|
||||
[/([a-zA-Z_]\w*(?:\.[a-zA-Z_]\w*)*)(\s*<:\s*)/, ['type', 'keyword']],
|
||||
[
|
||||
/([a-zA-Z_]\w*(?:\.[a-zA-Z_]\w*)*)(\s*<:\s*)/,
|
||||
['type', 'keyword']
|
||||
],
|
||||
[/[a-zA-Z_]\w*(?:\.[a-zA-Z_]\w*)*/, 'type', '@pop'],
|
||||
['', '', '@pop']
|
||||
],
|
||||
|
|
@ -189,9 +454,9 @@ export const language = <ILanguage>{
|
|||
[/[a-zA-Z_]\w*(?:\.[a-zA-Z_]\w*)*\{/, 'type', '@push'],
|
||||
[/[a-zA-Z_]\w*(?:\.[a-zA-Z_]\w*)*/, 'type'],
|
||||
[/<:/, 'keyword'],
|
||||
[/(\})(\s*<:\s*)/, ['type', {token: 'keyword', next: '@pop'}]],
|
||||
[/(\})(\s*<:\s*)/, ['type', { token: 'keyword', next: '@pop' }]],
|
||||
[/\}/, 'type', '@pop'],
|
||||
{include: '@root'}
|
||||
{ include: '@root' }
|
||||
],
|
||||
|
||||
// $(...)
|
||||
|
|
@ -199,7 +464,7 @@ export const language = <ILanguage>{
|
|||
[/\$\(/, 'key', '@paste'],
|
||||
[/\(/, '@brackets', '@paren'],
|
||||
[/\)/, 'metatag', '@pop'],
|
||||
{include: '@root'}
|
||||
{ include: '@root' }
|
||||
],
|
||||
|
||||
// :(...)
|
||||
|
|
@ -207,7 +472,7 @@ export const language = <ILanguage>{
|
|||
[/:\(/, 'metatag', '@quote'],
|
||||
[/\(/, '@brackets', '@paren'],
|
||||
[/\)/, 'key', '@pop'],
|
||||
{include: '@root'}
|
||||
{ include: '@root' }
|
||||
],
|
||||
|
||||
// (...)
|
||||
|
|
@ -216,7 +481,7 @@ export const language = <ILanguage>{
|
|||
[/:\(/, 'metatag', '@quote'],
|
||||
[/\(/, '@brackets', '@push'],
|
||||
[/\)/, '@brackets', '@pop'],
|
||||
{include: '@root'}
|
||||
{ include: '@root' }
|
||||
],
|
||||
|
||||
// r"egex string"
|
||||
|
|
@ -256,7 +521,7 @@ export const language = <ILanguage>{
|
|||
[/\$/, '', '@interpolated'],
|
||||
[/@escapes/, 'string.escape'],
|
||||
[/\\./, 'string.escape.invalid'],
|
||||
[/"/, 'string.delim', '@pop'],
|
||||
[/"/, 'string.delim', '@pop']
|
||||
],
|
||||
dtstring: [
|
||||
[/[^\\"\$]/, 'string'],
|
||||
|
|
@ -264,7 +529,7 @@ export const language = <ILanguage>{
|
|||
[/@escapes/, 'string.escape'],
|
||||
[/\\./, 'string.escape.invalid'],
|
||||
[/"(?!"")/, 'string'],
|
||||
[/"""/, 'string.delim', '@pop'],
|
||||
[/"""/, 'string.delim', '@pop']
|
||||
],
|
||||
|
||||
// interpolated sequence
|
||||
|
|
@ -275,23 +540,20 @@ export const language = <ILanguage>{
|
|||
],
|
||||
|
||||
// any code
|
||||
interpolated_compound: [
|
||||
[/\)/, '', '@pop'],
|
||||
{include: '@root'},
|
||||
],
|
||||
interpolated_compound: [[/\)/, '', '@pop'], { include: '@root' }],
|
||||
|
||||
// whitespace & comments
|
||||
whitespace: [
|
||||
[/[ \t\r\n]+/, ''],
|
||||
[/#=/, 'comment', '@multi_comment'],
|
||||
[/#.*$/, 'comment'],
|
||||
[/#.*$/, 'comment']
|
||||
],
|
||||
|
||||
multi_comment: [
|
||||
[/#=/, 'comment', '@push'],
|
||||
[/=#/, 'comment', '@pop'],
|
||||
[/=(?!#)|#(?!=)/, 'comment'],
|
||||
[/[^#=]+/, 'comment'],
|
||||
[/[^#=]+/, 'comment']
|
||||
]
|
||||
}
|
||||
};
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -13,32 +13,36 @@ export const conf: IRichLanguageConfiguration = {
|
|||
wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g,
|
||||
comments: {
|
||||
lineComment: '//',
|
||||
blockComment: ['/*', '*/'],
|
||||
blockComment: ['/*', '*/']
|
||||
},
|
||||
brackets: [
|
||||
['{', '}'],
|
||||
['[', ']'],
|
||||
['(', ')'],
|
||||
['(', ')']
|
||||
],
|
||||
autoClosingPairs: [
|
||||
{ open: '{', close: '}' },
|
||||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '"', close: '"' },
|
||||
{ open: '\'', close: '\'' },
|
||||
{ open: "'", close: "'" }
|
||||
],
|
||||
surroundingPairs: [
|
||||
{ open: '{', close: '}' },
|
||||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '"', close: '"' },
|
||||
{ open: '\'', close: '\'' },
|
||||
{ open: '<', close: '>' },
|
||||
{ open: "'", close: "'" },
|
||||
{ open: '<', close: '>' }
|
||||
],
|
||||
folding: {
|
||||
markers: {
|
||||
start: new RegExp("^\\s*//\\s*(?:(?:#?region\\b)|(?:<editor-fold\\b))"),
|
||||
end: new RegExp("^\\s*//\\s*(?:(?:#?endregion\\b)|(?:</editor-fold>))")
|
||||
start: new RegExp(
|
||||
'^\\s*//\\s*(?:(?:#?region\\b)|(?:<editor-fold\\b))'
|
||||
),
|
||||
end: new RegExp(
|
||||
'^\\s*//\\s*(?:(?:#?endregion\\b)|(?:</editor-fold>))'
|
||||
)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -48,22 +52,125 @@ export const language = <ILanguage>{
|
|||
tokenPostfix: '.kt',
|
||||
|
||||
keywords: [
|
||||
'as', 'as?', 'break', 'class', 'continue', 'do', 'else', 'false', 'for', 'fun', 'if',
|
||||
'in', '!in', 'interface', 'is', '!is', 'null', 'object', 'package', 'return', 'super',
|
||||
'this', 'throw', 'true', 'try', 'typealias', 'val', 'var', 'when', 'while', 'by',
|
||||
'catch', 'constructor', 'delegate', 'dynamic', 'field', 'file', 'finally', 'get',
|
||||
'import', 'init', 'param', 'property', 'receiver', 'set', 'setparam', 'where', 'actual',
|
||||
'abstract','annotation', 'companion', 'const', 'crossinline', 'data', 'enum', 'expect',
|
||||
'external', 'final', 'infix', 'inline', 'inner', 'internal', 'lateinit', 'noinline',
|
||||
'open', 'operator', 'out', 'override', 'private', 'protected', 'public', 'reified',
|
||||
'sealed', 'suspend', 'tailrec', 'vararg', 'field', 'it'
|
||||
'as',
|
||||
'as?',
|
||||
'break',
|
||||
'class',
|
||||
'continue',
|
||||
'do',
|
||||
'else',
|
||||
'false',
|
||||
'for',
|
||||
'fun',
|
||||
'if',
|
||||
'in',
|
||||
'!in',
|
||||
'interface',
|
||||
'is',
|
||||
'!is',
|
||||
'null',
|
||||
'object',
|
||||
'package',
|
||||
'return',
|
||||
'super',
|
||||
'this',
|
||||
'throw',
|
||||
'true',
|
||||
'try',
|
||||
'typealias',
|
||||
'val',
|
||||
'var',
|
||||
'when',
|
||||
'while',
|
||||
'by',
|
||||
'catch',
|
||||
'constructor',
|
||||
'delegate',
|
||||
'dynamic',
|
||||
'field',
|
||||
'file',
|
||||
'finally',
|
||||
'get',
|
||||
'import',
|
||||
'init',
|
||||
'param',
|
||||
'property',
|
||||
'receiver',
|
||||
'set',
|
||||
'setparam',
|
||||
'where',
|
||||
'actual',
|
||||
'abstract',
|
||||
'annotation',
|
||||
'companion',
|
||||
'const',
|
||||
'crossinline',
|
||||
'data',
|
||||
'enum',
|
||||
'expect',
|
||||
'external',
|
||||
'final',
|
||||
'infix',
|
||||
'inline',
|
||||
'inner',
|
||||
'internal',
|
||||
'lateinit',
|
||||
'noinline',
|
||||
'open',
|
||||
'operator',
|
||||
'out',
|
||||
'override',
|
||||
'private',
|
||||
'protected',
|
||||
'public',
|
||||
'reified',
|
||||
'sealed',
|
||||
'suspend',
|
||||
'tailrec',
|
||||
'vararg',
|
||||
'field',
|
||||
'it'
|
||||
],
|
||||
|
||||
operators: [
|
||||
'+', '-', '*', '/', '%', '=', '+=', '-=', '*=', '/=',
|
||||
'%=', '++', '--', '&&', '||', '!', '==', '!=', '===',
|
||||
'!==', '>', '<', '<=', '>=', '[', ']', '!!', '?.', '?:',
|
||||
'::', '..', ':', '?', '->', '@', ';', '$', '_'
|
||||
'+',
|
||||
'-',
|
||||
'*',
|
||||
'/',
|
||||
'%',
|
||||
'=',
|
||||
'+=',
|
||||
'-=',
|
||||
'*=',
|
||||
'/=',
|
||||
'%=',
|
||||
'++',
|
||||
'--',
|
||||
'&&',
|
||||
'||',
|
||||
'!',
|
||||
'==',
|
||||
'!=',
|
||||
'===',
|
||||
'!==',
|
||||
'>',
|
||||
'<',
|
||||
'<=',
|
||||
'>=',
|
||||
'[',
|
||||
']',
|
||||
'!!',
|
||||
'?.',
|
||||
'?:',
|
||||
'::',
|
||||
'..',
|
||||
':',
|
||||
'?',
|
||||
'->',
|
||||
'@',
|
||||
';',
|
||||
'$',
|
||||
'_'
|
||||
],
|
||||
|
||||
// we include these common regular expressions
|
||||
|
|
@ -76,18 +183,20 @@ export const language = <ILanguage>{
|
|||
|
||||
// The main tokenizer for our languages
|
||||
tokenizer: {
|
||||
|
||||
root: [
|
||||
// class name highlighting
|
||||
[/[A-Z][\w\$]*/, 'type.identifier' ],
|
||||
[/[A-Z][\w\$]*/, 'type.identifier'],
|
||||
|
||||
// identifiers and keywords
|
||||
[/[a-zA-Z_$][\w$]*/, {
|
||||
cases: {
|
||||
'@keywords': { token: 'keyword.$0' },
|
||||
'@default': 'identifier'
|
||||
[
|
||||
/[a-zA-Z_$][\w$]*/,
|
||||
{
|
||||
cases: {
|
||||
'@keywords': { token: 'keyword.$0' },
|
||||
'@default': 'identifier'
|
||||
}
|
||||
}
|
||||
}],
|
||||
],
|
||||
|
||||
// whitespace
|
||||
{ include: '@whitespace' },
|
||||
|
|
@ -95,19 +204,25 @@ export const language = <ILanguage>{
|
|||
// delimiters and operators
|
||||
[/[{}()\[\]]/, '@brackets'],
|
||||
[/[<>](?!@symbols)/, '@brackets'],
|
||||
[/@symbols/, {
|
||||
cases: {
|
||||
'@operators': 'delimiter',
|
||||
'@default': ''
|
||||
[
|
||||
/@symbols/,
|
||||
{
|
||||
cases: {
|
||||
'@operators': 'delimiter',
|
||||
'@default': ''
|
||||
}
|
||||
}
|
||||
}],
|
||||
],
|
||||
|
||||
// @ annotations.
|
||||
[/@\s*[a-zA-Z_\$][\w\$]*/, 'annotation'],
|
||||
|
||||
// numbers
|
||||
[/(@digits)[eE]([\-+]?(@digits))?[fFdD]?/, 'number.float'],
|
||||
[/(@digits)\.(@digits)([eE][\-+]?(@digits))?[fFdD]?/, 'number.float'],
|
||||
[
|
||||
/(@digits)\.(@digits)([eE][\-+]?(@digits))?[fFdD]?/,
|
||||
'number.float'
|
||||
],
|
||||
[/0[xX](@hexdigits)[Ll]?/, 'number.hex'],
|
||||
[/0(@octaldigits)[Ll]?/, 'number.octal'],
|
||||
[/0[bB](@binarydigits)[Ll]?/, 'number.binary'],
|
||||
|
|
@ -118,7 +233,7 @@ export const language = <ILanguage>{
|
|||
[/[;,.]/, 'delimiter'],
|
||||
|
||||
// strings
|
||||
[/"([^"\\]|\\.)*$/, 'string.invalid'], // non-teminated string
|
||||
[/"([^"\\]|\\.)*$/, 'string.invalid'], // non-teminated string
|
||||
[/"""/, 'string', '@multistring'],
|
||||
[/"/, 'string', '@string'],
|
||||
|
||||
|
|
@ -132,7 +247,7 @@ export const language = <ILanguage>{
|
|||
[/[ \t\r\n]+/, ''],
|
||||
[/\/\*\*(?!\/)/, 'comment.doc', '@javadoc'],
|
||||
[/\/\*/, 'comment', '@comment'],
|
||||
[/\/\/.*$/, 'comment'],
|
||||
[/\/\/.*$/, 'comment']
|
||||
],
|
||||
|
||||
comment: [
|
||||
|
|
@ -144,7 +259,7 @@ export const language = <ILanguage>{
|
|||
//Identical copy of comment above, except for the addition of .doc
|
||||
javadoc: [
|
||||
[/[^\/*]+/, 'comment.doc'],
|
||||
[/\/\*/, 'comment.doc', '@push' ],
|
||||
[/\/\*/, 'comment.doc', '@push'],
|
||||
[/\/\*/, 'comment.doc.invalid'],
|
||||
[/\*\//, 'comment.doc', '@pop'],
|
||||
[/[\/*]/, 'comment.doc']
|
||||
|
|
@ -163,6 +278,6 @@ export const language = <ILanguage>{
|
|||
[/\\./, 'string.escape.invalid'],
|
||||
[/"""/, 'string', '@pop'],
|
||||
[/./, 'string']
|
||||
],
|
||||
},
|
||||
]
|
||||
}
|
||||
};
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -17,26 +17,26 @@ export const conf: IRichLanguageConfiguration = {
|
|||
brackets: [
|
||||
['{', '}'],
|
||||
['[', ']'],
|
||||
['(', ')'],
|
||||
['(', ')']
|
||||
],
|
||||
autoClosingPairs: [
|
||||
{ open: '{', close: '}', notIn: ['string', 'comment'] },
|
||||
{ open: '[', close: ']', notIn: ['string', 'comment'] },
|
||||
{ open: '(', close: ')', notIn: ['string', 'comment'] },
|
||||
{ open: '"', close: '"', notIn: ['string', 'comment'] },
|
||||
{ open: '\'', close: '\'', notIn: ['string', 'comment'] },
|
||||
{ open: "'", close: "'", notIn: ['string', 'comment'] }
|
||||
],
|
||||
surroundingPairs: [
|
||||
{ open: '{', close: '}' },
|
||||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '"', close: '"' },
|
||||
{ open: '\'', close: '\'' },
|
||||
{ open: "'", close: "'" }
|
||||
],
|
||||
folding: {
|
||||
markers: {
|
||||
start: new RegExp("^\\s*\\/\\*\\s*#region\\b\\s*(.*?)\\s*\\*\\/"),
|
||||
end: new RegExp("^\\s*\\/\\*\\s*#endregion\\b.*\\*\\/")
|
||||
start: new RegExp('^\\s*\\/\\*\\s*#region\\b\\s*(.*?)\\s*\\*\\/'),
|
||||
end: new RegExp('^\\s*\\/\\*\\s*#endregion\\b.*\\*\\/')
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -45,8 +45,10 @@ export const language = <ILanguage>{
|
|||
defaultToken: '',
|
||||
tokenPostfix: '.less',
|
||||
|
||||
identifier: '-?-?([a-zA-Z]|(\\\\(([0-9a-fA-F]{1,6}\\s?)|[^[0-9a-fA-F])))([\\w\\-]|(\\\\(([0-9a-fA-F]{1,6}\\s?)|[^[0-9a-fA-F])))*',
|
||||
identifierPlus: '-?-?([a-zA-Z:.]|(\\\\(([0-9a-fA-F]{1,6}\\s?)|[^[0-9a-fA-F])))([\\w\\-:.]|(\\\\(([0-9a-fA-F]{1,6}\\s?)|[^[0-9a-fA-F])))*',
|
||||
identifier:
|
||||
'-?-?([a-zA-Z]|(\\\\(([0-9a-fA-F]{1,6}\\s?)|[^[0-9a-fA-F])))([\\w\\-]|(\\\\(([0-9a-fA-F]{1,6}\\s?)|[^[0-9a-fA-F])))*',
|
||||
identifierPlus:
|
||||
'-?-?([a-zA-Z:.]|(\\\\(([0-9a-fA-F]{1,6}\\s?)|[^[0-9a-fA-F])))([\\w\\-:.]|(\\\\(([0-9a-fA-F]{1,6}\\s?)|[^[0-9a-fA-F])))*',
|
||||
|
||||
brackets: [
|
||||
{ open: '{', close: '}', token: 'delimiter.curly' },
|
||||
|
|
@ -65,7 +67,11 @@ export const language = <ILanguage>{
|
|||
{ include: '@keyword' },
|
||||
{ include: '@strings' },
|
||||
{ include: '@numbers' },
|
||||
['[*_]?[a-zA-Z\\-\\s]+(?=:.*(;|(\\\\$)))', 'attribute.name', '@attribute'],
|
||||
[
|
||||
'[*_]?[a-zA-Z\\-\\s]+(?=:.*(;|(\\\\$)))',
|
||||
'attribute.name',
|
||||
'@attribute'
|
||||
],
|
||||
|
||||
['url(\\-prefix)?\\(', { token: 'tag', next: '@urldeclaration' }],
|
||||
|
||||
|
|
@ -88,25 +94,40 @@ export const language = <ILanguage>{
|
|||
|
||||
nestedJSBegin: [
|
||||
['``', 'delimiter.backtick'],
|
||||
['`', { token: 'delimiter.backtick', next: '@nestedJSEnd', nextEmbedded: 'text/javascript' }],
|
||||
[
|
||||
'`',
|
||||
{
|
||||
token: 'delimiter.backtick',
|
||||
next: '@nestedJSEnd',
|
||||
nextEmbedded: 'text/javascript'
|
||||
}
|
||||
]
|
||||
],
|
||||
|
||||
nestedJSEnd: [
|
||||
['`', { token: 'delimiter.backtick', next: '@pop', nextEmbedded: '@pop' }],
|
||||
[
|
||||
'`',
|
||||
{
|
||||
token: 'delimiter.backtick',
|
||||
next: '@pop',
|
||||
nextEmbedded: '@pop'
|
||||
}
|
||||
]
|
||||
],
|
||||
|
||||
operators: [
|
||||
['[<>=\\+\\-\\*\\/\\^\\|\\~]', 'operator']
|
||||
],
|
||||
operators: [['[<>=\\+\\-\\*\\/\\^\\|\\~]', 'operator']],
|
||||
|
||||
keyword: [
|
||||
['(@[\\s]*import|![\\s]*important|true|false|when|iscolor|isnumber|isstring|iskeyword|isurl|ispixel|ispercentage|isem|hue|saturation|lightness|alpha|lighten|darken|saturate|desaturate|fadein|fadeout|fade|spin|mix|round|ceil|floor|percentage)\\b', 'keyword']
|
||||
[
|
||||
'(@[\\s]*import|![\\s]*important|true|false|when|iscolor|isnumber|isstring|iskeyword|isurl|ispixel|ispercentage|isem|hue|saturation|lightness|alpha|lighten|darken|saturate|desaturate|fadein|fadeout|fade|spin|mix|round|ceil|floor|percentage)\\b',
|
||||
'keyword'
|
||||
]
|
||||
],
|
||||
|
||||
urldeclaration: [
|
||||
{ include: '@strings' },
|
||||
['[^)\r\n]+', 'string'],
|
||||
['\\)', { token: 'tag', next: '@pop' }],
|
||||
['\\)', { token: 'tag', next: '@pop' }]
|
||||
],
|
||||
|
||||
attribute: <any[]>[
|
||||
|
|
@ -135,26 +156,39 @@ export const language = <ILanguage>{
|
|||
|
||||
comments: [
|
||||
['\\/\\*', 'comment', '@comment'],
|
||||
['\\/\\/+.*', 'comment'],
|
||||
['\\/\\/+.*', 'comment']
|
||||
],
|
||||
|
||||
comment: [
|
||||
['\\*\\/', 'comment', '@pop'],
|
||||
['.', 'comment'],
|
||||
['.', 'comment']
|
||||
],
|
||||
|
||||
numbers: [
|
||||
['(\\d*\\.)?\\d+([eE][\\-+]?\\d+)?', { token: 'attribute.value.number', next: '@units' }],
|
||||
[
|
||||
'(\\d*\\.)?\\d+([eE][\\-+]?\\d+)?',
|
||||
{ token: 'attribute.value.number', next: '@units' }
|
||||
],
|
||||
['#[0-9a-fA-F_]+(?!\\w)', 'attribute.value.hex']
|
||||
],
|
||||
|
||||
units: [
|
||||
['(em|ex|ch|rem|vmin|vmax|vw|vh|vm|cm|mm|in|px|pt|pc|deg|grad|rad|turn|s|ms|Hz|kHz|%)?', 'attribute.value.unit', '@pop']
|
||||
[
|
||||
'(em|ex|ch|rem|vmin|vmax|vw|vh|vm|cm|mm|in|px|pt|pc|deg|grad|rad|turn|s|ms|Hz|kHz|%)?',
|
||||
'attribute.value.unit',
|
||||
'@pop'
|
||||
]
|
||||
],
|
||||
|
||||
strings: [
|
||||
<any[]>['~?"', { token: 'string.delimiter', next: '@stringsEndDoubleQuote' }],
|
||||
<any[]>['~?\'', { token: 'string.delimiter', next: '@stringsEndQuote' }]
|
||||
<any[]>[
|
||||
'~?"',
|
||||
{ token: 'string.delimiter', next: '@stringsEndDoubleQuote' }
|
||||
],
|
||||
<any[]>[
|
||||
"~?'",
|
||||
{ token: 'string.delimiter', next: '@stringsEndQuote' }
|
||||
]
|
||||
],
|
||||
|
||||
stringsEndDoubleQuote: [
|
||||
|
|
@ -164,8 +198,8 @@ export const language = <ILanguage>{
|
|||
],
|
||||
|
||||
stringsEndQuote: [
|
||||
['\\\\\'', 'string'],
|
||||
<any[]>['\'', { token: 'string.delimiter', next: '@popall' }],
|
||||
["\\\\'", 'string'],
|
||||
<any[]>["'", { token: 'string.delimiter', next: '@popall' }],
|
||||
['.', 'string']
|
||||
],
|
||||
|
||||
|
|
|
|||
|
|
@ -10,122 +10,139 @@ import { testTokenization } from '../test/testRunner';
|
|||
testTokenization('lexon', [
|
||||
// Tests
|
||||
|
||||
[{
|
||||
line: 'LEX Paid Escrow',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.lexon' },
|
||||
{ startIndex: 3, type: 'white.lexon' },
|
||||
{ startIndex: 4, type: 'identifier.lexon' },
|
||||
{ startIndex: 8, type: 'white.lexon' },
|
||||
{ startIndex: 9, type: 'identifier.lexon' },
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'LEX Paid Escrow',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.lexon' },
|
||||
{ startIndex: 3, type: 'white.lexon' },
|
||||
{ startIndex: 4, type: 'identifier.lexon' },
|
||||
{ startIndex: 8, type: 'white.lexon' },
|
||||
{ startIndex: 9, type: 'identifier.lexon' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: 'LEXON: 0.2.20',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.lexon' },
|
||||
{ startIndex: 5, type: 'delimiter.lexon' },
|
||||
{ startIndex: 6, type: 'white.lexon' },
|
||||
{ startIndex: 7, type: 'number.semver.lexon' },
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'LEXON: 0.2.20',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.lexon' },
|
||||
{ startIndex: 5, type: 'delimiter.lexon' },
|
||||
{ startIndex: 6, type: 'white.lexon' },
|
||||
{ startIndex: 7, type: 'number.semver.lexon' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: 'COMMENT: 3.f - an escrow that is controlled by a third party for a fee.',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.lexon' },
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line:
|
||||
'COMMENT: 3.f - an escrow that is controlled by a third party for a fee.',
|
||||
tokens: [{ startIndex: 0, type: 'comment.lexon' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '"Payer" is a person.',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'identifier.quote.lexon' },
|
||||
{ startIndex: 1, type: 'identifier.lexon' },
|
||||
{ startIndex: 6, type: 'identifier.quote.lexon' },
|
||||
{ startIndex: 7, type: 'white.lexon' },
|
||||
{ startIndex: 8, type: 'operator.lexon' },
|
||||
{ startIndex: 10, type: 'white.lexon' },
|
||||
{ startIndex: 11, type: 'identifier.lexon' },
|
||||
{ startIndex: 12, type: 'white.lexon' },
|
||||
{ startIndex: 13, type: 'keyword.type.lexon' },
|
||||
{ startIndex: 19, type: 'delimiter.lexon' },
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '"Payer" is a person.',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'identifier.quote.lexon' },
|
||||
{ startIndex: 1, type: 'identifier.lexon' },
|
||||
{ startIndex: 6, type: 'identifier.quote.lexon' },
|
||||
{ startIndex: 7, type: 'white.lexon' },
|
||||
{ startIndex: 8, type: 'operator.lexon' },
|
||||
{ startIndex: 10, type: 'white.lexon' },
|
||||
{ startIndex: 11, type: 'identifier.lexon' },
|
||||
{ startIndex: 12, type: 'white.lexon' },
|
||||
{ startIndex: 13, type: 'keyword.type.lexon' },
|
||||
{ startIndex: 19, type: 'delimiter.lexon' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '"Fee" is an amount.',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'identifier.quote.lexon' },
|
||||
{ startIndex: 1, type: 'identifier.lexon' },
|
||||
{ startIndex: 4, type: 'identifier.quote.lexon' },
|
||||
{ startIndex: 5, type: 'white.lexon' },
|
||||
{ startIndex: 6, type: 'operator.lexon' },
|
||||
{ startIndex: 8, type: 'white.lexon' },
|
||||
{ startIndex: 9, type: 'identifier.lexon' },
|
||||
{ startIndex: 11, type: 'white.lexon' },
|
||||
{ startIndex: 12, type: 'keyword.type.lexon' },
|
||||
{ startIndex: 18, type: 'delimiter.lexon' },
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '"Fee" is an amount.',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'identifier.quote.lexon' },
|
||||
{ startIndex: 1, type: 'identifier.lexon' },
|
||||
{ startIndex: 4, type: 'identifier.quote.lexon' },
|
||||
{ startIndex: 5, type: 'white.lexon' },
|
||||
{ startIndex: 6, type: 'operator.lexon' },
|
||||
{ startIndex: 8, type: 'white.lexon' },
|
||||
{ startIndex: 9, type: 'identifier.lexon' },
|
||||
{ startIndex: 11, type: 'white.lexon' },
|
||||
{ startIndex: 12, type: 'keyword.type.lexon' },
|
||||
{ startIndex: 18, type: 'delimiter.lexon' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: 'The Payer pays an Amount into escrow,',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'identifier.lexon' }, // The
|
||||
{ startIndex: 3, type: 'white.lexon' },
|
||||
{ startIndex: 4, type: 'identifier.lexon' }, // Payer
|
||||
{ startIndex: 9, type: 'white.lexon' },
|
||||
{ startIndex: 10, type: 'keyword.lexon' }, // pays
|
||||
{ startIndex: 14, type: 'white.lexon' },
|
||||
{ startIndex: 15, type: 'identifier.lexon' }, // an
|
||||
{ startIndex: 17, type: 'white.lexon' },
|
||||
{ startIndex: 18, type: 'keyword.type.lexon' }, // Amount
|
||||
{ startIndex: 24, type: 'white.lexon' },
|
||||
{ startIndex: 25, type: 'keyword.lexon' }, // into
|
||||
{ startIndex: 29, type: 'white.lexon' },
|
||||
{ startIndex: 30, type: 'identifier.lexon' }, // escrow
|
||||
{ startIndex: 36, type: 'delimiter.lexon' }, // ,
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'The Payer pays an Amount into escrow,',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'identifier.lexon' }, // The
|
||||
{ startIndex: 3, type: 'white.lexon' },
|
||||
{ startIndex: 4, type: 'identifier.lexon' }, // Payer
|
||||
{ startIndex: 9, type: 'white.lexon' },
|
||||
{ startIndex: 10, type: 'keyword.lexon' }, // pays
|
||||
{ startIndex: 14, type: 'white.lexon' },
|
||||
{ startIndex: 15, type: 'identifier.lexon' }, // an
|
||||
{ startIndex: 17, type: 'white.lexon' },
|
||||
{ startIndex: 18, type: 'keyword.type.lexon' }, // Amount
|
||||
{ startIndex: 24, type: 'white.lexon' },
|
||||
{ startIndex: 25, type: 'keyword.lexon' }, // into
|
||||
{ startIndex: 29, type: 'white.lexon' },
|
||||
{ startIndex: 30, type: 'identifier.lexon' }, // escrow
|
||||
{ startIndex: 36, type: 'delimiter.lexon' } // ,
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: 'appoints the Payee,',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.lexon' }, // Appoints
|
||||
{ startIndex: 8, type: 'white.lexon' },
|
||||
{ startIndex: 9, type: 'identifier.lexon' }, // the
|
||||
{ startIndex: 12, type: 'white.lexon' },
|
||||
{ startIndex: 13, type: 'identifier.lexon' }, // Payee
|
||||
{ startIndex: 18, type: 'delimiter.lexon' }, // ,
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'appoints the Payee,',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.lexon' }, // Appoints
|
||||
{ startIndex: 8, type: 'white.lexon' },
|
||||
{ startIndex: 9, type: 'identifier.lexon' }, // the
|
||||
{ startIndex: 12, type: 'white.lexon' },
|
||||
{ startIndex: 13, type: 'identifier.lexon' }, // Payee
|
||||
{ startIndex: 18, type: 'delimiter.lexon' } // ,
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: 'and also fixes the Fee.',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'operator.lexon' }, // and
|
||||
{ startIndex: 3, type: 'white.lexon' },
|
||||
{ startIndex: 4, type: 'identifier.lexon' }, // also
|
||||
{ startIndex: 8, type: 'white.lexon' },
|
||||
{ startIndex: 9, type: 'identifier.lexon' }, // fixes
|
||||
{ startIndex: 14, type: 'white.lexon' },
|
||||
{ startIndex: 15, type: 'identifier.lexon' }, // the
|
||||
{ startIndex: 18, type: 'white.lexon' },
|
||||
{ startIndex: 19, type: 'identifier.lexon' }, // Fee
|
||||
{ startIndex: 22, type: 'delimiter.lexon' }, // .
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'and also fixes the Fee.',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'operator.lexon' }, // and
|
||||
{ startIndex: 3, type: 'white.lexon' },
|
||||
{ startIndex: 4, type: 'identifier.lexon' }, // also
|
||||
{ startIndex: 8, type: 'white.lexon' },
|
||||
{ startIndex: 9, type: 'identifier.lexon' }, // fixes
|
||||
{ startIndex: 14, type: 'white.lexon' },
|
||||
{ startIndex: 15, type: 'identifier.lexon' }, // the
|
||||
{ startIndex: 18, type: 'white.lexon' },
|
||||
{ startIndex: 19, type: 'identifier.lexon' }, // Fee
|
||||
{ startIndex: 22, type: 'delimiter.lexon' } // .
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: 'CLAUSE: Pay Out.',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.lexon' }, // CLAUSE
|
||||
{ startIndex: 6, type: 'delimiter.lexon' }, // :
|
||||
{ startIndex: 7, type: 'white.lexon' },
|
||||
{ startIndex: 8, type: 'identifier.lexon' }, // Pay out
|
||||
{ startIndex: 15, type: 'delimiter.lexon' }, // .
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'CLAUSE: Pay Out.',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.lexon' }, // CLAUSE
|
||||
{ startIndex: 6, type: 'delimiter.lexon' }, // :
|
||||
{ startIndex: 7, type: 'white.lexon' },
|
||||
{ startIndex: 8, type: 'identifier.lexon' }, // Pay out
|
||||
{ startIndex: 15, type: 'delimiter.lexon' } // .
|
||||
]
|
||||
}
|
||||
]
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -10,18 +10,16 @@ import ILanguage = monaco.languages.IMonarchLanguage;
|
|||
|
||||
export const conf: IRichLanguageConfiguration = {
|
||||
comments: {
|
||||
lineComment: 'COMMENT',
|
||||
lineComment: 'COMMENT'
|
||||
// blockComment: ['COMMENT', '.'],
|
||||
},
|
||||
brackets: [
|
||||
['(', ')']
|
||||
],
|
||||
brackets: [['(', ')']],
|
||||
autoClosingPairs: [
|
||||
{ open: '{', close: '}' },
|
||||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '"', close: '"', },
|
||||
{ open: ':', close: '.', },
|
||||
{ open: '"', close: '"' },
|
||||
{ open: ':', close: '.' }
|
||||
],
|
||||
surroundingPairs: [
|
||||
{ open: '{', close: '}' },
|
||||
|
|
@ -29,13 +27,13 @@ export const conf: IRichLanguageConfiguration = {
|
|||
{ open: '(', close: ')' },
|
||||
{ open: '`', close: '`' },
|
||||
{ open: '"', close: '"' },
|
||||
{ open: '\'', close: '\'' },
|
||||
{ open: ':', close: '.', },
|
||||
{ open: "'", close: "'" },
|
||||
{ open: ':', close: '.' }
|
||||
],
|
||||
folding: {
|
||||
markers: {
|
||||
start: new RegExp("^\\s*(::\\s*|COMMENT\\s+)#region"),
|
||||
end: new RegExp("^\\s*(::\\s*|COMMENT\\s+)#endregion")
|
||||
start: new RegExp('^\\s*(::\\s*|COMMENT\\s+)#region'),
|
||||
end: new RegExp('^\\s*(::\\s*|COMMENT\\s+)#endregion')
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -47,24 +45,46 @@ export const language = <ILanguage>{
|
|||
ignoreCase: true,
|
||||
|
||||
keywords: [
|
||||
'lexon', 'lex', 'clause', 'terms', 'contracts', 'may', 'pay',
|
||||
'pays', 'appoints', 'into', 'to'
|
||||
'lexon',
|
||||
'lex',
|
||||
'clause',
|
||||
'terms',
|
||||
'contracts',
|
||||
'may',
|
||||
'pay',
|
||||
'pays',
|
||||
'appoints',
|
||||
'into',
|
||||
'to'
|
||||
],
|
||||
|
||||
typeKeywords: [
|
||||
'amount', 'person', 'key', 'time', 'date', 'asset', 'text'
|
||||
],
|
||||
typeKeywords: ['amount', 'person', 'key', 'time', 'date', 'asset', 'text'],
|
||||
|
||||
operators: [
|
||||
'less', 'greater', 'equal', 'le', 'gt', 'or', 'and',
|
||||
'add', 'added', 'subtract', 'subtracted', 'multiply', 'multiplied', 'times', 'divide', 'divided',
|
||||
'is', 'be', 'certified'
|
||||
'less',
|
||||
'greater',
|
||||
'equal',
|
||||
'le',
|
||||
'gt',
|
||||
'or',
|
||||
'and',
|
||||
'add',
|
||||
'added',
|
||||
'subtract',
|
||||
'subtracted',
|
||||
'multiply',
|
||||
'multiplied',
|
||||
'times',
|
||||
'divide',
|
||||
'divided',
|
||||
'is',
|
||||
'be',
|
||||
'certified'
|
||||
],
|
||||
|
||||
// we include these common regular expressions
|
||||
symbols: /[=><!~?:&|+\-*\/\^%]+/,
|
||||
|
||||
|
||||
// The main tokenizer for our languages
|
||||
tokenizer: {
|
||||
root: [
|
||||
|
|
@ -72,20 +92,44 @@ export const language = <ILanguage>{
|
|||
[/^(\s*)(comment:?(?:\s.*|))$/, ['', 'comment']],
|
||||
|
||||
// special identifier cases
|
||||
[/"/, { token: 'identifier.quote', bracket: '@open', next: '@quoted_identifier' }],
|
||||
['LEX$', { token: 'keyword', bracket: '@open', next: '@identifier_until_period' }],
|
||||
[
|
||||
/"/,
|
||||
{
|
||||
token: 'identifier.quote',
|
||||
bracket: '@open',
|
||||
next: '@quoted_identifier'
|
||||
}
|
||||
],
|
||||
[
|
||||
'LEX$',
|
||||
{
|
||||
token: 'keyword',
|
||||
bracket: '@open',
|
||||
next: '@identifier_until_period'
|
||||
}
|
||||
],
|
||||
['LEXON', { token: 'keyword', bracket: '@open', next: '@semver' }],
|
||||
[':', { token: 'delimiter', bracket: '@open', next: '@identifier_until_period' }],
|
||||
[
|
||||
':',
|
||||
{
|
||||
token: 'delimiter',
|
||||
bracket: '@open',
|
||||
next: '@identifier_until_period'
|
||||
}
|
||||
],
|
||||
|
||||
// identifiers and keywords
|
||||
[/[a-z_$][\w$]*/, {
|
||||
cases: {
|
||||
'@operators': 'operator',
|
||||
'@typeKeywords': 'keyword.type',
|
||||
'@keywords': 'keyword',
|
||||
'@default': 'identifier'
|
||||
[
|
||||
/[a-z_$][\w$]*/,
|
||||
{
|
||||
cases: {
|
||||
'@operators': 'operator',
|
||||
'@typeKeywords': 'keyword.type',
|
||||
'@keywords': 'keyword',
|
||||
'@default': 'identifier'
|
||||
}
|
||||
}
|
||||
}],
|
||||
],
|
||||
|
||||
// whitespace
|
||||
{ include: '@whitespace' },
|
||||
|
|
@ -102,17 +146,20 @@ export const language = <ILanguage>{
|
|||
[/\d+/, 'number'],
|
||||
|
||||
// delimiter: after number because of .\d floats
|
||||
[/[;,.]/, 'delimiter'],
|
||||
[/[;,.]/, 'delimiter']
|
||||
],
|
||||
|
||||
quoted_identifier: [
|
||||
[/[^\\"]+/, 'identifier'],
|
||||
[/"/, { token: 'identifier.quote', bracket: '@close', next: '@pop' }]
|
||||
[
|
||||
/"/,
|
||||
{ token: 'identifier.quote', bracket: '@close', next: '@pop' }
|
||||
]
|
||||
],
|
||||
|
||||
space_identifier_until_period: [
|
||||
[':', 'delimiter'],
|
||||
[' ', { token: 'white', next: '@identifier_rest' }],
|
||||
[' ', { token: 'white', next: '@identifier_rest' }]
|
||||
],
|
||||
|
||||
identifier_until_period: [
|
||||
|
|
@ -130,11 +177,12 @@ export const language = <ILanguage>{
|
|||
semver: [
|
||||
{ include: '@whitespace' },
|
||||
[':', 'delimiter'],
|
||||
[/\d*\.\d*\.\d*/, { token: 'number.semver', bracket: '@close', next: '@pop' }]
|
||||
[
|
||||
/\d*\.\d*\.\d*/,
|
||||
{ token: 'number.semver', bracket: '@close', next: '@pop' }
|
||||
]
|
||||
],
|
||||
|
||||
whitespace: [
|
||||
[/[ \t\r\n]+/, 'white'],
|
||||
],
|
||||
},
|
||||
whitespace: [[/[ \t\r\n]+/, 'white']]
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -8,74 +8,81 @@
|
|||
import { testTokenization } from '../test/testRunner';
|
||||
|
||||
testTokenization('lua', [
|
||||
|
||||
// Keywords
|
||||
[{
|
||||
line: 'local x, y = 1, 10',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.local.lua' },
|
||||
{ startIndex: 5, type: '' },
|
||||
{ startIndex: 6, type: 'identifier.lua' },
|
||||
{ startIndex: 7, type: 'delimiter.lua' },
|
||||
{ startIndex: 8, type: '' },
|
||||
{ startIndex: 9, type: 'identifier.lua' },
|
||||
{ startIndex: 10, type: '' },
|
||||
{ startIndex: 11, type: 'delimiter.lua' },
|
||||
{ startIndex: 12, type: '' },
|
||||
{ startIndex: 13, type: 'number.lua' },
|
||||
{ startIndex: 14, type: 'delimiter.lua' },
|
||||
{ startIndex: 15, type: '' },
|
||||
{ startIndex: 16, type: 'number.lua' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'local x, y = 1, 10',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.local.lua' },
|
||||
{ startIndex: 5, type: '' },
|
||||
{ startIndex: 6, type: 'identifier.lua' },
|
||||
{ startIndex: 7, type: 'delimiter.lua' },
|
||||
{ startIndex: 8, type: '' },
|
||||
{ startIndex: 9, type: 'identifier.lua' },
|
||||
{ startIndex: 10, type: '' },
|
||||
{ startIndex: 11, type: 'delimiter.lua' },
|
||||
{ startIndex: 12, type: '' },
|
||||
{ startIndex: 13, type: 'number.lua' },
|
||||
{ startIndex: 14, type: 'delimiter.lua' },
|
||||
{ startIndex: 15, type: '' },
|
||||
{ startIndex: 16, type: 'number.lua' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: 'foo = "Hello" .. "World"; local foo = foo',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'identifier.lua' },
|
||||
{ startIndex: 3, type: '' },
|
||||
{ startIndex: 4, type: 'delimiter.lua' },
|
||||
{ startIndex: 5, type: '' },
|
||||
{ startIndex: 6, type: 'string.lua' },
|
||||
{ startIndex: 13, type: '' },
|
||||
{ startIndex: 14, type: 'delimiter.lua' },
|
||||
{ startIndex: 16, type: '' },
|
||||
{ startIndex: 17, type: 'string.lua' },
|
||||
{ startIndex: 24, type: 'delimiter.lua' },
|
||||
{ startIndex: 25, type: '' },
|
||||
{ startIndex: 26, type: 'keyword.local.lua' },
|
||||
{ startIndex: 31, type: '' },
|
||||
{ startIndex: 32, type: 'identifier.lua' },
|
||||
{ startIndex: 35, type: '' },
|
||||
{ startIndex: 36, type: 'delimiter.lua' },
|
||||
{ startIndex: 37, type: '' },
|
||||
{ startIndex: 38, type: 'identifier.lua' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'foo = "Hello" .. "World"; local foo = foo',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'identifier.lua' },
|
||||
{ startIndex: 3, type: '' },
|
||||
{ startIndex: 4, type: 'delimiter.lua' },
|
||||
{ startIndex: 5, type: '' },
|
||||
{ startIndex: 6, type: 'string.lua' },
|
||||
{ startIndex: 13, type: '' },
|
||||
{ startIndex: 14, type: 'delimiter.lua' },
|
||||
{ startIndex: 16, type: '' },
|
||||
{ startIndex: 17, type: 'string.lua' },
|
||||
{ startIndex: 24, type: 'delimiter.lua' },
|
||||
{ startIndex: 25, type: '' },
|
||||
{ startIndex: 26, type: 'keyword.local.lua' },
|
||||
{ startIndex: 31, type: '' },
|
||||
{ startIndex: 32, type: 'identifier.lua' },
|
||||
{ startIndex: 35, type: '' },
|
||||
{ startIndex: 36, type: 'delimiter.lua' },
|
||||
{ startIndex: 37, type: '' },
|
||||
{ startIndex: 38, type: 'identifier.lua' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// Comments
|
||||
[{
|
||||
line: '--[[ text ]] x',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.lua' },
|
||||
{ startIndex: 12, type: '' },
|
||||
{ startIndex: 13, type: 'identifier.lua' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '--[[ text ]] x',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.lua' },
|
||||
{ startIndex: 12, type: '' },
|
||||
{ startIndex: 13, type: 'identifier.lua' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '--[===[ text ]===] x',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.lua' },
|
||||
{ startIndex: 18, type: '' },
|
||||
{ startIndex: 19, type: 'identifier.lua' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '--[===[ text ]===] x',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.lua' },
|
||||
{ startIndex: 18, type: '' },
|
||||
{ startIndex: 19, type: 'identifier.lua' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '--[===[ text ]==] x',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.lua' }
|
||||
]
|
||||
}]
|
||||
[
|
||||
{
|
||||
line: '--[===[ text ]==] x',
|
||||
tokens: [{ startIndex: 0, type: 'comment.lua' }]
|
||||
}
|
||||
]
|
||||
]);
|
||||
|
|
|
|||
128
src/lua/lua.ts
128
src/lua/lua.ts
|
|
@ -11,7 +11,7 @@ import ILanguage = monaco.languages.IMonarchLanguage;
|
|||
export const conf: IRichLanguageConfiguration = {
|
||||
comments: {
|
||||
lineComment: '--',
|
||||
blockComment: ['--[[', ']]'],
|
||||
blockComment: ['--[[', ']]']
|
||||
},
|
||||
brackets: [
|
||||
['{', '}'],
|
||||
|
|
@ -23,14 +23,14 @@ export const conf: IRichLanguageConfiguration = {
|
|||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '"', close: '"' },
|
||||
{ open: '\'', close: '\'' },
|
||||
{ open: "'", close: "'" }
|
||||
],
|
||||
surroundingPairs: [
|
||||
{ open: '{', close: '}' },
|
||||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '"', close: '"' },
|
||||
{ open: '\'', close: '\'' },
|
||||
{ open: "'", close: "'" }
|
||||
]
|
||||
};
|
||||
|
||||
|
|
@ -39,10 +39,27 @@ export const language = <ILanguage>{
|
|||
tokenPostfix: '.lua',
|
||||
|
||||
keywords: [
|
||||
'and', 'break', 'do', 'else', 'elseif',
|
||||
'end', 'false', 'for', 'function', 'goto', 'if',
|
||||
'in', 'local', 'nil', 'not', 'or',
|
||||
'repeat', 'return', 'then', 'true', 'until',
|
||||
'and',
|
||||
'break',
|
||||
'do',
|
||||
'else',
|
||||
'elseif',
|
||||
'end',
|
||||
'false',
|
||||
'for',
|
||||
'function',
|
||||
'goto',
|
||||
'if',
|
||||
'in',
|
||||
'local',
|
||||
'nil',
|
||||
'not',
|
||||
'or',
|
||||
'repeat',
|
||||
'return',
|
||||
'then',
|
||||
'true',
|
||||
'until',
|
||||
'while'
|
||||
],
|
||||
|
||||
|
|
@ -53,8 +70,26 @@ export const language = <ILanguage>{
|
|||
],
|
||||
|
||||
operators: [
|
||||
'+', '-', '*', '/', '%', '^', '#', '==', '~=', '<=', '>=', '<', '>', '=',
|
||||
';', ':', ',', '.', '..', '...'
|
||||
'+',
|
||||
'-',
|
||||
'*',
|
||||
'/',
|
||||
'%',
|
||||
'^',
|
||||
'#',
|
||||
'==',
|
||||
'~=',
|
||||
'<=',
|
||||
'>=',
|
||||
'<',
|
||||
'>',
|
||||
'=',
|
||||
';',
|
||||
':',
|
||||
',',
|
||||
'.',
|
||||
'..',
|
||||
'...'
|
||||
],
|
||||
|
||||
// we include these common regular expressions
|
||||
|
|
@ -65,27 +100,39 @@ export const language = <ILanguage>{
|
|||
tokenizer: {
|
||||
root: [
|
||||
// identifiers and keywords
|
||||
[/[a-zA-Z_]\w*/, {
|
||||
cases: {
|
||||
'@keywords': { token: 'keyword.$0' },
|
||||
'@default': 'identifier'
|
||||
[
|
||||
/[a-zA-Z_]\w*/,
|
||||
{
|
||||
cases: {
|
||||
'@keywords': { token: 'keyword.$0' },
|
||||
'@default': 'identifier'
|
||||
}
|
||||
}
|
||||
}],
|
||||
],
|
||||
// whitespace
|
||||
{ include: '@whitespace' },
|
||||
|
||||
// keys
|
||||
[/(,)(\s*)([a-zA-Z_]\w*)(\s*)(:)(?!:)/, ['delimiter', '', 'key', '', 'delimiter']],
|
||||
[/({)(\s*)([a-zA-Z_]\w*)(\s*)(:)(?!:)/, ['@brackets', '', 'key', '', 'delimiter']],
|
||||
[
|
||||
/(,)(\s*)([a-zA-Z_]\w*)(\s*)(:)(?!:)/,
|
||||
['delimiter', '', 'key', '', 'delimiter']
|
||||
],
|
||||
[
|
||||
/({)(\s*)([a-zA-Z_]\w*)(\s*)(:)(?!:)/,
|
||||
['@brackets', '', 'key', '', 'delimiter']
|
||||
],
|
||||
|
||||
// delimiters and operators
|
||||
[/[{}()\[\]]/, '@brackets'],
|
||||
[/@symbols/, {
|
||||
cases: {
|
||||
'@operators': 'delimiter',
|
||||
'@default': ''
|
||||
[
|
||||
/@symbols/,
|
||||
{
|
||||
cases: {
|
||||
'@operators': 'delimiter',
|
||||
'@default': ''
|
||||
}
|
||||
}
|
||||
}],
|
||||
],
|
||||
|
||||
// numbers
|
||||
[/\d*\.\d+([eE][\-+]?\d+)?/, 'number.float'],
|
||||
|
|
@ -96,26 +143,29 @@ export const language = <ILanguage>{
|
|||
[/[;,.]/, 'delimiter'],
|
||||
|
||||
// strings: recover on non-terminated strings
|
||||
[/"([^"\\]|\\.)*$/, 'string.invalid'], // non-teminated string
|
||||
[/'([^'\\]|\\.)*$/, 'string.invalid'], // non-teminated string
|
||||
[/"([^"\\]|\\.)*$/, 'string.invalid'], // non-teminated string
|
||||
[/'([^'\\]|\\.)*$/, 'string.invalid'], // non-teminated string
|
||||
[/"/, 'string', '@string."'],
|
||||
[/'/, 'string', '@string.\''],
|
||||
[/'/, 'string', "@string.'"]
|
||||
],
|
||||
|
||||
whitespace: [
|
||||
[/[ \t\r\n]+/, ''],
|
||||
[/--\[([=]*)\[/, 'comment', '@comment.$1'],
|
||||
[/--.*$/, 'comment'],
|
||||
[/--.*$/, 'comment']
|
||||
],
|
||||
|
||||
comment: [
|
||||
[/[^\]]+/, 'comment'],
|
||||
[/\]([=]*)\]/, {
|
||||
cases: {
|
||||
'$1==$S2': { token: 'comment', next: '@pop' },
|
||||
'@default': 'comment'
|
||||
[
|
||||
/\]([=]*)\]/,
|
||||
{
|
||||
cases: {
|
||||
'$1==$S2': { token: 'comment', next: '@pop' },
|
||||
'@default': 'comment'
|
||||
}
|
||||
}
|
||||
}],
|
||||
],
|
||||
[/./, 'comment']
|
||||
],
|
||||
|
||||
|
|
@ -123,13 +173,15 @@ export const language = <ILanguage>{
|
|||
[/[^\\"']+/, 'string'],
|
||||
[/@escapes/, 'string.escape'],
|
||||
[/\\./, 'string.escape.invalid'],
|
||||
[/["']/, {
|
||||
cases: {
|
||||
'$#==$S2': { token: 'string', next: '@pop' },
|
||||
'@default': 'string'
|
||||
[
|
||||
/["']/,
|
||||
{
|
||||
cases: {
|
||||
'$#==$S2': { token: 'string', next: '@pop' },
|
||||
'@default': 'string'
|
||||
}
|
||||
}
|
||||
}]
|
||||
],
|
||||
|
||||
},
|
||||
]
|
||||
]
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -8,7 +8,16 @@ import { registerLanguage } from '../_.contribution';
|
|||
|
||||
registerLanguage({
|
||||
id: 'markdown',
|
||||
extensions: ['.md', '.markdown', '.mdown', '.mkdn', '.mkd', '.mdwn', '.mdtxt', '.mdtext'],
|
||||
extensions: [
|
||||
'.md',
|
||||
'.markdown',
|
||||
'.mdown',
|
||||
'.mkdn',
|
||||
'.mkd',
|
||||
'.mdwn',
|
||||
'.mdtxt',
|
||||
'.mdtext'
|
||||
],
|
||||
aliases: ['Markdown', 'markdown'],
|
||||
loader: () => import('./markdown')
|
||||
});
|
||||
|
|
|
|||
|
|
@ -8,37 +8,42 @@
|
|||
import { testTokenization } from '../test/testRunner';
|
||||
|
||||
testTokenization('markdown', [
|
||||
[
|
||||
{
|
||||
line: '# Some header',
|
||||
tokens: [{ startIndex: 0, type: 'keyword.md' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '# Some header',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.md' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '* Some list item',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.md' },
|
||||
{ startIndex: 2, type: '' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '* Some list item',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.md' },
|
||||
{ startIndex: 2, type: '' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'some `code`',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 5, type: 'variable.md' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: 'some `code`',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 5, type: 'variable.md' }
|
||||
]
|
||||
}],
|
||||
|
||||
[{
|
||||
line: 'some ',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 5, type: 'string.link.md' },
|
||||
{ startIndex: 7, type: '' },
|
||||
{ startIndex: 11, type: 'string.link.md' }
|
||||
]
|
||||
}]
|
||||
[
|
||||
{
|
||||
line: 'some ',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 5, type: 'string.link.md' },
|
||||
{ startIndex: 7, type: '' },
|
||||
{ startIndex: 11, type: 'string.link.md' }
|
||||
]
|
||||
}
|
||||
]
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import ILanguage = monaco.languages.IMonarchLanguage;
|
|||
|
||||
export const conf: IRichLanguageConfiguration = {
|
||||
comments: {
|
||||
blockComment: ['<!--', '-->',]
|
||||
blockComment: ['<!--', '-->']
|
||||
},
|
||||
brackets: [
|
||||
['{', '}'],
|
||||
|
|
@ -26,12 +26,12 @@ export const conf: IRichLanguageConfiguration = {
|
|||
surroundingPairs: [
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '[', close: ']' },
|
||||
{ open: '`', close: '`' },
|
||||
{ open: '`', close: '`' }
|
||||
],
|
||||
folding: {
|
||||
markers: {
|
||||
start: new RegExp("^\\s*<!--\\s*#?region\\b.*-->"),
|
||||
end: new RegExp("^\\s*<!--\\s*#?endregion\\b.*-->")
|
||||
start: new RegExp('^\\s*<!--\\s*#?region\\b.*-->'),
|
||||
end: new RegExp('^\\s*<!--\\s*#?endregion\\b.*-->')
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -50,18 +50,31 @@ export const language = <ILanguage>{
|
|||
|
||||
// non matched elements
|
||||
empty: [
|
||||
'area', 'base', 'basefont', 'br', 'col', 'frame',
|
||||
'hr', 'img', 'input', 'isindex', 'link', 'meta', 'param'
|
||||
'area',
|
||||
'base',
|
||||
'basefont',
|
||||
'br',
|
||||
'col',
|
||||
'frame',
|
||||
'hr',
|
||||
'img',
|
||||
'input',
|
||||
'isindex',
|
||||
'link',
|
||||
'meta',
|
||||
'param'
|
||||
],
|
||||
|
||||
tokenizer: {
|
||||
root: [
|
||||
|
||||
// markdown tables
|
||||
[/^\s*\|/, '@rematch', '@table_header'],
|
||||
|
||||
// headers (with #)
|
||||
[/^(\s{0,3})(#+)((?:[^\\#]|@escapes)+)((?:#+)?)/, ['white', 'keyword', 'keyword', 'keyword']],
|
||||
[
|
||||
/^(\s{0,3})(#+)((?:[^\\#]|@escapes)+)((?:#+)?)/,
|
||||
['white', 'keyword', 'keyword', 'keyword']
|
||||
],
|
||||
|
||||
// headers (with =)
|
||||
[/^\s*(=+|\-+)\s*$/, 'keyword'],
|
||||
|
|
@ -79,55 +92,63 @@ export const language = <ILanguage>{
|
|||
[/^(\t|[ ]{4})[^ ].*$/, 'string'],
|
||||
|
||||
// code block (3 tilde)
|
||||
[/^\s*~~~\s*((?:\w|[\/\-#])+)?\s*$/, { token: 'string', next: '@codeblock' }],
|
||||
[
|
||||
/^\s*~~~\s*((?:\w|[\/\-#])+)?\s*$/,
|
||||
{ token: 'string', next: '@codeblock' }
|
||||
],
|
||||
|
||||
// github style code blocks (with backticks and language)
|
||||
[/^\s*```\s*((?:\w|[\/\-#])+).*$/, { token: 'string', next: '@codeblockgh', nextEmbedded: '$1' }],
|
||||
[
|
||||
/^\s*```\s*((?:\w|[\/\-#])+).*$/,
|
||||
{ token: 'string', next: '@codeblockgh', nextEmbedded: '$1' }
|
||||
],
|
||||
|
||||
// github style code blocks (with backticks but no language)
|
||||
[/^\s*```\s*$/, { token: 'string', next: '@codeblock' }],
|
||||
|
||||
// markup within lines
|
||||
{ include: '@linecontent' },
|
||||
{ include: '@linecontent' }
|
||||
],
|
||||
|
||||
table_header: [
|
||||
{ include: '@table_common' },
|
||||
[/[^\|]+/, 'keyword.table.header'], // table header
|
||||
[/[^\|]+/, 'keyword.table.header'] // table header
|
||||
],
|
||||
|
||||
table_body: [
|
||||
{ include: '@table_common' },
|
||||
{ include: '@linecontent' },
|
||||
],
|
||||
table_body: [{ include: '@table_common' }, { include: '@linecontent' }],
|
||||
|
||||
table_common: [
|
||||
[/\s*[\-:]+\s*/, { token: 'keyword', switchTo: 'table_body' }], // header-divider
|
||||
[/^\s*\|/, 'keyword.table.left'], // opening |
|
||||
[/^\s*[^\|]/, '@rematch', '@pop'], // exiting
|
||||
[/^\s*$/, '@rematch', '@pop'], // exiting
|
||||
[/\|/, {
|
||||
cases: {
|
||||
'@eos': 'keyword.table.right', // closing |
|
||||
'@default': 'keyword.table.middle', // inner |
|
||||
[
|
||||
/\|/,
|
||||
{
|
||||
cases: {
|
||||
'@eos': 'keyword.table.right', // closing |
|
||||
'@default': 'keyword.table.middle' // inner |
|
||||
}
|
||||
}
|
||||
}],
|
||||
]
|
||||
],
|
||||
|
||||
codeblock: [
|
||||
[/^\s*~~~\s*$/, { token: 'string', next: '@pop' }],
|
||||
[/^\s*```\s*$/, { token: 'string', next: '@pop' }],
|
||||
[/.*$/, 'variable.source'],
|
||||
[/.*$/, 'variable.source']
|
||||
],
|
||||
|
||||
// github style code blocks
|
||||
codeblockgh: [
|
||||
[/```\s*$/, { token: 'variable.source', next: '@pop', nextEmbedded: '@pop' }],
|
||||
[/[^`]+/, 'variable.source'],
|
||||
[
|
||||
/```\s*$/,
|
||||
{ token: 'variable.source', next: '@pop', nextEmbedded: '@pop' }
|
||||
],
|
||||
[/[^`]+/, 'variable.source']
|
||||
],
|
||||
|
||||
linecontent: [
|
||||
|
||||
// escapes
|
||||
[/&\w+;/, 'string.escape'],
|
||||
[/@escapes/, 'escape'],
|
||||
|
|
@ -141,11 +162,14 @@ export const language = <ILanguage>{
|
|||
|
||||
// links
|
||||
[/\{+[^}]+\}+/, 'string.target'],
|
||||
[/(!?\[)((?:[^\]\\]|@escapes)*)(\]\([^\)]+\))/, ['string.link', '', 'string.link']],
|
||||
[
|
||||
/(!?\[)((?:[^\]\\]|@escapes)*)(\]\([^\)]+\))/,
|
||||
['string.link', '', 'string.link']
|
||||
],
|
||||
[/(!?\[)((?:[^\]\\]|@escapes)*)(\])/, 'string.link'],
|
||||
|
||||
// or html
|
||||
{ include: 'html' },
|
||||
{ include: 'html' }
|
||||
],
|
||||
|
||||
// Note: it is tempting to rather switch to the real HTML mode instead of building our own here
|
||||
|
|
@ -156,12 +180,15 @@ export const language = <ILanguage>{
|
|||
html: [
|
||||
// html tags
|
||||
[/<(\w+)\/>/, 'tag'],
|
||||
[/<(\w+)/, {
|
||||
cases: {
|
||||
'@empty': { token: 'tag', next: '@tag.$1' },
|
||||
'@default': { token: 'tag', next: '@tag.$1' }
|
||||
[
|
||||
/<(\w+)/,
|
||||
{
|
||||
cases: {
|
||||
'@empty': { token: 'tag', next: '@tag.$1' },
|
||||
'@default': { token: 'tag', next: '@tag.$1' }
|
||||
}
|
||||
}
|
||||
}],
|
||||
],
|
||||
[/<\/(\w+)\s*>/, { token: 'tag' }],
|
||||
|
||||
[/<!--/, 'comment', '@comment']
|
||||
|
|
@ -177,39 +204,77 @@ export const language = <ILanguage>{
|
|||
// Almost full HTML tag matching, complete with embedded scripts & styles
|
||||
tag: [
|
||||
[/[ \t\r\n]+/, 'white'],
|
||||
[/(type)(\s*=\s*)(")([^"]+)(")/, ['attribute.name.html', 'delimiter.html', 'string.html',
|
||||
{ token: 'string.html', switchTo: '@tag.$S2.$4' },
|
||||
'string.html']],
|
||||
[/(type)(\s*=\s*)(')([^']+)(')/, ['attribute.name.html', 'delimiter.html', 'string.html',
|
||||
{ token: 'string.html', switchTo: '@tag.$S2.$4' },
|
||||
'string.html']],
|
||||
[/(\w+)(\s*=\s*)("[^"]*"|'[^']*')/, ['attribute.name.html', 'delimiter.html', 'string.html']],
|
||||
[
|
||||
/(type)(\s*=\s*)(")([^"]+)(")/,
|
||||
[
|
||||
'attribute.name.html',
|
||||
'delimiter.html',
|
||||
'string.html',
|
||||
{ token: 'string.html', switchTo: '@tag.$S2.$4' },
|
||||
'string.html'
|
||||
]
|
||||
],
|
||||
[
|
||||
/(type)(\s*=\s*)(')([^']+)(')/,
|
||||
[
|
||||
'attribute.name.html',
|
||||
'delimiter.html',
|
||||
'string.html',
|
||||
{ token: 'string.html', switchTo: '@tag.$S2.$4' },
|
||||
'string.html'
|
||||
]
|
||||
],
|
||||
[
|
||||
/(\w+)(\s*=\s*)("[^"]*"|'[^']*')/,
|
||||
['attribute.name.html', 'delimiter.html', 'string.html']
|
||||
],
|
||||
[/\w+/, 'attribute.name.html'],
|
||||
[/\/>/, 'tag', '@pop'],
|
||||
[/>/, {
|
||||
cases: {
|
||||
'$S2==style': { token: 'tag', switchTo: 'embeddedStyle', nextEmbedded: 'text/css' },
|
||||
'$S2==script': {
|
||||
cases: {
|
||||
'$S3': { token: 'tag', switchTo: 'embeddedScript', nextEmbedded: '$S3' },
|
||||
'@default': { token: 'tag', switchTo: 'embeddedScript', nextEmbedded: 'text/javascript' }
|
||||
}
|
||||
},
|
||||
'@default': { token: 'tag', next: '@pop' }
|
||||
[
|
||||
/>/,
|
||||
{
|
||||
cases: {
|
||||
'$S2==style': {
|
||||
token: 'tag',
|
||||
switchTo: 'embeddedStyle',
|
||||
nextEmbedded: 'text/css'
|
||||
},
|
||||
'$S2==script': {
|
||||
cases: {
|
||||
$S3: {
|
||||
token: 'tag',
|
||||
switchTo: 'embeddedScript',
|
||||
nextEmbedded: '$S3'
|
||||
},
|
||||
'@default': {
|
||||
token: 'tag',
|
||||
switchTo: 'embeddedScript',
|
||||
nextEmbedded: 'text/javascript'
|
||||
}
|
||||
}
|
||||
},
|
||||
'@default': { token: 'tag', next: '@pop' }
|
||||
}
|
||||
}
|
||||
}],
|
||||
]
|
||||
],
|
||||
|
||||
embeddedStyle: [
|
||||
[/[^<]+/, ''],
|
||||
[/<\/style\s*>/, { token: '@rematch', next: '@pop', nextEmbedded: '@pop' }],
|
||||
[
|
||||
/<\/style\s*>/,
|
||||
{ token: '@rematch', next: '@pop', nextEmbedded: '@pop' }
|
||||
],
|
||||
[/</, '']
|
||||
],
|
||||
|
||||
embeddedScript: [
|
||||
[/[^<]+/, ''],
|
||||
[/<\/script\s*>/, { token: '@rematch', next: '@pop', nextEmbedded: '@pop' }],
|
||||
[
|
||||
/<\/script\s*>/,
|
||||
{ token: '@rematch', next: '@pop', nextEmbedded: '@pop' }
|
||||
],
|
||||
[/</, '']
|
||||
],
|
||||
]
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -9,205 +9,234 @@ import { testTokenization } from '../test/testRunner';
|
|||
|
||||
testTokenization('mips', [
|
||||
// Comments
|
||||
[{
|
||||
line: '#',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.mips' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '#',
|
||||
tokens: [{ startIndex: 0, type: 'comment.mips' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: ' # a comment',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 4, type: 'comment.mips' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: ' # a comment',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 4, type: 'comment.mips' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '# a comment',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.mips' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '# a comment',
|
||||
tokens: [{ startIndex: 0, type: 'comment.mips' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '#sticky comment',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.mips' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '#sticky comment',
|
||||
tokens: [{ startIndex: 0, type: 'comment.mips' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '$x, 1 # my comment # is a nice one',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'variable.predefined.mips' },
|
||||
{ startIndex: 2, type: 'delimiter.mips' },
|
||||
{ startIndex: 3, type: '' },
|
||||
{ startIndex: 4, type: 'number.mips' },
|
||||
{ startIndex: 5, type: '' },
|
||||
{ startIndex: 6, type: 'comment.mips' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '$x, 1 # my comment # is a nice one',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'variable.predefined.mips' },
|
||||
{ startIndex: 2, type: 'delimiter.mips' },
|
||||
{ startIndex: 3, type: '' },
|
||||
{ startIndex: 4, type: 'number.mips' },
|
||||
{ startIndex: 5, type: '' },
|
||||
{ startIndex: 6, type: 'comment.mips' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '$x, 1e #is a exponent number',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'variable.predefined.mips' },
|
||||
{ startIndex: 2, type: 'delimiter.mips' },
|
||||
{ startIndex: 3, type: '' },
|
||||
{ startIndex: 4, type: 'number.float.mips' },
|
||||
{ startIndex: 6, type: '' },
|
||||
{ startIndex: 7, type: 'comment.mips' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '$x, 1e #is a exponent number',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'variable.predefined.mips' },
|
||||
{ startIndex: 2, type: 'delimiter.mips' },
|
||||
{ startIndex: 3, type: '' },
|
||||
{ startIndex: 4, type: 'number.float.mips' },
|
||||
{ startIndex: 6, type: '' },
|
||||
{ startIndex: 7, type: 'comment.mips' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '$x, 0x1F #is a hex number',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'variable.predefined.mips' },
|
||||
{ startIndex: 2, type: 'delimiter.mips' },
|
||||
{ startIndex: 3, type: '' },
|
||||
{ startIndex: 4, type: 'number.hex.mips' },
|
||||
{ startIndex: 8, type: '' },
|
||||
{ startIndex: 9, type: 'comment.mips' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '$x, 0x1F #is a hex number',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'variable.predefined.mips' },
|
||||
{ startIndex: 2, type: 'delimiter.mips' },
|
||||
{ startIndex: 3, type: '' },
|
||||
{ startIndex: 4, type: 'number.hex.mips' },
|
||||
{ startIndex: 8, type: '' },
|
||||
{ startIndex: 9, type: 'comment.mips' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// Keywords
|
||||
[{
|
||||
line: 'li $r0, 5',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.li.mips' },
|
||||
{ startIndex: 2, type: '' },
|
||||
{ startIndex: 3, type: 'variable.predefined.mips' },
|
||||
{ startIndex: 6, type: 'delimiter.mips' },
|
||||
{ startIndex: 7, type: '' },
|
||||
{ startIndex: 8, type: 'number.mips' },
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'li $r0, 5',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.li.mips' },
|
||||
{ startIndex: 2, type: '' },
|
||||
{ startIndex: 3, type: 'variable.predefined.mips' },
|
||||
{ startIndex: 6, type: 'delimiter.mips' },
|
||||
{ startIndex: 7, type: '' },
|
||||
{ startIndex: 8, type: 'number.mips' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '.data # Data declaration',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.\.data.mips' },
|
||||
{ startIndex: 5, type: '' },
|
||||
{ startIndex: 6, type: 'comment.mips' },
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '.data # Data declaration',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword..data.mips' },
|
||||
{ startIndex: 5, type: '' },
|
||||
{ startIndex: 6, type: 'comment.mips' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: 'even_str: .asciiz "The number is even!" # Output string for even integer',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 8, type: 'delimiter.mips' },
|
||||
{ startIndex: 9, type: '' },
|
||||
{ startIndex: 18, type: 'string.mips' },
|
||||
{ startIndex: 39, type: '' },
|
||||
{ startIndex: 40, type: 'comment.mips' },
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line:
|
||||
'even_str: .asciiz "The number is even!" # Output string for even integer',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 8, type: 'delimiter.mips' },
|
||||
{ startIndex: 9, type: '' },
|
||||
{ startIndex: 18, type: 'string.mips' },
|
||||
{ startIndex: 39, type: '' },
|
||||
{ startIndex: 40, type: 'comment.mips' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: ' add ',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 4, type: 'keyword.add.mips' },
|
||||
{ startIndex: 7, type: '' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: ' add ',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 4, type: 'keyword.add.mips' },
|
||||
{ startIndex: 7, type: '' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// Comments - range comment, single line
|
||||
[{
|
||||
line: '### a simple comment ###',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.mips' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '### a simple comment ###',
|
||||
tokens: [{ startIndex: 0, type: 'comment.mips' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: 'move $x, ### a simple comment ### 1',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.move.mips' },
|
||||
{ startIndex: 4, type: '' },
|
||||
{ startIndex: 5, type: 'variable.predefined.mips' },
|
||||
{ startIndex: 7, type: 'delimiter.mips' },
|
||||
{ startIndex: 8, type: '' },
|
||||
{ startIndex: 9, type: 'comment.mips' },
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'move $x, ### a simple comment ### 1',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.move.mips' },
|
||||
{ startIndex: 4, type: '' },
|
||||
{ startIndex: 5, type: 'variable.predefined.mips' },
|
||||
{ startIndex: 7, type: 'delimiter.mips' },
|
||||
{ startIndex: 8, type: '' },
|
||||
{ startIndex: 9, type: 'comment.mips' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '$x ###/',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'variable.predefined.mips' },
|
||||
{ startIndex: 2, type: '' },
|
||||
{ startIndex: 3, type: 'comment.mips' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '$x ###/',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'variable.predefined.mips' },
|
||||
{ startIndex: 2, type: '' },
|
||||
{ startIndex: 3, type: 'comment.mips' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// Numbers
|
||||
[{
|
||||
line: '0',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.mips' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '0',
|
||||
tokens: [{ startIndex: 0, type: 'number.mips' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: ' 0',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 1, type: 'number.mips' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: ' 0',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 1, type: 'number.mips' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: ' 0 ',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 1, type: 'number.mips' },
|
||||
{ startIndex: 2, type: '' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: ' 0 ',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 1, type: 'number.mips' },
|
||||
{ startIndex: 2, type: '' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '0 ',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.mips' },
|
||||
{ startIndex: 1, type: '' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '0 ',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.mips' },
|
||||
{ startIndex: 1, type: '' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '0123',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.octal.mips' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '0123',
|
||||
tokens: [{ startIndex: 0, type: 'number.octal.mips' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '01239',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.mips' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '01239',
|
||||
tokens: [{ startIndex: 0, type: 'number.mips' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '0x123',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.hex.mips' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '0x123',
|
||||
tokens: [{ startIndex: 0, type: 'number.hex.mips' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '1,2,3',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.mips' },
|
||||
{ startIndex: 1, type: 'delimiter.mips' },
|
||||
{ startIndex: 2, type: 'number.mips' },
|
||||
{ startIndex: 3, type: 'delimiter.mips' },
|
||||
{ startIndex: 4, type: 'number.mips' },
|
||||
]
|
||||
}]
|
||||
[
|
||||
{
|
||||
line: '1,2,3',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.mips' },
|
||||
{ startIndex: 1, type: 'delimiter.mips' },
|
||||
{ startIndex: 2, type: 'number.mips' },
|
||||
{ startIndex: 3, type: 'delimiter.mips' },
|
||||
{ startIndex: 4, type: 'number.mips' }
|
||||
]
|
||||
}
|
||||
]
|
||||
]);
|
||||
|
|
|
|||
168
src/mips/mips.ts
168
src/mips/mips.ts
|
|
@ -16,8 +16,8 @@ export const conf: IRichLanguageConfiguration = {
|
|||
},
|
||||
folding: {
|
||||
markers: {
|
||||
start: new RegExp("^\\s*#region\\b"),
|
||||
end: new RegExp("^\\s*#endregion\\b")
|
||||
start: new RegExp('^\\s*#region\\b'),
|
||||
end: new RegExp('^\\s*#endregion\\b')
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -30,15 +30,64 @@ export const language = <ILanguage>{
|
|||
regEx: /\/(?!\/\/)(?:[^\/\\]|\\.)*\/[igm]*/,
|
||||
|
||||
keywords: [
|
||||
'.data', '.text', 'syscall', 'trap',
|
||||
'add', 'addu', 'addi', 'addiu', 'and', 'andi',
|
||||
'div', 'divu', 'mult', 'multu', 'nor', 'or', 'ori',
|
||||
'sll', 'slv', 'sra', 'srav', 'srl', 'srlv',
|
||||
'sub', 'subu', 'xor', 'xori', 'lhi', 'lho',
|
||||
'lhi', 'llo', 'slt', 'slti', 'sltu', 'sltiu',
|
||||
'beq', 'bgtz', 'blez', 'bne', 'j', 'jal', 'jalr', 'jr',
|
||||
'lb', 'lbu', 'lh', 'lhu', 'lw', 'li', 'la',
|
||||
'sb', 'sh', 'sw', 'mfhi', 'mflo', 'mthi', 'mtlo', 'move',
|
||||
'.data',
|
||||
'.text',
|
||||
'syscall',
|
||||
'trap',
|
||||
'add',
|
||||
'addu',
|
||||
'addi',
|
||||
'addiu',
|
||||
'and',
|
||||
'andi',
|
||||
'div',
|
||||
'divu',
|
||||
'mult',
|
||||
'multu',
|
||||
'nor',
|
||||
'or',
|
||||
'ori',
|
||||
'sll',
|
||||
'slv',
|
||||
'sra',
|
||||
'srav',
|
||||
'srl',
|
||||
'srlv',
|
||||
'sub',
|
||||
'subu',
|
||||
'xor',
|
||||
'xori',
|
||||
'lhi',
|
||||
'lho',
|
||||
'lhi',
|
||||
'llo',
|
||||
'slt',
|
||||
'slti',
|
||||
'sltu',
|
||||
'sltiu',
|
||||
'beq',
|
||||
'bgtz',
|
||||
'blez',
|
||||
'bne',
|
||||
'j',
|
||||
'jal',
|
||||
'jalr',
|
||||
'jr',
|
||||
'lb',
|
||||
'lbu',
|
||||
'lh',
|
||||
'lhu',
|
||||
'lw',
|
||||
'li',
|
||||
'la',
|
||||
'sb',
|
||||
'sh',
|
||||
'sw',
|
||||
'mfhi',
|
||||
'mflo',
|
||||
'mthi',
|
||||
'mtlo',
|
||||
'move'
|
||||
],
|
||||
|
||||
// we include these common regular expressions
|
||||
|
|
@ -48,16 +97,18 @@ export const language = <ILanguage>{
|
|||
// The main tokenizer for our languages
|
||||
tokenizer: {
|
||||
root: [
|
||||
|
||||
// identifiers and keywords
|
||||
[/\$[a-zA-Z_]\w*/, 'variable.predefined'],
|
||||
[/[.a-zA-Z_]\w*/, {
|
||||
cases: {
|
||||
'this': 'variable.predefined',
|
||||
'@keywords': { token: 'keyword.$0' },
|
||||
'@default': ''
|
||||
[
|
||||
/[.a-zA-Z_]\w*/,
|
||||
{
|
||||
cases: {
|
||||
this: 'variable.predefined',
|
||||
'@keywords': { token: 'keyword.$0' },
|
||||
'@default': ''
|
||||
}
|
||||
}
|
||||
}],
|
||||
],
|
||||
|
||||
// whitespace
|
||||
[/[ \t\r\n]+/, ''],
|
||||
|
|
@ -72,7 +123,6 @@ export const language = <ILanguage>{
|
|||
[/(\,)(\s*)(@regEx)/, ['delimiter', '', 'regexp']],
|
||||
[/(\:)(\s*)(@regEx)/, ['delimiter', '', 'regexp']],
|
||||
|
||||
|
||||
// delimiters
|
||||
[/@symbols/, 'delimiter'],
|
||||
|
||||
|
|
@ -88,19 +138,25 @@ export const language = <ILanguage>{
|
|||
|
||||
// strings:
|
||||
[/"""/, 'string', '@herestring."""'],
|
||||
[/'''/, 'string', '@herestring.\'\'\''],
|
||||
[/"/, {
|
||||
cases: {
|
||||
'@eos': 'string',
|
||||
'@default': { token: 'string', next: '@string."' }
|
||||
[/'''/, 'string', "@herestring.'''"],
|
||||
[
|
||||
/"/,
|
||||
{
|
||||
cases: {
|
||||
'@eos': 'string',
|
||||
'@default': { token: 'string', next: '@string."' }
|
||||
}
|
||||
}
|
||||
}],
|
||||
[/'/, {
|
||||
cases: {
|
||||
'@eos': 'string',
|
||||
'@default': { token: 'string', next: '@string.\'' }
|
||||
],
|
||||
[
|
||||
/'/,
|
||||
{
|
||||
cases: {
|
||||
'@eos': 'string',
|
||||
'@default': { token: 'string', next: "@string.'" }
|
||||
}
|
||||
}
|
||||
}],
|
||||
]
|
||||
],
|
||||
|
||||
string: [
|
||||
|
|
@ -109,29 +165,41 @@ export const language = <ILanguage>{
|
|||
[/\./, 'string.escape.invalid'],
|
||||
[/\./, 'string.escape.invalid'],
|
||||
|
||||
[/#{/, {
|
||||
cases: {
|
||||
'$S2=="': { token: 'string', next: 'root.interpolatedstring' },
|
||||
'@default': 'string'
|
||||
[
|
||||
/#{/,
|
||||
{
|
||||
cases: {
|
||||
'$S2=="': {
|
||||
token: 'string',
|
||||
next: 'root.interpolatedstring'
|
||||
},
|
||||
'@default': 'string'
|
||||
}
|
||||
}
|
||||
}],
|
||||
],
|
||||
|
||||
[/["']/, {
|
||||
cases: {
|
||||
'$#==$S2': { token: 'string', next: '@pop' },
|
||||
'@default': 'string'
|
||||
[
|
||||
/["']/,
|
||||
{
|
||||
cases: {
|
||||
'$#==$S2': { token: 'string', next: '@pop' },
|
||||
'@default': 'string'
|
||||
}
|
||||
}
|
||||
}],
|
||||
],
|
||||
[/#/, 'string']
|
||||
],
|
||||
|
||||
herestring: [
|
||||
[/("""|''')/, {
|
||||
cases: {
|
||||
'$1==$S2': { token: 'string', next: '@pop' },
|
||||
'@default': 'string'
|
||||
[
|
||||
/("""|''')/,
|
||||
{
|
||||
cases: {
|
||||
'$1==$S2': { token: 'string', next: '@pop' },
|
||||
'@default': 'string'
|
||||
}
|
||||
}
|
||||
}],
|
||||
],
|
||||
[/[^#\\'"]+/, 'string'],
|
||||
[/['"]+/, 'string'],
|
||||
[/@escapes/, 'string.escape'],
|
||||
|
|
@ -142,8 +210,8 @@ export const language = <ILanguage>{
|
|||
],
|
||||
|
||||
comment: [
|
||||
[/[^#]+/, 'comment',],
|
||||
[/#/, 'comment'],
|
||||
[/[^#]+/, 'comment'],
|
||||
[/#/, 'comment']
|
||||
],
|
||||
|
||||
hereregexp: [
|
||||
|
|
@ -151,7 +219,7 @@ export const language = <ILanguage>{
|
|||
[/\\./, 'regexp'],
|
||||
[/#.*$/, 'comment'],
|
||||
['///[igm]*', { token: 'regexp', next: '@pop' }],
|
||||
[/\//, 'regexp'],
|
||||
],
|
||||
},
|
||||
[/\//, 'regexp']
|
||||
]
|
||||
}
|
||||
};
|
||||
|
|
|
|||
15
src/mocha.d.ts
vendored
15
src/mocha.d.ts
vendored
|
|
@ -5,9 +5,12 @@
|
|||
|
||||
declare function run(): void;
|
||||
|
||||
declare function suite(name: string, fn: (err?: any)=>void): void;
|
||||
declare function test(name: string, fn: (done: (err?: any)=>void)=>void): void;
|
||||
declare function suiteSetup(fn: (done: (err?: any)=>void)=>void): void;
|
||||
declare function suiteTeardown(fn: (done: (err?: any)=>void)=>void): void;
|
||||
declare function setup(fn: (done: (err?: any)=>void)=>void): void;
|
||||
declare function teardown(fn: (done: (err?: any)=>void)=>void): void;
|
||||
declare function suite(name: string, fn: (err?: any) => void): void;
|
||||
declare function test(
|
||||
name: string,
|
||||
fn: (done: (err?: any) => void) => void
|
||||
): void;
|
||||
declare function suiteSetup(fn: (done: (err?: any) => void) => void): void;
|
||||
declare function suiteTeardown(fn: (done: (err?: any) => void) => void): void;
|
||||
declare function setup(fn: (done: (err?: any) => void) => void): void;
|
||||
declare function teardown(fn: (done: (err?: any) => void) => void): void;
|
||||
|
|
|
|||
|
|
@ -9,406 +9,438 @@ import { testTokenization } from '../test/testRunner';
|
|||
|
||||
testTokenization('msdax', [
|
||||
// Comments
|
||||
[{
|
||||
line: '// a comment',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.msdax' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '// a comment',
|
||||
tokens: [{ startIndex: 0, type: 'comment.msdax' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '-almost a comment',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'operator.msdax' },
|
||||
{ startIndex: 1, type: 'identifier.msdax' },
|
||||
{ startIndex: 7, type: 'white.msdax' },
|
||||
{ startIndex: 8, type: 'identifier.msdax' },
|
||||
{ startIndex: 9, type: 'white.msdax' },
|
||||
{ startIndex: 10, type: 'identifier.msdax' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '-almost a comment',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'operator.msdax' },
|
||||
{ startIndex: 1, type: 'identifier.msdax' },
|
||||
{ startIndex: 7, type: 'white.msdax' },
|
||||
{ startIndex: 8, type: 'identifier.msdax' },
|
||||
{ startIndex: 9, type: 'white.msdax' },
|
||||
{ startIndex: 10, type: 'identifier.msdax' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '/* a full line comment */',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.quote.msdax' },
|
||||
{ startIndex: 2, type: 'comment.msdax' },
|
||||
{ startIndex: 23, type: 'comment.quote.msdax' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '/* a full line comment */',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.quote.msdax' },
|
||||
{ startIndex: 2, type: 'comment.msdax' },
|
||||
{ startIndex: 23, type: 'comment.quote.msdax' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '/* /// *** /// */',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.quote.msdax' },
|
||||
{ startIndex: 2, type: 'comment.msdax' },
|
||||
{ startIndex: 15, type: 'comment.quote.msdax' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '/* /// *** /// */',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.quote.msdax' },
|
||||
{ startIndex: 2, type: 'comment.msdax' },
|
||||
{ startIndex: 15, type: 'comment.quote.msdax' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: 'define measure x = /* a simple comment */ 1;',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.msdax' },
|
||||
{ startIndex: 6, type: 'white.msdax' },
|
||||
{ startIndex: 7, type: 'keyword.msdax' },
|
||||
{ startIndex: 14, type: 'white.msdax' },
|
||||
{ startIndex: 15, type: 'identifier.msdax' },
|
||||
{ startIndex: 16, type: 'white.msdax' },
|
||||
{ startIndex: 17, type: 'operator.msdax' },
|
||||
{ startIndex: 18, type: 'white.msdax' },
|
||||
{ startIndex: 19, type: 'comment.quote.msdax' },
|
||||
{ startIndex: 21, type: 'comment.msdax' },
|
||||
{ startIndex: 39, type: 'comment.quote.msdax' },
|
||||
{ startIndex: 41, type: 'white.msdax' },
|
||||
{ startIndex: 42, type: 'number.msdax' },
|
||||
{ startIndex: 43, type: 'delimiter.msdax' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'define measure x = /* a simple comment */ 1;',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.msdax' },
|
||||
{ startIndex: 6, type: 'white.msdax' },
|
||||
{ startIndex: 7, type: 'keyword.msdax' },
|
||||
{ startIndex: 14, type: 'white.msdax' },
|
||||
{ startIndex: 15, type: 'identifier.msdax' },
|
||||
{ startIndex: 16, type: 'white.msdax' },
|
||||
{ startIndex: 17, type: 'operator.msdax' },
|
||||
{ startIndex: 18, type: 'white.msdax' },
|
||||
{ startIndex: 19, type: 'comment.quote.msdax' },
|
||||
{ startIndex: 21, type: 'comment.msdax' },
|
||||
{ startIndex: 39, type: 'comment.quote.msdax' },
|
||||
{ startIndex: 41, type: 'white.msdax' },
|
||||
{ startIndex: 42, type: 'number.msdax' },
|
||||
{ startIndex: 43, type: 'delimiter.msdax' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// Numbers
|
||||
[{
|
||||
line: '123',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.msdax' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '123',
|
||||
tokens: [{ startIndex: 0, type: 'number.msdax' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '-123',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'operator.msdax' },
|
||||
{ startIndex: 1, type: 'number.msdax' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '-123',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'operator.msdax' },
|
||||
{ startIndex: 1, type: 'number.msdax' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '0xaBc123',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.msdax' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '0xaBc123',
|
||||
tokens: [{ startIndex: 0, type: 'number.msdax' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '0XaBc123',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.msdax' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '0XaBc123',
|
||||
tokens: [{ startIndex: 0, type: 'number.msdax' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '0x',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.msdax' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '0x',
|
||||
tokens: [{ startIndex: 0, type: 'number.msdax' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '0x0',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.msdax' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '0x0',
|
||||
tokens: [{ startIndex: 0, type: 'number.msdax' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '0xAB_CD',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.msdax' },
|
||||
{ startIndex: 4, type: 'identifier.msdax' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '0xAB_CD',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.msdax' },
|
||||
{ startIndex: 4, type: 'identifier.msdax' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '.',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'delimiter.msdax' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '.',
|
||||
tokens: [{ startIndex: 0, type: 'delimiter.msdax' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '123',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.msdax' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '123',
|
||||
tokens: [{ startIndex: 0, type: 'number.msdax' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '123.5678',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.msdax' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '123.5678',
|
||||
tokens: [{ startIndex: 0, type: 'number.msdax' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '0.99',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.msdax' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '0.99',
|
||||
tokens: [{ startIndex: 0, type: 'number.msdax' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '.99',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.msdax' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '.99',
|
||||
tokens: [{ startIndex: 0, type: 'number.msdax' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '99.',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.msdax' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '99.',
|
||||
tokens: [{ startIndex: 0, type: 'number.msdax' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '0.',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.msdax' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '0.',
|
||||
tokens: [{ startIndex: 0, type: 'number.msdax' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '.0',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.msdax' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '.0',
|
||||
tokens: [{ startIndex: 0, type: 'number.msdax' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '1E-2',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.msdax' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '1E-2',
|
||||
tokens: [{ startIndex: 0, type: 'number.msdax' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '1E+2',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.msdax' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '1E+2',
|
||||
tokens: [{ startIndex: 0, type: 'number.msdax' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '1E2',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.msdax' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '1E2',
|
||||
tokens: [{ startIndex: 0, type: 'number.msdax' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '0.1E2',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.msdax' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '0.1E2',
|
||||
tokens: [{ startIndex: 0, type: 'number.msdax' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '1.E2',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.msdax' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '1.E2',
|
||||
tokens: [{ startIndex: 0, type: 'number.msdax' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '.1E2',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.msdax' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '.1E2',
|
||||
tokens: [{ startIndex: 0, type: 'number.msdax' }]
|
||||
}
|
||||
],
|
||||
|
||||
// Identifiers
|
||||
[{
|
||||
line: '_abc01',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'identifier.msdax' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '_abc01',
|
||||
tokens: [{ startIndex: 0, type: 'identifier.msdax' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: 'abc01',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'identifier.msdax' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'abc01',
|
||||
tokens: [{ startIndex: 0, type: 'identifier.msdax' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: 'evaluate filter',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.msdax' },
|
||||
{ startIndex: 8, type: 'white.msdax' },
|
||||
{ startIndex: 9, type: 'keyword.msdax' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'evaluate filter',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.msdax' },
|
||||
{ startIndex: 8, type: 'white.msdax' },
|
||||
{ startIndex: 9, type: 'keyword.msdax' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '[abc[[ 321 ]] xyz]',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'identifier.quote.msdax' },
|
||||
{ startIndex: 1, type: 'identifier.msdax' },
|
||||
{ startIndex: 17, type: 'identifier.quote.msdax' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '[abc[[ 321 ]] xyz]',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'identifier.quote.msdax' },
|
||||
{ startIndex: 1, type: 'identifier.msdax' },
|
||||
{ startIndex: 17, type: 'identifier.quote.msdax' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '[abc',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'identifier.quote.msdax' },
|
||||
{ startIndex: 1, type: 'identifier.msdax' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '[abc',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'identifier.quote.msdax' },
|
||||
{ startIndex: 1, type: 'identifier.msdax' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: 'define measure \'abc\'[def]',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.msdax' },
|
||||
{ startIndex: 6, type: 'white.msdax' },
|
||||
{ startIndex: 7, type: 'keyword.msdax' },
|
||||
{ startIndex: 14, type: 'white.msdax' },
|
||||
{ startIndex: 15, type: 'identifier.quote.msdax' },
|
||||
{ startIndex: 16, type: 'identifier.msdax' },
|
||||
{ startIndex: 19, type: 'identifier.quote.msdax' },
|
||||
{ startIndex: 21, type: 'identifier.msdax' },
|
||||
{ startIndex: 24, type: 'identifier.quote.msdax' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: "define measure 'abc'[def]",
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.msdax' },
|
||||
{ startIndex: 6, type: 'white.msdax' },
|
||||
{ startIndex: 7, type: 'keyword.msdax' },
|
||||
{ startIndex: 14, type: 'white.msdax' },
|
||||
{ startIndex: 15, type: 'identifier.quote.msdax' },
|
||||
{ startIndex: 16, type: 'identifier.msdax' },
|
||||
{ startIndex: 19, type: 'identifier.quote.msdax' },
|
||||
{ startIndex: 21, type: 'identifier.msdax' },
|
||||
{ startIndex: 24, type: 'identifier.quote.msdax' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: 'int',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.msdax' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'int',
|
||||
tokens: [{ startIndex: 0, type: 'keyword.msdax' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '[int]',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'identifier.quote.msdax' },
|
||||
{ startIndex: 1, type: 'identifier.msdax' },
|
||||
{ startIndex: 4, type: 'identifier.quote.msdax' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '[int]',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'identifier.quote.msdax' },
|
||||
{ startIndex: 1, type: 'identifier.msdax' },
|
||||
{ startIndex: 4, type: 'identifier.quote.msdax' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// Strings
|
||||
[{
|
||||
line: '"abc"" 321 "" xyz"',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'string.msdax' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '"abc"" 321 "" xyz"',
|
||||
tokens: [{ startIndex: 0, type: 'string.msdax' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: 'define var x=\"a string\"',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.msdax' },
|
||||
{ startIndex: 6, type: 'white.msdax' },
|
||||
{ startIndex: 7, type: 'keyword.msdax' },
|
||||
{ startIndex: 10, type: 'white.msdax' },
|
||||
{ startIndex: 11, type: 'identifier.msdax' },
|
||||
{ startIndex: 12, type: 'operator.msdax' },
|
||||
{ startIndex: 13, type: 'string.msdax' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'define var x="a string"',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.msdax' },
|
||||
{ startIndex: 6, type: 'white.msdax' },
|
||||
{ startIndex: 7, type: 'keyword.msdax' },
|
||||
{ startIndex: 10, type: 'white.msdax' },
|
||||
{ startIndex: 11, type: 'identifier.msdax' },
|
||||
{ startIndex: 12, type: 'operator.msdax' },
|
||||
{ startIndex: 13, type: 'string.msdax' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '"a "" string with quotes"',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'string.msdax' },
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '"a "" string with quotes"',
|
||||
tokens: [{ startIndex: 0, type: 'string.msdax' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '"a // string with comment"',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'string.msdax' },
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '"a // string with comment"',
|
||||
tokens: [{ startIndex: 0, type: 'string.msdax' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: 'N"a unicode string"',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'string.msdax' },
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'N"a unicode string"',
|
||||
tokens: [{ startIndex: 0, type: 'string.msdax' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '"a endless string',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'string.msdax' },
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '"a endless string',
|
||||
tokens: [{ startIndex: 0, type: 'string.msdax' }]
|
||||
}
|
||||
],
|
||||
|
||||
// Operators
|
||||
[{
|
||||
line: 'define var x=1+3',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.msdax' },
|
||||
{ startIndex: 6, type: 'white.msdax' },
|
||||
{ startIndex: 7, type: 'keyword.msdax' },
|
||||
{ startIndex: 10, type: 'white.msdax' },
|
||||
{ startIndex: 11, type: 'identifier.msdax' },
|
||||
{ startIndex: 12, type: 'operator.msdax' },
|
||||
{ startIndex: 13, type: 'number.msdax' },
|
||||
{ startIndex: 14, type: 'operator.msdax' },
|
||||
{ startIndex: 15, type: 'number.msdax' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'define var x=1+3',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.msdax' },
|
||||
{ startIndex: 6, type: 'white.msdax' },
|
||||
{ startIndex: 7, type: 'keyword.msdax' },
|
||||
{ startIndex: 10, type: 'white.msdax' },
|
||||
{ startIndex: 11, type: 'identifier.msdax' },
|
||||
{ startIndex: 12, type: 'operator.msdax' },
|
||||
{ startIndex: 13, type: 'number.msdax' },
|
||||
{ startIndex: 14, type: 'operator.msdax' },
|
||||
{ startIndex: 15, type: 'number.msdax' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: 'define var x=1^+abc',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.msdax' },
|
||||
{ startIndex: 6, type: 'white.msdax' },
|
||||
{ startIndex: 7, type: 'keyword.msdax' },
|
||||
{ startIndex: 10, type: 'white.msdax' },
|
||||
{ startIndex: 11, type: 'identifier.msdax' },
|
||||
{ startIndex: 12, type: 'operator.msdax' },
|
||||
{ startIndex: 13, type: 'number.msdax' },
|
||||
{ startIndex: 14, type: 'operator.msdax' },
|
||||
{ startIndex: 16, type: 'identifier.msdax' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'define var x=1^+abc',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.msdax' },
|
||||
{ startIndex: 6, type: 'white.msdax' },
|
||||
{ startIndex: 7, type: 'keyword.msdax' },
|
||||
{ startIndex: 10, type: 'white.msdax' },
|
||||
{ startIndex: 11, type: 'identifier.msdax' },
|
||||
{ startIndex: 12, type: 'operator.msdax' },
|
||||
{ startIndex: 13, type: 'number.msdax' },
|
||||
{ startIndex: 14, type: 'operator.msdax' },
|
||||
{ startIndex: 16, type: 'identifier.msdax' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// Realistic queries and expressions
|
||||
[{
|
||||
line: 'EVALUATE \'Products\' ORDER BY [Product Id] DESC',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.msdax' },
|
||||
{ startIndex: 8, type: 'white.msdax' },
|
||||
{ startIndex: 9, type: 'identifier.quote.msdax' },
|
||||
{ startIndex: 10, type: 'identifier.msdax' },
|
||||
{ startIndex: 18, type: 'identifier.quote.msdax' },
|
||||
{ startIndex: 19, type: 'white.msdax' },
|
||||
{ startIndex: 20, type: 'keyword.msdax' },
|
||||
{ startIndex: 25, type: 'white.msdax' },
|
||||
{ startIndex: 26, type: 'keyword.msdax' },
|
||||
{ startIndex: 28, type: 'white.msdax' },
|
||||
{ startIndex: 29, type: 'identifier.quote.msdax' },
|
||||
{ startIndex: 30, type: 'identifier.msdax' },
|
||||
{ startIndex: 40, type: 'identifier.quote.msdax' },
|
||||
{ startIndex: 41, type: 'white.msdax' },
|
||||
{ startIndex: 42, type: 'keyword.msdax' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: "EVALUATE 'Products' ORDER BY [Product Id] DESC",
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.msdax' },
|
||||
{ startIndex: 8, type: 'white.msdax' },
|
||||
{ startIndex: 9, type: 'identifier.quote.msdax' },
|
||||
{ startIndex: 10, type: 'identifier.msdax' },
|
||||
{ startIndex: 18, type: 'identifier.quote.msdax' },
|
||||
{ startIndex: 19, type: 'white.msdax' },
|
||||
{ startIndex: 20, type: 'keyword.msdax' },
|
||||
{ startIndex: 25, type: 'white.msdax' },
|
||||
{ startIndex: 26, type: 'keyword.msdax' },
|
||||
{ startIndex: 28, type: 'white.msdax' },
|
||||
{ startIndex: 29, type: 'identifier.quote.msdax' },
|
||||
{ startIndex: 30, type: 'identifier.msdax' },
|
||||
{ startIndex: 40, type: 'identifier.quote.msdax' },
|
||||
{ startIndex: 41, type: 'white.msdax' },
|
||||
{ startIndex: 42, type: 'keyword.msdax' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: 'DATATABLE("Price", STRING, {{"Low"},{"Medium"}})',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.msdax' },
|
||||
{ startIndex: 9, type: 'delimiter.parenthesis.msdax' },
|
||||
{ startIndex: 10, type: 'string.msdax' },
|
||||
{ startIndex: 17, type: 'delimiter.msdax' },
|
||||
{ startIndex: 18, type: 'white.msdax' },
|
||||
{ startIndex: 19, type: 'keyword.msdax' },
|
||||
{ startIndex: 25, type: 'delimiter.msdax' },
|
||||
{ startIndex: 26, type: 'white.msdax' },
|
||||
{ startIndex: 27, type: 'delimiter.brackets.msdax' },
|
||||
{ startIndex: 29, type: 'string.msdax' },
|
||||
{ startIndex: 34, type: 'delimiter.brackets.msdax' },
|
||||
{ startIndex: 35, type: 'delimiter.msdax' },
|
||||
{ startIndex: 36, type: 'delimiter.brackets.msdax' },
|
||||
{ startIndex: 37, type: 'string.msdax' },
|
||||
{ startIndex: 45, type: 'delimiter.brackets.msdax' },
|
||||
{ startIndex: 47, type: 'delimiter.parenthesis.msdax' }
|
||||
]
|
||||
}]
|
||||
[
|
||||
{
|
||||
line: 'DATATABLE("Price", STRING, {{"Low"},{"Medium"}})',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.msdax' },
|
||||
{ startIndex: 9, type: 'delimiter.parenthesis.msdax' },
|
||||
{ startIndex: 10, type: 'string.msdax' },
|
||||
{ startIndex: 17, type: 'delimiter.msdax' },
|
||||
{ startIndex: 18, type: 'white.msdax' },
|
||||
{ startIndex: 19, type: 'keyword.msdax' },
|
||||
{ startIndex: 25, type: 'delimiter.msdax' },
|
||||
{ startIndex: 26, type: 'white.msdax' },
|
||||
{ startIndex: 27, type: 'delimiter.brackets.msdax' },
|
||||
{ startIndex: 29, type: 'string.msdax' },
|
||||
{ startIndex: 34, type: 'delimiter.brackets.msdax' },
|
||||
{ startIndex: 35, type: 'delimiter.msdax' },
|
||||
{ startIndex: 36, type: 'delimiter.brackets.msdax' },
|
||||
{ startIndex: 37, type: 'string.msdax' },
|
||||
{ startIndex: 45, type: 'delimiter.brackets.msdax' },
|
||||
{ startIndex: 47, type: 'delimiter.parenthesis.msdax' }
|
||||
]
|
||||
}
|
||||
]
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -11,15 +11,19 @@ import ILanguage = monaco.languages.IMonarchLanguage;
|
|||
export const conf: IRichLanguageConfiguration = {
|
||||
comments: {
|
||||
lineComment: '//',
|
||||
blockComment: ['/*', '*/'],
|
||||
blockComment: ['/*', '*/']
|
||||
},
|
||||
brackets: [['[', ']'], ['(', ')'], ['{', '}']],
|
||||
brackets: [
|
||||
['[', ']'],
|
||||
['(', ')'],
|
||||
['{', '}']
|
||||
],
|
||||
autoClosingPairs: [
|
||||
{ open: '"', close: '"', notIn: ['string', 'comment'] },
|
||||
{ open: '\'', close: '\'', notIn: ['string', 'comment'] },
|
||||
{ open: "'", close: "'", notIn: ['string', 'comment'] },
|
||||
{ open: '[', close: ']', notIn: ['string', 'comment'] },
|
||||
{ open: '(', close: ')', notIn: ['string', 'comment'] },
|
||||
{ open: '{', close: '}', notIn: ['string', 'comment'] },
|
||||
{ open: '{', close: '}', notIn: ['string', 'comment'] }
|
||||
]
|
||||
};
|
||||
|
||||
|
|
@ -60,59 +64,263 @@ export const language = <ILanguage>{
|
|||
],
|
||||
functions: [
|
||||
// Relational
|
||||
'CLOSINGBALANCEMONTH', 'CLOSINGBALANCEQUARTER', 'CLOSINGBALANCEYEAR', 'DATEADD', 'DATESBETWEEN',
|
||||
'DATESINPERIOD', 'DATESMTD', 'DATESQTD', 'DATESYTD', 'ENDOFMONTH',
|
||||
'ENDOFQUARTER', 'ENDOFYEAR', 'FIRSTDATE', 'FIRSTNONBLANK', 'LASTDATE',
|
||||
'LASTNONBLANK', 'NEXTDAY', 'NEXTMONTH', 'NEXTQUARTER', 'NEXTYEAR',
|
||||
'OPENINGBALANCEMONTH', 'OPENINGBALANCEQUARTER', 'OPENINGBALANCEYEAR', 'PARALLELPERIOD', 'PREVIOUSDAY',
|
||||
'PREVIOUSMONTH', 'PREVIOUSQUARTER', 'PREVIOUSYEAR', 'SAMEPERIODLASTYEAR', 'STARTOFMONTH',
|
||||
'STARTOFQUARTER', 'STARTOFYEAR', 'TOTALMTD', 'TOTALQTD', 'TOTALYTD',
|
||||
'ADDCOLUMNS', 'ADDMISSINGITEMS', 'ALL', 'ALLEXCEPT', 'ALLNOBLANKROW',
|
||||
'ALLSELECTED', 'CALCULATE', 'CALCULATETABLE', 'CALENDAR', 'CALENDARAUTO',
|
||||
'CROSSFILTER', 'CROSSJOIN', 'CURRENTGROUP', 'DATATABLE', 'DETAILROWS',
|
||||
'DISTINCT', 'EARLIER', 'EARLIEST', 'EXCEPT', 'FILTER',
|
||||
'FILTERS', 'GENERATE', 'GENERATEALL', 'GROUPBY', 'IGNORE',
|
||||
'INTERSECT', 'ISONORAFTER', 'KEEPFILTERS', 'LOOKUPVALUE', 'NATURALINNERJOIN',
|
||||
'NATURALLEFTOUTERJOIN', 'RELATED', 'RELATEDTABLE', 'ROLLUP', 'ROLLUPADDISSUBTOTAL',
|
||||
'ROLLUPGROUP', 'ROLLUPISSUBTOTAL', 'ROW', 'SAMPLE', 'SELECTCOLUMNS',
|
||||
'SUBSTITUTEWITHINDEX', 'SUMMARIZE', 'SUMMARIZECOLUMNS', 'TOPN', 'TREATAS',
|
||||
'UNION', 'USERELATIONSHIP', 'VALUES', 'SUM', 'SUMX',
|
||||
'PATH', 'PATHCONTAINS', 'PATHITEM', 'PATHITEMREVERSE', 'PATHLENGTH',
|
||||
'AVERAGE', 'AVERAGEA', 'AVERAGEX', 'COUNT', 'COUNTA',
|
||||
'COUNTAX', 'COUNTBLANK', 'COUNTROWS', 'COUNTX', 'DISTINCTCOUNT',
|
||||
'DIVIDE', 'GEOMEAN', 'GEOMEANX', 'MAX', 'MAXA',
|
||||
'MAXX', 'MEDIAN', 'MEDIANX', 'MIN', 'MINA',
|
||||
'MINX', 'PERCENTILE.EXC', 'PERCENTILE.INC', 'PERCENTILEX.EXC', 'PERCENTILEX.INC',
|
||||
'PRODUCT', 'PRODUCTX', 'RANK.EQ', 'RANKX', 'STDEV.P',
|
||||
'STDEV.S', 'STDEVX.P', 'STDEVX.S', 'VAR.P', 'VAR.S',
|
||||
'VARX.P', 'VARX.S', 'XIRR', 'XNPV',
|
||||
'CLOSINGBALANCEMONTH',
|
||||
'CLOSINGBALANCEQUARTER',
|
||||
'CLOSINGBALANCEYEAR',
|
||||
'DATEADD',
|
||||
'DATESBETWEEN',
|
||||
'DATESINPERIOD',
|
||||
'DATESMTD',
|
||||
'DATESQTD',
|
||||
'DATESYTD',
|
||||
'ENDOFMONTH',
|
||||
'ENDOFQUARTER',
|
||||
'ENDOFYEAR',
|
||||
'FIRSTDATE',
|
||||
'FIRSTNONBLANK',
|
||||
'LASTDATE',
|
||||
'LASTNONBLANK',
|
||||
'NEXTDAY',
|
||||
'NEXTMONTH',
|
||||
'NEXTQUARTER',
|
||||
'NEXTYEAR',
|
||||
'OPENINGBALANCEMONTH',
|
||||
'OPENINGBALANCEQUARTER',
|
||||
'OPENINGBALANCEYEAR',
|
||||
'PARALLELPERIOD',
|
||||
'PREVIOUSDAY',
|
||||
'PREVIOUSMONTH',
|
||||
'PREVIOUSQUARTER',
|
||||
'PREVIOUSYEAR',
|
||||
'SAMEPERIODLASTYEAR',
|
||||
'STARTOFMONTH',
|
||||
'STARTOFQUARTER',
|
||||
'STARTOFYEAR',
|
||||
'TOTALMTD',
|
||||
'TOTALQTD',
|
||||
'TOTALYTD',
|
||||
'ADDCOLUMNS',
|
||||
'ADDMISSINGITEMS',
|
||||
'ALL',
|
||||
'ALLEXCEPT',
|
||||
'ALLNOBLANKROW',
|
||||
'ALLSELECTED',
|
||||
'CALCULATE',
|
||||
'CALCULATETABLE',
|
||||
'CALENDAR',
|
||||
'CALENDARAUTO',
|
||||
'CROSSFILTER',
|
||||
'CROSSJOIN',
|
||||
'CURRENTGROUP',
|
||||
'DATATABLE',
|
||||
'DETAILROWS',
|
||||
'DISTINCT',
|
||||
'EARLIER',
|
||||
'EARLIEST',
|
||||
'EXCEPT',
|
||||
'FILTER',
|
||||
'FILTERS',
|
||||
'GENERATE',
|
||||
'GENERATEALL',
|
||||
'GROUPBY',
|
||||
'IGNORE',
|
||||
'INTERSECT',
|
||||
'ISONORAFTER',
|
||||
'KEEPFILTERS',
|
||||
'LOOKUPVALUE',
|
||||
'NATURALINNERJOIN',
|
||||
'NATURALLEFTOUTERJOIN',
|
||||
'RELATED',
|
||||
'RELATEDTABLE',
|
||||
'ROLLUP',
|
||||
'ROLLUPADDISSUBTOTAL',
|
||||
'ROLLUPGROUP',
|
||||
'ROLLUPISSUBTOTAL',
|
||||
'ROW',
|
||||
'SAMPLE',
|
||||
'SELECTCOLUMNS',
|
||||
'SUBSTITUTEWITHINDEX',
|
||||
'SUMMARIZE',
|
||||
'SUMMARIZECOLUMNS',
|
||||
'TOPN',
|
||||
'TREATAS',
|
||||
'UNION',
|
||||
'USERELATIONSHIP',
|
||||
'VALUES',
|
||||
'SUM',
|
||||
'SUMX',
|
||||
'PATH',
|
||||
'PATHCONTAINS',
|
||||
'PATHITEM',
|
||||
'PATHITEMREVERSE',
|
||||
'PATHLENGTH',
|
||||
'AVERAGE',
|
||||
'AVERAGEA',
|
||||
'AVERAGEX',
|
||||
'COUNT',
|
||||
'COUNTA',
|
||||
'COUNTAX',
|
||||
'COUNTBLANK',
|
||||
'COUNTROWS',
|
||||
'COUNTX',
|
||||
'DISTINCTCOUNT',
|
||||
'DIVIDE',
|
||||
'GEOMEAN',
|
||||
'GEOMEANX',
|
||||
'MAX',
|
||||
'MAXA',
|
||||
'MAXX',
|
||||
'MEDIAN',
|
||||
'MEDIANX',
|
||||
'MIN',
|
||||
'MINA',
|
||||
'MINX',
|
||||
'PERCENTILE.EXC',
|
||||
'PERCENTILE.INC',
|
||||
'PERCENTILEX.EXC',
|
||||
'PERCENTILEX.INC',
|
||||
'PRODUCT',
|
||||
'PRODUCTX',
|
||||
'RANK.EQ',
|
||||
'RANKX',
|
||||
'STDEV.P',
|
||||
'STDEV.S',
|
||||
'STDEVX.P',
|
||||
'STDEVX.S',
|
||||
'VAR.P',
|
||||
'VAR.S',
|
||||
'VARX.P',
|
||||
'VARX.S',
|
||||
'XIRR',
|
||||
'XNPV',
|
||||
// Scalar
|
||||
'DATE', 'DATEDIFF', 'DATEVALUE', 'DAY', 'EDATE',
|
||||
'EOMONTH', 'HOUR', 'MINUTE', 'MONTH', 'NOW',
|
||||
'SECOND', 'TIME', 'TIMEVALUE', 'TODAY', 'WEEKDAY',
|
||||
'WEEKNUM', 'YEAR', 'YEARFRAC', 'CONTAINS', 'CONTAINSROW',
|
||||
'CUSTOMDATA', 'ERROR', 'HASONEFILTER', 'HASONEVALUE', 'ISBLANK',
|
||||
'ISCROSSFILTERED', 'ISEMPTY', 'ISERROR', 'ISEVEN', 'ISFILTERED',
|
||||
'ISLOGICAL', 'ISNONTEXT', 'ISNUMBER', 'ISODD', 'ISSUBTOTAL',
|
||||
'ISTEXT', 'USERNAME', 'USERPRINCIPALNAME', 'AND', 'FALSE',
|
||||
'IF', 'IFERROR', 'NOT', 'OR', 'SWITCH',
|
||||
'TRUE', 'ABS', 'ACOS', 'ACOSH', 'ACOT',
|
||||
'ACOTH', 'ASIN', 'ASINH', 'ATAN', 'ATANH',
|
||||
'BETA.DIST', 'BETA.INV', 'CEILING', 'CHISQ.DIST', 'CHISQ.DIST.RT',
|
||||
'CHISQ.INV', 'CHISQ.INV.RT', 'COMBIN', 'COMBINA', 'CONFIDENCE.NORM',
|
||||
'CONFIDENCE.T', 'COS', 'COSH', 'COT', 'COTH',
|
||||
'CURRENCY', 'DEGREES', 'EVEN', 'EXP', 'EXPON.DIST',
|
||||
'FACT', 'FLOOR', 'GCD', 'INT', 'ISO.CEILING',
|
||||
'LCM', 'LN', 'LOG', 'LOG10', 'MOD',
|
||||
'MROUND', 'ODD', 'PERMUT', 'PI', 'POISSON.DIST',
|
||||
'POWER', 'QUOTIENT', 'RADIANS', 'RAND', 'RANDBETWEEN',
|
||||
'ROUND', 'ROUNDDOWN', 'ROUNDUP', 'SIGN', 'SIN',
|
||||
'SINH', 'SQRT', 'SQRTPI', 'TAN', 'TANH',
|
||||
'TRUNC', 'BLANK', 'CONCATENATE', 'CONCATENATEX', 'EXACT',
|
||||
'FIND', 'FIXED', 'FORMAT', 'LEFT', 'LEN',
|
||||
'LOWER', 'MID', 'REPLACE', 'REPT', 'RIGHT',
|
||||
'SEARCH', 'SUBSTITUTE', 'TRIM', 'UNICHAR', 'UNICODE',
|
||||
'UPPER', 'VALUE'
|
||||
'DATE',
|
||||
'DATEDIFF',
|
||||
'DATEVALUE',
|
||||
'DAY',
|
||||
'EDATE',
|
||||
'EOMONTH',
|
||||
'HOUR',
|
||||
'MINUTE',
|
||||
'MONTH',
|
||||
'NOW',
|
||||
'SECOND',
|
||||
'TIME',
|
||||
'TIMEVALUE',
|
||||
'TODAY',
|
||||
'WEEKDAY',
|
||||
'WEEKNUM',
|
||||
'YEAR',
|
||||
'YEARFRAC',
|
||||
'CONTAINS',
|
||||
'CONTAINSROW',
|
||||
'CUSTOMDATA',
|
||||
'ERROR',
|
||||
'HASONEFILTER',
|
||||
'HASONEVALUE',
|
||||
'ISBLANK',
|
||||
'ISCROSSFILTERED',
|
||||
'ISEMPTY',
|
||||
'ISERROR',
|
||||
'ISEVEN',
|
||||
'ISFILTERED',
|
||||
'ISLOGICAL',
|
||||
'ISNONTEXT',
|
||||
'ISNUMBER',
|
||||
'ISODD',
|
||||
'ISSUBTOTAL',
|
||||
'ISTEXT',
|
||||
'USERNAME',
|
||||
'USERPRINCIPALNAME',
|
||||
'AND',
|
||||
'FALSE',
|
||||
'IF',
|
||||
'IFERROR',
|
||||
'NOT',
|
||||
'OR',
|
||||
'SWITCH',
|
||||
'TRUE',
|
||||
'ABS',
|
||||
'ACOS',
|
||||
'ACOSH',
|
||||
'ACOT',
|
||||
'ACOTH',
|
||||
'ASIN',
|
||||
'ASINH',
|
||||
'ATAN',
|
||||
'ATANH',
|
||||
'BETA.DIST',
|
||||
'BETA.INV',
|
||||
'CEILING',
|
||||
'CHISQ.DIST',
|
||||
'CHISQ.DIST.RT',
|
||||
'CHISQ.INV',
|
||||
'CHISQ.INV.RT',
|
||||
'COMBIN',
|
||||
'COMBINA',
|
||||
'CONFIDENCE.NORM',
|
||||
'CONFIDENCE.T',
|
||||
'COS',
|
||||
'COSH',
|
||||
'COT',
|
||||
'COTH',
|
||||
'CURRENCY',
|
||||
'DEGREES',
|
||||
'EVEN',
|
||||
'EXP',
|
||||
'EXPON.DIST',
|
||||
'FACT',
|
||||
'FLOOR',
|
||||
'GCD',
|
||||
'INT',
|
||||
'ISO.CEILING',
|
||||
'LCM',
|
||||
'LN',
|
||||
'LOG',
|
||||
'LOG10',
|
||||
'MOD',
|
||||
'MROUND',
|
||||
'ODD',
|
||||
'PERMUT',
|
||||
'PI',
|
||||
'POISSON.DIST',
|
||||
'POWER',
|
||||
'QUOTIENT',
|
||||
'RADIANS',
|
||||
'RAND',
|
||||
'RANDBETWEEN',
|
||||
'ROUND',
|
||||
'ROUNDDOWN',
|
||||
'ROUNDUP',
|
||||
'SIGN',
|
||||
'SIN',
|
||||
'SINH',
|
||||
'SQRT',
|
||||
'SQRTPI',
|
||||
'TAN',
|
||||
'TANH',
|
||||
'TRUNC',
|
||||
'BLANK',
|
||||
'CONCATENATE',
|
||||
'CONCATENATEX',
|
||||
'EXACT',
|
||||
'FIND',
|
||||
'FIXED',
|
||||
'FORMAT',
|
||||
'LEFT',
|
||||
'LEN',
|
||||
'LOWER',
|
||||
'MID',
|
||||
'REPLACE',
|
||||
'REPT',
|
||||
'RIGHT',
|
||||
'SEARCH',
|
||||
'SUBSTITUTE',
|
||||
'TRIM',
|
||||
'UNICHAR',
|
||||
'UNICODE',
|
||||
'UPPER',
|
||||
'VALUE'
|
||||
],
|
||||
tokenizer: {
|
||||
root: [
|
||||
|
|
@ -123,18 +331,19 @@ export const language = <ILanguage>{
|
|||
{ include: '@complexIdentifiers' },
|
||||
[/[;,.]/, 'delimiter'],
|
||||
[/[({})]/, '@brackets'],
|
||||
[/[a-z_][a-zA-Z0-9_]*/, {
|
||||
cases: {
|
||||
'@keywords': 'keyword',
|
||||
'@functions': 'keyword',
|
||||
'@default': 'identifier'
|
||||
[
|
||||
/[a-z_][a-zA-Z0-9_]*/,
|
||||
{
|
||||
cases: {
|
||||
'@keywords': 'keyword',
|
||||
'@functions': 'keyword',
|
||||
'@default': 'identifier'
|
||||
}
|
||||
}
|
||||
}],
|
||||
[/[<>=!%&+\-*/|~^]/, 'operator'],
|
||||
],
|
||||
whitespace: [
|
||||
[/\s+/, 'white']
|
||||
],
|
||||
[/[<>=!%&+\-*/|~^]/, 'operator']
|
||||
],
|
||||
whitespace: [[/\s+/, 'white']],
|
||||
comments: [
|
||||
[/\/\/+.*/, 'comment'],
|
||||
[/\/\*/, { token: 'comment.quote', next: '@comment' }]
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
1190
src/mysql/mysql.ts
1190
src/mysql/mysql.ts
File diff suppressed because it is too large
Load diff
|
|
@ -9,312 +9,363 @@ import { testTokenization } from '../test/testRunner';
|
|||
|
||||
testTokenization('objective-c', [
|
||||
// Keywords
|
||||
[{
|
||||
line: '-(id) initWithParams:(id<anObject>) aHandler withDeviceStateManager:(id<anotherObject>) deviceStateManager',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 1, type: 'delimiter.parenthesis.objective-c' },
|
||||
{ startIndex: 2, type: 'keyword.objective-c' },
|
||||
{ startIndex: 4, type: 'delimiter.parenthesis.objective-c' },
|
||||
{ startIndex: 5, type: 'white.objective-c' },
|
||||
{ startIndex: 6, type: 'identifier.objective-c' },
|
||||
{ startIndex: 20, type: 'delimiter.objective-c' },
|
||||
{ startIndex: 21, type: 'delimiter.parenthesis.objective-c' },
|
||||
{ startIndex: 22, type: 'keyword.objective-c' },
|
||||
{ startIndex: 24, type: 'delimiter.angle.objective-c' },
|
||||
{ startIndex: 25, type: 'identifier.objective-c' },
|
||||
{ startIndex: 33, type: 'delimiter.angle.objective-c' },
|
||||
{ startIndex: 34, type: 'delimiter.parenthesis.objective-c' },
|
||||
{ startIndex: 35, type: 'white.objective-c' },
|
||||
{ startIndex: 36, type: 'identifier.objective-c' },
|
||||
{ startIndex: 44, type: 'white.objective-c' },
|
||||
{ startIndex: 45, type: 'identifier.objective-c' },
|
||||
{ startIndex: 67, type: 'delimiter.objective-c' },
|
||||
{ startIndex: 68, type: 'delimiter.parenthesis.objective-c' },
|
||||
{ startIndex: 69, type: 'keyword.objective-c' },
|
||||
{ startIndex: 71, type: 'delimiter.angle.objective-c' },
|
||||
{ startIndex: 72, type: 'identifier.objective-c' },
|
||||
{ startIndex: 85, type: 'delimiter.angle.objective-c' },
|
||||
{ startIndex: 86, type: 'delimiter.parenthesis.objective-c' },
|
||||
{ startIndex: 87, type: 'white.objective-c' },
|
||||
{ startIndex: 88, type: 'identifier.objective-c' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line:
|
||||
'-(id) initWithParams:(id<anObject>) aHandler withDeviceStateManager:(id<anotherObject>) deviceStateManager',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 1, type: 'delimiter.parenthesis.objective-c' },
|
||||
{ startIndex: 2, type: 'keyword.objective-c' },
|
||||
{ startIndex: 4, type: 'delimiter.parenthesis.objective-c' },
|
||||
{ startIndex: 5, type: 'white.objective-c' },
|
||||
{ startIndex: 6, type: 'identifier.objective-c' },
|
||||
{ startIndex: 20, type: 'delimiter.objective-c' },
|
||||
{ startIndex: 21, type: 'delimiter.parenthesis.objective-c' },
|
||||
{ startIndex: 22, type: 'keyword.objective-c' },
|
||||
{ startIndex: 24, type: 'delimiter.angle.objective-c' },
|
||||
{ startIndex: 25, type: 'identifier.objective-c' },
|
||||
{ startIndex: 33, type: 'delimiter.angle.objective-c' },
|
||||
{ startIndex: 34, type: 'delimiter.parenthesis.objective-c' },
|
||||
{ startIndex: 35, type: 'white.objective-c' },
|
||||
{ startIndex: 36, type: 'identifier.objective-c' },
|
||||
{ startIndex: 44, type: 'white.objective-c' },
|
||||
{ startIndex: 45, type: 'identifier.objective-c' },
|
||||
{ startIndex: 67, type: 'delimiter.objective-c' },
|
||||
{ startIndex: 68, type: 'delimiter.parenthesis.objective-c' },
|
||||
{ startIndex: 69, type: 'keyword.objective-c' },
|
||||
{ startIndex: 71, type: 'delimiter.angle.objective-c' },
|
||||
{ startIndex: 72, type: 'identifier.objective-c' },
|
||||
{ startIndex: 85, type: 'delimiter.angle.objective-c' },
|
||||
{ startIndex: 86, type: 'delimiter.parenthesis.objective-c' },
|
||||
{ startIndex: 87, type: 'white.objective-c' },
|
||||
{ startIndex: 88, type: 'identifier.objective-c' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// Comments - single line
|
||||
[{
|
||||
line: '//',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.objective-c' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '//',
|
||||
tokens: [{ startIndex: 0, type: 'comment.objective-c' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: ' // a comment',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'white.objective-c' },
|
||||
{ startIndex: 4, type: 'comment.objective-c' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: ' // a comment',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'white.objective-c' },
|
||||
{ startIndex: 4, type: 'comment.objective-c' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '// a comment',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.objective-c' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '// a comment',
|
||||
tokens: [{ startIndex: 0, type: 'comment.objective-c' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '//sticky comment',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.objective-c' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '//sticky comment',
|
||||
tokens: [{ startIndex: 0, type: 'comment.objective-c' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '/almost a comment',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'operator.objective-c' },
|
||||
{ startIndex: 1, type: 'identifier.objective-c' },
|
||||
{ startIndex: 7, type: 'white.objective-c' },
|
||||
{ startIndex: 8, type: 'identifier.objective-c' },
|
||||
{ startIndex: 9, type: 'white.objective-c' },
|
||||
{ startIndex: 10, type: 'identifier.objective-c' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '/almost a comment',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'operator.objective-c' },
|
||||
{ startIndex: 1, type: 'identifier.objective-c' },
|
||||
{ startIndex: 7, type: 'white.objective-c' },
|
||||
{ startIndex: 8, type: 'identifier.objective-c' },
|
||||
{ startIndex: 9, type: 'white.objective-c' },
|
||||
{ startIndex: 10, type: 'identifier.objective-c' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '1 / 2; /* comment',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.objective-c' },
|
||||
{ startIndex: 1, type: 'white.objective-c' },
|
||||
{ startIndex: 2, type: 'operator.objective-c' },
|
||||
{ startIndex: 3, type: 'white.objective-c' },
|
||||
{ startIndex: 4, type: 'number.objective-c' },
|
||||
{ startIndex: 5, type: 'delimiter.objective-c' },
|
||||
{ startIndex: 6, type: 'white.objective-c' },
|
||||
{ startIndex: 7, type: 'comment.objective-c' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '1 / 2; /* comment',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.objective-c' },
|
||||
{ startIndex: 1, type: 'white.objective-c' },
|
||||
{ startIndex: 2, type: 'operator.objective-c' },
|
||||
{ startIndex: 3, type: 'white.objective-c' },
|
||||
{ startIndex: 4, type: 'number.objective-c' },
|
||||
{ startIndex: 5, type: 'delimiter.objective-c' },
|
||||
{ startIndex: 6, type: 'white.objective-c' },
|
||||
{ startIndex: 7, type: 'comment.objective-c' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: 'int x = 1; // my comment // is a nice one',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.objective-c' },
|
||||
{ startIndex: 3, type: 'white.objective-c' },
|
||||
{ startIndex: 4, type: 'identifier.objective-c' },
|
||||
{ startIndex: 5, type: 'white.objective-c' },
|
||||
{ startIndex: 6, type: 'operator.objective-c' },
|
||||
{ startIndex: 7, type: 'white.objective-c' },
|
||||
{ startIndex: 8, type: 'number.objective-c' },
|
||||
{ startIndex: 9, type: 'delimiter.objective-c' },
|
||||
{ startIndex: 10, type: 'white.objective-c' },
|
||||
{ startIndex: 11, type: 'comment.objective-c' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'int x = 1; // my comment // is a nice one',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.objective-c' },
|
||||
{ startIndex: 3, type: 'white.objective-c' },
|
||||
{ startIndex: 4, type: 'identifier.objective-c' },
|
||||
{ startIndex: 5, type: 'white.objective-c' },
|
||||
{ startIndex: 6, type: 'operator.objective-c' },
|
||||
{ startIndex: 7, type: 'white.objective-c' },
|
||||
{ startIndex: 8, type: 'number.objective-c' },
|
||||
{ startIndex: 9, type: 'delimiter.objective-c' },
|
||||
{ startIndex: 10, type: 'white.objective-c' },
|
||||
{ startIndex: 11, type: 'comment.objective-c' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// Comments - range comment, single line
|
||||
[{
|
||||
line: '/* a simple comment */',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.objective-c' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '/* a simple comment */',
|
||||
tokens: [{ startIndex: 0, type: 'comment.objective-c' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: 'int x = /* embedded comment */ 1;',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.objective-c' },
|
||||
{ startIndex: 3, type: 'white.objective-c' },
|
||||
{ startIndex: 4, type: 'identifier.objective-c' },
|
||||
{ startIndex: 5, type: 'white.objective-c' },
|
||||
{ startIndex: 6, type: 'operator.objective-c' },
|
||||
{ startIndex: 7, type: 'white.objective-c' },
|
||||
{ startIndex: 8, type: 'comment.objective-c' },
|
||||
{ startIndex: 30, type: 'white.objective-c' },
|
||||
{ startIndex: 31, type: 'number.objective-c' },
|
||||
{ startIndex: 32, type: 'delimiter.objective-c' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'int x = /* embedded comment */ 1;',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.objective-c' },
|
||||
{ startIndex: 3, type: 'white.objective-c' },
|
||||
{ startIndex: 4, type: 'identifier.objective-c' },
|
||||
{ startIndex: 5, type: 'white.objective-c' },
|
||||
{ startIndex: 6, type: 'operator.objective-c' },
|
||||
{ startIndex: 7, type: 'white.objective-c' },
|
||||
{ startIndex: 8, type: 'comment.objective-c' },
|
||||
{ startIndex: 30, type: 'white.objective-c' },
|
||||
{ startIndex: 31, type: 'number.objective-c' },
|
||||
{ startIndex: 32, type: 'delimiter.objective-c' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: 'int x = /* comment and syntax error*/ 1; */',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.objective-c' },
|
||||
{ startIndex: 3, type: 'white.objective-c' },
|
||||
{ startIndex: 4, type: 'identifier.objective-c' },
|
||||
{ startIndex: 5, type: 'white.objective-c' },
|
||||
{ startIndex: 6, type: 'operator.objective-c' },
|
||||
{ startIndex: 7, type: 'white.objective-c' },
|
||||
{ startIndex: 8, type: 'comment.objective-c' },
|
||||
{ startIndex: 37, type: 'white.objective-c' },
|
||||
{ startIndex: 38, type: 'number.objective-c' },
|
||||
{ startIndex: 39, type: 'delimiter.objective-c' },
|
||||
{ startIndex: 40, type: 'white.objective-c' },
|
||||
{ startIndex: 41, type: 'operator.objective-c' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'int x = /* comment and syntax error*/ 1; */',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.objective-c' },
|
||||
{ startIndex: 3, type: 'white.objective-c' },
|
||||
{ startIndex: 4, type: 'identifier.objective-c' },
|
||||
{ startIndex: 5, type: 'white.objective-c' },
|
||||
{ startIndex: 6, type: 'operator.objective-c' },
|
||||
{ startIndex: 7, type: 'white.objective-c' },
|
||||
{ startIndex: 8, type: 'comment.objective-c' },
|
||||
{ startIndex: 37, type: 'white.objective-c' },
|
||||
{ startIndex: 38, type: 'number.objective-c' },
|
||||
{ startIndex: 39, type: 'delimiter.objective-c' },
|
||||
{ startIndex: 40, type: 'white.objective-c' },
|
||||
{ startIndex: 41, type: 'operator.objective-c' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: 'x = /**/;',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'identifier.objective-c' },
|
||||
{ startIndex: 1, type: 'white.objective-c' },
|
||||
{ startIndex: 2, type: 'operator.objective-c' },
|
||||
{ startIndex: 3, type: 'white.objective-c' },
|
||||
{ startIndex: 4, type: 'comment.objective-c' },
|
||||
{ startIndex: 8, type: 'delimiter.objective-c' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'x = /**/;',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'identifier.objective-c' },
|
||||
{ startIndex: 1, type: 'white.objective-c' },
|
||||
{ startIndex: 2, type: 'operator.objective-c' },
|
||||
{ startIndex: 3, type: 'white.objective-c' },
|
||||
{ startIndex: 4, type: 'comment.objective-c' },
|
||||
{ startIndex: 8, type: 'delimiter.objective-c' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: 'x = /*/;',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'identifier.objective-c' },
|
||||
{ startIndex: 1, type: 'white.objective-c' },
|
||||
{ startIndex: 2, type: 'operator.objective-c' },
|
||||
{ startIndex: 3, type: 'white.objective-c' },
|
||||
{ startIndex: 4, type: 'comment.objective-c' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'x = /*/;',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'identifier.objective-c' },
|
||||
{ startIndex: 1, type: 'white.objective-c' },
|
||||
{ startIndex: 2, type: 'operator.objective-c' },
|
||||
{ startIndex: 3, type: 'white.objective-c' },
|
||||
{ startIndex: 4, type: 'comment.objective-c' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// Non-Alpha Keywords
|
||||
[{
|
||||
line: '#import <GTLT.h>',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.objective-c' },
|
||||
{ startIndex: 7, type: 'white.objective-c' },
|
||||
{ startIndex: 8, type: 'delimiter.angle.objective-c' },
|
||||
{ startIndex: 9, type: 'identifier.objective-c' },
|
||||
{ startIndex: 13, type: '' },
|
||||
{ startIndex: 14, type: 'identifier.objective-c' },
|
||||
{ startIndex: 15, type: 'delimiter.angle.objective-c' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '#import <GTLT.h>',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.objective-c' },
|
||||
{ startIndex: 7, type: 'white.objective-c' },
|
||||
{ startIndex: 8, type: 'delimiter.angle.objective-c' },
|
||||
{ startIndex: 9, type: 'identifier.objective-c' },
|
||||
{ startIndex: 13, type: '' },
|
||||
{ startIndex: 14, type: 'identifier.objective-c' },
|
||||
{ startIndex: 15, type: 'delimiter.angle.objective-c' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// Numbers
|
||||
[{
|
||||
line: '0 ',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.objective-c' },
|
||||
{ startIndex: 1, type: 'white.objective-c' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '0 ',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.objective-c' },
|
||||
{ startIndex: 1, type: 'white.objective-c' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '0x ',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.hex.objective-c' },
|
||||
{ startIndex: 2, type: 'white.objective-c' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '0x ',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.hex.objective-c' },
|
||||
{ startIndex: 2, type: 'white.objective-c' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '0x123 ',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.hex.objective-c' },
|
||||
{ startIndex: 5, type: 'white.objective-c' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '0x123 ',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.hex.objective-c' },
|
||||
{ startIndex: 5, type: 'white.objective-c' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '23.5 ',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.float.objective-c' },
|
||||
{ startIndex: 4, type: 'white.objective-c' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '23.5 ',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.float.objective-c' },
|
||||
{ startIndex: 4, type: 'white.objective-c' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '23.5e3 ',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.float.objective-c' },
|
||||
{ startIndex: 6, type: 'white.objective-c' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '23.5e3 ',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.float.objective-c' },
|
||||
{ startIndex: 6, type: 'white.objective-c' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '23.5E3 ',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.float.objective-c' },
|
||||
{ startIndex: 6, type: 'white.objective-c' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '23.5E3 ',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.float.objective-c' },
|
||||
{ startIndex: 6, type: 'white.objective-c' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '23.5F ',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.float.objective-c' },
|
||||
{ startIndex: 5, type: 'white.objective-c' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '23.5F ',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.float.objective-c' },
|
||||
{ startIndex: 5, type: 'white.objective-c' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '23.5f ',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.float.objective-c' },
|
||||
{ startIndex: 5, type: 'white.objective-c' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '23.5f ',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.float.objective-c' },
|
||||
{ startIndex: 5, type: 'white.objective-c' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '1.72E3F ',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.float.objective-c' },
|
||||
{ startIndex: 7, type: 'white.objective-c' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '1.72E3F ',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.float.objective-c' },
|
||||
{ startIndex: 7, type: 'white.objective-c' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '1.72E3f ',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.float.objective-c' },
|
||||
{ startIndex: 7, type: 'white.objective-c' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '1.72E3f ',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.float.objective-c' },
|
||||
{ startIndex: 7, type: 'white.objective-c' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '1.72e3F ',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.float.objective-c' },
|
||||
{ startIndex: 7, type: 'white.objective-c' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '1.72e3F ',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.float.objective-c' },
|
||||
{ startIndex: 7, type: 'white.objective-c' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '1.72e3f ',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.float.objective-c' },
|
||||
{ startIndex: 7, type: 'white.objective-c' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '1.72e3f ',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.float.objective-c' },
|
||||
{ startIndex: 7, type: 'white.objective-c' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '0+0',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.objective-c' },
|
||||
{ startIndex: 1, type: 'operator.objective-c' },
|
||||
{ startIndex: 2, type: 'number.objective-c' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '0+0',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.objective-c' },
|
||||
{ startIndex: 1, type: 'operator.objective-c' },
|
||||
{ startIndex: 2, type: 'number.objective-c' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '100+10',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.objective-c' },
|
||||
{ startIndex: 3, type: 'operator.objective-c' },
|
||||
{ startIndex: 4, type: 'number.objective-c' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '100+10',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.objective-c' },
|
||||
{ startIndex: 3, type: 'operator.objective-c' },
|
||||
{ startIndex: 4, type: 'number.objective-c' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '0 + 0',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.objective-c' },
|
||||
{ startIndex: 1, type: 'white.objective-c' },
|
||||
{ startIndex: 2, type: 'operator.objective-c' },
|
||||
{ startIndex: 3, type: 'white.objective-c' },
|
||||
{ startIndex: 4, type: 'number.objective-c' }
|
||||
]
|
||||
}]
|
||||
[
|
||||
{
|
||||
line: '0 + 0',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.objective-c' },
|
||||
{ startIndex: 1, type: 'white.objective-c' },
|
||||
{ startIndex: 2, type: 'operator.objective-c' },
|
||||
{ startIndex: 3, type: 'white.objective-c' },
|
||||
{ startIndex: 4, type: 'number.objective-c' }
|
||||
]
|
||||
}
|
||||
]
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import ILanguage = monaco.languages.IMonarchLanguage;
|
|||
export const conf: IRichLanguageConfiguration = {
|
||||
comments: {
|
||||
lineComment: '//',
|
||||
blockComment: ['/*', '*/'],
|
||||
blockComment: ['/*', '*/']
|
||||
},
|
||||
brackets: [
|
||||
['{', '}'],
|
||||
|
|
@ -23,14 +23,14 @@ export const conf: IRichLanguageConfiguration = {
|
|||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '"', close: '"' },
|
||||
{ open: '\'', close: '\'' },
|
||||
{ open: "'", close: "'" }
|
||||
],
|
||||
surroundingPairs: [
|
||||
{ open: '{', close: '}' },
|
||||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '"', close: '"' },
|
||||
{ open: '\'', close: '\'' },
|
||||
{ open: "'", close: "'" }
|
||||
]
|
||||
};
|
||||
|
||||
|
|
@ -143,7 +143,7 @@ export const language = <ILanguage>{
|
|||
'volatile',
|
||||
'void',
|
||||
|
||||
'while',
|
||||
'while'
|
||||
],
|
||||
|
||||
decpart: /\d(_?\d)*/,
|
||||
|
|
@ -159,38 +159,42 @@ export const language = <ILanguage>{
|
|||
[/[,:;]/, 'delimiter'],
|
||||
[/[{}\[\]()<>]/, '@brackets'],
|
||||
|
||||
[/[a-zA-Z@#]\w*/, {
|
||||
cases: {
|
||||
'@keywords': 'keyword',
|
||||
'@default': 'identifier'
|
||||
[
|
||||
/[a-zA-Z@#]\w*/,
|
||||
{
|
||||
cases: {
|
||||
'@keywords': 'keyword',
|
||||
'@default': 'identifier'
|
||||
}
|
||||
}
|
||||
}],
|
||||
],
|
||||
|
||||
[/[<>=\\+\\-\\*\\/\\^\\|\\~,]|and\\b|or\\b|not\\b]/, 'operator'],
|
||||
[/[<>=\\+\\-\\*\\/\\^\\|\\~,]|and\\b|or\\b|not\\b]/, 'operator']
|
||||
],
|
||||
|
||||
whitespace: [
|
||||
[/\s+/, 'white'],
|
||||
],
|
||||
whitespace: [[/\s+/, 'white']],
|
||||
|
||||
comments: [
|
||||
['\\/\\*', 'comment', '@comment'],
|
||||
['\\/\\/+.*', 'comment'],
|
||||
['\\/\\/+.*', 'comment']
|
||||
],
|
||||
|
||||
comment: [
|
||||
['\\*\\/', 'comment', '@pop'],
|
||||
['.', 'comment',],
|
||||
['.', 'comment']
|
||||
],
|
||||
|
||||
numbers: [
|
||||
[/0[xX][0-9a-fA-F]*(_?[0-9a-fA-F])*/, 'number.hex'],
|
||||
[/@decimal((\.@decpart)?([eE][\-+]?@decpart)?)[fF]*/, {
|
||||
cases: {
|
||||
'(\\d)*': 'number',
|
||||
'$0': 'number.float'
|
||||
[
|
||||
/@decimal((\.@decpart)?([eE][\-+]?@decpart)?)[fF]*/,
|
||||
{
|
||||
cases: {
|
||||
'(\\d)*': 'number',
|
||||
$0: 'number.float'
|
||||
}
|
||||
}
|
||||
}]
|
||||
]
|
||||
],
|
||||
|
||||
// Recognize strings, including those broken across lines with \ (but not without)
|
||||
|
|
|
|||
|
|
@ -8,140 +8,146 @@
|
|||
import { testTokenization } from '../test/testRunner';
|
||||
|
||||
testTokenization('pascal', [
|
||||
|
||||
// Comments - single line
|
||||
[{
|
||||
line: '//',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.pascal' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '//',
|
||||
tokens: [{ startIndex: 0, type: 'comment.pascal' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: ' // a comment',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'white.pascal' },
|
||||
{ startIndex: 4, type: 'comment.pascal' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: ' // a comment',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'white.pascal' },
|
||||
{ startIndex: 4, type: 'comment.pascal' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '// a comment',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.pascal' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '// a comment',
|
||||
tokens: [{ startIndex: 0, type: 'comment.pascal' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '//sticky comment',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.pascal' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '//sticky comment',
|
||||
tokens: [{ startIndex: 0, type: 'comment.pascal' }]
|
||||
}
|
||||
],
|
||||
|
||||
// Comments - multi line (single line)
|
||||
[{
|
||||
line: '{}',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.pascal' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '{}',
|
||||
tokens: [{ startIndex: 0, type: 'comment.pascal' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: ' { a comment }',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'white.pascal' },
|
||||
{ startIndex: 4, type: 'comment.pascal' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: ' { a comment }',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'white.pascal' },
|
||||
{ startIndex: 4, type: 'comment.pascal' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '{ a comment }',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.pascal' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '{ a comment }',
|
||||
tokens: [{ startIndex: 0, type: 'comment.pascal' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '{sticky comment}',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.pascal' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '{sticky comment}',
|
||||
tokens: [{ startIndex: 0, type: 'comment.pascal' }]
|
||||
}
|
||||
],
|
||||
|
||||
// Comments - multi line (multi line)
|
||||
[{
|
||||
line: '{ start of multiline comment ',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.pascal' }
|
||||
]
|
||||
}, {
|
||||
line: 'a comment between curly',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.pascal'}
|
||||
]
|
||||
}, {
|
||||
line: 'end of multiline comment}',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.pascal'}
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '{ start of multiline comment ',
|
||||
tokens: [{ startIndex: 0, type: 'comment.pascal' }]
|
||||
},
|
||||
{
|
||||
line: 'a comment between curly',
|
||||
tokens: [{ startIndex: 0, type: 'comment.pascal' }]
|
||||
},
|
||||
{
|
||||
line: 'end of multiline comment}',
|
||||
tokens: [{ startIndex: 0, type: 'comment.pascal' }]
|
||||
}
|
||||
],
|
||||
|
||||
// Keywords
|
||||
[{
|
||||
line: 'program Test; begin writeln(\'hello\'); end.',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.program.pascal'},
|
||||
{ startIndex: 7, type: 'white.pascal'},
|
||||
{ startIndex: 8, type: 'identifier.pascal'},
|
||||
{ startIndex: 12, type: 'delimiter.pascal'},
|
||||
{ startIndex: 13, type: 'white.pascal'},
|
||||
{ startIndex: 14, type: 'keyword.begin.pascal'},
|
||||
{ startIndex: 19, type: 'white.pascal'},
|
||||
{ startIndex: 20, type: 'identifier.pascal'},
|
||||
{ startIndex: 27, type: 'delimiter.parenthesis.pascal'},
|
||||
{ startIndex: 28, type: 'string.pascal'},
|
||||
{ startIndex: 34, type: 'string.quote.pascal'},
|
||||
{ startIndex: 35, type: 'delimiter.parenthesis.pascal'},
|
||||
{ startIndex: 36, type: 'delimiter.pascal'},
|
||||
{ startIndex: 37, type: 'white.pascal'},
|
||||
{ startIndex: 38, type: 'keyword.end.pascal'},
|
||||
{ startIndex: 41, type: 'delimiter.pascal'},
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: "program Test; begin writeln('hello'); end.",
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.program.pascal' },
|
||||
{ startIndex: 7, type: 'white.pascal' },
|
||||
{ startIndex: 8, type: 'identifier.pascal' },
|
||||
{ startIndex: 12, type: 'delimiter.pascal' },
|
||||
{ startIndex: 13, type: 'white.pascal' },
|
||||
{ startIndex: 14, type: 'keyword.begin.pascal' },
|
||||
{ startIndex: 19, type: 'white.pascal' },
|
||||
{ startIndex: 20, type: 'identifier.pascal' },
|
||||
{ startIndex: 27, type: 'delimiter.parenthesis.pascal' },
|
||||
{ startIndex: 28, type: 'string.pascal' },
|
||||
{ startIndex: 34, type: 'string.quote.pascal' },
|
||||
{ startIndex: 35, type: 'delimiter.parenthesis.pascal' },
|
||||
{ startIndex: 36, type: 'delimiter.pascal' },
|
||||
{ startIndex: 37, type: 'white.pascal' },
|
||||
{ startIndex: 38, type: 'keyword.end.pascal' },
|
||||
{ startIndex: 41, type: 'delimiter.pascal' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// Numbers
|
||||
[{
|
||||
line: '0',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.pascal'}
|
||||
]
|
||||
}],
|
||||
[{
|
||||
line: '0;',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.pascal'},
|
||||
{ startIndex: 1, type: 'delimiter.pascal'}
|
||||
]
|
||||
}],
|
||||
[{
|
||||
line: '2.4',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.float.pascal'}
|
||||
]
|
||||
}],
|
||||
[{
|
||||
line: '2.4;',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.float.pascal'},
|
||||
{ startIndex: 3, type: 'delimiter.pascal'}
|
||||
]
|
||||
}],
|
||||
[{
|
||||
line: '$123FF',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.hex.pascal'}
|
||||
]
|
||||
}]
|
||||
|
||||
[
|
||||
{
|
||||
line: '0',
|
||||
tokens: [{ startIndex: 0, type: 'number.pascal' }]
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
line: '0;',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.pascal' },
|
||||
{ startIndex: 1, type: 'delimiter.pascal' }
|
||||
]
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
line: '2.4',
|
||||
tokens: [{ startIndex: 0, type: 'number.float.pascal' }]
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
line: '2.4;',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.float.pascal' },
|
||||
{ startIndex: 3, type: 'delimiter.pascal' }
|
||||
]
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
line: '$123FF',
|
||||
tokens: [{ startIndex: 0, type: 'number.hex.pascal' }]
|
||||
}
|
||||
]
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -13,32 +13,32 @@ export const conf: IRichLanguageConfiguration = {
|
|||
wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g,
|
||||
comments: {
|
||||
lineComment: '//',
|
||||
blockComment: ['{', '}'],
|
||||
blockComment: ['{', '}']
|
||||
},
|
||||
brackets: [
|
||||
['{', '}'],
|
||||
['[', ']'],
|
||||
['(', ')'],
|
||||
['<', '>'],
|
||||
['<', '>']
|
||||
],
|
||||
autoClosingPairs: [
|
||||
{ open: '{', close: '}' },
|
||||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '<', close: '>' },
|
||||
{ open: '\'', close: '\'' },
|
||||
{ open: "'", close: "'" }
|
||||
],
|
||||
surroundingPairs: [
|
||||
{ open: '{', close: '}' },
|
||||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '<', close: '>' },
|
||||
{ open: '\'', close: '\'' },
|
||||
{ open: "'", close: "'" }
|
||||
],
|
||||
folding: {
|
||||
markers: {
|
||||
start: new RegExp("^\\s*\\{\\$REGION(\\s\\'.*\\')?\\}"),
|
||||
end: new RegExp("^\\s*\\{\\$ENDREGION\\}")
|
||||
end: new RegExp('^\\s*\\{\\$ENDREGION\\}')
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -56,33 +56,147 @@ export const language = <ILanguage>{
|
|||
],
|
||||
|
||||
keywords: [
|
||||
'absolute', 'abstract', 'all', 'and_then', 'array', 'as', 'asm',
|
||||
'attribute', 'begin', 'bindable', 'case', 'class', 'const',
|
||||
'contains', 'default', 'div', 'else', 'end', 'except',
|
||||
'exports', 'external', 'far', 'file', 'finalization', 'finally',
|
||||
'forward', 'generic', 'goto', 'if', 'implements', 'import', 'in',
|
||||
'index', 'inherited', 'initialization', 'interrupt', 'is', 'label',
|
||||
'library', 'mod', 'module', 'name', 'near', 'not', 'object', 'of',
|
||||
'on', 'only', 'operator', 'or_else', 'otherwise', 'override',
|
||||
'package', 'packed', 'pow', 'private', 'program', 'protected',
|
||||
'public', 'published', 'interface', 'implementation', 'qualified',
|
||||
'read', 'record', 'resident', 'requires', 'resourcestring',
|
||||
'restricted', 'segment', 'set', 'shl', 'shr', 'specialize', 'stored',
|
||||
'then', 'threadvar', 'to', 'try', 'type', 'unit', 'uses', 'var',
|
||||
'view', 'virtual', 'dynamic', 'overload', 'reintroduce', 'with',
|
||||
'write', 'xor', 'true', 'false', 'procedure', 'function',
|
||||
'constructor','destructor','property', 'break', 'continue', 'exit',
|
||||
'abort', 'while', 'do', 'for', 'raise', 'repeat','until'
|
||||
'absolute',
|
||||
'abstract',
|
||||
'all',
|
||||
'and_then',
|
||||
'array',
|
||||
'as',
|
||||
'asm',
|
||||
'attribute',
|
||||
'begin',
|
||||
'bindable',
|
||||
'case',
|
||||
'class',
|
||||
'const',
|
||||
'contains',
|
||||
'default',
|
||||
'div',
|
||||
'else',
|
||||
'end',
|
||||
'except',
|
||||
'exports',
|
||||
'external',
|
||||
'far',
|
||||
'file',
|
||||
'finalization',
|
||||
'finally',
|
||||
'forward',
|
||||
'generic',
|
||||
'goto',
|
||||
'if',
|
||||
'implements',
|
||||
'import',
|
||||
'in',
|
||||
'index',
|
||||
'inherited',
|
||||
'initialization',
|
||||
'interrupt',
|
||||
'is',
|
||||
'label',
|
||||
'library',
|
||||
'mod',
|
||||
'module',
|
||||
'name',
|
||||
'near',
|
||||
'not',
|
||||
'object',
|
||||
'of',
|
||||
'on',
|
||||
'only',
|
||||
'operator',
|
||||
'or_else',
|
||||
'otherwise',
|
||||
'override',
|
||||
'package',
|
||||
'packed',
|
||||
'pow',
|
||||
'private',
|
||||
'program',
|
||||
'protected',
|
||||
'public',
|
||||
'published',
|
||||
'interface',
|
||||
'implementation',
|
||||
'qualified',
|
||||
'read',
|
||||
'record',
|
||||
'resident',
|
||||
'requires',
|
||||
'resourcestring',
|
||||
'restricted',
|
||||
'segment',
|
||||
'set',
|
||||
'shl',
|
||||
'shr',
|
||||
'specialize',
|
||||
'stored',
|
||||
'then',
|
||||
'threadvar',
|
||||
'to',
|
||||
'try',
|
||||
'type',
|
||||
'unit',
|
||||
'uses',
|
||||
'var',
|
||||
'view',
|
||||
'virtual',
|
||||
'dynamic',
|
||||
'overload',
|
||||
'reintroduce',
|
||||
'with',
|
||||
'write',
|
||||
'xor',
|
||||
'true',
|
||||
'false',
|
||||
'procedure',
|
||||
'function',
|
||||
'constructor',
|
||||
'destructor',
|
||||
'property',
|
||||
'break',
|
||||
'continue',
|
||||
'exit',
|
||||
'abort',
|
||||
'while',
|
||||
'do',
|
||||
'for',
|
||||
'raise',
|
||||
'repeat',
|
||||
'until'
|
||||
],
|
||||
|
||||
typeKeywords: [
|
||||
'boolean', 'double', 'byte', 'integer', 'shortint', 'char',
|
||||
'longint', 'float', 'string'
|
||||
'boolean',
|
||||
'double',
|
||||
'byte',
|
||||
'integer',
|
||||
'shortint',
|
||||
'char',
|
||||
'longint',
|
||||
'float',
|
||||
'string'
|
||||
],
|
||||
|
||||
operators: [
|
||||
'=', '>', '<', '<=', '>=', '<>', ':', ':=', 'and', 'or',
|
||||
'+', '-', '*', '/', '@', '&', '^', '%'
|
||||
'=',
|
||||
'>',
|
||||
'<',
|
||||
'<=',
|
||||
'>=',
|
||||
'<>',
|
||||
':',
|
||||
':=',
|
||||
'and',
|
||||
'or',
|
||||
'+',
|
||||
'-',
|
||||
'*',
|
||||
'/',
|
||||
'@',
|
||||
'&',
|
||||
'^',
|
||||
'%'
|
||||
],
|
||||
|
||||
// we include these common regular expressions
|
||||
|
|
@ -92,12 +206,15 @@ export const language = <ILanguage>{
|
|||
tokenizer: {
|
||||
root: [
|
||||
// identifiers and keywords
|
||||
[/[a-zA-Z_][\w]*/, {
|
||||
cases: {
|
||||
'@keywords': { token: 'keyword.$0' },
|
||||
'@default': 'identifier'
|
||||
[
|
||||
/[a-zA-Z_][\w]*/,
|
||||
{
|
||||
cases: {
|
||||
'@keywords': { token: 'keyword.$0' },
|
||||
'@default': 'identifier'
|
||||
}
|
||||
}
|
||||
}],
|
||||
],
|
||||
|
||||
// whitespace
|
||||
{ include: '@whitespace' },
|
||||
|
|
@ -105,12 +222,15 @@ export const language = <ILanguage>{
|
|||
// delimiters and operators
|
||||
[/[{}()\[\]]/, '@brackets'],
|
||||
[/[<>](?!@symbols)/, '@brackets'],
|
||||
[/@symbols/, {
|
||||
cases: {
|
||||
'@operators': 'delimiter',
|
||||
'@default': ''
|
||||
[
|
||||
/@symbols/,
|
||||
{
|
||||
cases: {
|
||||
'@operators': 'delimiter',
|
||||
'@default': ''
|
||||
}
|
||||
}
|
||||
}],
|
||||
],
|
||||
|
||||
// numbers
|
||||
[/\d*\.\d+([eE][\-+]?\d+)?/, 'number.float'],
|
||||
|
|
@ -121,32 +241,32 @@ export const language = <ILanguage>{
|
|||
[/[;,.]/, 'delimiter'],
|
||||
|
||||
// strings
|
||||
[/'([^'\\]|\\.)*$/, 'string.invalid'], // non-teminated string
|
||||
[/'([^'\\]|\\.)*$/, 'string.invalid'], // non-teminated string
|
||||
[/'/, 'string', '@string'],
|
||||
|
||||
// characters
|
||||
[/'[^\\']'/, 'string'],
|
||||
[/'/, 'string.invalid'],
|
||||
[/\#\d+/,'string']
|
||||
[/\#\d+/, 'string']
|
||||
],
|
||||
|
||||
comment: [
|
||||
[/[^\*\}]+/, 'comment' ],
|
||||
[/[^\*\}]+/, 'comment'],
|
||||
//[/\(\*/, 'comment', '@push' ], // nested comment not allowed :-(
|
||||
[/\}/, 'comment', '@pop' ],
|
||||
[/[\{]/, 'comment' ]
|
||||
],
|
||||
[/\}/, 'comment', '@pop'],
|
||||
[/[\{]/, 'comment']
|
||||
],
|
||||
|
||||
string: [
|
||||
[/[^\\']+/, 'string'],
|
||||
[/\\./, 'string.escape.invalid'],
|
||||
[/'/, { token: 'string.quote', bracket: '@close', next: '@pop' } ]
|
||||
[/[^\\']+/, 'string'],
|
||||
[/\\./, 'string.escape.invalid'],
|
||||
[/'/, { token: 'string.quote', bracket: '@close', next: '@pop' }]
|
||||
],
|
||||
|
||||
whitespace: [
|
||||
[/[ \t\r\n]+/, 'white'],
|
||||
[/\{/, 'comment', '@comment' ],
|
||||
[/\/\/.*$/, 'comment'],
|
||||
],
|
||||
},
|
||||
[/\{/, 'comment', '@comment'],
|
||||
[/\/\/.*$/, 'comment']
|
||||
]
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -8,132 +8,138 @@
|
|||
import { testTokenization } from '../test/testRunner';
|
||||
|
||||
testTokenization('pascaligo', [
|
||||
|
||||
// Comments - single line
|
||||
[{
|
||||
line: '//',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.pascaligo' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '//',
|
||||
tokens: [{ startIndex: 0, type: 'comment.pascaligo' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: ' // a comment',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'white.pascaligo' },
|
||||
{ startIndex: 4, type: 'comment.pascaligo' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: ' // a comment',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'white.pascaligo' },
|
||||
{ startIndex: 4, type: 'comment.pascaligo' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '// a comment',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.pascaligo' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '// a comment',
|
||||
tokens: [{ startIndex: 0, type: 'comment.pascaligo' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '//sticky comment',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.pascaligo' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '//sticky comment',
|
||||
tokens: [{ startIndex: 0, type: 'comment.pascaligo' }]
|
||||
}
|
||||
],
|
||||
|
||||
// Comments - multi line (single line)
|
||||
[{
|
||||
line: '(**)',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.pascaligo' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '(**)',
|
||||
tokens: [{ startIndex: 0, type: 'comment.pascaligo' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: ' (* a comment *)',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'white.pascaligo' },
|
||||
{ startIndex: 4, type: 'comment.pascaligo' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: ' (* a comment *)',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'white.pascaligo' },
|
||||
{ startIndex: 4, type: 'comment.pascaligo' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '(* a comment *)',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.pascaligo' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '(* a comment *)',
|
||||
tokens: [{ startIndex: 0, type: 'comment.pascaligo' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '(*sticky comment*)',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.pascaligo' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '(*sticky comment*)',
|
||||
tokens: [{ startIndex: 0, type: 'comment.pascaligo' }]
|
||||
}
|
||||
],
|
||||
|
||||
// Comments - multi line (multi line)
|
||||
[{
|
||||
line: '(* start of multiline comment ',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.pascaligo' }
|
||||
]
|
||||
}, {
|
||||
line: 'a comment between curly',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.pascaligo'}
|
||||
]
|
||||
}, {
|
||||
line: 'end of multiline comment*)',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.pascaligo'}
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '(* start of multiline comment ',
|
||||
tokens: [{ startIndex: 0, type: 'comment.pascaligo' }]
|
||||
},
|
||||
{
|
||||
line: 'a comment between curly',
|
||||
tokens: [{ startIndex: 0, type: 'comment.pascaligo' }]
|
||||
},
|
||||
{
|
||||
line: 'end of multiline comment*)',
|
||||
tokens: [{ startIndex: 0, type: 'comment.pascaligo' }]
|
||||
}
|
||||
],
|
||||
|
||||
// Keywords
|
||||
[{
|
||||
line: 'function add (const a',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.function.pascaligo'},
|
||||
{ startIndex: 8, type: 'white.pascaligo'},
|
||||
{ startIndex: 9, type: 'identifier.pascaligo'},
|
||||
{ startIndex: 12, type: 'white.pascaligo'},
|
||||
{ startIndex: 13, type: 'delimiter.parenthesis.pascaligo'},
|
||||
{ startIndex: 14, type: 'keyword.const.pascaligo'},
|
||||
{ startIndex: 19, type: 'white.pascaligo'},
|
||||
{ startIndex: 20, type: 'identifier.pascaligo'},
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'function add (const a',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.function.pascaligo' },
|
||||
{ startIndex: 8, type: 'white.pascaligo' },
|
||||
{ startIndex: 9, type: 'identifier.pascaligo' },
|
||||
{ startIndex: 12, type: 'white.pascaligo' },
|
||||
{ startIndex: 13, type: 'delimiter.parenthesis.pascaligo' },
|
||||
{ startIndex: 14, type: 'keyword.const.pascaligo' },
|
||||
{ startIndex: 19, type: 'white.pascaligo' },
|
||||
{ startIndex: 20, type: 'identifier.pascaligo' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// Numbers
|
||||
[{
|
||||
line: '0',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.pascaligo'}
|
||||
]
|
||||
}],
|
||||
[{
|
||||
line: '0;',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.pascaligo'},
|
||||
{ startIndex: 1, type: 'delimiter.pascaligo'}
|
||||
]
|
||||
}],
|
||||
[{
|
||||
line: '2.4',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.float.pascaligo'}
|
||||
]
|
||||
}],
|
||||
[{
|
||||
line: '2.4;',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.float.pascaligo'},
|
||||
{ startIndex: 3, type: 'delimiter.pascaligo'}
|
||||
]
|
||||
}],
|
||||
[{
|
||||
line: '$123FF',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.hex.pascaligo'}
|
||||
]
|
||||
}]
|
||||
|
||||
[
|
||||
{
|
||||
line: '0',
|
||||
tokens: [{ startIndex: 0, type: 'number.pascaligo' }]
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
line: '0;',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.pascaligo' },
|
||||
{ startIndex: 1, type: 'delimiter.pascaligo' }
|
||||
]
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
line: '2.4',
|
||||
tokens: [{ startIndex: 0, type: 'number.float.pascaligo' }]
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
line: '2.4;',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.float.pascaligo' },
|
||||
{ startIndex: 3, type: 'delimiter.pascaligo' }
|
||||
]
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
line: '$123FF',
|
||||
tokens: [{ startIndex: 0, type: 'number.hex.pascaligo' }]
|
||||
}
|
||||
]
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -11,27 +11,27 @@ import ILanguage = monaco.languages.IMonarchLanguage;
|
|||
export const conf: IRichLanguageConfiguration = {
|
||||
comments: {
|
||||
lineComment: '//',
|
||||
blockComment: ['(*', '*)'],
|
||||
blockComment: ['(*', '*)']
|
||||
},
|
||||
brackets: [
|
||||
['{', '}'],
|
||||
['[', ']'],
|
||||
['(', ')'],
|
||||
['<', '>'],
|
||||
['<', '>']
|
||||
],
|
||||
autoClosingPairs: [
|
||||
{ open: '{', close: '}' },
|
||||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '<', close: '>' },
|
||||
{ open: '\'', close: '\'' },
|
||||
{ open: "'", close: "'" }
|
||||
],
|
||||
surroundingPairs: [
|
||||
{ open: '{', close: '}' },
|
||||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '<', close: '>' },
|
||||
{ open: '\'', close: '\'' },
|
||||
{ open: "'", close: "'" }
|
||||
]
|
||||
};
|
||||
|
||||
|
|
@ -48,20 +48,68 @@ export const language = <ILanguage>{
|
|||
],
|
||||
|
||||
keywords: [
|
||||
'begin', 'block', 'case', 'const', 'else', 'end',
|
||||
'fail', 'for', 'from', 'function', 'if', 'is', 'nil',
|
||||
'of', 'remove', 'return', 'skip', 'then', 'type', 'var',
|
||||
'while', 'with', 'option', 'None', 'transaction'
|
||||
'begin',
|
||||
'block',
|
||||
'case',
|
||||
'const',
|
||||
'else',
|
||||
'end',
|
||||
'fail',
|
||||
'for',
|
||||
'from',
|
||||
'function',
|
||||
'if',
|
||||
'is',
|
||||
'nil',
|
||||
'of',
|
||||
'remove',
|
||||
'return',
|
||||
'skip',
|
||||
'then',
|
||||
'type',
|
||||
'var',
|
||||
'while',
|
||||
'with',
|
||||
'option',
|
||||
'None',
|
||||
'transaction'
|
||||
],
|
||||
|
||||
typeKeywords: [
|
||||
'bool', 'int', 'list', 'map', 'nat', 'record',
|
||||
'string', 'unit', 'address', 'map', 'mtz', 'xtz'
|
||||
'bool',
|
||||
'int',
|
||||
'list',
|
||||
'map',
|
||||
'nat',
|
||||
'record',
|
||||
'string',
|
||||
'unit',
|
||||
'address',
|
||||
'map',
|
||||
'mtz',
|
||||
'xtz'
|
||||
],
|
||||
|
||||
operators: [
|
||||
'=', '>', '<', '<=', '>=', '<>', ':', ':=', 'and', 'mod', 'or',
|
||||
'+', '-', '*', '/', '@', '&', '^', '%'
|
||||
'=',
|
||||
'>',
|
||||
'<',
|
||||
'<=',
|
||||
'>=',
|
||||
'<>',
|
||||
':',
|
||||
':=',
|
||||
'and',
|
||||
'mod',
|
||||
'or',
|
||||
'+',
|
||||
'-',
|
||||
'*',
|
||||
'/',
|
||||
'@',
|
||||
'&',
|
||||
'^',
|
||||
'%'
|
||||
],
|
||||
|
||||
// we include these common regular expressions
|
||||
|
|
@ -71,12 +119,15 @@ export const language = <ILanguage>{
|
|||
tokenizer: {
|
||||
root: [
|
||||
// identifiers and keywords
|
||||
[/[a-zA-Z_][\w]*/, {
|
||||
cases: {
|
||||
'@keywords': { token: 'keyword.$0' },
|
||||
'@default': 'identifier'
|
||||
[
|
||||
/[a-zA-Z_][\w]*/,
|
||||
{
|
||||
cases: {
|
||||
'@keywords': { token: 'keyword.$0' },
|
||||
'@default': 'identifier'
|
||||
}
|
||||
}
|
||||
}],
|
||||
],
|
||||
|
||||
// whitespace
|
||||
{ include: '@whitespace' },
|
||||
|
|
@ -84,12 +135,15 @@ export const language = <ILanguage>{
|
|||
// delimiters and operators
|
||||
[/[{}()\[\]]/, '@brackets'],
|
||||
[/[<>](?!@symbols)/, '@brackets'],
|
||||
[/@symbols/, {
|
||||
cases: {
|
||||
'@operators': 'delimiter',
|
||||
'@default': ''
|
||||
[
|
||||
/@symbols/,
|
||||
{
|
||||
cases: {
|
||||
'@operators': 'delimiter',
|
||||
'@default': ''
|
||||
}
|
||||
}
|
||||
}],
|
||||
],
|
||||
|
||||
// numbers
|
||||
[/\d*\.\d+([eE][\-+]?\d+)?/, 'number.float'],
|
||||
|
|
@ -100,33 +154,33 @@ export const language = <ILanguage>{
|
|||
[/[;,.]/, 'delimiter'],
|
||||
|
||||
// strings
|
||||
[/'([^'\\]|\\.)*$/, 'string.invalid'], // non-teminated string
|
||||
[/'([^'\\]|\\.)*$/, 'string.invalid'], // non-teminated string
|
||||
[/'/, 'string', '@string'],
|
||||
|
||||
// characters
|
||||
[/'[^\\']'/, 'string'],
|
||||
[/'/, 'string.invalid'],
|
||||
[/\#\d+/,'string']
|
||||
[/\#\d+/, 'string']
|
||||
],
|
||||
/* */
|
||||
|
||||
comment: [
|
||||
[/[^\(\*]+/, 'comment' ],
|
||||
[/[^\(\*]+/, 'comment'],
|
||||
//[/\(\*/, 'comment', '@push' ], // nested comment not allowed :-(
|
||||
[/\*\)/, 'comment', '@pop' ],
|
||||
[/\(\*/, 'comment' ]
|
||||
[/\*\)/, 'comment', '@pop'],
|
||||
[/\(\*/, 'comment']
|
||||
],
|
||||
|
||||
string: [
|
||||
[/[^\\']+/, 'string'],
|
||||
[/\\./, 'string.escape.invalid'],
|
||||
[/'/, { token: 'string.quote', bracket: '@close', next: '@pop' } ]
|
||||
[/[^\\']+/, 'string'],
|
||||
[/\\./, 'string.escape.invalid'],
|
||||
[/'/, { token: 'string.quote', bracket: '@close', next: '@pop' }]
|
||||
],
|
||||
|
||||
whitespace: [
|
||||
[/[ \t\r\n]+/, 'white'],
|
||||
[/\(\*/, 'comment', '@comment' ],
|
||||
[/\/\/.*$/, 'comment'],
|
||||
],
|
||||
},
|
||||
[/\(\*/, 'comment', '@comment'],
|
||||
[/\/\/.*$/, 'comment']
|
||||
]
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import { registerLanguage } from '../_.contribution';
|
||||
|
|
@ -10,5 +10,5 @@ registerLanguage({
|
|||
id: 'perl',
|
||||
extensions: ['.pl'],
|
||||
aliases: ['Perl', 'pl'],
|
||||
loader: () => import('./perl'),
|
||||
loader: () => import('./perl')
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import { testTokenization } from '../test/testRunner';
|
||||
|
|
@ -14,9 +14,9 @@ testTokenization('perl', [
|
|||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.perl' },
|
||||
{ startIndex: 2, type: 'white.perl' },
|
||||
{ startIndex: 3, type: 'variable.perl' },
|
||||
],
|
||||
},
|
||||
{ startIndex: 3, type: 'variable.perl' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// Builtins
|
||||
|
|
@ -26,25 +26,25 @@ testTokenization('perl', [
|
|||
tokens: [
|
||||
{ startIndex: 0, type: 'type.identifier.perl' },
|
||||
{ startIndex: 3, type: 'white.perl' },
|
||||
{ startIndex: 4, type: 'variable.predefined.perl' },
|
||||
],
|
||||
},
|
||||
{ startIndex: 4, type: 'variable.predefined.perl' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// Shebang
|
||||
[
|
||||
{
|
||||
line: '#!/bin/env perl',
|
||||
tokens: [{ startIndex: 0, type: 'metatag.perl' }],
|
||||
},
|
||||
tokens: [{ startIndex: 0, type: 'metatag.perl' }]
|
||||
}
|
||||
],
|
||||
|
||||
// Comments - single line
|
||||
[
|
||||
{
|
||||
line: '#',
|
||||
tokens: [{ startIndex: 0, type: 'comment.perl' }],
|
||||
},
|
||||
tokens: [{ startIndex: 0, type: 'comment.perl' }]
|
||||
}
|
||||
],
|
||||
|
||||
[
|
||||
|
|
@ -52,66 +52,66 @@ testTokenization('perl', [
|
|||
line: ' # a comment',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'white.perl' },
|
||||
{ startIndex: 4, type: 'comment.perl' },
|
||||
],
|
||||
},
|
||||
{ startIndex: 4, type: 'comment.perl' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[
|
||||
{
|
||||
line: '# a comment',
|
||||
tokens: [{ startIndex: 0, type: 'comment.perl' }],
|
||||
},
|
||||
tokens: [{ startIndex: 0, type: 'comment.perl' }]
|
||||
}
|
||||
],
|
||||
|
||||
// number
|
||||
[
|
||||
{
|
||||
line: '0',
|
||||
tokens: [{ startIndex: 0, type: 'number.perl' }],
|
||||
},
|
||||
tokens: [{ startIndex: 0, type: 'number.perl' }]
|
||||
}
|
||||
],
|
||||
|
||||
[
|
||||
{
|
||||
line: '0.0',
|
||||
tokens: [{ startIndex: 0, type: 'number.float.perl' }],
|
||||
},
|
||||
tokens: [{ startIndex: 0, type: 'number.float.perl' }]
|
||||
}
|
||||
],
|
||||
|
||||
[
|
||||
{
|
||||
line: '0x123',
|
||||
tokens: [{ startIndex: 0, type: 'number.hex.perl' }],
|
||||
},
|
||||
tokens: [{ startIndex: 0, type: 'number.hex.perl' }]
|
||||
}
|
||||
],
|
||||
|
||||
[
|
||||
{
|
||||
line: '23.5',
|
||||
tokens: [{ startIndex: 0, type: 'number.float.perl' }],
|
||||
},
|
||||
tokens: [{ startIndex: 0, type: 'number.float.perl' }]
|
||||
}
|
||||
],
|
||||
|
||||
[
|
||||
{
|
||||
line: '23.5e3',
|
||||
tokens: [{ startIndex: 0, type: 'number.float.perl' }],
|
||||
},
|
||||
tokens: [{ startIndex: 0, type: 'number.float.perl' }]
|
||||
}
|
||||
],
|
||||
|
||||
[
|
||||
{
|
||||
line: '23.5E3',
|
||||
tokens: [{ startIndex: 0, type: 'number.float.perl' }],
|
||||
},
|
||||
tokens: [{ startIndex: 0, type: 'number.float.perl' }]
|
||||
}
|
||||
],
|
||||
|
||||
[
|
||||
{
|
||||
line: '1.72e-3',
|
||||
tokens: [{ startIndex: 0, type: 'number.float.perl' }],
|
||||
},
|
||||
tokens: [{ startIndex: 0, type: 'number.float.perl' }]
|
||||
}
|
||||
],
|
||||
|
||||
[
|
||||
|
|
@ -120,9 +120,9 @@ testTokenization('perl', [
|
|||
tokens: [
|
||||
{ startIndex: 0, type: 'number.perl' },
|
||||
{ startIndex: 1, type: 'operators.perl' },
|
||||
{ startIndex: 2, type: 'number.perl' },
|
||||
],
|
||||
},
|
||||
{ startIndex: 2, type: 'number.perl' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[
|
||||
|
|
@ -131,9 +131,9 @@ testTokenization('perl', [
|
|||
tokens: [
|
||||
{ startIndex: 0, type: 'number.perl' },
|
||||
{ startIndex: 3, type: 'operators.perl' },
|
||||
{ startIndex: 4, type: 'number.perl' },
|
||||
],
|
||||
},
|
||||
{ startIndex: 4, type: 'number.perl' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[
|
||||
|
|
@ -144,9 +144,9 @@ testTokenization('perl', [
|
|||
{ startIndex: 1, type: 'white.perl' },
|
||||
{ startIndex: 2, type: 'operators.perl' },
|
||||
{ startIndex: 3, type: 'white.perl' },
|
||||
{ startIndex: 4, type: 'number.perl' },
|
||||
],
|
||||
},
|
||||
{ startIndex: 4, type: 'number.perl' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// Strings
|
||||
|
|
@ -155,8 +155,8 @@ testTokenization('perl', [
|
|||
[
|
||||
{
|
||||
line: '"string"',
|
||||
tokens: [{ startIndex: 0, type: 'string.perl' }],
|
||||
},
|
||||
tokens: [{ startIndex: 0, type: 'string.perl' }]
|
||||
}
|
||||
],
|
||||
|
||||
[
|
||||
|
|
@ -165,28 +165,28 @@ testTokenization('perl', [
|
|||
tokens: [
|
||||
{ startIndex: 0, type: 'string.perl' },
|
||||
{ startIndex: 6, type: 'variable.perl' },
|
||||
{ startIndex: 10, type: 'string.perl' },
|
||||
],
|
||||
},
|
||||
{ startIndex: 10, type: 'string.perl' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[
|
||||
{
|
||||
line: '"test',
|
||||
tokens: [{ startIndex: 0, type: 'string.perl' }],
|
||||
tokens: [{ startIndex: 0, type: 'string.perl' }]
|
||||
},
|
||||
{
|
||||
line: '',
|
||||
tokens: [],
|
||||
tokens: []
|
||||
},
|
||||
{
|
||||
line: 'string $foo string2"',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'string.perl' },
|
||||
{ startIndex: 7, type: 'variable.perl' },
|
||||
{ startIndex: 11, type: 'string.perl' },
|
||||
],
|
||||
},
|
||||
{ startIndex: 11, type: 'string.perl' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[
|
||||
|
|
@ -196,48 +196,48 @@ testTokenization('perl', [
|
|||
{ startIndex: 0, type: 'string.perl' },
|
||||
{
|
||||
startIndex: 7,
|
||||
type: 'string.escape.perl',
|
||||
type: 'string.escape.perl'
|
||||
},
|
||||
{ startIndex: 9, type: 'string.perl' },
|
||||
],
|
||||
},
|
||||
{ startIndex: 9, type: 'string.perl' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// Single quoted string
|
||||
[
|
||||
{
|
||||
line: "'string'",
|
||||
tokens: [{ startIndex: 0, type: 'string.perl' }],
|
||||
},
|
||||
tokens: [{ startIndex: 0, type: 'string.perl' }]
|
||||
}
|
||||
],
|
||||
|
||||
[
|
||||
{
|
||||
line: "'test $foo'",
|
||||
tokens: [{ startIndex: 0, type: 'string.perl' }],
|
||||
},
|
||||
tokens: [{ startIndex: 0, type: 'string.perl' }]
|
||||
}
|
||||
],
|
||||
|
||||
[
|
||||
{
|
||||
line: "'test",
|
||||
tokens: [{ startIndex: 0, type: 'string.perl' }],
|
||||
tokens: [{ startIndex: 0, type: 'string.perl' }]
|
||||
},
|
||||
{
|
||||
line: '',
|
||||
tokens: [],
|
||||
tokens: []
|
||||
},
|
||||
{
|
||||
line: "string $foo string2'",
|
||||
tokens: [{ startIndex: 0, type: 'string.perl' }],
|
||||
},
|
||||
tokens: [{ startIndex: 0, type: 'string.perl' }]
|
||||
}
|
||||
],
|
||||
|
||||
[
|
||||
{
|
||||
line: "'string\\t'",
|
||||
tokens: [{ startIndex: 0, type: 'string.perl' }],
|
||||
},
|
||||
tokens: [{ startIndex: 0, type: 'string.perl' }]
|
||||
}
|
||||
],
|
||||
|
||||
[
|
||||
|
|
@ -247,11 +247,11 @@ testTokenization('perl', [
|
|||
{ startIndex: 0, type: 'string.perl' },
|
||||
{
|
||||
startIndex: 7,
|
||||
type: 'string.escape.perl',
|
||||
type: 'string.escape.perl'
|
||||
},
|
||||
{ startIndex: 9, type: 'string.perl' },
|
||||
],
|
||||
},
|
||||
{ startIndex: 9, type: 'string.perl' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// Variables
|
||||
|
|
@ -263,9 +263,9 @@ testTokenization('perl', [
|
|||
{ startIndex: 4, type: 'white.perl' },
|
||||
{ startIndex: 5, type: 'variable.predefined.perl' },
|
||||
{ startIndex: 7, type: 'white.perl' },
|
||||
{ startIndex: 8, type: 'variable.perl' },
|
||||
],
|
||||
},
|
||||
{ startIndex: 8, type: 'variable.perl' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[
|
||||
|
|
@ -276,10 +276,10 @@ testTokenization('perl', [
|
|||
{ startIndex: 7, type: 'white.perl' },
|
||||
{
|
||||
startIndex: 8,
|
||||
type: 'variable.perl',
|
||||
},
|
||||
],
|
||||
},
|
||||
type: 'variable.perl'
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[
|
||||
|
|
@ -289,22 +289,22 @@ testTokenization('perl', [
|
|||
{ startIndex: 0, type: 'variable.perl' },
|
||||
{
|
||||
startIndex: 5,
|
||||
type: 'white.perl',
|
||||
type: 'white.perl'
|
||||
},
|
||||
{
|
||||
startIndex: 6,
|
||||
type: 'variable.perl',
|
||||
},
|
||||
],
|
||||
},
|
||||
type: 'variable.perl'
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// RegExp
|
||||
[
|
||||
{
|
||||
line: '/abc/',
|
||||
tokens: [{ startIndex: 0, type: 'regexp.perl' }],
|
||||
},
|
||||
tokens: [{ startIndex: 0, type: 'regexp.perl' }]
|
||||
}
|
||||
],
|
||||
|
||||
[
|
||||
|
|
@ -313,9 +313,9 @@ testTokenization('perl', [
|
|||
tokens: [
|
||||
{ startIndex: 0, type: 'regexp.delim.perl' },
|
||||
{ startIndex: 2, type: 'regexp.perl' },
|
||||
{ startIndex: 5, type: 'regexp.delim.perl' },
|
||||
],
|
||||
},
|
||||
{ startIndex: 5, type: 'regexp.delim.perl' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[
|
||||
|
|
@ -325,9 +325,9 @@ testTokenization('perl', [
|
|||
{ startIndex: 0, type: 'regexp.delim.perl' },
|
||||
{ startIndex: 2, type: 'regexp.perl' },
|
||||
{ startIndex: 8, type: 'regexp.delim.perl' },
|
||||
{ startIndex: 9, type: 'regexp.modifier.perl' },
|
||||
],
|
||||
},
|
||||
{ startIndex: 9, type: 'regexp.modifier.perl' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// Operators
|
||||
|
|
@ -338,16 +338,16 @@ testTokenization('perl', [
|
|||
{ startIndex: 0, type: 'variable.predefined.perl' },
|
||||
{
|
||||
startIndex: 2,
|
||||
type: 'white.perl',
|
||||
type: 'white.perl'
|
||||
},
|
||||
{
|
||||
startIndex: 3,
|
||||
type: 'operators.perl',
|
||||
type: 'operators.perl'
|
||||
},
|
||||
{ startIndex: 4, type: 'white.perl' },
|
||||
{ startIndex: 5, type: 'variable.predefined.perl' },
|
||||
],
|
||||
},
|
||||
{ startIndex: 5, type: 'variable.predefined.perl' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// Embedded Doc
|
||||
|
|
@ -357,43 +357,43 @@ testTokenization('perl', [
|
|||
tokens: [
|
||||
{
|
||||
startIndex: 0,
|
||||
type: 'comment.doc.perl',
|
||||
},
|
||||
],
|
||||
type: 'comment.doc.perl'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
line: 'this is my doc',
|
||||
tokens: [
|
||||
{
|
||||
startIndex: 0,
|
||||
type: 'comment.doc.perl',
|
||||
},
|
||||
],
|
||||
type: 'comment.doc.perl'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
line: '=cut',
|
||||
tokens: [{ startIndex: 0, type: 'type.identifier.perl' }],
|
||||
},
|
||||
tokens: [{ startIndex: 0, type: 'type.identifier.perl' }]
|
||||
}
|
||||
],
|
||||
|
||||
// Here Doc
|
||||
[
|
||||
{
|
||||
line: '<< HTML',
|
||||
tokens: [{ startIndex: 0, type: 'string.heredoc.delimiter.perl' }],
|
||||
tokens: [{ startIndex: 0, type: 'string.heredoc.delimiter.perl' }]
|
||||
},
|
||||
{
|
||||
line: 'test here doc',
|
||||
tokens: [
|
||||
{
|
||||
startIndex: 0,
|
||||
type: 'string.heredoc.perl',
|
||||
},
|
||||
],
|
||||
type: 'string.heredoc.perl'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
line: 'HTML',
|
||||
tokens: [{ startIndex: 0, type: 'string.heredoc.delimiter.perl' }],
|
||||
tokens: [{ startIndex: 0, type: 'string.heredoc.delimiter.perl' }]
|
||||
},
|
||||
{
|
||||
line: 'my $msg',
|
||||
|
|
@ -401,30 +401,30 @@ testTokenization('perl', [
|
|||
{ startIndex: 0, type: 'type.identifier.perl' },
|
||||
{
|
||||
startIndex: 2,
|
||||
type: 'white.perl',
|
||||
type: 'white.perl'
|
||||
},
|
||||
{ startIndex: 3, type: 'variable.perl' },
|
||||
],
|
||||
},
|
||||
{ startIndex: 3, type: 'variable.perl' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[
|
||||
{
|
||||
line: '<<"HTML"',
|
||||
tokens: [{ startIndex: 0, type: 'string.heredoc.delimiter.perl' }],
|
||||
tokens: [{ startIndex: 0, type: 'string.heredoc.delimiter.perl' }]
|
||||
},
|
||||
{
|
||||
line: 'test here doc',
|
||||
tokens: [
|
||||
{
|
||||
startIndex: 0,
|
||||
type: 'string.heredoc.perl',
|
||||
},
|
||||
],
|
||||
type: 'string.heredoc.perl'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
line: 'HTML',
|
||||
tokens: [{ startIndex: 0, type: 'string.heredoc.delimiter.perl' }],
|
||||
tokens: [{ startIndex: 0, type: 'string.heredoc.delimiter.perl' }]
|
||||
},
|
||||
{
|
||||
line: 'my $msg',
|
||||
|
|
@ -432,23 +432,23 @@ testTokenization('perl', [
|
|||
{ startIndex: 0, type: 'type.identifier.perl' },
|
||||
{
|
||||
startIndex: 2,
|
||||
type: 'white.perl',
|
||||
type: 'white.perl'
|
||||
},
|
||||
{ startIndex: 3, type: 'variable.perl' },
|
||||
],
|
||||
},
|
||||
{ startIndex: 3, type: 'variable.perl' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// Quoted constructs
|
||||
// Quoted constructs
|
||||
[
|
||||
{
|
||||
line: "m!can't!",
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'regexp.delim.perl' },
|
||||
{ startIndex: 2, type: 'regexp.perl' },
|
||||
{ startIndex: 7, type: 'regexp.delim.perl' },
|
||||
],
|
||||
},
|
||||
{ startIndex: 7, type: 'regexp.delim.perl' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[
|
||||
|
|
@ -457,9 +457,9 @@ testTokenization('perl', [
|
|||
tokens: [
|
||||
{ startIndex: 0, type: 'string.delim.perl' },
|
||||
{ startIndex: 3, type: 'string.perl' },
|
||||
{ startIndex: 6, type: 'string.delim.perl' },
|
||||
],
|
||||
},
|
||||
{ startIndex: 6, type: 'string.delim.perl' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[
|
||||
|
|
@ -469,8 +469,8 @@ testTokenization('perl', [
|
|||
{ startIndex: 0, type: 'string.delim.perl' },
|
||||
{ startIndex: 3, type: 'string.perl' },
|
||||
{ startIndex: 8, type: 'variable.perl' },
|
||||
{ startIndex: 12, type: 'string.delim.perl' },
|
||||
],
|
||||
},
|
||||
],
|
||||
{ startIndex: 12, type: 'string.delim.perl' }
|
||||
]
|
||||
}
|
||||
]
|
||||
]);
|
||||
|
|
|
|||
235
src/perl/perl.ts
235
src/perl/perl.ts
|
|
@ -1,7 +1,7 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
|
|
@ -10,16 +10,20 @@ import ILanguage = monaco.languages.IMonarchLanguage;
|
|||
|
||||
export const conf: IRichLanguageConfiguration = {
|
||||
comments: {
|
||||
lineComment: '#',
|
||||
lineComment: '#'
|
||||
},
|
||||
brackets: [['{', '}'], ['[', ']'], ['(', ')']],
|
||||
brackets: [
|
||||
['{', '}'],
|
||||
['[', ']'],
|
||||
['(', ')']
|
||||
],
|
||||
autoClosingPairs: [
|
||||
{ open: '{', close: '}' },
|
||||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '"', close: '"' },
|
||||
{ open: "'", close: "'" },
|
||||
{ open: '`', close: '`' },
|
||||
{ open: '`', close: '`' }
|
||||
],
|
||||
surroundingPairs: [
|
||||
{ open: '{', close: '}' },
|
||||
|
|
@ -27,8 +31,8 @@ export const conf: IRichLanguageConfiguration = {
|
|||
{ open: '(', close: ')' },
|
||||
{ open: '"', close: '"' },
|
||||
{ open: "'", close: "'" },
|
||||
{ open: '`', close: '`' },
|
||||
],
|
||||
{ open: '`', close: '`' }
|
||||
]
|
||||
};
|
||||
|
||||
export const language = <ILanguage>{
|
||||
|
|
@ -38,7 +42,7 @@ export const language = <ILanguage>{
|
|||
brackets: [
|
||||
{ token: 'delimiter.bracket', open: '{', close: '}' },
|
||||
{ token: 'delimiter.parenthesis', open: '(', close: ')' },
|
||||
{ token: 'delimiter.square', open: '[', close: ']' },
|
||||
{ token: 'delimiter.square', open: '[', close: ']' }
|
||||
],
|
||||
|
||||
// https://learn.perl.org/docs/keywords.html
|
||||
|
|
@ -78,7 +82,7 @@ export const language = <ILanguage>{
|
|||
'le',
|
||||
|
||||
'__DIE__',
|
||||
'__WARN__',
|
||||
'__WARN__'
|
||||
],
|
||||
|
||||
// Perl functions
|
||||
|
|
@ -317,11 +321,18 @@ export const language = <ILanguage>{
|
|||
'write',
|
||||
'each',
|
||||
'lcfirst',
|
||||
'setnetent',
|
||||
'setnetent'
|
||||
],
|
||||
|
||||
// File handlers
|
||||
builtinFileHandlers: ['ARGV', 'STDERR', 'STDOUT', 'ARGVOUT', 'STDIN', 'ENV'],
|
||||
builtinFileHandlers: [
|
||||
'ARGV',
|
||||
'STDERR',
|
||||
'STDOUT',
|
||||
'ARGVOUT',
|
||||
'STDIN',
|
||||
'ENV'
|
||||
],
|
||||
|
||||
// Perl variables
|
||||
builtinVariables: [
|
||||
|
|
@ -454,7 +465,7 @@ export const language = <ILanguage>{
|
|||
'$^R',
|
||||
'$LAST_MATCH_END',
|
||||
'$^RE_DEBUG_FLAGS',
|
||||
'$LAST_PAREN_MATCH',
|
||||
'$LAST_PAREN_MATCH'
|
||||
],
|
||||
|
||||
// operators
|
||||
|
|
@ -475,10 +486,13 @@ export const language = <ILanguage>{
|
|||
'@keywords': 'keyword',
|
||||
'@builtinFunctions': 'type.identifier',
|
||||
'@builtinFileHandlers': 'variable.predefined',
|
||||
'@quoteLikeOps': { token: '@rematch', next: 'quotedConstructs' },
|
||||
'@default': '',
|
||||
},
|
||||
},
|
||||
'@quoteLikeOps': {
|
||||
token: '@rematch',
|
||||
next: 'quotedConstructs'
|
||||
},
|
||||
'@default': ''
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
// Perl variables
|
||||
|
|
@ -487,9 +501,9 @@ export const language = <ILanguage>{
|
|||
{
|
||||
cases: {
|
||||
'@builtinVariables': 'variable.predefined',
|
||||
'@default': 'variable',
|
||||
},
|
||||
},
|
||||
'@default': 'variable'
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
{ include: '@strings' },
|
||||
|
|
@ -506,26 +520,26 @@ export const language = <ILanguage>{
|
|||
// RegExp
|
||||
[
|
||||
/[\/](?:(?:\[(?:\\]|[^\]])+\])|(?:\\\/|[^\]\/]))*[\/]\w*\s*(?=[).,;]|$)/,
|
||||
'regexp',
|
||||
'regexp'
|
||||
],
|
||||
|
||||
[/@symbols/, 'operators'],
|
||||
|
||||
{ include: '@numbers' },
|
||||
|
||||
[/[,;]/, 'delimiter'],
|
||||
[/[,;]/, 'delimiter']
|
||||
],
|
||||
|
||||
whitespace: [
|
||||
[/\s+/, 'white'],
|
||||
[/(^#!.*$)/, 'metatag'],
|
||||
[/(^#.*$)/, 'comment'],
|
||||
[/(^#.*$)/, 'comment']
|
||||
],
|
||||
|
||||
numbers: [
|
||||
[/\d*\.\d+([eE][\-+]?\d+)?/, 'number.float'],
|
||||
[/0[xX][0-9a-fA-F_]*[0-9a-fA-F]/, 'number.hex'],
|
||||
[/\d+/, 'number'],
|
||||
[/\d+/, 'number']
|
||||
],
|
||||
|
||||
// Single quote string
|
||||
|
|
@ -534,7 +548,7 @@ export const language = <ILanguage>{
|
|||
stringBody: [
|
||||
[/'/, 'string', '@popall'],
|
||||
[/\\'/, 'string.escape'],
|
||||
[/./, 'string'],
|
||||
[/./, 'string']
|
||||
],
|
||||
|
||||
// Double quote string
|
||||
|
|
@ -545,36 +559,93 @@ export const language = <ILanguage>{
|
|||
[/@escapes/, 'string.escape'],
|
||||
[/\\./, 'string.escape.invalid'],
|
||||
{ include: '@variables' },
|
||||
[/./, 'string'],
|
||||
[/./, 'string']
|
||||
],
|
||||
|
||||
// Quoted constructs
|
||||
// Percent strings in Ruby are similar to quote-like operators in Perl.
|
||||
// This is adapted from pstrings in ../ruby/ruby.ts.
|
||||
quotedConstructs: [
|
||||
[/(q|qw|tr|y)\s*\(/, { token: 'string.delim', switchTo: '@qstring.(.)' }],
|
||||
[/(q|qw|tr|y)\s*\[/, { token: 'string.delim', switchTo: '@qstring.[.]' }],
|
||||
[/(q|qw|tr|y)\s*\{/, { token: 'string.delim', switchTo: '@qstring.{.}' }],
|
||||
[/(q|qw|tr|y)\s*</, { token: 'string.delim', switchTo: '@qstring.<.>' }],
|
||||
[/(q|qw|tr|y)#/, { token: 'string.delim', switchTo: '@qstring.#.#' }],
|
||||
[/(q|qw|tr|y)\s*([^A-Za-z0-9#\s])/, { token: 'string.delim', switchTo: '@qstring.$2.$2' }],
|
||||
[/(q|qw|tr|y)\s+(\w)/, { token: 'string.delim', switchTo: '@qstring.$2.$2' }],
|
||||
[
|
||||
/(q|qw|tr|y)\s*\(/,
|
||||
{ token: 'string.delim', switchTo: '@qstring.(.)' }
|
||||
],
|
||||
[
|
||||
/(q|qw|tr|y)\s*\[/,
|
||||
{ token: 'string.delim', switchTo: '@qstring.[.]' }
|
||||
],
|
||||
[
|
||||
/(q|qw|tr|y)\s*\{/,
|
||||
{ token: 'string.delim', switchTo: '@qstring.{.}' }
|
||||
],
|
||||
[
|
||||
/(q|qw|tr|y)\s*</,
|
||||
{ token: 'string.delim', switchTo: '@qstring.<.>' }
|
||||
],
|
||||
[
|
||||
/(q|qw|tr|y)#/,
|
||||
{ token: 'string.delim', switchTo: '@qstring.#.#' }
|
||||
],
|
||||
[
|
||||
/(q|qw|tr|y)\s*([^A-Za-z0-9#\s])/,
|
||||
{ token: 'string.delim', switchTo: '@qstring.$2.$2' }
|
||||
],
|
||||
[
|
||||
/(q|qw|tr|y)\s+(\w)/,
|
||||
{ token: 'string.delim', switchTo: '@qstring.$2.$2' }
|
||||
],
|
||||
|
||||
[/(qr|m|s)\s*\(/, { token: 'regexp.delim', switchTo: '@qregexp.(.)' }],
|
||||
[/(qr|m|s)\s*\[/, { token: 'regexp.delim', switchTo: '@qregexp.[.]' }],
|
||||
[/(qr|m|s)\s*\{/, { token: 'regexp.delim', switchTo: '@qregexp.{.}' }],
|
||||
[/(qr|m|s)\s*</, { token: 'regexp.delim', switchTo: '@qregexp.<.>' }],
|
||||
[
|
||||
/(qr|m|s)\s*\(/,
|
||||
{ token: 'regexp.delim', switchTo: '@qregexp.(.)' }
|
||||
],
|
||||
[
|
||||
/(qr|m|s)\s*\[/,
|
||||
{ token: 'regexp.delim', switchTo: '@qregexp.[.]' }
|
||||
],
|
||||
[
|
||||
/(qr|m|s)\s*\{/,
|
||||
{ token: 'regexp.delim', switchTo: '@qregexp.{.}' }
|
||||
],
|
||||
[
|
||||
/(qr|m|s)\s*</,
|
||||
{ token: 'regexp.delim', switchTo: '@qregexp.<.>' }
|
||||
],
|
||||
[/(qr|m|s)#/, { token: 'regexp.delim', switchTo: '@qregexp.#.#' }],
|
||||
[/(qr|m|s)\s*([^A-Za-z0-9_#\s])/, { token: 'regexp.delim', switchTo: '@qregexp.$2.$2' }],
|
||||
[/(qr|m|s)\s+(\w)/, { token: 'regexp.delim', switchTo: '@qregexp.$2.$2' }],
|
||||
[
|
||||
/(qr|m|s)\s*([^A-Za-z0-9_#\s])/,
|
||||
{ token: 'regexp.delim', switchTo: '@qregexp.$2.$2' }
|
||||
],
|
||||
[
|
||||
/(qr|m|s)\s+(\w)/,
|
||||
{ token: 'regexp.delim', switchTo: '@qregexp.$2.$2' }
|
||||
],
|
||||
|
||||
[/(qq|qx)\s*\(/, { token: 'string.delim', switchTo: '@qqstring.(.)' }],
|
||||
[/(qq|qx)\s*\[/, { token: 'string.delim', switchTo: '@qqstring.[.]' }],
|
||||
[/(qq|qx)\s*\{/, { token: 'string.delim', switchTo: '@qqstring.{.}' }],
|
||||
[/(qq|qx)\s*</, { token: 'string.delim', switchTo: '@qqstring.<.>' }],
|
||||
[
|
||||
/(qq|qx)\s*\(/,
|
||||
{ token: 'string.delim', switchTo: '@qqstring.(.)' }
|
||||
],
|
||||
[
|
||||
/(qq|qx)\s*\[/,
|
||||
{ token: 'string.delim', switchTo: '@qqstring.[.]' }
|
||||
],
|
||||
[
|
||||
/(qq|qx)\s*\{/,
|
||||
{ token: 'string.delim', switchTo: '@qqstring.{.}' }
|
||||
],
|
||||
[
|
||||
/(qq|qx)\s*</,
|
||||
{ token: 'string.delim', switchTo: '@qqstring.<.>' }
|
||||
],
|
||||
[/(qq|qx)#/, { token: 'string.delim', switchTo: '@qqstring.#.#' }],
|
||||
[/(qq|qx)\s*([^A-Za-z0-9#\s])/, { token: 'string.delim', switchTo: '@qqstring.$2.$2' }],
|
||||
[/(qq|qx)\s+(\w)/, { token: 'string.delim', switchTo: '@qqstring.$2.$2' }],
|
||||
[
|
||||
/(qq|qx)\s*([^A-Za-z0-9#\s])/,
|
||||
{ token: 'string.delim', switchTo: '@qqstring.$2.$2' }
|
||||
],
|
||||
[
|
||||
/(qq|qx)\s+(\w)/,
|
||||
{ token: 'string.delim', switchTo: '@qqstring.$2.$2' }
|
||||
]
|
||||
],
|
||||
|
||||
// Non-expanded quoted string
|
||||
|
|
@ -583,49 +654,58 @@ export const language = <ILanguage>{
|
|||
// close = close delimiter
|
||||
qstring: [
|
||||
[/\\./, 'string.escape'],
|
||||
[/./, {
|
||||
cases: {
|
||||
'$#==$S3': { token: 'string.delim', next: '@pop' },
|
||||
'$#==$S2': { token: 'string.delim', next: '@push' }, // nested delimiters
|
||||
'@default': 'string'
|
||||
[
|
||||
/./,
|
||||
{
|
||||
cases: {
|
||||
'$#==$S3': { token: 'string.delim', next: '@pop' },
|
||||
'$#==$S2': { token: 'string.delim', next: '@push' }, // nested delimiters
|
||||
'@default': 'string'
|
||||
}
|
||||
}
|
||||
}],
|
||||
]
|
||||
],
|
||||
|
||||
// Quoted regexp
|
||||
// Quoted regexp
|
||||
// qregexp.<open>.<close>
|
||||
// open = open delimiter
|
||||
// close = close delimiter
|
||||
qregexp: [
|
||||
{ include: '@variables' },
|
||||
[/\\./, 'regexp.escape'],
|
||||
[/./, {
|
||||
cases: {
|
||||
'$#==$S3': { token: 'regexp.delim', next: '@regexpModifiers' },
|
||||
'$#==$S2': { token: 'regexp.delim', next: '@push' }, // nested delimiters
|
||||
'@default': 'regexp'
|
||||
[
|
||||
/./,
|
||||
{
|
||||
cases: {
|
||||
'$#==$S3': {
|
||||
token: 'regexp.delim',
|
||||
next: '@regexpModifiers'
|
||||
},
|
||||
'$#==$S2': { token: 'regexp.delim', next: '@push' }, // nested delimiters
|
||||
'@default': 'regexp'
|
||||
}
|
||||
}
|
||||
}],
|
||||
]
|
||||
],
|
||||
|
||||
regexpModifiers: [
|
||||
[/[msixpodualngcer]+/, { token: 'regexp.modifier', next: '@popall' }],
|
||||
regexpModifiers: [
|
||||
[
|
||||
/[msixpodualngcer]+/,
|
||||
{ token: 'regexp.modifier', next: '@popall' }
|
||||
]
|
||||
],
|
||||
|
||||
// Expanded quoted string
|
||||
// qqstring.<open>.<close>
|
||||
// open = open delimiter
|
||||
// close = close delimiter
|
||||
qqstring: [
|
||||
{ include: '@variables' },
|
||||
{ include: '@qstring' },
|
||||
],
|
||||
qqstring: [{ include: '@variables' }, { include: '@qstring' }],
|
||||
|
||||
heredoc: [
|
||||
[
|
||||
/<<\s*['"`]?([\w\-]+)['"`]?/,
|
||||
{ token: 'string.heredoc.delimiter', next: '@heredocBody.$1' },
|
||||
],
|
||||
{ token: 'string.heredoc.delimiter', next: '@heredocBody.$1' }
|
||||
]
|
||||
],
|
||||
|
||||
heredocBody: [
|
||||
|
|
@ -633,25 +713,30 @@ export const language = <ILanguage>{
|
|||
/^([\w\-]+)$/,
|
||||
{
|
||||
cases: {
|
||||
'$1==$S2': [{ token: 'string.heredoc.delimiter', next: '@popall' }],
|
||||
'@default': 'string.heredoc',
|
||||
},
|
||||
},
|
||||
'$1==$S2': [
|
||||
{
|
||||
token: 'string.heredoc.delimiter',
|
||||
next: '@popall'
|
||||
}
|
||||
],
|
||||
'@default': 'string.heredoc'
|
||||
}
|
||||
}
|
||||
],
|
||||
[/./, 'string.heredoc'],
|
||||
[/./, 'string.heredoc']
|
||||
],
|
||||
|
||||
perldoc: [[/^=\w/, 'comment.doc', '@perldocBody']],
|
||||
|
||||
perldocBody: [
|
||||
[/^=cut\b/, 'type.identifier', '@popall'],
|
||||
[/./, 'comment.doc'],
|
||||
[/./, 'comment.doc']
|
||||
],
|
||||
|
||||
variables: [
|
||||
[/\$\w+/, 'variable'], // scalar
|
||||
[/@\w+/, 'variable'], // array
|
||||
[/%\w+/, 'variable'], // key/value
|
||||
],
|
||||
},
|
||||
[/%\w+/, 'variable'] // key/value
|
||||
]
|
||||
}
|
||||
};
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
1409
src/pgsql/pgsql.ts
1409
src/pgsql/pgsql.ts
File diff suppressed because it is too large
Load diff
4491
src/php/php.test.ts
4491
src/php/php.test.ts
File diff suppressed because it is too large
Load diff
390
src/php/php.ts
390
src/php/php.ts
|
|
@ -27,13 +27,13 @@ export const conf: IRichLanguageConfiguration = {
|
|||
{ open: '[', close: ']', notIn: ['string'] },
|
||||
{ open: '(', close: ')', notIn: ['string'] },
|
||||
{ open: '"', close: '"', notIn: ['string'] },
|
||||
{ open: '\'', close: '\'', notIn: ['string', 'comment'] }
|
||||
{ open: "'", close: "'", notIn: ['string', 'comment'] }
|
||||
],
|
||||
|
||||
folding: {
|
||||
markers: {
|
||||
start: new RegExp("^\\s*(#|\/\/)region\\b"),
|
||||
end: new RegExp("^\\s*(#|\/\/)endregion\\b")
|
||||
start: new RegExp('^\\s*(#|//)region\\b'),
|
||||
end: new RegExp('^\\s*(#|//)endregion\\b')
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -46,79 +46,171 @@ export const language = <ILanguage>{
|
|||
// The main tokenizer for our languages
|
||||
tokenizer: {
|
||||
root: [
|
||||
[/<\?((php)|=)?/, { token: '@rematch', switchTo: '@phpInSimpleState.root' }],
|
||||
[
|
||||
/<\?((php)|=)?/,
|
||||
{ token: '@rematch', switchTo: '@phpInSimpleState.root' }
|
||||
],
|
||||
[/<!DOCTYPE/, 'metatag.html', '@doctype'],
|
||||
[/<!--/, 'comment.html', '@comment'],
|
||||
[/(<)(\w+)(\/>)/, ['delimiter.html', 'tag.html', 'delimiter.html']],
|
||||
[/(<)(script)/, ['delimiter.html', { token: 'tag.html', next: '@script' }]],
|
||||
[/(<)(style)/, ['delimiter.html', { token: 'tag.html', next: '@style' }]],
|
||||
[/(<)([:\w]+)/, ['delimiter.html', { token: 'tag.html', next: '@otherTag' }]],
|
||||
[/(<\/)(\w+)/, ['delimiter.html', { token: 'tag.html', next: '@otherTag' }]],
|
||||
[
|
||||
/(<)(script)/,
|
||||
['delimiter.html', { token: 'tag.html', next: '@script' }]
|
||||
],
|
||||
[
|
||||
/(<)(style)/,
|
||||
['delimiter.html', { token: 'tag.html', next: '@style' }]
|
||||
],
|
||||
[
|
||||
/(<)([:\w]+)/,
|
||||
['delimiter.html', { token: 'tag.html', next: '@otherTag' }]
|
||||
],
|
||||
[
|
||||
/(<\/)(\w+)/,
|
||||
['delimiter.html', { token: 'tag.html', next: '@otherTag' }]
|
||||
],
|
||||
[/</, 'delimiter.html'],
|
||||
[/[^<]+/] // text
|
||||
],
|
||||
|
||||
doctype: [
|
||||
[/<\?((php)|=)?/, { token: '@rematch', switchTo: '@phpInSimpleState.comment' }],
|
||||
[
|
||||
/<\?((php)|=)?/,
|
||||
{ token: '@rematch', switchTo: '@phpInSimpleState.comment' }
|
||||
],
|
||||
[/[^>]+/, 'metatag.content.html'],
|
||||
[/>/, 'metatag.html', '@pop'],
|
||||
[/>/, 'metatag.html', '@pop']
|
||||
],
|
||||
|
||||
comment: [
|
||||
[/<\?((php)|=)?/, { token: '@rematch', switchTo: '@phpInSimpleState.comment' }],
|
||||
[
|
||||
/<\?((php)|=)?/,
|
||||
{ token: '@rematch', switchTo: '@phpInSimpleState.comment' }
|
||||
],
|
||||
[/-->/, 'comment.html', '@pop'],
|
||||
[/[^-]+/, 'comment.content.html'],
|
||||
[/./, 'comment.content.html']
|
||||
],
|
||||
|
||||
otherTag: [
|
||||
[/<\?((php)|=)?/, { token: '@rematch', switchTo: '@phpInSimpleState.otherTag' }],
|
||||
[
|
||||
/<\?((php)|=)?/,
|
||||
{ token: '@rematch', switchTo: '@phpInSimpleState.otherTag' }
|
||||
],
|
||||
[/\/?>/, 'delimiter.html', '@pop'],
|
||||
[/"([^"]*)"/, 'attribute.value'],
|
||||
[/'([^']*)'/, 'attribute.value'],
|
||||
[/[\w\-]+/, 'attribute.name'],
|
||||
[/=/, 'delimiter'],
|
||||
[/[ \t\r\n]+/], // whitespace
|
||||
[/[ \t\r\n]+/] // whitespace
|
||||
],
|
||||
|
||||
// -- BEGIN <script> tags handling
|
||||
|
||||
// After <script
|
||||
script: [
|
||||
[/<\?((php)|=)?/, { token: '@rematch', switchTo: '@phpInSimpleState.script' }],
|
||||
[
|
||||
/<\?((php)|=)?/,
|
||||
{ token: '@rematch', switchTo: '@phpInSimpleState.script' }
|
||||
],
|
||||
[/type/, 'attribute.name', '@scriptAfterType'],
|
||||
[/"([^"]*)"/, 'attribute.value'],
|
||||
[/'([^']*)'/, 'attribute.value'],
|
||||
[/[\w\-]+/, 'attribute.name'],
|
||||
[/=/, 'delimiter'],
|
||||
[/>/, { token: 'delimiter.html', next: '@scriptEmbedded.text/javascript', nextEmbedded: 'text/javascript' }],
|
||||
[
|
||||
/>/,
|
||||
{
|
||||
token: 'delimiter.html',
|
||||
next: '@scriptEmbedded.text/javascript',
|
||||
nextEmbedded: 'text/javascript'
|
||||
}
|
||||
],
|
||||
[/[ \t\r\n]+/], // whitespace
|
||||
[/(<\/)(script\s*)(>)/, ['delimiter.html', 'tag.html', { token: 'delimiter.html', next: '@pop' }]]
|
||||
[
|
||||
/(<\/)(script\s*)(>)/,
|
||||
[
|
||||
'delimiter.html',
|
||||
'tag.html',
|
||||
{ token: 'delimiter.html', next: '@pop' }
|
||||
]
|
||||
]
|
||||
],
|
||||
|
||||
// After <script ... type
|
||||
scriptAfterType: [
|
||||
[/<\?((php)|=)?/, { token: '@rematch', switchTo: '@phpInSimpleState.scriptAfterType' }],
|
||||
[
|
||||
/<\?((php)|=)?/,
|
||||
{
|
||||
token: '@rematch',
|
||||
switchTo: '@phpInSimpleState.scriptAfterType'
|
||||
}
|
||||
],
|
||||
[/=/, 'delimiter', '@scriptAfterTypeEquals'],
|
||||
[/>/, { token: 'delimiter.html', next: '@scriptEmbedded.text/javascript', nextEmbedded: 'text/javascript' }], // cover invalid e.g. <script type>
|
||||
[
|
||||
/>/,
|
||||
{
|
||||
token: 'delimiter.html',
|
||||
next: '@scriptEmbedded.text/javascript',
|
||||
nextEmbedded: 'text/javascript'
|
||||
}
|
||||
], // cover invalid e.g. <script type>
|
||||
[/[ \t\r\n]+/], // whitespace
|
||||
[/<\/script\s*>/, { token: '@rematch', next: '@pop' }]
|
||||
],
|
||||
|
||||
// After <script ... type =
|
||||
scriptAfterTypeEquals: [
|
||||
[/<\?((php)|=)?/, { token: '@rematch', switchTo: '@phpInSimpleState.scriptAfterTypeEquals' }],
|
||||
[/"([^"]*)"/, { token: 'attribute.value', switchTo: '@scriptWithCustomType.$1' }],
|
||||
[/'([^']*)'/, { token: 'attribute.value', switchTo: '@scriptWithCustomType.$1' }],
|
||||
[/>/, { token: 'delimiter.html', next: '@scriptEmbedded.text/javascript', nextEmbedded: 'text/javascript' }], // cover invalid e.g. <script type=>
|
||||
[
|
||||
/<\?((php)|=)?/,
|
||||
{
|
||||
token: '@rematch',
|
||||
switchTo: '@phpInSimpleState.scriptAfterTypeEquals'
|
||||
}
|
||||
],
|
||||
[
|
||||
/"([^"]*)"/,
|
||||
{
|
||||
token: 'attribute.value',
|
||||
switchTo: '@scriptWithCustomType.$1'
|
||||
}
|
||||
],
|
||||
[
|
||||
/'([^']*)'/,
|
||||
{
|
||||
token: 'attribute.value',
|
||||
switchTo: '@scriptWithCustomType.$1'
|
||||
}
|
||||
],
|
||||
[
|
||||
/>/,
|
||||
{
|
||||
token: 'delimiter.html',
|
||||
next: '@scriptEmbedded.text/javascript',
|
||||
nextEmbedded: 'text/javascript'
|
||||
}
|
||||
], // cover invalid e.g. <script type=>
|
||||
[/[ \t\r\n]+/], // whitespace
|
||||
[/<\/script\s*>/, { token: '@rematch', next: '@pop' }]
|
||||
],
|
||||
|
||||
// After <script ... type = $S2
|
||||
scriptWithCustomType: [
|
||||
[/<\?((php)|=)?/, { token: '@rematch', switchTo: '@phpInSimpleState.scriptWithCustomType.$S2' }],
|
||||
[/>/, { token: 'delimiter.html', next: '@scriptEmbedded.$S2', nextEmbedded: '$S2' }],
|
||||
[
|
||||
/<\?((php)|=)?/,
|
||||
{
|
||||
token: '@rematch',
|
||||
switchTo: '@phpInSimpleState.scriptWithCustomType.$S2'
|
||||
}
|
||||
],
|
||||
[
|
||||
/>/,
|
||||
{
|
||||
token: 'delimiter.html',
|
||||
next: '@scriptEmbedded.$S2',
|
||||
nextEmbedded: '$S2'
|
||||
}
|
||||
],
|
||||
[/"([^"]*)"/, 'attribute.value'],
|
||||
[/'([^']*)'/, 'attribute.value'],
|
||||
[/[\w\-]+/, 'attribute.name'],
|
||||
|
|
@ -128,51 +220,128 @@ export const language = <ILanguage>{
|
|||
],
|
||||
|
||||
scriptEmbedded: [
|
||||
[/<\?((php)|=)?/, { token: '@rematch', switchTo: '@phpInEmbeddedState.scriptEmbedded.$S2', nextEmbedded: '@pop' }],
|
||||
[/<\/script/, { token: '@rematch', next: '@pop', nextEmbedded: '@pop' }]
|
||||
[
|
||||
/<\?((php)|=)?/,
|
||||
{
|
||||
token: '@rematch',
|
||||
switchTo: '@phpInEmbeddedState.scriptEmbedded.$S2',
|
||||
nextEmbedded: '@pop'
|
||||
}
|
||||
],
|
||||
[
|
||||
/<\/script/,
|
||||
{ token: '@rematch', next: '@pop', nextEmbedded: '@pop' }
|
||||
]
|
||||
],
|
||||
|
||||
// -- END <script> tags handling
|
||||
|
||||
|
||||
// -- BEGIN <style> tags handling
|
||||
|
||||
// After <style
|
||||
style: [
|
||||
[/<\?((php)|=)?/, { token: '@rematch', switchTo: '@phpInSimpleState.style' }],
|
||||
[
|
||||
/<\?((php)|=)?/,
|
||||
{ token: '@rematch', switchTo: '@phpInSimpleState.style' }
|
||||
],
|
||||
[/type/, 'attribute.name', '@styleAfterType'],
|
||||
[/"([^"]*)"/, 'attribute.value'],
|
||||
[/'([^']*)'/, 'attribute.value'],
|
||||
[/[\w\-]+/, 'attribute.name'],
|
||||
[/=/, 'delimiter'],
|
||||
[/>/, { token: 'delimiter.html', next: '@styleEmbedded.text/css', nextEmbedded: 'text/css' }],
|
||||
[
|
||||
/>/,
|
||||
{
|
||||
token: 'delimiter.html',
|
||||
next: '@styleEmbedded.text/css',
|
||||
nextEmbedded: 'text/css'
|
||||
}
|
||||
],
|
||||
[/[ \t\r\n]+/], // whitespace
|
||||
[/(<\/)(style\s*)(>)/, ['delimiter.html', 'tag.html', { token: 'delimiter.html', next: '@pop' }]]
|
||||
[
|
||||
/(<\/)(style\s*)(>)/,
|
||||
[
|
||||
'delimiter.html',
|
||||
'tag.html',
|
||||
{ token: 'delimiter.html', next: '@pop' }
|
||||
]
|
||||
]
|
||||
],
|
||||
|
||||
// After <style ... type
|
||||
styleAfterType: [
|
||||
[/<\?((php)|=)?/, { token: '@rematch', switchTo: '@phpInSimpleState.styleAfterType' }],
|
||||
[
|
||||
/<\?((php)|=)?/,
|
||||
{
|
||||
token: '@rematch',
|
||||
switchTo: '@phpInSimpleState.styleAfterType'
|
||||
}
|
||||
],
|
||||
[/=/, 'delimiter', '@styleAfterTypeEquals'],
|
||||
[/>/, { token: 'delimiter.html', next: '@styleEmbedded.text/css', nextEmbedded: 'text/css' }], // cover invalid e.g. <style type>
|
||||
[
|
||||
/>/,
|
||||
{
|
||||
token: 'delimiter.html',
|
||||
next: '@styleEmbedded.text/css',
|
||||
nextEmbedded: 'text/css'
|
||||
}
|
||||
], // cover invalid e.g. <style type>
|
||||
[/[ \t\r\n]+/], // whitespace
|
||||
[/<\/style\s*>/, { token: '@rematch', next: '@pop' }]
|
||||
],
|
||||
|
||||
// After <style ... type =
|
||||
styleAfterTypeEquals: [
|
||||
[/<\?((php)|=)?/, { token: '@rematch', switchTo: '@phpInSimpleState.styleAfterTypeEquals' }],
|
||||
[/"([^"]*)"/, { token: 'attribute.value', switchTo: '@styleWithCustomType.$1' }],
|
||||
[/'([^']*)'/, { token: 'attribute.value', switchTo: '@styleWithCustomType.$1' }],
|
||||
[/>/, { token: 'delimiter.html', next: '@styleEmbedded.text/css', nextEmbedded: 'text/css' }], // cover invalid e.g. <style type=>
|
||||
[
|
||||
/<\?((php)|=)?/,
|
||||
{
|
||||
token: '@rematch',
|
||||
switchTo: '@phpInSimpleState.styleAfterTypeEquals'
|
||||
}
|
||||
],
|
||||
[
|
||||
/"([^"]*)"/,
|
||||
{
|
||||
token: 'attribute.value',
|
||||
switchTo: '@styleWithCustomType.$1'
|
||||
}
|
||||
],
|
||||
[
|
||||
/'([^']*)'/,
|
||||
{
|
||||
token: 'attribute.value',
|
||||
switchTo: '@styleWithCustomType.$1'
|
||||
}
|
||||
],
|
||||
[
|
||||
/>/,
|
||||
{
|
||||
token: 'delimiter.html',
|
||||
next: '@styleEmbedded.text/css',
|
||||
nextEmbedded: 'text/css'
|
||||
}
|
||||
], // cover invalid e.g. <style type=>
|
||||
[/[ \t\r\n]+/], // whitespace
|
||||
[/<\/style\s*>/, { token: '@rematch', next: '@pop' }]
|
||||
],
|
||||
|
||||
// After <style ... type = $S2
|
||||
styleWithCustomType: [
|
||||
[/<\?((php)|=)?/, { token: '@rematch', switchTo: '@phpInSimpleState.styleWithCustomType.$S2' }],
|
||||
[/>/, { token: 'delimiter.html', next: '@styleEmbedded.$S2', nextEmbedded: '$S2' }],
|
||||
[
|
||||
/<\?((php)|=)?/,
|
||||
{
|
||||
token: '@rematch',
|
||||
switchTo: '@phpInSimpleState.styleWithCustomType.$S2'
|
||||
}
|
||||
],
|
||||
[
|
||||
/>/,
|
||||
{
|
||||
token: 'delimiter.html',
|
||||
next: '@styleEmbedded.$S2',
|
||||
nextEmbedded: '$S2'
|
||||
}
|
||||
],
|
||||
[/"([^"]*)"/, 'attribute.value'],
|
||||
[/'([^']*)'/, 'attribute.value'],
|
||||
[/[\w\-]+/, 'attribute.name'],
|
||||
|
|
@ -182,13 +351,22 @@ export const language = <ILanguage>{
|
|||
],
|
||||
|
||||
styleEmbedded: [
|
||||
[/<\?((php)|=)?/, { token: '@rematch', switchTo: '@phpInEmbeddedState.styleEmbedded.$S2', nextEmbedded: '@pop' }],
|
||||
[/<\/style/, { token: '@rematch', next: '@pop', nextEmbedded: '@pop' }]
|
||||
[
|
||||
/<\?((php)|=)?/,
|
||||
{
|
||||
token: '@rematch',
|
||||
switchTo: '@phpInEmbeddedState.styleEmbedded.$S2',
|
||||
nextEmbedded: '@pop'
|
||||
}
|
||||
],
|
||||
[
|
||||
/<\/style/,
|
||||
{ token: '@rematch', next: '@pop', nextEmbedded: '@pop' }
|
||||
]
|
||||
],
|
||||
|
||||
// -- END <style> tags handling
|
||||
|
||||
|
||||
phpInSimpleState: [
|
||||
[/<\?((php)|=)?/, 'metatag.php'],
|
||||
[/\?>/, { token: 'metatag.php', switchTo: '@$S2.$S3' }],
|
||||
|
|
@ -197,24 +375,39 @@ export const language = <ILanguage>{
|
|||
|
||||
phpInEmbeddedState: [
|
||||
[/<\?((php)|=)?/, 'metatag.php'],
|
||||
[/\?>/, { token: 'metatag.php', switchTo: '@$S2.$S3', nextEmbedded: '$S3' }],
|
||||
[
|
||||
/\?>/,
|
||||
{
|
||||
token: 'metatag.php',
|
||||
switchTo: '@$S2.$S3',
|
||||
nextEmbedded: '$S3'
|
||||
}
|
||||
],
|
||||
{ include: 'phpRoot' }
|
||||
],
|
||||
|
||||
phpRoot: [
|
||||
[/[a-zA-Z_]\w*/, {
|
||||
cases: {
|
||||
'@phpKeywords': { token: 'keyword.php' },
|
||||
'@phpCompileTimeConstants': { token: 'constant.php' },
|
||||
'@default': 'identifier.php'
|
||||
[
|
||||
/[a-zA-Z_]\w*/,
|
||||
{
|
||||
cases: {
|
||||
'@phpKeywords': { token: 'keyword.php' },
|
||||
'@phpCompileTimeConstants': { token: 'constant.php' },
|
||||
'@default': 'identifier.php'
|
||||
}
|
||||
}
|
||||
}],
|
||||
[/[$a-zA-Z_]\w*/, {
|
||||
cases: {
|
||||
'@phpPreDefinedVariables': { token: 'variable.predefined.php' },
|
||||
'@default': 'variable.php'
|
||||
],
|
||||
[
|
||||
/[$a-zA-Z_]\w*/,
|
||||
{
|
||||
cases: {
|
||||
'@phpPreDefinedVariables': {
|
||||
token: 'variable.predefined.php'
|
||||
},
|
||||
'@default': 'variable.php'
|
||||
}
|
||||
}
|
||||
}],
|
||||
],
|
||||
|
||||
// brackets
|
||||
[/[{}]/, 'delimiter.bracket.php'],
|
||||
|
|
@ -245,7 +438,7 @@ export const language = <ILanguage>{
|
|||
[/0[0-7']*[0-7]/, 'number.octal.php'],
|
||||
[/0[bB][0-1']*[0-1]/, 'number.binary.php'],
|
||||
[/\d[\d']*/, 'number.php'],
|
||||
[/\d/, 'number.php'],
|
||||
[/\d/, 'number.php']
|
||||
],
|
||||
|
||||
phpComment: [
|
||||
|
|
@ -274,23 +467,82 @@ export const language = <ILanguage>{
|
|||
[/@escapes/, 'string.escape.php'],
|
||||
[/\\./, 'string.escape.invalid.php'],
|
||||
[/'/, 'string.php', '@pop']
|
||||
],
|
||||
]
|
||||
},
|
||||
|
||||
phpKeywords: [
|
||||
'abstract', 'and', 'array', 'as', 'break',
|
||||
'callable', 'case', 'catch', 'cfunction', 'class', 'clone',
|
||||
'const', 'continue', 'declare', 'default', 'do',
|
||||
'else', 'elseif', 'enddeclare', 'endfor', 'endforeach',
|
||||
'endif', 'endswitch', 'endwhile', 'extends', 'false', 'final',
|
||||
'for', 'foreach', 'function', 'global', 'goto',
|
||||
'if', 'implements', 'interface', 'instanceof', 'insteadof',
|
||||
'namespace', 'new', 'null', 'object', 'old_function', 'or', 'private',
|
||||
'protected', 'public', 'resource', 'static', 'switch', 'throw', 'trait',
|
||||
'try', 'true', 'use', 'var', 'while', 'xor',
|
||||
'die', 'echo', 'empty', 'exit', 'eval',
|
||||
'include', 'include_once', 'isset', 'list', 'require',
|
||||
'require_once', 'return', 'print', 'unset', 'yield',
|
||||
'abstract',
|
||||
'and',
|
||||
'array',
|
||||
'as',
|
||||
'break',
|
||||
'callable',
|
||||
'case',
|
||||
'catch',
|
||||
'cfunction',
|
||||
'class',
|
||||
'clone',
|
||||
'const',
|
||||
'continue',
|
||||
'declare',
|
||||
'default',
|
||||
'do',
|
||||
'else',
|
||||
'elseif',
|
||||
'enddeclare',
|
||||
'endfor',
|
||||
'endforeach',
|
||||
'endif',
|
||||
'endswitch',
|
||||
'endwhile',
|
||||
'extends',
|
||||
'false',
|
||||
'final',
|
||||
'for',
|
||||
'foreach',
|
||||
'function',
|
||||
'global',
|
||||
'goto',
|
||||
'if',
|
||||
'implements',
|
||||
'interface',
|
||||
'instanceof',
|
||||
'insteadof',
|
||||
'namespace',
|
||||
'new',
|
||||
'null',
|
||||
'object',
|
||||
'old_function',
|
||||
'or',
|
||||
'private',
|
||||
'protected',
|
||||
'public',
|
||||
'resource',
|
||||
'static',
|
||||
'switch',
|
||||
'throw',
|
||||
'trait',
|
||||
'try',
|
||||
'true',
|
||||
'use',
|
||||
'var',
|
||||
'while',
|
||||
'xor',
|
||||
'die',
|
||||
'echo',
|
||||
'empty',
|
||||
'exit',
|
||||
'eval',
|
||||
'include',
|
||||
'include_once',
|
||||
'isset',
|
||||
'list',
|
||||
'require',
|
||||
'require_once',
|
||||
'return',
|
||||
'print',
|
||||
'unset',
|
||||
'yield',
|
||||
'__construct'
|
||||
],
|
||||
|
||||
|
|
@ -322,7 +574,7 @@ export const language = <ILanguage>{
|
|||
'$argv'
|
||||
],
|
||||
|
||||
escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
|
||||
escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/
|
||||
};
|
||||
|
||||
// TESTED WITH
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -13,14 +13,19 @@ import ILanguage = monaco.languages.IMonarchLanguage;
|
|||
export const conf: IRichLanguageConfiguration = {
|
||||
comments: {
|
||||
lineComment: '//',
|
||||
blockComment: ['(*', '*)'],
|
||||
blockComment: ['(*', '*)']
|
||||
},
|
||||
brackets: [['{', '}'], ['[', ']'], ['(', ')'], ['<', '>']],
|
||||
brackets: [
|
||||
['{', '}'],
|
||||
['[', ']'],
|
||||
['(', ')'],
|
||||
['<', '>']
|
||||
],
|
||||
autoClosingPairs: [
|
||||
{ open: '"', close: '"', notIn: ['string', 'comment'] },
|
||||
{ open: '{', close: '}', notIn: ['string', 'comment'] },
|
||||
{ open: '[', close: ']', notIn: ['string', 'comment'] },
|
||||
{ open: '(', close: ')', notIn: ['string', 'comment'] },
|
||||
{ open: '(', close: ')', notIn: ['string', 'comment'] }
|
||||
]
|
||||
};
|
||||
|
||||
|
|
@ -38,78 +43,78 @@ export const language = <ILanguage>{
|
|||
|
||||
keywords: [
|
||||
//
|
||||
"abstype", // ABSTYPE
|
||||
"abst0ype", // ABST0YPE
|
||||
"absprop", // ABSPROP
|
||||
"absview", // ABSVIEW
|
||||
"absvtype", // ABSVIEWTYPE
|
||||
"absviewtype", // ABSVIEWTYPE
|
||||
"absvt0ype", // ABSVIEWT0YPE
|
||||
"absviewt0ype", // ABSVIEWT0YPE
|
||||
'abstype', // ABSTYPE
|
||||
'abst0ype', // ABST0YPE
|
||||
'absprop', // ABSPROP
|
||||
'absview', // ABSVIEW
|
||||
'absvtype', // ABSVIEWTYPE
|
||||
'absviewtype', // ABSVIEWTYPE
|
||||
'absvt0ype', // ABSVIEWT0YPE
|
||||
'absviewt0ype', // ABSVIEWT0YPE
|
||||
//
|
||||
"as", // T_AS
|
||||
'as', // T_AS
|
||||
//
|
||||
"and", // T_AND
|
||||
'and', // T_AND
|
||||
//
|
||||
"assume", // T_ASSUME
|
||||
'assume', // T_ASSUME
|
||||
//
|
||||
"begin", // T_BEGIN
|
||||
'begin', // T_BEGIN
|
||||
//
|
||||
/*
|
||||
"case", // CASE
|
||||
*/
|
||||
//
|
||||
"classdec", // T_CLASSDEC
|
||||
'classdec', // T_CLASSDEC
|
||||
//
|
||||
"datasort", // T_DATASORT
|
||||
'datasort', // T_DATASORT
|
||||
//
|
||||
"datatype", // DATATYPE
|
||||
"dataprop", // DATAPROP
|
||||
"dataview", // DATAVIEW
|
||||
"datavtype", // DATAVIEWTYPE
|
||||
"dataviewtype", // DATAVIEWTYPE
|
||||
'datatype', // DATATYPE
|
||||
'dataprop', // DATAPROP
|
||||
'dataview', // DATAVIEW
|
||||
'datavtype', // DATAVIEWTYPE
|
||||
'dataviewtype', // DATAVIEWTYPE
|
||||
//
|
||||
"do", // T_DO
|
||||
'do', // T_DO
|
||||
//
|
||||
"end", // T_END
|
||||
'end', // T_END
|
||||
//
|
||||
"extern", // T_EXTERN
|
||||
"extype", // T_EXTYPE
|
||||
"extvar", // T_EXTVAR
|
||||
'extern', // T_EXTERN
|
||||
'extype', // T_EXTYPE
|
||||
'extvar', // T_EXTVAR
|
||||
//
|
||||
"exception", // T_EXCEPTION
|
||||
'exception', // T_EXCEPTION
|
||||
//
|
||||
"fn", // FN // non-recursive
|
||||
"fnx", // FNX // mutual tail-rec.
|
||||
"fun", // FUN // general-recursive
|
||||
'fn', // FN // non-recursive
|
||||
'fnx', // FNX // mutual tail-rec.
|
||||
'fun', // FUN // general-recursive
|
||||
//
|
||||
"prfn", // PRFN
|
||||
"prfun", // PRFUN
|
||||
'prfn', // PRFN
|
||||
'prfun', // PRFUN
|
||||
//
|
||||
"praxi", // PRAXI
|
||||
"castfn", // CASTFN
|
||||
'praxi', // PRAXI
|
||||
'castfn', // CASTFN
|
||||
//
|
||||
"if", // T_IF
|
||||
"then", // T_THEN
|
||||
"else", // T_ELSE
|
||||
'if', // T_IF
|
||||
'then', // T_THEN
|
||||
'else', // T_ELSE
|
||||
//
|
||||
"ifcase", // T_IFCASE
|
||||
'ifcase', // T_IFCASE
|
||||
//
|
||||
"in", // T_IN
|
||||
'in', // T_IN
|
||||
//
|
||||
"infix", // INFIX
|
||||
"infixl", // INFIXL
|
||||
"infixr", // INFIXR
|
||||
"prefix", // PREFIX
|
||||
"postfix", // POSTFIX
|
||||
'infix', // INFIX
|
||||
'infixl', // INFIXL
|
||||
'infixr', // INFIXR
|
||||
'prefix', // PREFIX
|
||||
'postfix', // POSTFIX
|
||||
//
|
||||
"implmnt", // IMPLMNT // 0
|
||||
"implement", // IMPLEMENT // 1
|
||||
'implmnt', // IMPLMNT // 0
|
||||
'implement', // IMPLEMENT // 1
|
||||
//
|
||||
"primplmnt", // PRIMPLMNT // ~1
|
||||
"primplement", // PRIMPLMNT // ~1
|
||||
'primplmnt', // PRIMPLMNT // ~1
|
||||
'primplement', // PRIMPLMNT // ~1
|
||||
//
|
||||
"import", // T_IMPORT // for importing packages
|
||||
'import', // T_IMPORT // for importing packages
|
||||
//
|
||||
/*
|
||||
"lam", // LAM
|
||||
|
|
@ -117,242 +122,242 @@ export const language = <ILanguage>{
|
|||
"fix", // FIX
|
||||
*/
|
||||
//
|
||||
"let", // T_LET
|
||||
'let', // T_LET
|
||||
//
|
||||
"local", // T_LOCAL
|
||||
'local', // T_LOCAL
|
||||
//
|
||||
"macdef", // MACDEF
|
||||
"macrodef", // MACRODEF
|
||||
'macdef', // MACDEF
|
||||
'macrodef', // MACRODEF
|
||||
//
|
||||
"nonfix", // T_NONFIX
|
||||
'nonfix', // T_NONFIX
|
||||
//
|
||||
"symelim", // T_SYMELIM
|
||||
"symintr", // T_SYMINTR
|
||||
"overload", // T_OVERLOAD
|
||||
'symelim', // T_SYMELIM
|
||||
'symintr', // T_SYMINTR
|
||||
'overload', // T_OVERLOAD
|
||||
//
|
||||
"of", // T_OF
|
||||
"op", // T_OP
|
||||
'of', // T_OF
|
||||
'op', // T_OP
|
||||
//
|
||||
"rec", // T_REC
|
||||
'rec', // T_REC
|
||||
//
|
||||
"sif", // T_SIF
|
||||
"scase", // T_SCASE
|
||||
'sif', // T_SIF
|
||||
'scase', // T_SCASE
|
||||
//
|
||||
"sortdef", // T_SORTDEF
|
||||
'sortdef', // T_SORTDEF
|
||||
/*
|
||||
// HX: [sta] is now deprecated
|
||||
*/
|
||||
"sta", // T_STACST
|
||||
"stacst", // T_STACST
|
||||
"stadef", // T_STADEF
|
||||
"static", // T_STATIC
|
||||
'sta', // T_STACST
|
||||
'stacst', // T_STACST
|
||||
'stadef', // T_STADEF
|
||||
'static', // T_STATIC
|
||||
/*
|
||||
"stavar", // T_STAVAR
|
||||
*/
|
||||
//
|
||||
"staload", // T_STALOAD
|
||||
"dynload", // T_DYNLOAD
|
||||
'staload', // T_STALOAD
|
||||
'dynload', // T_DYNLOAD
|
||||
//
|
||||
"try", // T_TRY
|
||||
'try', // T_TRY
|
||||
//
|
||||
"tkindef", // T_TKINDEF // HX-2012-05-23
|
||||
'tkindef', // T_TKINDEF // HX-2012-05-23
|
||||
//
|
||||
/*
|
||||
"type", // TYPE
|
||||
*/
|
||||
"typedef", // TYPEDEF
|
||||
"propdef", // PROPDEF
|
||||
"viewdef", // VIEWDEF
|
||||
"vtypedef", // VIEWTYPEDEF
|
||||
"viewtypedef", // VIEWTYPEDEF
|
||||
'typedef', // TYPEDEF
|
||||
'propdef', // PROPDEF
|
||||
'viewdef', // VIEWDEF
|
||||
'vtypedef', // VIEWTYPEDEF
|
||||
'viewtypedef', // VIEWTYPEDEF
|
||||
//
|
||||
/*
|
||||
"val", // VAL
|
||||
*/
|
||||
"prval", // PRVAL
|
||||
'prval', // PRVAL
|
||||
//
|
||||
"var", // VAR
|
||||
"prvar", // PRVAR
|
||||
'var', // VAR
|
||||
'prvar', // PRVAR
|
||||
//
|
||||
"when", // T_WHEN
|
||||
"where", // T_WHERE
|
||||
'when', // T_WHEN
|
||||
'where', // T_WHERE
|
||||
//
|
||||
/*
|
||||
"for", // T_FOR
|
||||
"while", // T_WHILE
|
||||
*/
|
||||
//
|
||||
"with", // T_WITH
|
||||
'with', // T_WITH
|
||||
//
|
||||
"withtype", // WITHTYPE
|
||||
"withprop", // WITHPROP
|
||||
"withview", // WITHVIEW
|
||||
"withvtype", // WITHVIEWTYPE
|
||||
"withviewtype", // WITHVIEWTYPE
|
||||
'withtype', // WITHTYPE
|
||||
'withprop', // WITHPROP
|
||||
'withview', // WITHVIEW
|
||||
'withvtype', // WITHVIEWTYPE
|
||||
'withviewtype' // WITHVIEWTYPE
|
||||
//
|
||||
],
|
||||
keywords_dlr: [
|
||||
"$delay", // DLRDELAY
|
||||
"$ldelay", // DLRLDELAY
|
||||
'$delay', // DLRDELAY
|
||||
'$ldelay', // DLRLDELAY
|
||||
//
|
||||
"$arrpsz", // T_DLRARRPSZ
|
||||
"$arrptrsize", // T_DLRARRPSZ
|
||||
'$arrpsz', // T_DLRARRPSZ
|
||||
'$arrptrsize', // T_DLRARRPSZ
|
||||
//
|
||||
"$d2ctype", // T_DLRD2CTYPE
|
||||
'$d2ctype', // T_DLRD2CTYPE
|
||||
//
|
||||
"$effmask", // DLREFFMASK
|
||||
"$effmask_ntm", // DLREFFMASK_NTM
|
||||
"$effmask_exn", // DLREFFMASK_EXN
|
||||
"$effmask_ref", // DLREFFMASK_REF
|
||||
"$effmask_wrt", // DLREFFMASK_WRT
|
||||
"$effmask_all", // DLREFFMASK_ALL
|
||||
'$effmask', // DLREFFMASK
|
||||
'$effmask_ntm', // DLREFFMASK_NTM
|
||||
'$effmask_exn', // DLREFFMASK_EXN
|
||||
'$effmask_ref', // DLREFFMASK_REF
|
||||
'$effmask_wrt', // DLREFFMASK_WRT
|
||||
'$effmask_all', // DLREFFMASK_ALL
|
||||
//
|
||||
"$extern", // T_DLREXTERN
|
||||
"$extkind", // T_DLREXTKIND
|
||||
"$extype", // T_DLREXTYPE
|
||||
"$extype_struct", // T_DLREXTYPE_STRUCT
|
||||
'$extern', // T_DLREXTERN
|
||||
'$extkind', // T_DLREXTKIND
|
||||
'$extype', // T_DLREXTYPE
|
||||
'$extype_struct', // T_DLREXTYPE_STRUCT
|
||||
//
|
||||
"$extval", // T_DLREXTVAL
|
||||
"$extfcall", // T_DLREXTFCALL
|
||||
"$extmcall", // T_DLREXTMCALL
|
||||
'$extval', // T_DLREXTVAL
|
||||
'$extfcall', // T_DLREXTFCALL
|
||||
'$extmcall', // T_DLREXTMCALL
|
||||
//
|
||||
"$literal", // T_DLRLITERAL
|
||||
'$literal', // T_DLRLITERAL
|
||||
//
|
||||
"$myfilename", // T_DLRMYFILENAME
|
||||
"$mylocation", // T_DLRMYLOCATION
|
||||
"$myfunction", // T_DLRMYFUNCTION
|
||||
'$myfilename', // T_DLRMYFILENAME
|
||||
'$mylocation', // T_DLRMYLOCATION
|
||||
'$myfunction', // T_DLRMYFUNCTION
|
||||
//
|
||||
"$lst", // DLRLST
|
||||
"$lst_t", // DLRLST_T
|
||||
"$lst_vt", // DLRLST_VT
|
||||
"$list", // DLRLST
|
||||
"$list_t", // DLRLST_T
|
||||
"$list_vt", // DLRLST_VT
|
||||
'$lst', // DLRLST
|
||||
'$lst_t', // DLRLST_T
|
||||
'$lst_vt', // DLRLST_VT
|
||||
'$list', // DLRLST
|
||||
'$list_t', // DLRLST_T
|
||||
'$list_vt', // DLRLST_VT
|
||||
//
|
||||
"$rec", // DLRREC
|
||||
"$rec_t", // DLRREC_T
|
||||
"$rec_vt", // DLRREC_VT
|
||||
"$record", // DLRREC
|
||||
"$record_t", // DLRREC_T
|
||||
"$record_vt", // DLRREC_VT
|
||||
'$rec', // DLRREC
|
||||
'$rec_t', // DLRREC_T
|
||||
'$rec_vt', // DLRREC_VT
|
||||
'$record', // DLRREC
|
||||
'$record_t', // DLRREC_T
|
||||
'$record_vt', // DLRREC_VT
|
||||
//
|
||||
"$tup", // DLRTUP
|
||||
"$tup_t", // DLRTUP_T
|
||||
"$tup_vt", // DLRTUP_VT
|
||||
"$tuple", // DLRTUP
|
||||
"$tuple_t", // DLRTUP_T
|
||||
"$tuple_vt", // DLRTUP_VT
|
||||
'$tup', // DLRTUP
|
||||
'$tup_t', // DLRTUP_T
|
||||
'$tup_vt', // DLRTUP_VT
|
||||
'$tuple', // DLRTUP
|
||||
'$tuple_t', // DLRTUP_T
|
||||
'$tuple_vt', // DLRTUP_VT
|
||||
//
|
||||
"$break", // T_DLRBREAK
|
||||
"$continue", // T_DLRCONTINUE
|
||||
'$break', // T_DLRBREAK
|
||||
'$continue', // T_DLRCONTINUE
|
||||
//
|
||||
"$raise", // T_DLRRAISE
|
||||
'$raise', // T_DLRRAISE
|
||||
//
|
||||
"$showtype", // T_DLRSHOWTYPE
|
||||
'$showtype', // T_DLRSHOWTYPE
|
||||
//
|
||||
"$vcopyenv_v", // DLRVCOPYENV_V
|
||||
"$vcopyenv_vt", // DLRVCOPYENV_VT
|
||||
'$vcopyenv_v', // DLRVCOPYENV_V
|
||||
'$vcopyenv_vt', // DLRVCOPYENV_VT
|
||||
//
|
||||
"$tempenver", // T_DLRTEMPENVER
|
||||
'$tempenver', // T_DLRTEMPENVER
|
||||
//
|
||||
"$solver_assert", // T_DLRSOLASSERT
|
||||
"$solver_verify", // T_DLRSOLVERIFY
|
||||
'$solver_assert', // T_DLRSOLASSERT
|
||||
'$solver_verify' // T_DLRSOLVERIFY
|
||||
],
|
||||
keywords_srp: [
|
||||
//
|
||||
"#if", // T_SRPIF
|
||||
"#ifdef", // T_SRPIFDEF
|
||||
"#ifndef", // T_SRPIFNDEF
|
||||
'#if', // T_SRPIF
|
||||
'#ifdef', // T_SRPIFDEF
|
||||
'#ifndef', // T_SRPIFNDEF
|
||||
//
|
||||
"#then", // T_SRPTHEN
|
||||
'#then', // T_SRPTHEN
|
||||
//
|
||||
"#elif", // T_SRPELIF
|
||||
"#elifdef", // T_SRPELIFDEF
|
||||
"#elifndef", // T_SRPELIFNDEF
|
||||
'#elif', // T_SRPELIF
|
||||
'#elifdef', // T_SRPELIFDEF
|
||||
'#elifndef', // T_SRPELIFNDEF
|
||||
//
|
||||
"#else", // T_SRPELSE
|
||||
"#endif", // T_SRPENDIF
|
||||
'#else', // T_SRPELSE
|
||||
'#endif', // T_SRPENDIF
|
||||
//
|
||||
"#error", // T_SRPERROR
|
||||
'#error', // T_SRPERROR
|
||||
//
|
||||
"#prerr", // T_SRPPRERR // outpui to stderr
|
||||
"#print", // T_SRPPRINT // output to stdout
|
||||
'#prerr', // T_SRPPRERR // outpui to stderr
|
||||
'#print', // T_SRPPRINT // output to stdout
|
||||
//
|
||||
"#assert", // T_SRPASSERT
|
||||
'#assert', // T_SRPASSERT
|
||||
//
|
||||
"#undef", // T_SRPUNDEF
|
||||
"#define", // T_SRPDEFINE
|
||||
'#undef', // T_SRPUNDEF
|
||||
'#define', // T_SRPDEFINE
|
||||
//
|
||||
"#include", // T_SRPINCLUDE
|
||||
"#require", // T_SRPREQUIRE
|
||||
'#include', // T_SRPINCLUDE
|
||||
'#require', // T_SRPREQUIRE
|
||||
//
|
||||
"#pragma", // T_SRPPRAGMA // HX: general pragma
|
||||
"#codegen2", // T_SRPCODEGEN2 // for level-2 codegen
|
||||
"#codegen3", // T_SRPCODEGEN3 // for level-3 codegen
|
||||
'#pragma', // T_SRPPRAGMA // HX: general pragma
|
||||
'#codegen2', // T_SRPCODEGEN2 // for level-2 codegen
|
||||
'#codegen3' // T_SRPCODEGEN3 // for level-3 codegen
|
||||
//
|
||||
// HX: end of special tokens
|
||||
//
|
||||
],
|
||||
|
||||
irregular_keyword_list: [
|
||||
"val+",
|
||||
"val-",
|
||||
"val",
|
||||
"case+",
|
||||
"case-",
|
||||
"case",
|
||||
"addr@",
|
||||
"addr",
|
||||
"fold@",
|
||||
"free@",
|
||||
"fix@",
|
||||
"fix",
|
||||
"lam@",
|
||||
"lam",
|
||||
"llam@",
|
||||
"llam",
|
||||
"viewt@ype+",
|
||||
"viewt@ype-",
|
||||
"viewt@ype",
|
||||
"viewtype+",
|
||||
"viewtype-",
|
||||
"viewtype",
|
||||
"view+",
|
||||
"view-",
|
||||
"view@",
|
||||
"view",
|
||||
"type+",
|
||||
"type-",
|
||||
"type",
|
||||
"vtype+",
|
||||
"vtype-",
|
||||
"vtype",
|
||||
"vt@ype+",
|
||||
"vt@ype-",
|
||||
"vt@ype",
|
||||
"viewt@ype+",
|
||||
"viewt@ype-",
|
||||
"viewt@ype",
|
||||
"viewtype+",
|
||||
"viewtype-",
|
||||
"viewtype",
|
||||
"prop+",
|
||||
"prop-",
|
||||
"prop",
|
||||
"type+",
|
||||
"type-",
|
||||
"type",
|
||||
"t@ype",
|
||||
"t@ype+",
|
||||
"t@ype-",
|
||||
"abst@ype",
|
||||
"abstype",
|
||||
"absviewt@ype",
|
||||
"absvt@ype",
|
||||
"for*",
|
||||
"for",
|
||||
"while*",
|
||||
"while"
|
||||
'val+',
|
||||
'val-',
|
||||
'val',
|
||||
'case+',
|
||||
'case-',
|
||||
'case',
|
||||
'addr@',
|
||||
'addr',
|
||||
'fold@',
|
||||
'free@',
|
||||
'fix@',
|
||||
'fix',
|
||||
'lam@',
|
||||
'lam',
|
||||
'llam@',
|
||||
'llam',
|
||||
'viewt@ype+',
|
||||
'viewt@ype-',
|
||||
'viewt@ype',
|
||||
'viewtype+',
|
||||
'viewtype-',
|
||||
'viewtype',
|
||||
'view+',
|
||||
'view-',
|
||||
'view@',
|
||||
'view',
|
||||
'type+',
|
||||
'type-',
|
||||
'type',
|
||||
'vtype+',
|
||||
'vtype-',
|
||||
'vtype',
|
||||
'vt@ype+',
|
||||
'vt@ype-',
|
||||
'vt@ype',
|
||||
'viewt@ype+',
|
||||
'viewt@ype-',
|
||||
'viewt@ype',
|
||||
'viewtype+',
|
||||
'viewtype-',
|
||||
'viewtype',
|
||||
'prop+',
|
||||
'prop-',
|
||||
'prop',
|
||||
'type+',
|
||||
'type-',
|
||||
'type',
|
||||
't@ype',
|
||||
't@ype+',
|
||||
't@ype-',
|
||||
'abst@ype',
|
||||
'abstype',
|
||||
'absviewt@ype',
|
||||
'absvt@ype',
|
||||
'for*',
|
||||
'for',
|
||||
'while*',
|
||||
'while'
|
||||
],
|
||||
|
||||
keywords_types: [
|
||||
|
|
@ -372,53 +377,53 @@ export const language = <ILanguage>{
|
|||
|
||||
// TODO: reference for this?
|
||||
keywords_effects: [
|
||||
"0", // no effects
|
||||
"fun",
|
||||
"clo",
|
||||
"prf",
|
||||
"funclo",
|
||||
"cloptr",
|
||||
"cloref",
|
||||
"ref",
|
||||
"ntm",
|
||||
"1" // all effects
|
||||
'0', // no effects
|
||||
'fun',
|
||||
'clo',
|
||||
'prf',
|
||||
'funclo',
|
||||
'cloptr',
|
||||
'cloref',
|
||||
'ref',
|
||||
'ntm',
|
||||
'1' // all effects
|
||||
],
|
||||
|
||||
operators: [
|
||||
"@", // T_AT
|
||||
"!", // T_BANG
|
||||
"|", // T_BAR
|
||||
"`", // T_BQUOTE
|
||||
":", // T_COLON
|
||||
"$", // T_DOLLAR
|
||||
".", // T_DOT
|
||||
"=", // T_EQ
|
||||
"#", // T_HASH
|
||||
"~", // T_TILDE
|
||||
'@', // T_AT
|
||||
'!', // T_BANG
|
||||
'|', // T_BAR
|
||||
'`', // T_BQUOTE
|
||||
':', // T_COLON
|
||||
'$', // T_DOLLAR
|
||||
'.', // T_DOT
|
||||
'=', // T_EQ
|
||||
'#', // T_HASH
|
||||
'~', // T_TILDE
|
||||
//
|
||||
"..", // T_DOTDOT
|
||||
"...", // T_DOTDOTDOT
|
||||
'..', // T_DOTDOT
|
||||
'...', // T_DOTDOTDOT
|
||||
//
|
||||
"=>", // T_EQGT
|
||||
'=>', // T_EQGT
|
||||
// "=<", // T_EQLT
|
||||
"=<>", // T_EQLTGT
|
||||
"=/=>", // T_EQSLASHEQGT
|
||||
"=>>", // T_EQGTGT
|
||||
"=/=>>", // T_EQSLASHEQGTGT
|
||||
'=<>', // T_EQLTGT
|
||||
'=/=>', // T_EQSLASHEQGT
|
||||
'=>>', // T_EQGTGT
|
||||
'=/=>>', // T_EQSLASHEQGTGT
|
||||
//
|
||||
"<", // T_LT // opening a tmparg
|
||||
">", // T_GT // closing a tmparg
|
||||
'<', // T_LT // opening a tmparg
|
||||
'>', // T_GT // closing a tmparg
|
||||
//
|
||||
"><", // T_GTLT
|
||||
'><', // T_GTLT
|
||||
//
|
||||
".<", // T_DOTLT
|
||||
">.", // T_GTDOT
|
||||
'.<', // T_DOTLT
|
||||
'>.', // T_GTDOT
|
||||
//
|
||||
".<>.", // T_DOTLTGTDOT
|
||||
'.<>.', // T_DOTLTGTDOT
|
||||
//
|
||||
"->", // T_MINUSGT
|
||||
'->', // T_MINUSGT
|
||||
//"-<", // T_MINUSLT
|
||||
"-<>", // T_MINUSLTGT
|
||||
'-<>' // T_MINUSLTGT
|
||||
//
|
||||
/*
|
||||
":<", // T_COLONLT
|
||||
|
|
@ -429,8 +434,8 @@ export const language = <ILanguage>{
|
|||
{ open: ',(', close: ')', token: 'delimiter.parenthesis' }, // meta-programming syntax
|
||||
{ open: '`(', close: ')', token: 'delimiter.parenthesis' },
|
||||
{ open: '%(', close: ')', token: 'delimiter.parenthesis' },
|
||||
{ open: '\'(', close: ')', token: 'delimiter.parenthesis' },
|
||||
{ open: '\'{', close: '}', token: 'delimiter.parenthesis' },
|
||||
{ open: "'(", close: ')', token: 'delimiter.parenthesis' },
|
||||
{ open: "'{", close: '}', token: 'delimiter.parenthesis' },
|
||||
{ open: '@(', close: ')', token: 'delimiter.parenthesis' },
|
||||
{ open: '@{', close: '}', token: 'delimiter.brace' },
|
||||
{ open: '@[', close: ']', token: 'delimiter.square' },
|
||||
|
|
@ -471,27 +476,63 @@ export const language = <ILanguage>{
|
|||
|
||||
// NOTE: (*) is an invalid ML-like comment!
|
||||
{ regex: /\(\*\)/, action: { token: 'invalid' } },
|
||||
{ regex: /\(\*/, action: { token: 'comment', next: 'lexing_COMMENT_block_ml' } },
|
||||
{ regex: /\(/, action: '@brackets'/*{ token: 'delimiter.parenthesis' }*/ },
|
||||
{ regex: /\)/, action: '@brackets'/*{ token: 'delimiter.parenthesis' }*/ },
|
||||
{ regex: /\[/, action: '@brackets'/*{ token: 'delimiter.bracket' }*/ },
|
||||
{ regex: /\]/, action: '@brackets'/*{ token: 'delimiter.bracket' }*/ },
|
||||
{ regex: /\{/, action: '@brackets'/*{ token: 'delimiter.brace' }*/ },
|
||||
{ regex: /\}/, action: '@brackets'/*{ token: 'delimiter.brace' }*/ },
|
||||
{
|
||||
regex: /\(\*/,
|
||||
action: { token: 'comment', next: 'lexing_COMMENT_block_ml' }
|
||||
},
|
||||
{
|
||||
regex: /\(/,
|
||||
action: '@brackets' /*{ token: 'delimiter.parenthesis' }*/
|
||||
},
|
||||
{
|
||||
regex: /\)/,
|
||||
action: '@brackets' /*{ token: 'delimiter.parenthesis' }*/
|
||||
},
|
||||
{
|
||||
regex: /\[/,
|
||||
action: '@brackets' /*{ token: 'delimiter.bracket' }*/
|
||||
},
|
||||
{
|
||||
regex: /\]/,
|
||||
action: '@brackets' /*{ token: 'delimiter.bracket' }*/
|
||||
},
|
||||
{
|
||||
regex: /\{/,
|
||||
action: '@brackets' /*{ token: 'delimiter.brace' }*/
|
||||
},
|
||||
{
|
||||
regex: /\}/,
|
||||
action: '@brackets' /*{ token: 'delimiter.brace' }*/
|
||||
},
|
||||
|
||||
// lexing_COMMA
|
||||
{ regex: /,\(/, action: '@brackets'/*{ token: 'delimiter.parenthesis' }*/ }, // meta-programming syntax
|
||||
{
|
||||
regex: /,\(/,
|
||||
action: '@brackets' /*{ token: 'delimiter.parenthesis' }*/
|
||||
}, // meta-programming syntax
|
||||
{ regex: /,/, action: { token: 'delimiter.comma' } },
|
||||
|
||||
{ regex: /;/, action: { token: 'delimiter.semicolon' } },
|
||||
|
||||
// lexing_AT
|
||||
{ regex: /@\(/, action: '@brackets'/* { token: 'delimiter.parenthesis' }*/ },
|
||||
{ regex: /@\[/, action: '@brackets'/* { token: 'delimiter.bracket' }*/ },
|
||||
{ regex: /@\{/, action: '@brackets'/*{ token: 'delimiter.brace' }*/ },
|
||||
{
|
||||
regex: /@\(/,
|
||||
action: '@brackets' /* { token: 'delimiter.parenthesis' }*/
|
||||
},
|
||||
{
|
||||
regex: /@\[/,
|
||||
action: '@brackets' /* { token: 'delimiter.bracket' }*/
|
||||
},
|
||||
{
|
||||
regex: /@\{/,
|
||||
action: '@brackets' /*{ token: 'delimiter.brace' }*/
|
||||
},
|
||||
|
||||
// lexing_COLON
|
||||
{ regex: /:</, action: { token: 'keyword', next: '@lexing_EFFECT_commaseq0' } }, // T_COLONLT
|
||||
{
|
||||
regex: /:</,
|
||||
action: { token: 'keyword', next: '@lexing_EFFECT_commaseq0' }
|
||||
}, // T_COLONLT
|
||||
|
||||
/*
|
||||
lexing_DOT:
|
||||
|
|
@ -502,7 +543,10 @@ export const language = <ILanguage>{
|
|||
*/
|
||||
{ regex: /\.@symbolic+/, action: { token: 'identifier.sym' } },
|
||||
// FLOATDOT case
|
||||
{ regex: /\.@digit*@fexponent@FLOATSP*/, action: { token: 'number.float' } },
|
||||
{
|
||||
regex: /\.@digit*@fexponent@FLOATSP*/,
|
||||
action: { token: 'number.float' }
|
||||
},
|
||||
{ regex: /\.@digit+/, action: { token: 'number.float' } }, // T_DOTINT
|
||||
|
||||
// lexing_DOLLAR:
|
||||
|
|
@ -512,7 +556,7 @@ export const language = <ILanguage>{
|
|||
action: {
|
||||
cases: {
|
||||
'@keywords_dlr': { token: 'keyword.dlr' },
|
||||
'@default': { token: 'namespace' }, // most likely a module qualifier
|
||||
'@default': { token: 'namespace' } // most likely a module qualifier
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
@ -523,28 +567,41 @@ export const language = <ILanguage>{
|
|||
action: {
|
||||
cases: {
|
||||
'@keywords_srp': { token: 'keyword.srp' },
|
||||
'@default': { token: 'identifier' },
|
||||
'@default': { token: 'identifier' }
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// lexing_PERCENT:
|
||||
{ regex: /%\(/, action: { token: 'delimiter.parenthesis' } },
|
||||
{ regex: /^%{(#|\^|\$)?/, action: { token: 'keyword', next: '@lexing_EXTCODE', nextEmbedded: 'text/javascript' } },
|
||||
{
|
||||
regex: /^%{(#|\^|\$)?/,
|
||||
action: {
|
||||
token: 'keyword',
|
||||
next: '@lexing_EXTCODE',
|
||||
nextEmbedded: 'text/javascript'
|
||||
}
|
||||
},
|
||||
{ regex: /^%}/, action: { token: 'keyword' } },
|
||||
|
||||
// lexing_QUOTE
|
||||
{ regex: /'\(/, action: { token: 'delimiter.parenthesis' } },
|
||||
{ regex: /'\[/, action: { token: 'delimiter.bracket' } },
|
||||
{ regex: /'\{/, action: { token: 'delimiter.brace' } },
|
||||
[/(')(\\@ESCHAR|\\[xX]@xdigit+|\\@digit+)(')/, ['string', 'string.escape', 'string']],
|
||||
[
|
||||
/(')(\\@ESCHAR|\\[xX]@xdigit+|\\@digit+)(')/,
|
||||
['string', 'string.escape', 'string']
|
||||
],
|
||||
[/'[^\\']'/, 'string'],
|
||||
|
||||
// lexing_DQUOTE
|
||||
[/"/, 'string.quote', '@lexing_DQUOTE'],
|
||||
|
||||
// lexing_BQUOTE
|
||||
{ regex: /`\(/, action: '@brackets'/* { token: 'delimiter.parenthesis' }*/ },
|
||||
{
|
||||
regex: /`\(/,
|
||||
action: '@brackets' /* { token: 'delimiter.parenthesis' }*/
|
||||
},
|
||||
// TODO: otherwise, try lexing_IDENT_sym
|
||||
|
||||
{ regex: /\\/, action: { token: 'punctuation' } }, // just T_BACKSLASH
|
||||
|
|
@ -552,7 +609,10 @@ export const language = <ILanguage>{
|
|||
// lexing_IDENT_alp:
|
||||
// NOTE: (?!regex) is syntax for "not-followed-by" regex
|
||||
// to resolve ambiguity such as foreach$fwork being incorrectly lexed as [for] [each$fwork]!
|
||||
{ regex: /@irregular_keywords(?!@IDENTRST)/, action: { token: 'keyword' } },
|
||||
{
|
||||
regex: /@irregular_keywords(?!@IDENTRST)/,
|
||||
action: { token: 'keyword' }
|
||||
},
|
||||
{
|
||||
regex: /@IDENTFST@IDENTRST*[<!\[]?/,
|
||||
action: {
|
||||
|
|
@ -570,11 +630,20 @@ export const language = <ILanguage>{
|
|||
}
|
||||
},
|
||||
// lexing_IDENT_sym:
|
||||
{ regex: /\/\/\/\//, action: { token: 'comment', next: '@lexing_COMMENT_rest' } },
|
||||
{
|
||||
regex: /\/\/\/\//,
|
||||
action: { token: 'comment', next: '@lexing_COMMENT_rest' }
|
||||
},
|
||||
{ regex: /\/\/.*$/, action: { token: 'comment' } },
|
||||
{ regex: /\/\*/, action: { token: 'comment', next: '@lexing_COMMENT_block_c' } },
|
||||
{
|
||||
regex: /\/\*/,
|
||||
action: { token: 'comment', next: '@lexing_COMMENT_block_c' }
|
||||
},
|
||||
// AS-20160627: specifically for effect annotations
|
||||
{ regex: /-<|=</, action: { token: 'keyword', next: '@lexing_EFFECT_commaseq0' } },
|
||||
{
|
||||
regex: /-<|=</,
|
||||
action: { token: 'keyword', next: '@lexing_EFFECT_commaseq0' }
|
||||
},
|
||||
{
|
||||
regex: /@symbolic+/,
|
||||
action: {
|
||||
|
|
@ -593,20 +662,31 @@ export const language = <ILanguage>{
|
|||
// - testing_intspseq0 => T_INT_hex
|
||||
|
||||
// lexing_INT_hex:
|
||||
{ regex: /0[xX]@xdigit+(@hexiexp|@fexponent_bin)@FLOATSP*/, action: { token: 'number.float' } },
|
||||
{
|
||||
regex: /0[xX]@xdigit+(@hexiexp|@fexponent_bin)@FLOATSP*/,
|
||||
action: { token: 'number.float' }
|
||||
},
|
||||
{ regex: /0[xX]@xdigit+@INTSP*/, action: { token: 'number.hex' } },
|
||||
{ regex: /0[0-7]+(?![0-9])@INTSP*/, action: { token: 'number.octal' } }, // lexing_INT_oct
|
||||
{
|
||||
regex: /0[0-7]+(?![0-9])@INTSP*/,
|
||||
action: { token: 'number.octal' }
|
||||
}, // lexing_INT_oct
|
||||
//{regex: /0/, action: { token: 'number' } }, // INTZERO
|
||||
|
||||
// lexing_INT_dec:
|
||||
// - testing_deciexp => lexing_FLOAT_deciexp
|
||||
// - testing_fexponent => lexing_FLOAT_deciexp
|
||||
// - otherwise => intspseq0 ([0-9]*[lLuU]?)
|
||||
{ regex: /@digit+(@fexponent|@deciexp)@FLOATSP*/, action: { token: 'number.float' } },
|
||||
{ regex: /@digit@digitseq0@INTSP*/, action: { token: 'number.decimal' } },
|
||||
{
|
||||
regex: /@digit+(@fexponent|@deciexp)@FLOATSP*/,
|
||||
action: { token: 'number.float' }
|
||||
},
|
||||
{
|
||||
regex: /@digit@digitseq0@INTSP*/,
|
||||
action: { token: 'number.decimal' }
|
||||
},
|
||||
// DIGIT, if followed by digitseq0, is lexing_INT_dec
|
||||
{ regex: /@digit+@INTSP*/, action: { token: 'number' } },
|
||||
|
||||
{ regex: /@digit+@INTSP*/, action: { token: 'number' } }
|
||||
],
|
||||
|
||||
lexing_COMMENT_block_ml: [
|
||||
|
|
@ -640,22 +720,38 @@ export const language = <ILanguage>{
|
|||
}
|
||||
},
|
||||
{ regex: /,/, action: { token: 'punctuation' } },
|
||||
{ regex: />/, action: { token: '@rematch', next: '@pop' } },
|
||||
{ regex: />/, action: { token: '@rematch', next: '@pop' } }
|
||||
],
|
||||
|
||||
lexing_EXTCODE: [
|
||||
{ regex: /^%}/, action: { token: '@rematch', next: '@pop', nextEmbedded: '@pop' } },
|
||||
{ regex: /[^%]+/, action: '' },
|
||||
{
|
||||
regex: /^%}/,
|
||||
action: {
|
||||
token: '@rematch',
|
||||
next: '@pop',
|
||||
nextEmbedded: '@pop'
|
||||
}
|
||||
},
|
||||
{ regex: /[^%]+/, action: '' }
|
||||
],
|
||||
|
||||
lexing_DQUOTE: [
|
||||
{ regex: /"/, action: { token: 'string.quote', next: '@pop' } },
|
||||
// AS-20160628: additional hi-lighting for variables in staload/dynload strings
|
||||
{ regex: /(\{\$)(@IDENTFST@IDENTRST*)(\})/, action: [{ token: 'string.escape' }, { token: 'identifier' }, { token: 'string.escape' }] },
|
||||
{
|
||||
regex: /(\{\$)(@IDENTFST@IDENTRST*)(\})/,
|
||||
action: [
|
||||
{ token: 'string.escape' },
|
||||
{ token: 'identifier' },
|
||||
{ token: 'string.escape' }
|
||||
]
|
||||
},
|
||||
{ regex: /\\$/, action: { token: 'string.escape' } },
|
||||
{ regex: /\\(@ESCHAR|[xX]@xdigit+|@digit+)/, action: { token: 'string.escape' } },
|
||||
{
|
||||
regex: /\\(@ESCHAR|[xX]@xdigit+|@digit+)/,
|
||||
action: { token: 'string.escape' }
|
||||
},
|
||||
{ regex: /[^\\"]+/, action: { token: 'string' } }
|
||||
],
|
||||
},
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -9,366 +9,410 @@ import { testTokenization } from '../test/testRunner';
|
|||
|
||||
testTokenization('powerquery', [
|
||||
// Comments
|
||||
[{
|
||||
line: '// a comment',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.pq' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '// a comment',
|
||||
tokens: [{ startIndex: 0, type: 'comment.pq' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: ' // a comment */',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'white.pq' },
|
||||
{ startIndex: 4, type: 'comment.pq' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: ' // a comment */',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'white.pq' },
|
||||
{ startIndex: 4, type: 'comment.pq' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '// a comment',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.pq' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '// a comment',
|
||||
tokens: [{ startIndex: 0, type: 'comment.pq' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '// /* #A */',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.pq' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '// /* #A */',
|
||||
tokens: [{ startIndex: 0, type: 'comment.pq' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '/*ABCD12$!()\\u000D%%%%%*/',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.pq' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '/*ABCD12$!()\\u000D%%%%%*/',
|
||||
tokens: [{ startIndex: 0, type: 'comment.pq' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '42 /* + 45 */ /*',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.pq' },
|
||||
{ startIndex: 2, type: 'white.pq' },
|
||||
{ startIndex: 3, type: 'comment.pq' },
|
||||
{ startIndex: 13, type: 'white.pq' },
|
||||
{ startIndex: 14, type: 'comment.pq' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '42 /* + 45 */ /*',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.pq' },
|
||||
{ startIndex: 2, type: 'white.pq' },
|
||||
{ startIndex: 3, type: 'comment.pq' },
|
||||
{ startIndex: 13, type: 'white.pq' },
|
||||
{ startIndex: 14, type: 'comment.pq' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '/* //*/ a',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.pq' },
|
||||
{ startIndex: 7, type: 'white.pq' },
|
||||
{ startIndex: 8, type: 'identifier.pq' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '/* //*/ a',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.pq' },
|
||||
{ startIndex: 7, type: 'white.pq' },
|
||||
{ startIndex: 8, type: 'identifier.pq' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '1 / 2; /* comment',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.pq' },
|
||||
{ startIndex: 1, type: 'white.pq' },
|
||||
{ startIndex: 2, type: 'operators.pq' },
|
||||
{ startIndex: 3, type: 'white.pq' },
|
||||
{ startIndex: 4, type: 'number.pq' },
|
||||
{ startIndex: 5, type: 'delimiter.pq' },
|
||||
{ startIndex: 6, type: 'white.pq' },
|
||||
{ startIndex: 7, type: 'comment.pq' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '1 / 2; /* comment',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.pq' },
|
||||
{ startIndex: 1, type: 'white.pq' },
|
||||
{ startIndex: 2, type: 'operators.pq' },
|
||||
{ startIndex: 3, type: 'white.pq' },
|
||||
{ startIndex: 4, type: 'number.pq' },
|
||||
{ startIndex: 5, type: 'delimiter.pq' },
|
||||
{ startIndex: 6, type: 'white.pq' },
|
||||
{ startIndex: 7, type: 'comment.pq' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// Quoted Identifiers
|
||||
[{
|
||||
line: '#"Change Types"',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'identifier.quote.pq' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '#"Change Types"',
|
||||
tokens: [{ startIndex: 0, type: 'identifier.quote.pq' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '#"A B" = 1+2,',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'identifier.quote.pq' },
|
||||
{ startIndex: 7, type: 'white.pq' },
|
||||
{ startIndex: 8, type: 'operators.pq' },
|
||||
{ startIndex: 9, type: 'white.pq' },
|
||||
{ startIndex: 10, type: 'number.pq' },
|
||||
{ startIndex: 11, type: 'operators.pq' },
|
||||
{ startIndex: 12, type: 'number.pq' },
|
||||
{ startIndex: 13, type: 'delimiter.pq' },
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '#"A B" = 1+2,',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'identifier.quote.pq' },
|
||||
{ startIndex: 7, type: 'white.pq' },
|
||||
{ startIndex: 8, type: 'operators.pq' },
|
||||
{ startIndex: 9, type: 'white.pq' },
|
||||
{ startIndex: 10, type: 'number.pq' },
|
||||
{ startIndex: 11, type: 'operators.pq' },
|
||||
{ startIndex: 12, type: 'number.pq' },
|
||||
{ startIndex: 13, type: 'delimiter.pq' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: 'a = #"escap ed"+ 1',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'identifier.pq' },
|
||||
{ startIndex: 1, type: 'white.pq' },
|
||||
{ startIndex: 2, type: 'operators.pq' },
|
||||
{ startIndex: 3, type: 'white.pq' },
|
||||
{ startIndex: 4, type: 'identifier.quote.pq' },
|
||||
{ startIndex: 15, type: 'operators.pq' },
|
||||
{ startIndex: 16, type: 'white.pq' },
|
||||
{ startIndex: 17, type: 'number.pq' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'a = #"escap ed"+ 1',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'identifier.pq' },
|
||||
{ startIndex: 1, type: 'white.pq' },
|
||||
{ startIndex: 2, type: 'operators.pq' },
|
||||
{ startIndex: 3, type: 'white.pq' },
|
||||
{ startIndex: 4, type: 'identifier.quote.pq' },
|
||||
{ startIndex: 15, type: 'operators.pq' },
|
||||
{ startIndex: 16, type: 'white.pq' },
|
||||
{ startIndex: 17, type: 'number.pq' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// Number formats
|
||||
[{
|
||||
line: '0Xabc',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.hex.pq' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '0Xabc',
|
||||
tokens: [{ startIndex: 0, type: 'number.hex.pq' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '0xA',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.hex.pq' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '0xA',
|
||||
tokens: [{ startIndex: 0, type: 'number.hex.pq' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '1e1',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.pq' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '1e1',
|
||||
tokens: [{ startIndex: 0, type: 'number.pq' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '5 / 1.2e+2 + 0x1234abc',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.pq' },
|
||||
{ startIndex: 1, type: 'white.pq' },
|
||||
{ startIndex: 2, type: 'operators.pq' },
|
||||
{ startIndex: 3, type: 'white.pq' },
|
||||
{ startIndex: 4, type: 'number.float.pq' },
|
||||
{ startIndex: 10, type: 'white.pq' },
|
||||
{ startIndex: 11, type: 'operators.pq' },
|
||||
{ startIndex: 12, type: 'white.pq'},
|
||||
{ startIndex: 13, type: 'number.hex.pq'}
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '5 / 1.2e+2 + 0x1234abc',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.pq' },
|
||||
{ startIndex: 1, type: 'white.pq' },
|
||||
{ startIndex: 2, type: 'operators.pq' },
|
||||
{ startIndex: 3, type: 'white.pq' },
|
||||
{ startIndex: 4, type: 'number.float.pq' },
|
||||
{ startIndex: 10, type: 'white.pq' },
|
||||
{ startIndex: 11, type: 'operators.pq' },
|
||||
{ startIndex: 12, type: 'white.pq' },
|
||||
{ startIndex: 13, type: 'number.hex.pq' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '0xb *(.2)',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.hex.pq' },
|
||||
{ startIndex: 3, type: 'white.pq' },
|
||||
{ startIndex: 4, type: 'operators.pq' },
|
||||
{ startIndex: 5, type: 'delimiter.parenthesis.pq' },
|
||||
{ startIndex: 6, type: 'number.float.pq' },
|
||||
{ startIndex: 8, type: 'delimiter.parenthesis.pq' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '0xb *(.2)',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.hex.pq' },
|
||||
{ startIndex: 3, type: 'white.pq' },
|
||||
{ startIndex: 4, type: 'operators.pq' },
|
||||
{ startIndex: 5, type: 'delimiter.parenthesis.pq' },
|
||||
{ startIndex: 6, type: 'number.float.pq' },
|
||||
{ startIndex: 8, type: 'delimiter.parenthesis.pq' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '1.23e34+1.2e-2-.3e2',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.float.pq' },
|
||||
{ startIndex: 7, type: 'operators.pq' },
|
||||
{ startIndex: 8, type: 'number.float.pq' },
|
||||
{ startIndex: 14, type: 'operators.pq' },
|
||||
{ startIndex: 15, type: 'number.float.pq' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '1.23e34+1.2e-2-.3e2',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.float.pq' },
|
||||
{ startIndex: 7, type: 'operators.pq' },
|
||||
{ startIndex: 8, type: 'number.float.pq' },
|
||||
{ startIndex: 14, type: 'operators.pq' },
|
||||
{ startIndex: 15, type: 'number.float.pq' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// strings
|
||||
[{
|
||||
line: ' "string"',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'white.pq' },
|
||||
{ startIndex: 2, type: 'string.pq' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: ' "string"',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'white.pq' },
|
||||
{ startIndex: 2, type: 'string.pq' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '"string" & "another"',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'string.pq' },
|
||||
{ startIndex: 8, type: 'white.pq' },
|
||||
{ startIndex: 9, type: 'operators.pq' },
|
||||
{ startIndex: 10, type: 'white.pq' },
|
||||
{ startIndex: 11, type: 'string.pq' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '"string" & "another"',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'string.pq' },
|
||||
{ startIndex: 8, type: 'white.pq' },
|
||||
{ startIndex: 9, type: 'operators.pq' },
|
||||
{ startIndex: 10, type: 'white.pq' },
|
||||
{ startIndex: 11, type: 'string.pq' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '"with ""escaped "" \'text',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'string.pq' },
|
||||
{ startIndex: 7, type: 'string.escape.pq' },
|
||||
{ startIndex: 9, type: 'string.pq' },
|
||||
{ startIndex: 17, type: 'string.escape.pq' },
|
||||
{ startIndex: 19, type: 'string.pq' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '"with ""escaped "" \'text',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'string.pq' },
|
||||
{ startIndex: 7, type: 'string.escape.pq' },
|
||||
{ startIndex: 9, type: 'string.pq' },
|
||||
{ startIndex: 17, type: 'string.escape.pq' },
|
||||
{ startIndex: 19, type: 'string.pq' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// built-in keywords/identifiers
|
||||
[{
|
||||
line: 'And as Each each _',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'identifier.pq' },
|
||||
{ startIndex: 3, type: 'white.pq' },
|
||||
{ startIndex: 4, type: 'keyword.pq' },
|
||||
{ startIndex: 6, type: 'white.pq' },
|
||||
{ startIndex: 7, type: 'identifier.pq' },
|
||||
{ startIndex: 11, type: 'white.pq' },
|
||||
{ startIndex: 12, type: 'keyword.pq' },
|
||||
{ startIndex: 16, type: 'white.pq' },
|
||||
{ startIndex: 17, type: 'identifier.pq' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'And as Each each _',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'identifier.pq' },
|
||||
{ startIndex: 3, type: 'white.pq' },
|
||||
{ startIndex: 4, type: 'keyword.pq' },
|
||||
{ startIndex: 6, type: 'white.pq' },
|
||||
{ startIndex: 7, type: 'identifier.pq' },
|
||||
{ startIndex: 11, type: 'white.pq' },
|
||||
{ startIndex: 12, type: 'keyword.pq' },
|
||||
{ startIndex: 16, type: 'white.pq' },
|
||||
{ startIndex: 17, type: 'identifier.pq' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: ' #table({})',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'white.pq' },
|
||||
{ startIndex: 2, type: 'constructor.pq' },
|
||||
{ startIndex: 8, type: 'delimiter.parenthesis.pq' },
|
||||
{ startIndex: 9, type: 'delimiter.brackets.pq' },
|
||||
{ startIndex: 11, type: "delimiter.parenthesis.pq" }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: ' #table({})',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'white.pq' },
|
||||
{ startIndex: 2, type: 'constructor.pq' },
|
||||
{ startIndex: 8, type: 'delimiter.parenthesis.pq' },
|
||||
{ startIndex: 9, type: 'delimiter.brackets.pq' },
|
||||
{ startIndex: 11, type: 'delimiter.parenthesis.pq' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: 'param as number',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'identifier.pq' },
|
||||
{ startIndex: 5, type: 'white.pq' },
|
||||
{ startIndex: 6, type: 'keyword.pq' },
|
||||
{ startIndex: 8, type: 'white.pq' },
|
||||
{ startIndex: 9, type: 'type.pq' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'param as number',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'identifier.pq' },
|
||||
{ startIndex: 5, type: 'white.pq' },
|
||||
{ startIndex: 6, type: 'keyword.pq' },
|
||||
{ startIndex: 8, type: 'white.pq' },
|
||||
{ startIndex: 9, type: 'type.pq' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: 'type table',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.pq' },
|
||||
{ startIndex: 4, type: 'white.pq' },
|
||||
{ startIndex: 5, type: 'type.pq' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'type table',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.pq' },
|
||||
{ startIndex: 4, type: 'white.pq' },
|
||||
{ startIndex: 5, type: 'type.pq' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: 'if (a = #nan) then null else a',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: "keyword.pq" },
|
||||
{ startIndex: 2, type: "white.pq" },
|
||||
{ startIndex: 3, type: "delimiter.parenthesis.pq"},
|
||||
{ startIndex: 4, type: "identifier.pq" },
|
||||
{ startIndex: 5, type: "white.pq" },
|
||||
{ startIndex: 6, type: "operators.pq" },
|
||||
{ startIndex: 7, type: "white.pq" },
|
||||
{ startIndex: 8, type: "constant.pq" },
|
||||
{ startIndex: 12, type: "delimiter.parenthesis.pq"},
|
||||
{ startIndex: 13, type: "white.pq" },
|
||||
{ startIndex: 14, type: "keyword.pq" },
|
||||
{ startIndex: 18, type: "white.pq" },
|
||||
{ startIndex: 19, type: "type.pq" },
|
||||
{ startIndex: 23, type: "white.pq" },
|
||||
{ startIndex: 24, type: "keyword.pq" },
|
||||
{ startIndex: 28, type: "white.pq" },
|
||||
{ startIndex: 29, type: "identifier.pq" },
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'if (a = #nan) then null else a',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.pq' },
|
||||
{ startIndex: 2, type: 'white.pq' },
|
||||
{ startIndex: 3, type: 'delimiter.parenthesis.pq' },
|
||||
{ startIndex: 4, type: 'identifier.pq' },
|
||||
{ startIndex: 5, type: 'white.pq' },
|
||||
{ startIndex: 6, type: 'operators.pq' },
|
||||
{ startIndex: 7, type: 'white.pq' },
|
||||
{ startIndex: 8, type: 'constant.pq' },
|
||||
{ startIndex: 12, type: 'delimiter.parenthesis.pq' },
|
||||
{ startIndex: 13, type: 'white.pq' },
|
||||
{ startIndex: 14, type: 'keyword.pq' },
|
||||
{ startIndex: 18, type: 'white.pq' },
|
||||
{ startIndex: 19, type: 'type.pq' },
|
||||
{ startIndex: 23, type: 'white.pq' },
|
||||
{ startIndex: 24, type: 'keyword.pq' },
|
||||
{ startIndex: 28, type: 'white.pq' },
|
||||
{ startIndex: 29, type: 'identifier.pq' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// built-ins
|
||||
[{
|
||||
line: 'Text.From(1)',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.function.pq' },
|
||||
{ startIndex: 9, type: 'delimiter.parenthesis.pq'},
|
||||
{ startIndex: 10, type: 'number.pq' },
|
||||
{ startIndex: 11, type: 'delimiter.parenthesis.pq'}
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'Text.From(1)',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.function.pq' },
|
||||
{ startIndex: 9, type: 'delimiter.parenthesis.pq' },
|
||||
{ startIndex: 10, type: 'number.pq' },
|
||||
{ startIndex: 11, type: 'delimiter.parenthesis.pq' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: 'Text.ToBinary("123", BinaryEncoding.Base64)',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.function.pq' },
|
||||
{ startIndex: 13, type: 'delimiter.parenthesis.pq' },
|
||||
{ startIndex: 14, type: 'string.pq' },
|
||||
{ startIndex: 19, type: 'delimiter.pq' },
|
||||
{ startIndex: 20, type: 'white.pq' },
|
||||
{ startIndex: 21, type: 'constant.pq' },
|
||||
{ startIndex: 42, type: 'delimiter.parenthesis.pq' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'Text.ToBinary("123", BinaryEncoding.Base64)',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.function.pq' },
|
||||
{ startIndex: 13, type: 'delimiter.parenthesis.pq' },
|
||||
{ startIndex: 14, type: 'string.pq' },
|
||||
{ startIndex: 19, type: 'delimiter.pq' },
|
||||
{ startIndex: 20, type: 'white.pq' },
|
||||
{ startIndex: 21, type: 'constant.pq' },
|
||||
{ startIndex: 42, type: 'delimiter.parenthesis.pq' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: 'Int8.Type',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'type.pq' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'Int8.Type',
|
||||
tokens: [{ startIndex: 0, type: 'type.pq' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: 'DB2.Database',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.function.pq' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'DB2.Database',
|
||||
tokens: [{ startIndex: 0, type: 'keyword.function.pq' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: 'RelativePosition.Type',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'type.pq' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'RelativePosition.Type',
|
||||
tokens: [{ startIndex: 0, type: 'type.pq' }]
|
||||
}
|
||||
],
|
||||
|
||||
// other statements
|
||||
[{
|
||||
line: '[version="1.0.0.1"] section Foo; shared Member.Name = 1;',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: "delimiter.square.pq" },
|
||||
{ startIndex: 1, type: "identifier.pq" },
|
||||
{ startIndex: 8, type: "operators.pq" },
|
||||
{ startIndex: 9, type: "string.pq" },
|
||||
{ startIndex: 18, type: "delimiter.square.pq" },
|
||||
{ startIndex: 19, type: "white.pq" },
|
||||
{ startIndex: 20, type: "keyword.pq" },
|
||||
{ startIndex: 27, type: "white.pq" },
|
||||
{ startIndex: 28, type: "identifier.pq" },
|
||||
{ startIndex: 31, type: "delimiter.pq" },
|
||||
{ startIndex: 32, type: "white.pq" },
|
||||
{ startIndex: 33, type: "keyword.pq" },
|
||||
{ startIndex: 39, type: "white.pq" },
|
||||
{ startIndex: 40, type: "identifier.pq" },
|
||||
{ startIndex: 51, type: "white.pq" },
|
||||
{ startIndex: 52, type: "operators.pq" },
|
||||
{ startIndex: 53, type: "white.pq" },
|
||||
{ startIndex: 54, type: "number.pq" },
|
||||
{ startIndex: 55, type: "delimiter.pq" }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '[version="1.0.0.1"] section Foo; shared Member.Name = 1;',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'delimiter.square.pq' },
|
||||
{ startIndex: 1, type: 'identifier.pq' },
|
||||
{ startIndex: 8, type: 'operators.pq' },
|
||||
{ startIndex: 9, type: 'string.pq' },
|
||||
{ startIndex: 18, type: 'delimiter.square.pq' },
|
||||
{ startIndex: 19, type: 'white.pq' },
|
||||
{ startIndex: 20, type: 'keyword.pq' },
|
||||
{ startIndex: 27, type: 'white.pq' },
|
||||
{ startIndex: 28, type: 'identifier.pq' },
|
||||
{ startIndex: 31, type: 'delimiter.pq' },
|
||||
{ startIndex: 32, type: 'white.pq' },
|
||||
{ startIndex: 33, type: 'keyword.pq' },
|
||||
{ startIndex: 39, type: 'white.pq' },
|
||||
{ startIndex: 40, type: 'identifier.pq' },
|
||||
{ startIndex: 51, type: 'white.pq' },
|
||||
{ startIndex: 52, type: 'operators.pq' },
|
||||
{ startIndex: 53, type: 'white.pq' },
|
||||
{ startIndex: 54, type: 'number.pq' },
|
||||
{ startIndex: 55, type: 'delimiter.pq' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: 'isFunctionthen = 1;// comment',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'identifier.pq' },
|
||||
{ startIndex: 14, type: 'white.pq' },
|
||||
{ startIndex: 15, type: 'operators.pq' },
|
||||
{ startIndex: 16, type: 'white.pq' },
|
||||
{ startIndex: 17, type: 'number.pq' },
|
||||
{ startIndex: 18, type: 'delimiter.pq' },
|
||||
{ startIndex: 19, type: 'comment.pq' },
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'isFunctionthen = 1;// comment',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'identifier.pq' },
|
||||
{ startIndex: 14, type: 'white.pq' },
|
||||
{ startIndex: 15, type: 'operators.pq' },
|
||||
{ startIndex: 16, type: 'white.pq' },
|
||||
{ startIndex: 17, type: 'number.pq' },
|
||||
{ startIndex: 18, type: 'delimiter.pq' },
|
||||
{ startIndex: 19, type: 'comment.pq' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '@RecursiveFunction()+@Rec.Func()',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'operators.pq' },
|
||||
{ startIndex: 1, type: 'identifier.pq' },
|
||||
{ startIndex: 18, type: "delimiter.parenthesis.pq"},
|
||||
{ startIndex: 20, type: 'operators.pq' },
|
||||
{ startIndex: 22, type: 'identifier.pq' },
|
||||
{ startIndex: 30, type: "delimiter.parenthesis.pq"},
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '@RecursiveFunction()+@Rec.Func()',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'operators.pq' },
|
||||
{ startIndex: 1, type: 'identifier.pq' },
|
||||
{ startIndex: 18, type: 'delimiter.parenthesis.pq' },
|
||||
{ startIndex: 20, type: 'operators.pq' },
|
||||
{ startIndex: 22, type: 'identifier.pq' },
|
||||
{ startIndex: 30, type: 'delimiter.parenthesis.pq' }
|
||||
]
|
||||
}
|
||||
]
|
||||
]);
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -13,7 +13,7 @@ export const conf: IRichLanguageConfiguration = {
|
|||
wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\@\#%\^\&\*\(\)\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g,
|
||||
comments: {
|
||||
lineComment: '#',
|
||||
blockComment: ['<#', '#>'],
|
||||
blockComment: ['<#', '#>']
|
||||
},
|
||||
brackets: [
|
||||
['{', '}'],
|
||||
|
|
@ -25,19 +25,19 @@ export const conf: IRichLanguageConfiguration = {
|
|||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '"', close: '"', notIn: ['string'] },
|
||||
{ open: '\'', close: '\'', notIn: ['string', 'comment'] },
|
||||
{ open: "'", close: "'", notIn: ['string', 'comment'] }
|
||||
],
|
||||
surroundingPairs: [
|
||||
{ open: '{', close: '}' },
|
||||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '"', close: '"' },
|
||||
{ open: '\'', close: '\'' },
|
||||
{ open: "'", close: "'" }
|
||||
],
|
||||
folding: {
|
||||
markers: {
|
||||
start: new RegExp("^\\s*#region\\b"),
|
||||
end: new RegExp("^\\s*#endregion\\b")
|
||||
start: new RegExp('^\\s*#region\\b'),
|
||||
end: new RegExp('^\\s*#endregion\\b')
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -54,12 +54,43 @@ export const language = <ILanguage>{
|
|||
],
|
||||
|
||||
keywords: [
|
||||
'begin', 'break', 'catch', 'class', 'continue', 'data',
|
||||
'define', 'do', 'dynamicparam', 'else', 'elseif', 'end',
|
||||
'exit', 'filter', 'finally', 'for', 'foreach', 'from',
|
||||
'function', 'if', 'in', 'param', 'process', 'return',
|
||||
'switch', 'throw', 'trap', 'try', 'until', 'using',
|
||||
'var', 'while', 'workflow', 'parallel', 'sequence', 'inlinescript', 'configuration'
|
||||
'begin',
|
||||
'break',
|
||||
'catch',
|
||||
'class',
|
||||
'continue',
|
||||
'data',
|
||||
'define',
|
||||
'do',
|
||||
'dynamicparam',
|
||||
'else',
|
||||
'elseif',
|
||||
'end',
|
||||
'exit',
|
||||
'filter',
|
||||
'finally',
|
||||
'for',
|
||||
'foreach',
|
||||
'from',
|
||||
'function',
|
||||
'if',
|
||||
'in',
|
||||
'param',
|
||||
'process',
|
||||
'return',
|
||||
'switch',
|
||||
'throw',
|
||||
'trap',
|
||||
'try',
|
||||
'until',
|
||||
'using',
|
||||
'var',
|
||||
'while',
|
||||
'workflow',
|
||||
'parallel',
|
||||
'sequence',
|
||||
'inlinescript',
|
||||
'configuration'
|
||||
],
|
||||
|
||||
helpKeywords: /SYNOPSIS|DESCRIPTION|PARAMETER|EXAMPLE|INPUTS|OUTPUTS|NOTES|LINK|COMPONENT|ROLE|FUNCTIONALITY|FORWARDHELPTARGETNAME|FORWARDHELPCATEGORY|REMOTEHELPRUNSPACE|EXTERNALHELP/,
|
||||
|
|
@ -71,14 +102,16 @@ export const language = <ILanguage>{
|
|||
// The main tokenizer for our languages
|
||||
tokenizer: {
|
||||
root: [
|
||||
|
||||
// commands and keywords
|
||||
[/[a-zA-Z_][\w-]*/, {
|
||||
cases: {
|
||||
'@keywords': { token: 'keyword.$0' },
|
||||
'@default': ''
|
||||
[
|
||||
/[a-zA-Z_][\w-]*/,
|
||||
{
|
||||
cases: {
|
||||
'@keywords': { token: 'keyword.$0' },
|
||||
'@default': ''
|
||||
}
|
||||
}
|
||||
}],
|
||||
],
|
||||
|
||||
// whitespace
|
||||
[/[ \t\r\n]+/, ''],
|
||||
|
|
@ -87,7 +120,10 @@ export const language = <ILanguage>{
|
|||
[/^:\w*/, 'metatag'],
|
||||
|
||||
// variables
|
||||
[/\$(\{((global|local|private|script|using):)?[\w]+\}|((global|local|private|script|using):)?[\w]+)/, 'variable'],
|
||||
[
|
||||
/\$(\{((global|local|private|script|using):)?[\w]+\}|((global|local|private|script|using):)?[\w]+)/,
|
||||
'variable'
|
||||
],
|
||||
|
||||
// Comments
|
||||
[/<#/, 'comment', '@comment'],
|
||||
|
|
@ -107,83 +143,116 @@ export const language = <ILanguage>{
|
|||
|
||||
// strings:
|
||||
[/\@"/, 'string', '@herestring."'],
|
||||
[/\@'/, 'string', '@herestring.\''],
|
||||
[/"/, {
|
||||
cases: {
|
||||
'@eos': 'string',
|
||||
'@default': { token: 'string', next: '@string."' }
|
||||
[/\@'/, 'string', "@herestring.'"],
|
||||
[
|
||||
/"/,
|
||||
{
|
||||
cases: {
|
||||
'@eos': 'string',
|
||||
'@default': { token: 'string', next: '@string."' }
|
||||
}
|
||||
}
|
||||
}],
|
||||
[/'/, {
|
||||
cases: {
|
||||
'@eos': 'string',
|
||||
'@default': { token: 'string', next: '@string.\'' }
|
||||
],
|
||||
[
|
||||
/'/,
|
||||
{
|
||||
cases: {
|
||||
'@eos': 'string',
|
||||
'@default': { token: 'string', next: "@string.'" }
|
||||
}
|
||||
}
|
||||
}],
|
||||
]
|
||||
],
|
||||
|
||||
string: [
|
||||
[/[^"'\$`]+/, {
|
||||
cases: {
|
||||
'@eos': { token: 'string', next: '@popall' },
|
||||
'@default': 'string'
|
||||
[
|
||||
/[^"'\$`]+/,
|
||||
{
|
||||
cases: {
|
||||
'@eos': { token: 'string', next: '@popall' },
|
||||
'@default': 'string'
|
||||
}
|
||||
}
|
||||
}],
|
||||
[/@escapes/, {
|
||||
cases: {
|
||||
'@eos': { token: 'string.escape', next: '@popall' },
|
||||
'@default': 'string.escape'
|
||||
],
|
||||
[
|
||||
/@escapes/,
|
||||
{
|
||||
cases: {
|
||||
'@eos': { token: 'string.escape', next: '@popall' },
|
||||
'@default': 'string.escape'
|
||||
}
|
||||
}
|
||||
}],
|
||||
[/`./, {
|
||||
cases: {
|
||||
'@eos': { token: 'string.escape.invalid', next: '@popall' },
|
||||
'@default': 'string.escape.invalid'
|
||||
],
|
||||
[
|
||||
/`./,
|
||||
{
|
||||
cases: {
|
||||
'@eos': {
|
||||
token: 'string.escape.invalid',
|
||||
next: '@popall'
|
||||
},
|
||||
'@default': 'string.escape.invalid'
|
||||
}
|
||||
}
|
||||
}],
|
||||
],
|
||||
|
||||
[/\$[\w]+$/, {
|
||||
cases: {
|
||||
'$S2=="': { token: 'variable', next: '@popall' },
|
||||
'@default': { token: 'string', next: '@popall' }
|
||||
[
|
||||
/\$[\w]+$/,
|
||||
{
|
||||
cases: {
|
||||
'$S2=="': { token: 'variable', next: '@popall' },
|
||||
'@default': { token: 'string', next: '@popall' }
|
||||
}
|
||||
}
|
||||
}],
|
||||
[/\$[\w]+/, {
|
||||
cases: {
|
||||
'$S2=="': 'variable',
|
||||
'@default': 'string'
|
||||
],
|
||||
[
|
||||
/\$[\w]+/,
|
||||
{
|
||||
cases: {
|
||||
'$S2=="': 'variable',
|
||||
'@default': 'string'
|
||||
}
|
||||
}
|
||||
}],
|
||||
],
|
||||
|
||||
[/["']/, {
|
||||
cases: {
|
||||
'$#==$S2': { token: 'string', next: '@pop' },
|
||||
'@default': {
|
||||
cases: {
|
||||
'@eos': { token: 'string', next: '@popall' },
|
||||
'@default': 'string'
|
||||
[
|
||||
/["']/,
|
||||
{
|
||||
cases: {
|
||||
'$#==$S2': { token: 'string', next: '@pop' },
|
||||
'@default': {
|
||||
cases: {
|
||||
'@eos': { token: 'string', next: '@popall' },
|
||||
'@default': 'string'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}],
|
||||
]
|
||||
],
|
||||
|
||||
herestring: [
|
||||
[/^\s*(["'])@/, {
|
||||
cases: {
|
||||
'$1==$S2': { token: 'string', next: '@pop' },
|
||||
'@default': 'string'
|
||||
[
|
||||
/^\s*(["'])@/,
|
||||
{
|
||||
cases: {
|
||||
'$1==$S2': { token: 'string', next: '@pop' },
|
||||
'@default': 'string'
|
||||
}
|
||||
}
|
||||
}],
|
||||
],
|
||||
[/[^\$`]+/, 'string'],
|
||||
[/@escapes/, 'string.escape'],
|
||||
[/`./, 'string.escape.invalid'],
|
||||
[/\$[\w]+/, {
|
||||
cases: {
|
||||
'$S2=="': 'variable',
|
||||
'@default': 'string'
|
||||
[
|
||||
/\$[\w]+/,
|
||||
{
|
||||
cases: {
|
||||
'$S2=="': 'variable',
|
||||
'@default': 'string'
|
||||
}
|
||||
}
|
||||
}],
|
||||
]
|
||||
],
|
||||
|
||||
comment: [
|
||||
|
|
@ -191,6 +260,6 @@ export const language = <ILanguage>{
|
|||
[/#>/, 'comment', '@pop'],
|
||||
[/(\.)(@helpKeywords)(?!\w)/, { token: 'comment.keyword.$2' }],
|
||||
[/[\.#]/, 'comment']
|
||||
],
|
||||
},
|
||||
]
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -9,425 +9,469 @@ import { testTokenization } from '../test/testRunner';
|
|||
|
||||
testTokenization('pug', [
|
||||
// Tags [Pug]
|
||||
[{
|
||||
line: 'p 5',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'tag.pug' },
|
||||
{ startIndex: 1, type: '' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'p 5',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'tag.pug' },
|
||||
{ startIndex: 1, type: '' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: 'div#container.stuff',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'tag.pug' },
|
||||
{ startIndex: 3, type: 'tag.id.pug' },
|
||||
{ startIndex: 13, type: 'tag.class.pug' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'div#container.stuff',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'tag.pug' },
|
||||
{ startIndex: 3, type: 'tag.id.pug' },
|
||||
{ startIndex: 13, type: 'tag.class.pug' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: 'div.container#stuff',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'tag.pug' },
|
||||
{ startIndex: 3, type: 'tag.class.pug' },
|
||||
{ startIndex: 13, type: 'tag.id.pug' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'div.container#stuff',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'tag.pug' },
|
||||
{ startIndex: 3, type: 'tag.class.pug' },
|
||||
{ startIndex: 13, type: 'tag.id.pug' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: 'div.container#stuff .container',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'tag.pug' },
|
||||
{ startIndex: 3, type: 'tag.class.pug' },
|
||||
{ startIndex: 13, type: 'tag.id.pug' },
|
||||
{ startIndex: 19, type: '' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'div.container#stuff .container',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'tag.pug' },
|
||||
{ startIndex: 3, type: 'tag.class.pug' },
|
||||
{ startIndex: 13, type: 'tag.id.pug' },
|
||||
{ startIndex: 19, type: '' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '#tag-id-1',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'tag.id.pug' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '#tag-id-1',
|
||||
tokens: [{ startIndex: 0, type: 'tag.id.pug' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '.tag-id-1',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'tag.class.pug' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '.tag-id-1',
|
||||
tokens: [{ startIndex: 0, type: 'tag.class.pug' }]
|
||||
}
|
||||
],
|
||||
|
||||
// Attributes - Single Line [Pug]
|
||||
[{
|
||||
line: 'input(type="checkbox")',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'tag.pug' },
|
||||
{ startIndex: 5, type: 'delimiter.parenthesis.pug' },
|
||||
{ startIndex: 6, type: 'attribute.name.pug' },
|
||||
{ startIndex: 10, type: 'delimiter.pug' },
|
||||
{ startIndex: 11, type: 'attribute.value.pug' },
|
||||
{ startIndex: 21, type: 'delimiter.parenthesis.pug' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'input(type="checkbox")',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'tag.pug' },
|
||||
{ startIndex: 5, type: 'delimiter.parenthesis.pug' },
|
||||
{ startIndex: 6, type: 'attribute.name.pug' },
|
||||
{ startIndex: 10, type: 'delimiter.pug' },
|
||||
{ startIndex: 11, type: 'attribute.value.pug' },
|
||||
{ startIndex: 21, type: 'delimiter.parenthesis.pug' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: 'input (type="checkbox")',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'tag.pug' },
|
||||
{ startIndex: 5, type: '' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'input (type="checkbox")',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'tag.pug' },
|
||||
{ startIndex: 5, type: '' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: 'input(type="checkbox",name="agreement",checked)',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'tag.pug' },
|
||||
{ startIndex: 5, type: 'delimiter.parenthesis.pug' },
|
||||
{ startIndex: 6, type: 'attribute.name.pug' },
|
||||
{ startIndex: 10, type: 'delimiter.pug' },
|
||||
{ startIndex: 11, type: 'attribute.value.pug' },
|
||||
{ startIndex: 21, type: 'attribute.delimiter.pug' },
|
||||
{ startIndex: 22, type: 'attribute.name.pug' },
|
||||
{ startIndex: 26, type: 'delimiter.pug' },
|
||||
{ startIndex: 27, type: 'attribute.value.pug' },
|
||||
{ startIndex: 38, type: 'attribute.delimiter.pug' },
|
||||
{ startIndex: 39, type: 'attribute.name.pug' },
|
||||
{ startIndex: 46, type: 'delimiter.parenthesis.pug' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'input(type="checkbox",name="agreement",checked)',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'tag.pug' },
|
||||
{ startIndex: 5, type: 'delimiter.parenthesis.pug' },
|
||||
{ startIndex: 6, type: 'attribute.name.pug' },
|
||||
{ startIndex: 10, type: 'delimiter.pug' },
|
||||
{ startIndex: 11, type: 'attribute.value.pug' },
|
||||
{ startIndex: 21, type: 'attribute.delimiter.pug' },
|
||||
{ startIndex: 22, type: 'attribute.name.pug' },
|
||||
{ startIndex: 26, type: 'delimiter.pug' },
|
||||
{ startIndex: 27, type: 'attribute.value.pug' },
|
||||
{ startIndex: 38, type: 'attribute.delimiter.pug' },
|
||||
{ startIndex: 39, type: 'attribute.name.pug' },
|
||||
{ startIndex: 46, type: 'delimiter.parenthesis.pug' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: 'input(type="checkbox"',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'tag.pug' },
|
||||
{ startIndex: 5, type: 'delimiter.parenthesis.pug' },
|
||||
{ startIndex: 6, type: 'attribute.name.pug' },
|
||||
{ startIndex: 10, type: 'delimiter.pug' },
|
||||
{ startIndex: 11, type: 'attribute.value.pug' }
|
||||
]
|
||||
}, {
|
||||
line: 'name="agreement"',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'attribute.name.pug' },
|
||||
{ startIndex: 4, type: 'delimiter.pug' },
|
||||
{ startIndex: 5, type: 'attribute.value.pug' }
|
||||
]
|
||||
}, {
|
||||
line: 'checked)',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'attribute.name.pug' },
|
||||
{ startIndex: 7, type: 'delimiter.parenthesis.pug' }
|
||||
]
|
||||
}, {
|
||||
line: 'body',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'tag.pug' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'input(type="checkbox"',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'tag.pug' },
|
||||
{ startIndex: 5, type: 'delimiter.parenthesis.pug' },
|
||||
{ startIndex: 6, type: 'attribute.name.pug' },
|
||||
{ startIndex: 10, type: 'delimiter.pug' },
|
||||
{ startIndex: 11, type: 'attribute.value.pug' }
|
||||
]
|
||||
},
|
||||
{
|
||||
line: 'name="agreement"',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'attribute.name.pug' },
|
||||
{ startIndex: 4, type: 'delimiter.pug' },
|
||||
{ startIndex: 5, type: 'attribute.value.pug' }
|
||||
]
|
||||
},
|
||||
{
|
||||
line: 'checked)',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'attribute.name.pug' },
|
||||
{ startIndex: 7, type: 'delimiter.parenthesis.pug' }
|
||||
]
|
||||
},
|
||||
{
|
||||
line: 'body',
|
||||
tokens: [{ startIndex: 0, type: 'tag.pug' }]
|
||||
}
|
||||
],
|
||||
|
||||
// Attributes - MultiLine [Pug]
|
||||
[{
|
||||
line: 'input(type="checkbox"',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'tag.pug' },
|
||||
{ startIndex: 5, type: 'delimiter.parenthesis.pug' },
|
||||
{ startIndex: 6, type: 'attribute.name.pug' },
|
||||
{ startIndex: 10, type: 'delimiter.pug' },
|
||||
{ startIndex: 11, type: 'attribute.value.pug' }
|
||||
]
|
||||
}, {
|
||||
line: 'disabled',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'attribute.name.pug' }
|
||||
]
|
||||
}, {
|
||||
line: 'checked)',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'attribute.name.pug' },
|
||||
{ startIndex: 7, type: 'delimiter.parenthesis.pug' }
|
||||
]
|
||||
}, {
|
||||
line: 'body',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'tag.pug' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'input(type="checkbox"',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'tag.pug' },
|
||||
{ startIndex: 5, type: 'delimiter.parenthesis.pug' },
|
||||
{ startIndex: 6, type: 'attribute.name.pug' },
|
||||
{ startIndex: 10, type: 'delimiter.pug' },
|
||||
{ startIndex: 11, type: 'attribute.value.pug' }
|
||||
]
|
||||
},
|
||||
{
|
||||
line: 'disabled',
|
||||
tokens: [{ startIndex: 0, type: 'attribute.name.pug' }]
|
||||
},
|
||||
{
|
||||
line: 'checked)',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'attribute.name.pug' },
|
||||
{ startIndex: 7, type: 'delimiter.parenthesis.pug' }
|
||||
]
|
||||
},
|
||||
{
|
||||
line: 'body',
|
||||
tokens: [{ startIndex: 0, type: 'tag.pug' }]
|
||||
}
|
||||
],
|
||||
|
||||
// Interpolation [Pug]
|
||||
[{
|
||||
line: 'p print #{count} lines',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'tag.pug' },
|
||||
{ startIndex: 1, type: '' },
|
||||
{ startIndex: 8, type: 'interpolation.delimiter.pug' },
|
||||
{ startIndex: 10, type: 'interpolation.pug' },
|
||||
{ startIndex: 15, type: 'interpolation.delimiter.pug' },
|
||||
{ startIndex: 16, type: '' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'p print #{count} lines',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'tag.pug' },
|
||||
{ startIndex: 1, type: '' },
|
||||
{ startIndex: 8, type: 'interpolation.delimiter.pug' },
|
||||
{ startIndex: 10, type: 'interpolation.pug' },
|
||||
{ startIndex: 15, type: 'interpolation.delimiter.pug' },
|
||||
{ startIndex: 16, type: '' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: 'p print "#{count}" lines',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'tag.pug' },
|
||||
{ startIndex: 1, type: '' },
|
||||
{ startIndex: 9, type: 'interpolation.delimiter.pug' },
|
||||
{ startIndex: 11, type: 'interpolation.pug' },
|
||||
{ startIndex: 16, type: 'interpolation.delimiter.pug' },
|
||||
{ startIndex: 17, type: '' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'p print "#{count}" lines',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'tag.pug' },
|
||||
{ startIndex: 1, type: '' },
|
||||
{ startIndex: 9, type: 'interpolation.delimiter.pug' },
|
||||
{ startIndex: 11, type: 'interpolation.pug' },
|
||||
{ startIndex: 16, type: 'interpolation.delimiter.pug' },
|
||||
{ startIndex: 17, type: '' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '{ key: 123 }',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'delimiter.curly.pug' },
|
||||
{ startIndex: 1, type: '' },
|
||||
{ startIndex: 5, type: 'delimiter.pug' },
|
||||
{ startIndex: 6, type: '' },
|
||||
{ startIndex: 7, type: 'number.pug' },
|
||||
{ startIndex: 10, type: '' },
|
||||
{ startIndex: 11, type: 'delimiter.curly.pug' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '{ key: 123 }',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'delimiter.curly.pug' },
|
||||
{ startIndex: 1, type: '' },
|
||||
{ startIndex: 5, type: 'delimiter.pug' },
|
||||
{ startIndex: 6, type: '' },
|
||||
{ startIndex: 7, type: 'number.pug' },
|
||||
{ startIndex: 10, type: '' },
|
||||
{ startIndex: 11, type: 'delimiter.curly.pug' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// Comments - Single Line [Pug]
|
||||
[{
|
||||
line: '// html#id1.class1',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.pug' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '// html#id1.class1',
|
||||
tokens: [{ startIndex: 0, type: 'comment.pug' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: 'body hello // not a comment 123',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'tag.pug' },
|
||||
{ startIndex: 4, type: '' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'body hello // not a comment 123',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'tag.pug' },
|
||||
{ startIndex: 4, type: '' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// Comments - MultiLine [Pug]
|
||||
[{
|
||||
line: '//',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.pug' }
|
||||
]
|
||||
}, {
|
||||
line: ' should be a comment',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.pug' }
|
||||
]
|
||||
}, {
|
||||
line: ' should still be a comment',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.pug' }
|
||||
]
|
||||
}, {
|
||||
line: 'div should not be a comment',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'tag.pug' },
|
||||
{ startIndex: 3, type: '' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '//',
|
||||
tokens: [{ startIndex: 0, type: 'comment.pug' }]
|
||||
},
|
||||
{
|
||||
line: ' should be a comment',
|
||||
tokens: [{ startIndex: 0, type: 'comment.pug' }]
|
||||
},
|
||||
{
|
||||
line: ' should still be a comment',
|
||||
tokens: [{ startIndex: 0, type: 'comment.pug' }]
|
||||
},
|
||||
{
|
||||
line: 'div should not be a comment',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'tag.pug' },
|
||||
{ startIndex: 3, type: '' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// Code [Pug]
|
||||
[{
|
||||
line: '- var a = 1',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 2, type: 'keyword.var.pug' },
|
||||
{ startIndex: 5, type: '' },
|
||||
{ startIndex: 8, type: 'delimiter.pug' },
|
||||
{ startIndex: 9, type: '' },
|
||||
{ startIndex: 10, type: 'number.pug' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '- var a = 1',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 2, type: 'keyword.var.pug' },
|
||||
{ startIndex: 5, type: '' },
|
||||
{ startIndex: 8, type: 'delimiter.pug' },
|
||||
{ startIndex: 9, type: '' },
|
||||
{ startIndex: 10, type: 'number.pug' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: 'each item in items',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.each.pug' },
|
||||
{ startIndex: 4, type: '' },
|
||||
{ startIndex: 10, type: 'keyword.in.pug' },
|
||||
{ startIndex: 12, type: '' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'each item in items',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.each.pug' },
|
||||
{ startIndex: 4, type: '' },
|
||||
{ startIndex: 10, type: 'keyword.in.pug' },
|
||||
{ startIndex: 12, type: '' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '- var html = "<script></script>"',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 2, type: 'keyword.var.pug' },
|
||||
{ startIndex: 5, type: '' },
|
||||
{ startIndex: 11, type: 'delimiter.pug' },
|
||||
{ startIndex: 12, type: '' },
|
||||
{ startIndex: 13, type: 'string.pug' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '- var html = "<script></script>"',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 2, type: 'keyword.var.pug' },
|
||||
{ startIndex: 5, type: '' },
|
||||
{ startIndex: 11, type: 'delimiter.pug' },
|
||||
{ startIndex: 12, type: '' },
|
||||
{ startIndex: 13, type: 'string.pug' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// Generated from sample
|
||||
[{
|
||||
line: 'doctype 5',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.doctype.pug' },
|
||||
{ startIndex: 7, type: '' },
|
||||
{ startIndex: 8, type: 'number.pug' }
|
||||
]
|
||||
}, {
|
||||
line: 'html(lang="en")',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'tag.pug' },
|
||||
{ startIndex: 4, type: 'delimiter.parenthesis.pug' },
|
||||
{ startIndex: 5, type: 'attribute.name.pug' },
|
||||
{ startIndex: 9, type: 'delimiter.pug' },
|
||||
{ startIndex: 10, type: 'attribute.value.pug' },
|
||||
{ startIndex: 14, type: 'delimiter.parenthesis.pug' }
|
||||
]
|
||||
}, {
|
||||
line: ' head',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 4, type: 'tag.pug' }
|
||||
]
|
||||
}, {
|
||||
line: ' title= pageTitle',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 8, type: 'tag.pug' },
|
||||
{ startIndex: 13, type: '' }
|
||||
]
|
||||
}, {
|
||||
line: ' script(type=\'text/javascript\')',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 8, type: 'tag.pug' },
|
||||
{ startIndex: 14, type: 'delimiter.parenthesis.pug' },
|
||||
{ startIndex: 15, type: 'attribute.name.pug' },
|
||||
{ startIndex: 19, type: 'delimiter.pug' },
|
||||
{ startIndex: 20, type: 'attribute.value.pug' },
|
||||
{ startIndex: 37, type: 'delimiter.parenthesis.pug' }
|
||||
]
|
||||
}, {
|
||||
line: ' if (foo) {',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 12, type: 'keyword.if.pug' },
|
||||
{ startIndex: 14, type: '' },
|
||||
{ startIndex: 15, type: 'delimiter.parenthesis.pug' },
|
||||
{ startIndex: 16, type: '' },
|
||||
{ startIndex: 19, type: 'delimiter.parenthesis.pug' },
|
||||
{ startIndex: 20, type: '' },
|
||||
{ startIndex: 21, type: 'delimiter.curly.pug' }
|
||||
]
|
||||
}, {
|
||||
line: ' bar()',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 19, type: 'delimiter.parenthesis.pug' }
|
||||
]
|
||||
}, {
|
||||
line: ' }',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 12, type: 'delimiter.curly.pug' }
|
||||
]
|
||||
}, {
|
||||
line: ' body',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 4, type: 'tag.pug' }
|
||||
]
|
||||
}, {
|
||||
line: ' // Disclaimer: You will need to turn insertSpaces to true in order for the',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.pug' }
|
||||
]
|
||||
}, {
|
||||
line: ' syntax highlighting to kick in properly (especially for comments)',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.pug' }
|
||||
]
|
||||
}, {
|
||||
line: ' Enjoy :)',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'comment.pug' }
|
||||
]
|
||||
}, {
|
||||
line: ' h1 Pug - node template engine if in',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 8, type: 'tag.pug' },
|
||||
{ startIndex: 10, type: '' }
|
||||
]
|
||||
}, {
|
||||
line: ' p.',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 8, type: 'tag.pug' },
|
||||
{ startIndex: 9, type: 'delimiter.pug' }
|
||||
]
|
||||
}, {
|
||||
line: ' text ',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' }
|
||||
]
|
||||
}, {
|
||||
line: ' text',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' }
|
||||
]
|
||||
}, {
|
||||
line: ' #container',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' }
|
||||
]
|
||||
}, {
|
||||
line: ' #container',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' }
|
||||
]
|
||||
}, {
|
||||
line: ' #container',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 8, type: 'tag.id.pug' }
|
||||
]
|
||||
}, {
|
||||
line: ' if youAreUsingPug',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 10, type: 'keyword.if.pug' },
|
||||
{ startIndex: 12, type: '' }
|
||||
]
|
||||
}, {
|
||||
line: ' p You are amazing',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 12, type: 'tag.pug' },
|
||||
{ startIndex: 13, type: '' }
|
||||
]
|
||||
}, {
|
||||
line: ' else',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 10, type: 'keyword.else.pug' }
|
||||
]
|
||||
}, {
|
||||
line: ' p Get on it!',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 12, type: 'tag.pug' },
|
||||
{ startIndex: 13, type: '' }
|
||||
]
|
||||
}, {
|
||||
line: ' p Text can be included in a number of different ways.',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 5, type: 'tag.pug' },
|
||||
{ startIndex: 6, type: '' }
|
||||
]
|
||||
}]
|
||||
[
|
||||
{
|
||||
line: 'doctype 5',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.doctype.pug' },
|
||||
{ startIndex: 7, type: '' },
|
||||
{ startIndex: 8, type: 'number.pug' }
|
||||
]
|
||||
},
|
||||
{
|
||||
line: 'html(lang="en")',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'tag.pug' },
|
||||
{ startIndex: 4, type: 'delimiter.parenthesis.pug' },
|
||||
{ startIndex: 5, type: 'attribute.name.pug' },
|
||||
{ startIndex: 9, type: 'delimiter.pug' },
|
||||
{ startIndex: 10, type: 'attribute.value.pug' },
|
||||
{ startIndex: 14, type: 'delimiter.parenthesis.pug' }
|
||||
]
|
||||
},
|
||||
{
|
||||
line: ' head',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 4, type: 'tag.pug' }
|
||||
]
|
||||
},
|
||||
{
|
||||
line: ' title= pageTitle',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 8, type: 'tag.pug' },
|
||||
{ startIndex: 13, type: '' }
|
||||
]
|
||||
},
|
||||
{
|
||||
line: " script(type='text/javascript')",
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 8, type: 'tag.pug' },
|
||||
{ startIndex: 14, type: 'delimiter.parenthesis.pug' },
|
||||
{ startIndex: 15, type: 'attribute.name.pug' },
|
||||
{ startIndex: 19, type: 'delimiter.pug' },
|
||||
{ startIndex: 20, type: 'attribute.value.pug' },
|
||||
{ startIndex: 37, type: 'delimiter.parenthesis.pug' }
|
||||
]
|
||||
},
|
||||
{
|
||||
line: ' if (foo) {',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 12, type: 'keyword.if.pug' },
|
||||
{ startIndex: 14, type: '' },
|
||||
{ startIndex: 15, type: 'delimiter.parenthesis.pug' },
|
||||
{ startIndex: 16, type: '' },
|
||||
{ startIndex: 19, type: 'delimiter.parenthesis.pug' },
|
||||
{ startIndex: 20, type: '' },
|
||||
{ startIndex: 21, type: 'delimiter.curly.pug' }
|
||||
]
|
||||
},
|
||||
{
|
||||
line: ' bar()',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 19, type: 'delimiter.parenthesis.pug' }
|
||||
]
|
||||
},
|
||||
{
|
||||
line: ' }',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 12, type: 'delimiter.curly.pug' }
|
||||
]
|
||||
},
|
||||
{
|
||||
line: ' body',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 4, type: 'tag.pug' }
|
||||
]
|
||||
},
|
||||
{
|
||||
line:
|
||||
' // Disclaimer: You will need to turn insertSpaces to true in order for the',
|
||||
tokens: [{ startIndex: 0, type: 'comment.pug' }]
|
||||
},
|
||||
{
|
||||
line:
|
||||
' syntax highlighting to kick in properly (especially for comments)',
|
||||
tokens: [{ startIndex: 0, type: 'comment.pug' }]
|
||||
},
|
||||
{
|
||||
line: ' Enjoy :)',
|
||||
tokens: [{ startIndex: 0, type: 'comment.pug' }]
|
||||
},
|
||||
{
|
||||
line: ' h1 Pug - node template engine if in',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 8, type: 'tag.pug' },
|
||||
{ startIndex: 10, type: '' }
|
||||
]
|
||||
},
|
||||
{
|
||||
line: ' p.',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 8, type: 'tag.pug' },
|
||||
{ startIndex: 9, type: 'delimiter.pug' }
|
||||
]
|
||||
},
|
||||
{
|
||||
line: ' text ',
|
||||
tokens: [{ startIndex: 0, type: '' }]
|
||||
},
|
||||
{
|
||||
line: ' text',
|
||||
tokens: [{ startIndex: 0, type: '' }]
|
||||
},
|
||||
{
|
||||
line: ' #container',
|
||||
tokens: [{ startIndex: 0, type: '' }]
|
||||
},
|
||||
{
|
||||
line: ' #container',
|
||||
tokens: [{ startIndex: 0, type: '' }]
|
||||
},
|
||||
{
|
||||
line: ' #container',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 8, type: 'tag.id.pug' }
|
||||
]
|
||||
},
|
||||
{
|
||||
line: ' if youAreUsingPug',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 10, type: 'keyword.if.pug' },
|
||||
{ startIndex: 12, type: '' }
|
||||
]
|
||||
},
|
||||
{
|
||||
line: ' p You are amazing',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 12, type: 'tag.pug' },
|
||||
{ startIndex: 13, type: '' }
|
||||
]
|
||||
},
|
||||
{
|
||||
line: ' else',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 10, type: 'keyword.else.pug' }
|
||||
]
|
||||
},
|
||||
{
|
||||
line: ' p Get on it!',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 12, type: 'tag.pug' },
|
||||
{ startIndex: 13, type: '' }
|
||||
]
|
||||
},
|
||||
{
|
||||
line: ' p Text can be included in a number of different ways.',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 5, type: 'tag.pug' },
|
||||
{ startIndex: 6, type: '' }
|
||||
]
|
||||
}
|
||||
]
|
||||
]);
|
||||
|
|
|
|||
430
src/pug/pug.ts
430
src/pug/pug.ts
|
|
@ -12,13 +12,17 @@ export const conf: IRichLanguageConfiguration = {
|
|||
comments: {
|
||||
lineComment: '//'
|
||||
},
|
||||
brackets: [['{', '}'], ['[', ']'], ['(', ')']],
|
||||
brackets: [
|
||||
['{', '}'],
|
||||
['[', ']'],
|
||||
['(', ')']
|
||||
],
|
||||
autoClosingPairs: [
|
||||
{ open: '"', close: '"', notIn: ['string', 'comment'] },
|
||||
{ open: '\'', close: '\'', notIn: ['string', 'comment'] },
|
||||
{ open: "'", close: "'", notIn: ['string', 'comment'] },
|
||||
{ open: '{', close: '}', notIn: ['string', 'comment'] },
|
||||
{ open: '[', close: ']', notIn: ['string', 'comment'] },
|
||||
{ open: '(', close: ')', notIn: ['string', 'comment'] },
|
||||
{ open: '(', close: ')', notIn: ['string', 'comment'] }
|
||||
],
|
||||
folding: {
|
||||
offSide: true
|
||||
|
|
@ -37,29 +41,140 @@ export const language = <ILanguage>{
|
|||
{ token: 'delimiter.parenthesis', open: '(', close: ')' }
|
||||
],
|
||||
|
||||
keywords: ['append', 'block', 'case', 'default', 'doctype', 'each', 'else', 'extends',
|
||||
'for', 'if', 'in', 'include', 'mixin', 'typeof', 'unless', 'var', 'when'],
|
||||
keywords: [
|
||||
'append',
|
||||
'block',
|
||||
'case',
|
||||
'default',
|
||||
'doctype',
|
||||
'each',
|
||||
'else',
|
||||
'extends',
|
||||
'for',
|
||||
'if',
|
||||
'in',
|
||||
'include',
|
||||
'mixin',
|
||||
'typeof',
|
||||
'unless',
|
||||
'var',
|
||||
'when'
|
||||
],
|
||||
|
||||
tags: [
|
||||
'a', 'abbr', 'acronym', 'address', 'area', 'article', 'aside', 'audio',
|
||||
'b', 'base', 'basefont', 'bdi', 'bdo', 'blockquote', 'body', 'br', 'button',
|
||||
'canvas', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'command',
|
||||
'datalist', 'dd', 'del', 'details', 'dfn', 'div', 'dl', 'dt',
|
||||
'em', 'embed',
|
||||
'fieldset', 'figcaption', 'figure', 'font', 'footer', 'form', 'frame', 'frameset',
|
||||
'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html',
|
||||
'i', 'iframe', 'img', 'input', 'ins',
|
||||
'keygen', 'kbd',
|
||||
'label', 'li', 'link',
|
||||
'map', 'mark', 'menu', 'meta', 'meter',
|
||||
'nav', 'noframes', 'noscript',
|
||||
'object', 'ol', 'optgroup', 'option', 'output',
|
||||
'p', 'param', 'pre', 'progress',
|
||||
'a',
|
||||
'abbr',
|
||||
'acronym',
|
||||
'address',
|
||||
'area',
|
||||
'article',
|
||||
'aside',
|
||||
'audio',
|
||||
'b',
|
||||
'base',
|
||||
'basefont',
|
||||
'bdi',
|
||||
'bdo',
|
||||
'blockquote',
|
||||
'body',
|
||||
'br',
|
||||
'button',
|
||||
'canvas',
|
||||
'caption',
|
||||
'center',
|
||||
'cite',
|
||||
'code',
|
||||
'col',
|
||||
'colgroup',
|
||||
'command',
|
||||
'datalist',
|
||||
'dd',
|
||||
'del',
|
||||
'details',
|
||||
'dfn',
|
||||
'div',
|
||||
'dl',
|
||||
'dt',
|
||||
'em',
|
||||
'embed',
|
||||
'fieldset',
|
||||
'figcaption',
|
||||
'figure',
|
||||
'font',
|
||||
'footer',
|
||||
'form',
|
||||
'frame',
|
||||
'frameset',
|
||||
'h1',
|
||||
'h2',
|
||||
'h3',
|
||||
'h4',
|
||||
'h5',
|
||||
'h6',
|
||||
'head',
|
||||
'header',
|
||||
'hgroup',
|
||||
'hr',
|
||||
'html',
|
||||
'i',
|
||||
'iframe',
|
||||
'img',
|
||||
'input',
|
||||
'ins',
|
||||
'keygen',
|
||||
'kbd',
|
||||
'label',
|
||||
'li',
|
||||
'link',
|
||||
'map',
|
||||
'mark',
|
||||
'menu',
|
||||
'meta',
|
||||
'meter',
|
||||
'nav',
|
||||
'noframes',
|
||||
'noscript',
|
||||
'object',
|
||||
'ol',
|
||||
'optgroup',
|
||||
'option',
|
||||
'output',
|
||||
'p',
|
||||
'param',
|
||||
'pre',
|
||||
'progress',
|
||||
'q',
|
||||
'rp', 'rt', 'ruby',
|
||||
's', 'samp', 'script', 'section', 'select', 'small', 'source', 'span', 'strike', 'strong', 'style', 'sub', 'summary', 'sup',
|
||||
'table', 'tbody', 'td', 'textarea', 'tfoot', 'th', 'thead', 'time', 'title', 'tr', 'tracks', 'tt',
|
||||
'u', 'ul',
|
||||
'rp',
|
||||
'rt',
|
||||
'ruby',
|
||||
's',
|
||||
'samp',
|
||||
'script',
|
||||
'section',
|
||||
'select',
|
||||
'small',
|
||||
'source',
|
||||
'span',
|
||||
'strike',
|
||||
'strong',
|
||||
'style',
|
||||
'sub',
|
||||
'summary',
|
||||
'sup',
|
||||
'table',
|
||||
'tbody',
|
||||
'td',
|
||||
'textarea',
|
||||
'tfoot',
|
||||
'th',
|
||||
'thead',
|
||||
'time',
|
||||
'title',
|
||||
'tr',
|
||||
'tracks',
|
||||
'tt',
|
||||
'u',
|
||||
'ul',
|
||||
'video',
|
||||
'wbr'
|
||||
],
|
||||
|
|
@ -70,38 +185,50 @@ export const language = <ILanguage>{
|
|||
|
||||
tokenizer: {
|
||||
root: [
|
||||
|
||||
// Tag or a keyword at start
|
||||
[/^(\s*)([a-zA-Z_-][\w-]*)/,
|
||||
[
|
||||
/^(\s*)([a-zA-Z_-][\w-]*)/,
|
||||
{
|
||||
cases: {
|
||||
'$2@tags': {
|
||||
cases: {
|
||||
'@eos': ['', 'tag'],
|
||||
'@default': ['', { token: 'tag', next: '@tag.$1' },]
|
||||
'@default': [
|
||||
'',
|
||||
{ token: 'tag', next: '@tag.$1' }
|
||||
]
|
||||
}
|
||||
},
|
||||
'$2@keywords': ['', { token: 'keyword.$2' },],
|
||||
'@default': ['', '',]
|
||||
'$2@keywords': ['', { token: 'keyword.$2' }],
|
||||
'@default': ['', '']
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
// id
|
||||
[/^(\s*)(#[a-zA-Z_-][\w-]*)/, {
|
||||
cases: {
|
||||
'@eos': ['', 'tag.id'],
|
||||
'@default': ['', { token: 'tag.id', next: '@tag.$1' }]
|
||||
[
|
||||
/^(\s*)(#[a-zA-Z_-][\w-]*)/,
|
||||
{
|
||||
cases: {
|
||||
'@eos': ['', 'tag.id'],
|
||||
'@default': ['', { token: 'tag.id', next: '@tag.$1' }]
|
||||
}
|
||||
}
|
||||
}],
|
||||
],
|
||||
|
||||
// class
|
||||
[/^(\s*)(\.[a-zA-Z_-][\w-]*)/, {
|
||||
cases: {
|
||||
'@eos': ['', 'tag.class'],
|
||||
'@default': ['', { token: 'tag.class', next: '@tag.$1' }]
|
||||
[
|
||||
/^(\s*)(\.[a-zA-Z_-][\w-]*)/,
|
||||
{
|
||||
cases: {
|
||||
'@eos': ['', 'tag.class'],
|
||||
'@default': [
|
||||
'',
|
||||
{ token: 'tag.class', next: '@tag.$1' }
|
||||
]
|
||||
}
|
||||
}
|
||||
}],
|
||||
],
|
||||
|
||||
// plain text with pipe
|
||||
[/^(\s*)(\|.*)$/, ''],
|
||||
|
|
@ -109,12 +236,15 @@ export const language = <ILanguage>{
|
|||
{ include: '@whitespace' },
|
||||
|
||||
// keywords
|
||||
[/[a-zA-Z_$][\w$]*/, {
|
||||
cases: {
|
||||
'@keywords': { token: 'keyword.$0' },
|
||||
'@default': ''
|
||||
[
|
||||
/[a-zA-Z_$][\w$]*/,
|
||||
{
|
||||
cases: {
|
||||
'@keywords': { token: 'keyword.$0' },
|
||||
'@default': ''
|
||||
}
|
||||
}
|
||||
}],
|
||||
],
|
||||
|
||||
// delimiters and operators
|
||||
[/[{}()\[\]]/, '@brackets'],
|
||||
|
|
@ -126,29 +256,38 @@ export const language = <ILanguage>{
|
|||
|
||||
// strings:
|
||||
[/"/, 'string', '@string."'],
|
||||
[/'/, 'string', '@string.\''],
|
||||
[/'/, 'string', "@string.'"]
|
||||
],
|
||||
|
||||
tag: [
|
||||
[/(\.)(\s*$)/, [{ token: 'delimiter', next: '@blockText.$S2.' }, '']],
|
||||
[
|
||||
/(\.)(\s*$)/,
|
||||
[{ token: 'delimiter', next: '@blockText.$S2.' }, '']
|
||||
],
|
||||
[/\s+/, { token: '', next: '@simpleText' }],
|
||||
|
||||
// id
|
||||
[/#[a-zA-Z_-][\w-]*/, {
|
||||
cases: {
|
||||
'@eos': { token: 'tag.id', next: '@pop' },
|
||||
'@default': 'tag.id'
|
||||
[
|
||||
/#[a-zA-Z_-][\w-]*/,
|
||||
{
|
||||
cases: {
|
||||
'@eos': { token: 'tag.id', next: '@pop' },
|
||||
'@default': 'tag.id'
|
||||
}
|
||||
}
|
||||
}],
|
||||
],
|
||||
// class
|
||||
[/\.[a-zA-Z_-][\w-]*/, {
|
||||
cases: {
|
||||
'@eos': { token: 'tag.class', next: '@pop' },
|
||||
'@default': 'tag.class'
|
||||
[
|
||||
/\.[a-zA-Z_-][\w-]*/,
|
||||
{
|
||||
cases: {
|
||||
'@eos': { token: 'tag.class', next: '@pop' },
|
||||
'@default': 'tag.class'
|
||||
}
|
||||
}
|
||||
}],
|
||||
],
|
||||
// attributes
|
||||
[/\(/, { token: 'delimiter.parenthesis', next: '@attributeList' }],
|
||||
[/\(/, { token: 'delimiter.parenthesis', next: '@attributeList' }]
|
||||
],
|
||||
|
||||
simpleText: [
|
||||
|
|
@ -156,12 +295,26 @@ export const language = <ILanguage>{
|
|||
[/[^#]+/, { token: '' }],
|
||||
|
||||
// interpolation
|
||||
[/(#{)([^}]*)(})/, {
|
||||
cases: {
|
||||
'@eos': ['interpolation.delimiter', 'interpolation', { token: 'interpolation.delimiter', next: '@popall' }],
|
||||
'@default': ['interpolation.delimiter', 'interpolation', 'interpolation.delimiter']
|
||||
[
|
||||
/(#{)([^}]*)(})/,
|
||||
{
|
||||
cases: {
|
||||
'@eos': [
|
||||
'interpolation.delimiter',
|
||||
'interpolation',
|
||||
{
|
||||
token: 'interpolation.delimiter',
|
||||
next: '@popall'
|
||||
}
|
||||
],
|
||||
'@default': [
|
||||
'interpolation.delimiter',
|
||||
'interpolation',
|
||||
'interpolation.delimiter'
|
||||
]
|
||||
}
|
||||
}
|
||||
}],
|
||||
],
|
||||
|
||||
[/#$/, { token: '', next: '@popall' }],
|
||||
[/#/, '']
|
||||
|
|
@ -169,34 +322,52 @@ export const language = <ILanguage>{
|
|||
|
||||
attributeList: [
|
||||
[/\s+/, ''],
|
||||
[/(\w+)(\s*=\s*)("|')/, ['attribute.name', 'delimiter', { token: 'attribute.value', next: '@value.$3' }]],
|
||||
[
|
||||
/(\w+)(\s*=\s*)("|')/,
|
||||
[
|
||||
'attribute.name',
|
||||
'delimiter',
|
||||
{ token: 'attribute.value', next: '@value.$3' }
|
||||
]
|
||||
],
|
||||
[/\w+/, 'attribute.name'],
|
||||
|
||||
|
||||
[/,/, {
|
||||
cases: {
|
||||
'@eos': { token: 'attribute.delimiter', next: '@popall' },
|
||||
'@default': 'attribute.delimiter'
|
||||
[
|
||||
/,/,
|
||||
{
|
||||
cases: {
|
||||
'@eos': {
|
||||
token: 'attribute.delimiter',
|
||||
next: '@popall'
|
||||
},
|
||||
'@default': 'attribute.delimiter'
|
||||
}
|
||||
}
|
||||
}],
|
||||
],
|
||||
|
||||
[/\)$/, { token: 'delimiter.parenthesis', next: '@popall' }],
|
||||
[/\)/, { token: 'delimiter.parenthesis', next: '@pop' }],
|
||||
[/\)/, { token: 'delimiter.parenthesis', next: '@pop' }]
|
||||
],
|
||||
|
||||
whitespace: [
|
||||
[/^(\s*)(\/\/.*)$/, { token: 'comment', next: '@blockText.$1.comment' }],
|
||||
[
|
||||
/^(\s*)(\/\/.*)$/,
|
||||
{ token: 'comment', next: '@blockText.$1.comment' }
|
||||
],
|
||||
[/[ \t\r\n]+/, ''],
|
||||
[/<!--/, { token: 'comment', next: '@comment' }],
|
||||
[/<!--/, { token: 'comment', next: '@comment' }]
|
||||
],
|
||||
|
||||
blockText: [
|
||||
[/^\s+.*$/, {
|
||||
cases: {
|
||||
'($S2\\s+.*$)': { token: '$S3' },
|
||||
'@default': { token: '@rematch', next: '@popall' }
|
||||
[
|
||||
/^\s+.*$/,
|
||||
{
|
||||
cases: {
|
||||
'($S2\\s+.*$)': { token: '$S3' },
|
||||
'@default': { token: '@rematch', next: '@popall' }
|
||||
}
|
||||
}
|
||||
}],
|
||||
],
|
||||
[/./, { token: '@rematch', next: '@popall' }]
|
||||
],
|
||||
|
||||
|
|
@ -208,55 +379,86 @@ export const language = <ILanguage>{
|
|||
],
|
||||
|
||||
string: [
|
||||
[/[^\\"'#]+/, {
|
||||
cases: {
|
||||
'@eos': { token: 'string', next: '@popall' },
|
||||
'@default': 'string'
|
||||
[
|
||||
/[^\\"'#]+/,
|
||||
{
|
||||
cases: {
|
||||
'@eos': { token: 'string', next: '@popall' },
|
||||
'@default': 'string'
|
||||
}
|
||||
}
|
||||
}],
|
||||
[/@escapes/, {
|
||||
cases: {
|
||||
'@eos': { token: 'string.escape', next: '@popall' },
|
||||
'@default': 'string.escape'
|
||||
],
|
||||
[
|
||||
/@escapes/,
|
||||
{
|
||||
cases: {
|
||||
'@eos': { token: 'string.escape', next: '@popall' },
|
||||
'@default': 'string.escape'
|
||||
}
|
||||
}
|
||||
}],
|
||||
[/\\./, {
|
||||
cases: {
|
||||
'@eos': { token: 'string.escape.invalid', next: '@popall' },
|
||||
'@default': 'string.escape.invalid'
|
||||
],
|
||||
[
|
||||
/\\./,
|
||||
{
|
||||
cases: {
|
||||
'@eos': {
|
||||
token: 'string.escape.invalid',
|
||||
next: '@popall'
|
||||
},
|
||||
'@default': 'string.escape.invalid'
|
||||
}
|
||||
}
|
||||
}],
|
||||
],
|
||||
// interpolation
|
||||
[/(#{)([^}]*)(})/, ['interpolation.delimiter', 'interpolation', 'interpolation.delimiter']],
|
||||
[
|
||||
/(#{)([^}]*)(})/,
|
||||
[
|
||||
'interpolation.delimiter',
|
||||
'interpolation',
|
||||
'interpolation.delimiter'
|
||||
]
|
||||
],
|
||||
[/#/, 'string'],
|
||||
[/["']/, {
|
||||
cases: {
|
||||
'$#==$S2': { token: 'string', next: '@pop' },
|
||||
'@default': { token: 'string' }
|
||||
[
|
||||
/["']/,
|
||||
{
|
||||
cases: {
|
||||
'$#==$S2': { token: 'string', next: '@pop' },
|
||||
'@default': { token: 'string' }
|
||||
}
|
||||
}
|
||||
}],
|
||||
]
|
||||
],
|
||||
|
||||
// Almost identical to above, except for escapes and the output token
|
||||
value: [
|
||||
[/[^\\"']+/, {
|
||||
cases: {
|
||||
'@eos': { token: 'attribute.value', next: '@popall' },
|
||||
'@default': 'attribute.value'
|
||||
[
|
||||
/[^\\"']+/,
|
||||
{
|
||||
cases: {
|
||||
'@eos': { token: 'attribute.value', next: '@popall' },
|
||||
'@default': 'attribute.value'
|
||||
}
|
||||
}
|
||||
}],
|
||||
[/\\./, {
|
||||
cases: {
|
||||
'@eos': { token: 'attribute.value', next: '@popall' },
|
||||
'@default': 'attribute.value'
|
||||
],
|
||||
[
|
||||
/\\./,
|
||||
{
|
||||
cases: {
|
||||
'@eos': { token: 'attribute.value', next: '@popall' },
|
||||
'@default': 'attribute.value'
|
||||
}
|
||||
}
|
||||
}],
|
||||
[/["']/, {
|
||||
cases: {
|
||||
'$#==$S2': { token: 'attribute.value', next: '@pop' },
|
||||
'@default': { token: 'attribute.value' }
|
||||
],
|
||||
[
|
||||
/["']/,
|
||||
{
|
||||
cases: {
|
||||
'$#==$S2': { token: 'attribute.value', next: '@pop' },
|
||||
'@default': { token: 'attribute.value' }
|
||||
}
|
||||
}
|
||||
}],
|
||||
],
|
||||
},
|
||||
]
|
||||
]
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -9,172 +9,187 @@ import { testTokenization } from '../test/testRunner';
|
|||
|
||||
testTokenization('python', [
|
||||
// Keywords
|
||||
[{
|
||||
line: 'def func():',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.python' },
|
||||
{ startIndex: 3, type: 'white.python' },
|
||||
{ startIndex: 4, type: 'identifier.python' },
|
||||
{ startIndex: 8, type: 'delimiter.parenthesis.python' },
|
||||
{ startIndex: 10, type: 'delimiter.python' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'def func():',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.python' },
|
||||
{ startIndex: 3, type: 'white.python' },
|
||||
{ startIndex: 4, type: 'identifier.python' },
|
||||
{ startIndex: 8, type: 'delimiter.parenthesis.python' },
|
||||
{ startIndex: 10, type: 'delimiter.python' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: 'func(str Y3)',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'identifier.python' },
|
||||
{ startIndex: 4, type: 'delimiter.parenthesis.python' },
|
||||
{ startIndex: 5, type: 'keyword.python' },
|
||||
{ startIndex: 8, type: 'white.python' },
|
||||
{ startIndex: 9, type: 'identifier.python' },
|
||||
{ startIndex: 11, type: 'delimiter.parenthesis.python' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'func(str Y3)',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'identifier.python' },
|
||||
{ startIndex: 4, type: 'delimiter.parenthesis.python' },
|
||||
{ startIndex: 5, type: 'keyword.python' },
|
||||
{ startIndex: 8, type: 'white.python' },
|
||||
{ startIndex: 9, type: 'identifier.python' },
|
||||
{ startIndex: 11, type: 'delimiter.parenthesis.python' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '@Dec0_rator:',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'tag.python' },
|
||||
{ startIndex: 11, type: 'delimiter.python' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '@Dec0_rator:',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'tag.python' },
|
||||
{ startIndex: 11, type: 'delimiter.python' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// Comments
|
||||
[{
|
||||
line: ' # Comments! ## "jfkd" ',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'white.python' },
|
||||
{ startIndex: 1, type: 'comment.python' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: ' # Comments! ## "jfkd" ',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'white.python' },
|
||||
{ startIndex: 1, type: 'comment.python' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// Strings
|
||||
[{
|
||||
line: '\'s0\'',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'string.escape.python' },
|
||||
{ startIndex: 1, type: 'string.python' },
|
||||
{ startIndex: 3, type: 'string.escape.python' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: "'s0'",
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'string.escape.python' },
|
||||
{ startIndex: 1, type: 'string.python' },
|
||||
{ startIndex: 3, type: 'string.escape.python' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '"\' " "',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'string.escape.python' },
|
||||
{ startIndex: 1, type: 'string.python' },
|
||||
{ startIndex: 3, type: 'string.escape.python' },
|
||||
{ startIndex: 4, type: 'white.python' },
|
||||
{ startIndex: 5, type: 'string.escape.python' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '"\' " "',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'string.escape.python' },
|
||||
{ startIndex: 1, type: 'string.python' },
|
||||
{ startIndex: 3, type: 'string.escape.python' },
|
||||
{ startIndex: 4, type: 'white.python' },
|
||||
{ startIndex: 5, type: 'string.escape.python' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '\'\'\'Lots of string\'\'\'',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'string.python' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: "'''Lots of string'''",
|
||||
tokens: [{ startIndex: 0, type: 'string.python' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '"""Lots \'\'\' \'\'\'"""',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'string.python' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '"""Lots \'\'\' \'\'\'"""',
|
||||
tokens: [{ startIndex: 0, type: 'string.python' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '\'\'\'Lots \'\'\'0.3e-5',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'string.python' },
|
||||
{ startIndex: 11, type: 'number.python' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: "'''Lots '''0.3e-5",
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'string.python' },
|
||||
{ startIndex: 11, type: 'number.python' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// https://github.com/Microsoft/monaco-editor/issues/1170
|
||||
[{
|
||||
line: 'def f():',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.python' },
|
||||
{ startIndex: 3, type: 'white.python' },
|
||||
{ startIndex: 4, type: 'identifier.python' },
|
||||
{ startIndex: 5, type: 'delimiter.parenthesis.python' },
|
||||
{ startIndex: 7, type: 'delimiter.python' },
|
||||
]
|
||||
}, {
|
||||
line: ' """multi',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'white.python' },
|
||||
{ startIndex: 3, type: 'string.python' },
|
||||
]
|
||||
}, {
|
||||
line: ' line',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'string.python' },
|
||||
]
|
||||
}, {
|
||||
line: ' comment',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'string.python' },
|
||||
]
|
||||
}, {
|
||||
line: ' """ + """',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'string.python' },
|
||||
{ startIndex: 6, type: 'white.python' },
|
||||
{ startIndex: 7, type: '' },
|
||||
{ startIndex: 8, type: 'white.python' },
|
||||
{ startIndex: 9, type: 'string.python' },
|
||||
]
|
||||
}, {
|
||||
line: ' another',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'string.python' },
|
||||
]
|
||||
}, {
|
||||
line: ' multi',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'string.python' },
|
||||
]
|
||||
}, {
|
||||
line: ' line',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'string.python' },
|
||||
]
|
||||
}, {
|
||||
line: ' comment"""',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'string.python' },
|
||||
]
|
||||
}, {
|
||||
line: ' code',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'white.python' },
|
||||
{ startIndex: 3, type: 'identifier.python' },
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'def f():',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.python' },
|
||||
{ startIndex: 3, type: 'white.python' },
|
||||
{ startIndex: 4, type: 'identifier.python' },
|
||||
{ startIndex: 5, type: 'delimiter.parenthesis.python' },
|
||||
{ startIndex: 7, type: 'delimiter.python' }
|
||||
]
|
||||
},
|
||||
{
|
||||
line: ' """multi',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'white.python' },
|
||||
{ startIndex: 3, type: 'string.python' }
|
||||
]
|
||||
},
|
||||
{
|
||||
line: ' line',
|
||||
tokens: [{ startIndex: 0, type: 'string.python' }]
|
||||
},
|
||||
{
|
||||
line: ' comment',
|
||||
tokens: [{ startIndex: 0, type: 'string.python' }]
|
||||
},
|
||||
{
|
||||
line: ' """ + """',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'string.python' },
|
||||
{ startIndex: 6, type: 'white.python' },
|
||||
{ startIndex: 7, type: '' },
|
||||
{ startIndex: 8, type: 'white.python' },
|
||||
{ startIndex: 9, type: 'string.python' }
|
||||
]
|
||||
},
|
||||
{
|
||||
line: ' another',
|
||||
tokens: [{ startIndex: 0, type: 'string.python' }]
|
||||
},
|
||||
{
|
||||
line: ' multi',
|
||||
tokens: [{ startIndex: 0, type: 'string.python' }]
|
||||
},
|
||||
{
|
||||
line: ' line',
|
||||
tokens: [{ startIndex: 0, type: 'string.python' }]
|
||||
},
|
||||
{
|
||||
line: ' comment"""',
|
||||
tokens: [{ startIndex: 0, type: 'string.python' }]
|
||||
},
|
||||
{
|
||||
line: ' code',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'white.python' },
|
||||
{ startIndex: 3, type: 'identifier.python' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// Numbers
|
||||
[{
|
||||
line: '0xAcBFd',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.hex.python' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '0xAcBFd',
|
||||
tokens: [{ startIndex: 0, type: 'number.hex.python' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '0x0cH',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.hex.python' },
|
||||
{ startIndex: 4, type: 'identifier.python' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '0x0cH',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.hex.python' },
|
||||
{ startIndex: 4, type: 'identifier.python' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '456.7e-7j',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.python' }
|
||||
]
|
||||
}]
|
||||
[
|
||||
{
|
||||
line: '456.7e-7j',
|
||||
tokens: [{ startIndex: 0, type: 'number.python' }]
|
||||
}
|
||||
]
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -9,12 +9,13 @@ import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration;
|
|||
import ILanguage = monaco.languages.IMonarchLanguage;
|
||||
|
||||
// Allow for running under nodejs/requirejs in tests
|
||||
const _monaco: typeof monaco = (typeof monaco === 'undefined' ? (<any>self).monaco : monaco);
|
||||
const _monaco: typeof monaco =
|
||||
typeof monaco === 'undefined' ? (<any>self).monaco : monaco;
|
||||
|
||||
export const conf: IRichLanguageConfiguration = {
|
||||
comments: {
|
||||
lineComment: '#',
|
||||
blockComment: ['\'\'\'', '\'\'\''],
|
||||
blockComment: ["'''", "'''"]
|
||||
},
|
||||
brackets: [
|
||||
['{', '}'],
|
||||
|
|
@ -26,26 +27,28 @@ export const conf: IRichLanguageConfiguration = {
|
|||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '"', close: '"', notIn: ['string'] },
|
||||
{ open: '\'', close: '\'', notIn: ['string', 'comment'] },
|
||||
{ open: "'", close: "'", notIn: ['string', 'comment'] }
|
||||
],
|
||||
surroundingPairs: [
|
||||
{ open: '{', close: '}' },
|
||||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '"', close: '"' },
|
||||
{ open: '\'', close: '\'' },
|
||||
{ open: "'", close: "'" }
|
||||
],
|
||||
onEnterRules: [
|
||||
{
|
||||
beforeText: new RegExp("^\\s*(?:def|class|for|if|elif|else|while|try|with|finally|except|async).*?:\\s*$"),
|
||||
beforeText: new RegExp(
|
||||
'^\\s*(?:def|class|for|if|elif|else|while|try|with|finally|except|async).*?:\\s*$'
|
||||
),
|
||||
action: { indentAction: _monaco.languages.IndentAction.Indent }
|
||||
}
|
||||
],
|
||||
folding: {
|
||||
offSide: true,
|
||||
markers: {
|
||||
start: new RegExp("^\\s*#region\\b"),
|
||||
end: new RegExp("^\\s*#endregion\\b")
|
||||
start: new RegExp('^\\s*#region\\b'),
|
||||
end: new RegExp('^\\s*#endregion\\b')
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -209,12 +212,15 @@ export const language = <ILanguage>{
|
|||
[/[{}\[\]()]/, '@brackets'],
|
||||
|
||||
[/@[a-zA-Z_]\w*/, 'tag'],
|
||||
[/[a-zA-Z_]\w*/, {
|
||||
cases: {
|
||||
'@keywords': 'keyword',
|
||||
'@default': 'identifier'
|
||||
[
|
||||
/[a-zA-Z_]\w*/,
|
||||
{
|
||||
cases: {
|
||||
'@keywords': 'keyword',
|
||||
'@default': 'identifier'
|
||||
}
|
||||
}
|
||||
}]
|
||||
]
|
||||
],
|
||||
|
||||
// Deal with white space, including single and multi-line comments
|
||||
|
|
|
|||
974
src/r/r.test.ts
974
src/r/r.test.ts
File diff suppressed because it is too large
Load diff
79
src/r/r.ts
79
src/r/r.ts
|
|
@ -21,13 +21,13 @@ export const conf: IRichLanguageConfiguration = {
|
|||
{ open: '{', close: '}' },
|
||||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '"', close: '"' },
|
||||
{ open: '"', close: '"' }
|
||||
],
|
||||
surroundingPairs: [
|
||||
{ open: '{', close: '}' },
|
||||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '"', close: '"' },
|
||||
{ open: '"', close: '"' }
|
||||
]
|
||||
};
|
||||
|
||||
|
|
@ -136,7 +136,7 @@ export const language = <ILanguage>{
|
|||
'\\a',
|
||||
'\\f',
|
||||
'\\v',
|
||||
'\\\'',
|
||||
"\\'",
|
||||
'\\"',
|
||||
'\\\\'
|
||||
],
|
||||
|
|
@ -164,30 +164,39 @@ export const language = <ILanguage>{
|
|||
[/[,:;]/, 'delimiter'],
|
||||
|
||||
[/@[a-zA-Z]\w*/, 'tag'],
|
||||
[/[a-zA-Z]\w*/, {
|
||||
cases: {
|
||||
'@keywords': 'keyword',
|
||||
'@constants': 'constant',
|
||||
'@default': 'identifier'
|
||||
[
|
||||
/[a-zA-Z]\w*/,
|
||||
{
|
||||
cases: {
|
||||
'@keywords': 'keyword',
|
||||
'@constants': 'constant',
|
||||
'@default': 'identifier'
|
||||
}
|
||||
}
|
||||
}]
|
||||
]
|
||||
],
|
||||
|
||||
// Recognize Roxygen comments
|
||||
roxygen: [
|
||||
[/@\w+/, {
|
||||
cases: {
|
||||
'@roxygen': 'tag',
|
||||
'@eos': { token: 'comment.doc', next: '@pop' },
|
||||
'@default': 'comment.doc'
|
||||
[
|
||||
/@\w+/,
|
||||
{
|
||||
cases: {
|
||||
'@roxygen': 'tag',
|
||||
'@eos': { token: 'comment.doc', next: '@pop' },
|
||||
'@default': 'comment.doc'
|
||||
}
|
||||
}
|
||||
}],
|
||||
[/\s+/, {
|
||||
cases: {
|
||||
'@eos': { token: 'comment.doc', next: '@pop' },
|
||||
'@default': 'comment.doc'
|
||||
],
|
||||
[
|
||||
/\s+/,
|
||||
{
|
||||
cases: {
|
||||
'@eos': { token: 'comment.doc', next: '@pop' },
|
||||
'@default': 'comment.doc'
|
||||
}
|
||||
}
|
||||
}],
|
||||
],
|
||||
[/.*/, { token: 'comment.doc', next: '@pop' }]
|
||||
],
|
||||
|
||||
|
|
@ -217,24 +226,30 @@ export const language = <ILanguage>{
|
|||
[/"/, 'string.escape', '@dblStringBody']
|
||||
],
|
||||
stringBody: [
|
||||
[/\\./, {
|
||||
cases: {
|
||||
'@special': 'string',
|
||||
'@default': 'error-token'
|
||||
[
|
||||
/\\./,
|
||||
{
|
||||
cases: {
|
||||
'@special': 'string',
|
||||
'@default': 'error-token'
|
||||
}
|
||||
}
|
||||
}],
|
||||
],
|
||||
[/'/, 'string.escape', '@popall'],
|
||||
[/./, 'string'],
|
||||
[/./, 'string']
|
||||
],
|
||||
dblStringBody: [
|
||||
[/\\./, {
|
||||
cases: {
|
||||
'@special': 'string',
|
||||
'@default': 'error-token'
|
||||
[
|
||||
/\\./,
|
||||
{
|
||||
cases: {
|
||||
'@special': 'string',
|
||||
'@default': 'error-token'
|
||||
}
|
||||
}
|
||||
}],
|
||||
],
|
||||
[/"/, 'string.escape', '@popall'],
|
||||
[/./, 'string'],
|
||||
[/./, 'string']
|
||||
]
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -8,71 +8,76 @@
|
|||
import { testTokenization } from '../test/testRunner';
|
||||
|
||||
testTokenization('razor', [
|
||||
|
||||
// Embedding - embedded html
|
||||
[{
|
||||
line: '@{ var x; <b>x</b> }',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'metatag.cs' },
|
||||
{ startIndex: 2, type: '' },
|
||||
{ startIndex: 3, type: 'keyword.cs' },
|
||||
{ startIndex: 6, type: '' },
|
||||
{ startIndex: 7, type: 'identifier.cs' },
|
||||
{ startIndex: 8, type: 'delimiter.cs' },
|
||||
{ startIndex: 9, type: '' },
|
||||
{ startIndex: 10, type: 'delimiter.html' },
|
||||
{ startIndex: 11, type: 'tag.html' },
|
||||
{ startIndex: 12, type: 'delimiter.html' },
|
||||
{ startIndex: 13, type: 'identifier.cs' },
|
||||
{ startIndex: 14, type: 'delimiter.html' },
|
||||
{ startIndex: 16, type: 'tag.html' },
|
||||
{ startIndex: 17, type: 'delimiter.html' },
|
||||
{ startIndex: 18, type: '' },
|
||||
{ startIndex: 19, type: 'metatag.cs' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '@{ var x; <b>x</b> }',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'metatag.cs' },
|
||||
{ startIndex: 2, type: '' },
|
||||
{ startIndex: 3, type: 'keyword.cs' },
|
||||
{ startIndex: 6, type: '' },
|
||||
{ startIndex: 7, type: 'identifier.cs' },
|
||||
{ startIndex: 8, type: 'delimiter.cs' },
|
||||
{ startIndex: 9, type: '' },
|
||||
{ startIndex: 10, type: 'delimiter.html' },
|
||||
{ startIndex: 11, type: 'tag.html' },
|
||||
{ startIndex: 12, type: 'delimiter.html' },
|
||||
{ startIndex: 13, type: 'identifier.cs' },
|
||||
{ startIndex: 14, type: 'delimiter.html' },
|
||||
{ startIndex: 16, type: 'tag.html' },
|
||||
{ startIndex: 17, type: 'delimiter.html' },
|
||||
{ startIndex: 18, type: '' },
|
||||
{ startIndex: 19, type: 'metatag.cs' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// Comments - razor comment inside csharp
|
||||
[{
|
||||
line: '@{ var x; @* comment *@ x= 0; }',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'metatag.cs' },
|
||||
{ startIndex: 2, type: '' },
|
||||
{ startIndex: 3, type: 'keyword.cs' },
|
||||
{ startIndex: 6, type: '' },
|
||||
{ startIndex: 7, type: 'identifier.cs' },
|
||||
{ startIndex: 8, type: 'delimiter.cs' },
|
||||
{ startIndex: 9, type: '' },
|
||||
{ startIndex: 10, type: 'comment.cs' },
|
||||
{ startIndex: 23, type: '' },
|
||||
{ startIndex: 24, type: 'identifier.cs' },
|
||||
{ startIndex: 25, type: 'delimiter.cs' },
|
||||
{ startIndex: 26, type: '' },
|
||||
{ startIndex: 27, type: 'number.cs' },
|
||||
{ startIndex: 28, type: 'delimiter.cs' },
|
||||
{ startIndex: 29, type: '' },
|
||||
{ startIndex: 30, type: 'metatag.cs' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '@{ var x; @* comment *@ x= 0; }',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'metatag.cs' },
|
||||
{ startIndex: 2, type: '' },
|
||||
{ startIndex: 3, type: 'keyword.cs' },
|
||||
{ startIndex: 6, type: '' },
|
||||
{ startIndex: 7, type: 'identifier.cs' },
|
||||
{ startIndex: 8, type: 'delimiter.cs' },
|
||||
{ startIndex: 9, type: '' },
|
||||
{ startIndex: 10, type: 'comment.cs' },
|
||||
{ startIndex: 23, type: '' },
|
||||
{ startIndex: 24, type: 'identifier.cs' },
|
||||
{ startIndex: 25, type: 'delimiter.cs' },
|
||||
{ startIndex: 26, type: '' },
|
||||
{ startIndex: 27, type: 'number.cs' },
|
||||
{ startIndex: 28, type: 'delimiter.cs' },
|
||||
{ startIndex: 29, type: '' },
|
||||
{ startIndex: 30, type: 'metatag.cs' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// Blocks - simple
|
||||
[{
|
||||
line: '@{ var total = 0; }',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'metatag.cs' },
|
||||
{ startIndex: 2, type: '' },
|
||||
{ startIndex: 3, type: 'keyword.cs' },
|
||||
{ startIndex: 6, type: '' },
|
||||
{ startIndex: 7, type: 'identifier.cs' },
|
||||
{ startIndex: 12, type: '' },
|
||||
{ startIndex: 13, type: 'delimiter.cs' },
|
||||
{ startIndex: 14, type: '' },
|
||||
{ startIndex: 15, type: 'number.cs' },
|
||||
{ startIndex: 16, type: 'delimiter.cs' },
|
||||
{ startIndex: 17, type: '' },
|
||||
{ startIndex: 18, type: 'metatag.cs' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '@{ var total = 0; }',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'metatag.cs' },
|
||||
{ startIndex: 2, type: '' },
|
||||
{ startIndex: 3, type: 'keyword.cs' },
|
||||
{ startIndex: 6, type: '' },
|
||||
{ startIndex: 7, type: 'identifier.cs' },
|
||||
{ startIndex: 12, type: '' },
|
||||
{ startIndex: 13, type: 'delimiter.cs' },
|
||||
{ startIndex: 14, type: '' },
|
||||
{ startIndex: 15, type: 'number.cs' },
|
||||
{ startIndex: 16, type: 'delimiter.cs' },
|
||||
{ startIndex: 17, type: '' },
|
||||
{ startIndex: 18, type: 'metatag.cs' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// [{
|
||||
// line: '@if(true){ var total = 0; }',
|
||||
|
|
@ -97,66 +102,76 @@ testTokenization('razor', [
|
|||
// ]}],
|
||||
|
||||
// Expressions - csharp expressions in html
|
||||
[{
|
||||
line: 'test@xyz<br>',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 4, type: 'metatag.cs' },
|
||||
{ startIndex: 5, type: 'identifier.cs' },
|
||||
{ startIndex: 8, type: 'delimiter.html' },
|
||||
{ startIndex: 9, type: 'tag.html' },
|
||||
{ startIndex: 11, type: 'delimiter.html' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'test@xyz<br>',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 4, type: 'metatag.cs' },
|
||||
{ startIndex: 5, type: 'identifier.cs' },
|
||||
{ startIndex: 8, type: 'delimiter.html' },
|
||||
{ startIndex: 9, type: 'tag.html' },
|
||||
{ startIndex: 11, type: 'delimiter.html' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: 'test@xyz',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 4, type: 'metatag.cs' },
|
||||
{ startIndex: 5, type: 'identifier.cs' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'test@xyz',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 4, type: 'metatag.cs' },
|
||||
{ startIndex: 5, type: 'identifier.cs' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: 'test @ xyz',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 5, type: 'metatag.cs' },
|
||||
{ startIndex: 6, type: 'identifier.cs' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'test @ xyz',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 5, type: 'metatag.cs' },
|
||||
{ startIndex: 6, type: 'identifier.cs' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: 'test @(foo) xyz',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 5, type: 'metatag.cs' },
|
||||
{ startIndex: 7, type: 'identifier.cs' },
|
||||
{ startIndex: 10, type: 'metatag.cs' },
|
||||
{ startIndex: 11, type: '' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'test @(foo) xyz',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 5, type: 'metatag.cs' },
|
||||
{ startIndex: 7, type: 'identifier.cs' },
|
||||
{ startIndex: 10, type: 'metatag.cs' },
|
||||
{ startIndex: 11, type: '' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: 'test @(foo(\")\")) xyz',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 5, type: 'metatag.cs' },
|
||||
{ startIndex: 7, type: 'identifier.cs' },
|
||||
{ startIndex: 10, type: 'delimiter.parenthesis.cs' },
|
||||
{ startIndex: 11, type: 'string.cs' },
|
||||
{ startIndex: 14, type: 'delimiter.parenthesis.cs' },
|
||||
{ startIndex: 15, type: 'metatag.cs' },
|
||||
{ startIndex: 16, type: '' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'test @(foo(")")) xyz',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' },
|
||||
{ startIndex: 5, type: 'metatag.cs' },
|
||||
{ startIndex: 7, type: 'identifier.cs' },
|
||||
{ startIndex: 10, type: 'delimiter.parenthesis.cs' },
|
||||
{ startIndex: 11, type: 'string.cs' },
|
||||
{ startIndex: 14, type: 'delimiter.parenthesis.cs' },
|
||||
{ startIndex: 15, type: 'metatag.cs' },
|
||||
{ startIndex: 16, type: '' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// Escaping - escaped at character
|
||||
[{
|
||||
line: 'test@@xyz',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: '' }
|
||||
]
|
||||
}]
|
||||
[
|
||||
{
|
||||
line: 'test@@xyz',
|
||||
tokens: [{ startIndex: 0, type: '' }]
|
||||
}
|
||||
]
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -9,9 +9,27 @@ import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration;
|
|||
import ILanguage = monaco.languages.IMonarchLanguage;
|
||||
|
||||
// Allow for running under nodejs/requirejs in tests
|
||||
const _monaco: typeof monaco = (typeof monaco === 'undefined' ? (<any>self).monaco : monaco);
|
||||
const _monaco: typeof monaco =
|
||||
typeof monaco === 'undefined' ? (<any>self).monaco : monaco;
|
||||
|
||||
const EMPTY_ELEMENTS: string[] = ['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'menuitem', 'meta', 'param', 'source', 'track', 'wbr'];
|
||||
const EMPTY_ELEMENTS: string[] = [
|
||||
'area',
|
||||
'base',
|
||||
'br',
|
||||
'col',
|
||||
'embed',
|
||||
'hr',
|
||||
'img',
|
||||
'input',
|
||||
'keygen',
|
||||
'link',
|
||||
'menuitem',
|
||||
'meta',
|
||||
'param',
|
||||
'source',
|
||||
'track',
|
||||
'wbr'
|
||||
];
|
||||
|
||||
export const conf: IRichLanguageConfiguration = {
|
||||
wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\@\$\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\s]+)/g,
|
||||
|
|
@ -32,26 +50,38 @@ export const conf: IRichLanguageConfiguration = {
|
|||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '"', close: '"' },
|
||||
{ open: '\'', close: '\'' }
|
||||
{ open: "'", close: "'" }
|
||||
],
|
||||
|
||||
surroundingPairs: [
|
||||
{ open: '"', close: '"' },
|
||||
{ open: '\'', close: '\'' },
|
||||
{ open: "'", close: "'" },
|
||||
{ open: '<', close: '>' }
|
||||
],
|
||||
|
||||
onEnterRules: [
|
||||
{
|
||||
beforeText: new RegExp(`<(?!(?:${EMPTY_ELEMENTS.join('|')}))(\\w[\\w\\d]*)([^/>]*(?!/)>)[^<]*$`, 'i'),
|
||||
beforeText: new RegExp(
|
||||
`<(?!(?:${EMPTY_ELEMENTS.join(
|
||||
'|'
|
||||
)}))(\\w[\\w\\d]*)([^/>]*(?!/)>)[^<]*$`,
|
||||
'i'
|
||||
),
|
||||
afterText: /^<\/(\w[\w\d]*)\s*>$/i,
|
||||
action: { indentAction: _monaco.languages.IndentAction.IndentOutdent }
|
||||
action: {
|
||||
indentAction: _monaco.languages.IndentAction.IndentOutdent
|
||||
}
|
||||
},
|
||||
{
|
||||
beforeText: new RegExp(`<(?!(?:${EMPTY_ELEMENTS.join('|')}))(\\w[\\w\\d]*)([^/>]*(?!/)>)[^<]*$`, 'i'),
|
||||
beforeText: new RegExp(
|
||||
`<(?!(?:${EMPTY_ELEMENTS.join(
|
||||
'|'
|
||||
)}))(\\w[\\w\\d]*)([^/>]*(?!/)>)[^<]*$`,
|
||||
'i'
|
||||
),
|
||||
action: { indentAction: _monaco.languages.IndentAction.Indent }
|
||||
}
|
||||
],
|
||||
]
|
||||
};
|
||||
|
||||
export const language = <ILanguage>{
|
||||
|
|
@ -63,80 +93,172 @@ export const language = <ILanguage>{
|
|||
tokenizer: {
|
||||
root: [
|
||||
[/@@/], // text
|
||||
[/@[^@]/, { token: '@rematch', switchTo: '@razorInSimpleState.root' }],
|
||||
[
|
||||
/@[^@]/,
|
||||
{ token: '@rematch', switchTo: '@razorInSimpleState.root' }
|
||||
],
|
||||
[/<!DOCTYPE/, 'metatag.html', '@doctype'],
|
||||
[/<!--/, 'comment.html', '@comment'],
|
||||
[/(<)(\w+)(\/>)/, ['delimiter.html', 'tag.html', 'delimiter.html']],
|
||||
[/(<)(script)/, ['delimiter.html', { token: 'tag.html', next: '@script' }]],
|
||||
[/(<)(style)/, ['delimiter.html', { token: 'tag.html', next: '@style' }]],
|
||||
[/(<)([:\w]+)/, ['delimiter.html', { token: 'tag.html', next: '@otherTag' }]],
|
||||
[/(<\/)(\w+)/, ['delimiter.html', { token: 'tag.html', next: '@otherTag' }]],
|
||||
[
|
||||
/(<)(script)/,
|
||||
['delimiter.html', { token: 'tag.html', next: '@script' }]
|
||||
],
|
||||
[
|
||||
/(<)(style)/,
|
||||
['delimiter.html', { token: 'tag.html', next: '@style' }]
|
||||
],
|
||||
[
|
||||
/(<)([:\w]+)/,
|
||||
['delimiter.html', { token: 'tag.html', next: '@otherTag' }]
|
||||
],
|
||||
[
|
||||
/(<\/)(\w+)/,
|
||||
['delimiter.html', { token: 'tag.html', next: '@otherTag' }]
|
||||
],
|
||||
[/</, 'delimiter.html'],
|
||||
[/[ \t\r\n]+/], // whitespace
|
||||
[/[^<@]+/], // text
|
||||
[/[^<@]+/] // text
|
||||
],
|
||||
|
||||
doctype: [
|
||||
[/@[^@]/, { token: '@rematch', switchTo: '@razorInSimpleState.comment' }],
|
||||
[
|
||||
/@[^@]/,
|
||||
{ token: '@rematch', switchTo: '@razorInSimpleState.comment' }
|
||||
],
|
||||
[/[^>]+/, 'metatag.content.html'],
|
||||
[/>/, 'metatag.html', '@pop'],
|
||||
[/>/, 'metatag.html', '@pop']
|
||||
],
|
||||
|
||||
comment: [
|
||||
[/@[^@]/, { token: '@rematch', switchTo: '@razorInSimpleState.comment' }],
|
||||
[
|
||||
/@[^@]/,
|
||||
{ token: '@rematch', switchTo: '@razorInSimpleState.comment' }
|
||||
],
|
||||
[/-->/, 'comment.html', '@pop'],
|
||||
[/[^-]+/, 'comment.content.html'],
|
||||
[/./, 'comment.content.html']
|
||||
],
|
||||
|
||||
otherTag: [
|
||||
[/@[^@]/, { token: '@rematch', switchTo: '@razorInSimpleState.otherTag' }],
|
||||
[
|
||||
/@[^@]/,
|
||||
{ token: '@rematch', switchTo: '@razorInSimpleState.otherTag' }
|
||||
],
|
||||
[/\/?>/, 'delimiter.html', '@pop'],
|
||||
[/"([^"]*)"/, 'attribute.value'],
|
||||
[/'([^']*)'/, 'attribute.value'],
|
||||
[/[\w\-]+/, 'attribute.name'],
|
||||
[/=/, 'delimiter'],
|
||||
[/[ \t\r\n]+/], // whitespace
|
||||
[/[ \t\r\n]+/] // whitespace
|
||||
],
|
||||
|
||||
// -- BEGIN <script> tags handling
|
||||
|
||||
// After <script
|
||||
script: [
|
||||
[/@[^@]/, { token: '@rematch', switchTo: '@razorInSimpleState.script' }],
|
||||
[
|
||||
/@[^@]/,
|
||||
{ token: '@rematch', switchTo: '@razorInSimpleState.script' }
|
||||
],
|
||||
[/type/, 'attribute.name', '@scriptAfterType'],
|
||||
[/"([^"]*)"/, 'attribute.value'],
|
||||
[/'([^']*)'/, 'attribute.value'],
|
||||
[/[\w\-]+/, 'attribute.name'],
|
||||
[/=/, 'delimiter'],
|
||||
[/>/, { token: 'delimiter.html', next: '@scriptEmbedded.text/javascript', nextEmbedded: 'text/javascript' }],
|
||||
[
|
||||
/>/,
|
||||
{
|
||||
token: 'delimiter.html',
|
||||
next: '@scriptEmbedded.text/javascript',
|
||||
nextEmbedded: 'text/javascript'
|
||||
}
|
||||
],
|
||||
[/[ \t\r\n]+/], // whitespace
|
||||
[/(<\/)(script\s*)(>)/, ['delimiter.html', 'tag.html', { token: 'delimiter.html', next: '@pop' }]]
|
||||
[
|
||||
/(<\/)(script\s*)(>)/,
|
||||
[
|
||||
'delimiter.html',
|
||||
'tag.html',
|
||||
{ token: 'delimiter.html', next: '@pop' }
|
||||
]
|
||||
]
|
||||
],
|
||||
|
||||
// After <script ... type
|
||||
scriptAfterType: [
|
||||
[/@[^@]/, { token: '@rematch', switchTo: '@razorInSimpleState.scriptAfterType' }],
|
||||
[
|
||||
/@[^@]/,
|
||||
{
|
||||
token: '@rematch',
|
||||
switchTo: '@razorInSimpleState.scriptAfterType'
|
||||
}
|
||||
],
|
||||
[/=/, 'delimiter', '@scriptAfterTypeEquals'],
|
||||
[/>/, { token: 'delimiter.html', next: '@scriptEmbedded.text/javascript', nextEmbedded: 'text/javascript' }], // cover invalid e.g. <script type>
|
||||
[
|
||||
/>/,
|
||||
{
|
||||
token: 'delimiter.html',
|
||||
next: '@scriptEmbedded.text/javascript',
|
||||
nextEmbedded: 'text/javascript'
|
||||
}
|
||||
], // cover invalid e.g. <script type>
|
||||
[/[ \t\r\n]+/], // whitespace
|
||||
[/<\/script\s*>/, { token: '@rematch', next: '@pop' }]
|
||||
],
|
||||
|
||||
// After <script ... type =
|
||||
scriptAfterTypeEquals: [
|
||||
[/@[^@]/, { token: '@rematch', switchTo: '@razorInSimpleState.scriptAfterTypeEquals' }],
|
||||
[/"([^"]*)"/, { token: 'attribute.value', switchTo: '@scriptWithCustomType.$1' }],
|
||||
[/'([^']*)'/, { token: 'attribute.value', switchTo: '@scriptWithCustomType.$1' }],
|
||||
[/>/, { token: 'delimiter.html', next: '@scriptEmbedded.text/javascript', nextEmbedded: 'text/javascript' }], // cover invalid e.g. <script type=>
|
||||
[
|
||||
/@[^@]/,
|
||||
{
|
||||
token: '@rematch',
|
||||
switchTo: '@razorInSimpleState.scriptAfterTypeEquals'
|
||||
}
|
||||
],
|
||||
[
|
||||
/"([^"]*)"/,
|
||||
{
|
||||
token: 'attribute.value',
|
||||
switchTo: '@scriptWithCustomType.$1'
|
||||
}
|
||||
],
|
||||
[
|
||||
/'([^']*)'/,
|
||||
{
|
||||
token: 'attribute.value',
|
||||
switchTo: '@scriptWithCustomType.$1'
|
||||
}
|
||||
],
|
||||
[
|
||||
/>/,
|
||||
{
|
||||
token: 'delimiter.html',
|
||||
next: '@scriptEmbedded.text/javascript',
|
||||
nextEmbedded: 'text/javascript'
|
||||
}
|
||||
], // cover invalid e.g. <script type=>
|
||||
[/[ \t\r\n]+/], // whitespace
|
||||
[/<\/script\s*>/, { token: '@rematch', next: '@pop' }]
|
||||
],
|
||||
|
||||
// After <script ... type = $S2
|
||||
scriptWithCustomType: [
|
||||
[/@[^@]/, { token: '@rematch', switchTo: '@razorInSimpleState.scriptWithCustomType.$S2' }],
|
||||
[/>/, { token: 'delimiter.html', next: '@scriptEmbedded.$S2', nextEmbedded: '$S2' }],
|
||||
[
|
||||
/@[^@]/,
|
||||
{
|
||||
token: '@rematch',
|
||||
switchTo: '@razorInSimpleState.scriptWithCustomType.$S2'
|
||||
}
|
||||
],
|
||||
[
|
||||
/>/,
|
||||
{
|
||||
token: 'delimiter.html',
|
||||
next: '@scriptEmbedded.$S2',
|
||||
nextEmbedded: '$S2'
|
||||
}
|
||||
],
|
||||
[/"([^"]*)"/, 'attribute.value'],
|
||||
[/'([^']*)'/, 'attribute.value'],
|
||||
[/[\w\-]+/, 'attribute.name'],
|
||||
|
|
@ -146,51 +268,128 @@ export const language = <ILanguage>{
|
|||
],
|
||||
|
||||
scriptEmbedded: [
|
||||
[/@[^@]/, { token: '@rematch', switchTo: '@razorInEmbeddedState.scriptEmbedded.$S2', nextEmbedded: '@pop' }],
|
||||
[/<\/script/, { token: '@rematch', next: '@pop', nextEmbedded: '@pop' }]
|
||||
[
|
||||
/@[^@]/,
|
||||
{
|
||||
token: '@rematch',
|
||||
switchTo: '@razorInEmbeddedState.scriptEmbedded.$S2',
|
||||
nextEmbedded: '@pop'
|
||||
}
|
||||
],
|
||||
[
|
||||
/<\/script/,
|
||||
{ token: '@rematch', next: '@pop', nextEmbedded: '@pop' }
|
||||
]
|
||||
],
|
||||
|
||||
// -- END <script> tags handling
|
||||
|
||||
|
||||
// -- BEGIN <style> tags handling
|
||||
|
||||
// After <style
|
||||
style: [
|
||||
[/@[^@]/, { token: '@rematch', switchTo: '@razorInSimpleState.style' }],
|
||||
[
|
||||
/@[^@]/,
|
||||
{ token: '@rematch', switchTo: '@razorInSimpleState.style' }
|
||||
],
|
||||
[/type/, 'attribute.name', '@styleAfterType'],
|
||||
[/"([^"]*)"/, 'attribute.value'],
|
||||
[/'([^']*)'/, 'attribute.value'],
|
||||
[/[\w\-]+/, 'attribute.name'],
|
||||
[/=/, 'delimiter'],
|
||||
[/>/, { token: 'delimiter.html', next: '@styleEmbedded.text/css', nextEmbedded: 'text/css' }],
|
||||
[
|
||||
/>/,
|
||||
{
|
||||
token: 'delimiter.html',
|
||||
next: '@styleEmbedded.text/css',
|
||||
nextEmbedded: 'text/css'
|
||||
}
|
||||
],
|
||||
[/[ \t\r\n]+/], // whitespace
|
||||
[/(<\/)(style\s*)(>)/, ['delimiter.html', 'tag.html', { token: 'delimiter.html', next: '@pop' }]]
|
||||
[
|
||||
/(<\/)(style\s*)(>)/,
|
||||
[
|
||||
'delimiter.html',
|
||||
'tag.html',
|
||||
{ token: 'delimiter.html', next: '@pop' }
|
||||
]
|
||||
]
|
||||
],
|
||||
|
||||
// After <style ... type
|
||||
styleAfterType: [
|
||||
[/@[^@]/, { token: '@rematch', switchTo: '@razorInSimpleState.styleAfterType' }],
|
||||
[
|
||||
/@[^@]/,
|
||||
{
|
||||
token: '@rematch',
|
||||
switchTo: '@razorInSimpleState.styleAfterType'
|
||||
}
|
||||
],
|
||||
[/=/, 'delimiter', '@styleAfterTypeEquals'],
|
||||
[/>/, { token: 'delimiter.html', next: '@styleEmbedded.text/css', nextEmbedded: 'text/css' }], // cover invalid e.g. <style type>
|
||||
[
|
||||
/>/,
|
||||
{
|
||||
token: 'delimiter.html',
|
||||
next: '@styleEmbedded.text/css',
|
||||
nextEmbedded: 'text/css'
|
||||
}
|
||||
], // cover invalid e.g. <style type>
|
||||
[/[ \t\r\n]+/], // whitespace
|
||||
[/<\/style\s*>/, { token: '@rematch', next: '@pop' }]
|
||||
],
|
||||
|
||||
// After <style ... type =
|
||||
styleAfterTypeEquals: [
|
||||
[/@[^@]/, { token: '@rematch', switchTo: '@razorInSimpleState.styleAfterTypeEquals' }],
|
||||
[/"([^"]*)"/, { token: 'attribute.value', switchTo: '@styleWithCustomType.$1' }],
|
||||
[/'([^']*)'/, { token: 'attribute.value', switchTo: '@styleWithCustomType.$1' }],
|
||||
[/>/, { token: 'delimiter.html', next: '@styleEmbedded.text/css', nextEmbedded: 'text/css' }], // cover invalid e.g. <style type=>
|
||||
[
|
||||
/@[^@]/,
|
||||
{
|
||||
token: '@rematch',
|
||||
switchTo: '@razorInSimpleState.styleAfterTypeEquals'
|
||||
}
|
||||
],
|
||||
[
|
||||
/"([^"]*)"/,
|
||||
{
|
||||
token: 'attribute.value',
|
||||
switchTo: '@styleWithCustomType.$1'
|
||||
}
|
||||
],
|
||||
[
|
||||
/'([^']*)'/,
|
||||
{
|
||||
token: 'attribute.value',
|
||||
switchTo: '@styleWithCustomType.$1'
|
||||
}
|
||||
],
|
||||
[
|
||||
/>/,
|
||||
{
|
||||
token: 'delimiter.html',
|
||||
next: '@styleEmbedded.text/css',
|
||||
nextEmbedded: 'text/css'
|
||||
}
|
||||
], // cover invalid e.g. <style type=>
|
||||
[/[ \t\r\n]+/], // whitespace
|
||||
[/<\/style\s*>/, { token: '@rematch', next: '@pop' }]
|
||||
],
|
||||
|
||||
// After <style ... type = $S2
|
||||
styleWithCustomType: [
|
||||
[/@[^@]/, { token: '@rematch', switchTo: '@razorInSimpleState.styleWithCustomType.$S2' }],
|
||||
[/>/, { token: 'delimiter.html', next: '@styleEmbedded.$S2', nextEmbedded: '$S2' }],
|
||||
[
|
||||
/@[^@]/,
|
||||
{
|
||||
token: '@rematch',
|
||||
switchTo: '@razorInSimpleState.styleWithCustomType.$S2'
|
||||
}
|
||||
],
|
||||
[
|
||||
/>/,
|
||||
{
|
||||
token: 'delimiter.html',
|
||||
next: '@styleEmbedded.$S2',
|
||||
nextEmbedded: '$S2'
|
||||
}
|
||||
],
|
||||
[/"([^"]*)"/, 'attribute.value'],
|
||||
[/'([^']*)'/, 'attribute.value'],
|
||||
[/[\w\-]+/, 'attribute.name'],
|
||||
|
|
@ -200,27 +399,63 @@ export const language = <ILanguage>{
|
|||
],
|
||||
|
||||
styleEmbedded: [
|
||||
[/@[^@]/, { token: '@rematch', switchTo: '@razorInEmbeddedState.styleEmbedded.$S2', nextEmbedded: '@pop' }],
|
||||
[/<\/style/, { token: '@rematch', next: '@pop', nextEmbedded: '@pop' }]
|
||||
[
|
||||
/@[^@]/,
|
||||
{
|
||||
token: '@rematch',
|
||||
switchTo: '@razorInEmbeddedState.styleEmbedded.$S2',
|
||||
nextEmbedded: '@pop'
|
||||
}
|
||||
],
|
||||
[
|
||||
/<\/style/,
|
||||
{ token: '@rematch', next: '@pop', nextEmbedded: '@pop' }
|
||||
]
|
||||
],
|
||||
|
||||
// -- END <style> tags handling
|
||||
|
||||
|
||||
razorInSimpleState: [
|
||||
[/@\*/, 'comment.cs', '@razorBlockCommentTopLevel'],
|
||||
[/@[{(]/, 'metatag.cs', '@razorRootTopLevel'],
|
||||
[/(@)(\s*[\w]+)/, ['metatag.cs', { token: 'identifier.cs', switchTo: '@$S2.$S3' }]],
|
||||
[
|
||||
/(@)(\s*[\w]+)/,
|
||||
['metatag.cs', { token: 'identifier.cs', switchTo: '@$S2.$S3' }]
|
||||
],
|
||||
[/[})]/, { token: 'metatag.cs', switchTo: '@$S2.$S3' }],
|
||||
[/\*@/, { token: 'comment.cs', switchTo: '@$S2.$S3' }],
|
||||
[/\*@/, { token: 'comment.cs', switchTo: '@$S2.$S3' }]
|
||||
],
|
||||
|
||||
razorInEmbeddedState: [
|
||||
[/@\*/, 'comment.cs', '@razorBlockCommentTopLevel'],
|
||||
[/@[{(]/, 'metatag.cs', '@razorRootTopLevel'],
|
||||
[/(@)(\s*[\w]+)/, ['metatag.cs', { token: 'identifier.cs', switchTo: '@$S2.$S3', nextEmbedded: '$S3' }]],
|
||||
[/[})]/, { token: 'metatag.cs', switchTo: '@$S2.$S3', nextEmbedded: '$S3' }],
|
||||
[/\*@/, { token: 'comment.cs', switchTo: '@$S2.$S3', nextEmbedded: '$S3' }],
|
||||
[
|
||||
/(@)(\s*[\w]+)/,
|
||||
[
|
||||
'metatag.cs',
|
||||
{
|
||||
token: 'identifier.cs',
|
||||
switchTo: '@$S2.$S3',
|
||||
nextEmbedded: '$S3'
|
||||
}
|
||||
]
|
||||
],
|
||||
[
|
||||
/[})]/,
|
||||
{
|
||||
token: 'metatag.cs',
|
||||
switchTo: '@$S2.$S3',
|
||||
nextEmbedded: '$S3'
|
||||
}
|
||||
],
|
||||
[
|
||||
/\*@/,
|
||||
{
|
||||
token: 'comment.cs',
|
||||
switchTo: '@$S2.$S3',
|
||||
nextEmbedded: '$S3'
|
||||
}
|
||||
]
|
||||
],
|
||||
|
||||
razorBlockCommentTopLevel: [
|
||||
|
|
@ -251,12 +486,15 @@ export const language = <ILanguage>{
|
|||
],
|
||||
|
||||
razorCommon: [
|
||||
[/[a-zA-Z_]\w*/, {
|
||||
cases: {
|
||||
'@razorKeywords': { token: 'keyword.cs' },
|
||||
'@default': 'identifier.cs'
|
||||
[
|
||||
/[a-zA-Z_]\w*/,
|
||||
{
|
||||
cases: {
|
||||
'@razorKeywords': { token: 'keyword.cs' },
|
||||
'@default': 'identifier.cs'
|
||||
}
|
||||
}
|
||||
}],
|
||||
],
|
||||
|
||||
// brackets
|
||||
[/[\[\]]/, 'delimiter.array.cs'],
|
||||
|
|
@ -287,36 +525,105 @@ export const language = <ILanguage>{
|
|||
[/0[0-7']*[0-7]/, 'number.octal.cs'],
|
||||
[/0[bB][0-1']*[0-1]/, 'number.binary.cs'],
|
||||
[/\d[\d']*/, 'number.cs'],
|
||||
[/\d/, 'number.cs'],
|
||||
[/\d/, 'number.cs']
|
||||
]
|
||||
},
|
||||
|
||||
razorKeywords: [
|
||||
'abstract', 'as', 'async', 'await', 'base', 'bool',
|
||||
'break', 'by', 'byte', 'case',
|
||||
'catch', 'char', 'checked', 'class',
|
||||
'const', 'continue', 'decimal', 'default',
|
||||
'delegate', 'do', 'double', 'descending',
|
||||
'explicit', 'event', 'extern', 'else',
|
||||
'enum', 'false', 'finally', 'fixed',
|
||||
'float', 'for', 'foreach', 'from',
|
||||
'goto', 'group', 'if', 'implicit',
|
||||
'in', 'int', 'interface', 'internal',
|
||||
'into', 'is', 'lock', 'long', 'nameof',
|
||||
'new', 'null', 'namespace', 'object',
|
||||
'operator', 'out', 'override', 'orderby',
|
||||
'params', 'private', 'protected', 'public',
|
||||
'readonly', 'ref', 'return', 'switch',
|
||||
'struct', 'sbyte', 'sealed', 'short',
|
||||
'sizeof', 'stackalloc', 'static', 'string',
|
||||
'select', 'this', 'throw', 'true',
|
||||
'try', 'typeof', 'uint', 'ulong',
|
||||
'unchecked', 'unsafe', 'ushort', 'using',
|
||||
'var', 'virtual', 'volatile', 'void', 'when',
|
||||
'while', 'where', 'yield',
|
||||
'model', 'inject' // Razor specific
|
||||
'abstract',
|
||||
'as',
|
||||
'async',
|
||||
'await',
|
||||
'base',
|
||||
'bool',
|
||||
'break',
|
||||
'by',
|
||||
'byte',
|
||||
'case',
|
||||
'catch',
|
||||
'char',
|
||||
'checked',
|
||||
'class',
|
||||
'const',
|
||||
'continue',
|
||||
'decimal',
|
||||
'default',
|
||||
'delegate',
|
||||
'do',
|
||||
'double',
|
||||
'descending',
|
||||
'explicit',
|
||||
'event',
|
||||
'extern',
|
||||
'else',
|
||||
'enum',
|
||||
'false',
|
||||
'finally',
|
||||
'fixed',
|
||||
'float',
|
||||
'for',
|
||||
'foreach',
|
||||
'from',
|
||||
'goto',
|
||||
'group',
|
||||
'if',
|
||||
'implicit',
|
||||
'in',
|
||||
'int',
|
||||
'interface',
|
||||
'internal',
|
||||
'into',
|
||||
'is',
|
||||
'lock',
|
||||
'long',
|
||||
'nameof',
|
||||
'new',
|
||||
'null',
|
||||
'namespace',
|
||||
'object',
|
||||
'operator',
|
||||
'out',
|
||||
'override',
|
||||
'orderby',
|
||||
'params',
|
||||
'private',
|
||||
'protected',
|
||||
'public',
|
||||
'readonly',
|
||||
'ref',
|
||||
'return',
|
||||
'switch',
|
||||
'struct',
|
||||
'sbyte',
|
||||
'sealed',
|
||||
'short',
|
||||
'sizeof',
|
||||
'stackalloc',
|
||||
'static',
|
||||
'string',
|
||||
'select',
|
||||
'this',
|
||||
'throw',
|
||||
'true',
|
||||
'try',
|
||||
'typeof',
|
||||
'uint',
|
||||
'ulong',
|
||||
'unchecked',
|
||||
'unsafe',
|
||||
'ushort',
|
||||
'using',
|
||||
'var',
|
||||
'virtual',
|
||||
'volatile',
|
||||
'void',
|
||||
'when',
|
||||
'while',
|
||||
'where',
|
||||
'yield',
|
||||
'model',
|
||||
'inject' // Razor specific
|
||||
],
|
||||
|
||||
escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
|
||||
|
||||
escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/
|
||||
};
|
||||
|
|
|
|||
|
|
@ -8,288 +8,302 @@
|
|||
import { testTokenization } from '../test/testRunner';
|
||||
|
||||
testTokenization('redis', [
|
||||
|
||||
// Numbers
|
||||
[{
|
||||
line: '123',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.redis' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '123',
|
||||
tokens: [{ startIndex: 0, type: 'number.redis' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '-123',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'operator.redis' },
|
||||
{ startIndex: 1, type: 'number.redis' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '-123',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'operator.redis' },
|
||||
{ startIndex: 1, type: 'number.redis' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '0xaBc123',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.redis' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '0xaBc123',
|
||||
tokens: [{ startIndex: 0, type: 'number.redis' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '0XaBc123',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.redis' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '0XaBc123',
|
||||
tokens: [{ startIndex: 0, type: 'number.redis' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '0x',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.redis' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '0x',
|
||||
tokens: [{ startIndex: 0, type: 'number.redis' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '0x0',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.redis' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '0x0',
|
||||
tokens: [{ startIndex: 0, type: 'number.redis' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '0xAB_CD',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.redis' },
|
||||
{ startIndex: 4, type: 'identifier.redis' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '0xAB_CD',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.redis' },
|
||||
{ startIndex: 4, type: 'identifier.redis' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '$',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.redis' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '$',
|
||||
tokens: [{ startIndex: 0, type: 'number.redis' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '$-123',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.redis' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '$-123',
|
||||
tokens: [{ startIndex: 0, type: 'number.redis' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '$-+-123',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.redis' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '$-+-123',
|
||||
tokens: [{ startIndex: 0, type: 'number.redis' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '$123.5678',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.redis' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '$123.5678',
|
||||
tokens: [{ startIndex: 0, type: 'number.redis' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '$0.99',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.redis' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '$0.99',
|
||||
tokens: [{ startIndex: 0, type: 'number.redis' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '$.99',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.redis' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '$.99',
|
||||
tokens: [{ startIndex: 0, type: 'number.redis' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '$99.',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.redis' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '$99.',
|
||||
tokens: [{ startIndex: 0, type: 'number.redis' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '$0.',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.redis' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '$0.',
|
||||
tokens: [{ startIndex: 0, type: 'number.redis' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '$.0',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.redis' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '$.0',
|
||||
tokens: [{ startIndex: 0, type: 'number.redis' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '.',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'delimiter.redis' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '.',
|
||||
tokens: [{ startIndex: 0, type: 'delimiter.redis' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '123',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.redis' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '123',
|
||||
tokens: [{ startIndex: 0, type: 'number.redis' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '123.5678',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.redis' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '123.5678',
|
||||
tokens: [{ startIndex: 0, type: 'number.redis' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '0.99',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.redis' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '0.99',
|
||||
tokens: [{ startIndex: 0, type: 'number.redis' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '.99',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.redis' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '.99',
|
||||
tokens: [{ startIndex: 0, type: 'number.redis' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '99.',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.redis' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '99.',
|
||||
tokens: [{ startIndex: 0, type: 'number.redis' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '0.',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.redis' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '0.',
|
||||
tokens: [{ startIndex: 0, type: 'number.redis' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '.0',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.redis' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '.0',
|
||||
tokens: [{ startIndex: 0, type: 'number.redis' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '1E-2',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.redis' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '1E-2',
|
||||
tokens: [{ startIndex: 0, type: 'number.redis' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '1E+2',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.redis' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '1E+2',
|
||||
tokens: [{ startIndex: 0, type: 'number.redis' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '1E2',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.redis' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '1E2',
|
||||
tokens: [{ startIndex: 0, type: 'number.redis' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '0.1E2',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.redis' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '0.1E2',
|
||||
tokens: [{ startIndex: 0, type: 'number.redis' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '1.E2',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.redis' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '1.E2',
|
||||
tokens: [{ startIndex: 0, type: 'number.redis' }]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: '.1E2',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.redis' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: '.1E2',
|
||||
tokens: [{ startIndex: 0, type: 'number.redis' }]
|
||||
}
|
||||
],
|
||||
|
||||
// Strings
|
||||
|
||||
[{
|
||||
line: 'SET key1 "Hello"',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.redis' },
|
||||
{ startIndex: 3, type: 'white.redis' },
|
||||
{ startIndex: 4, type: 'identifier.redis' },
|
||||
{ startIndex: 8, type: 'white.redis' },
|
||||
{ startIndex: 9, type: 'string.double.redis' },
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'SET key1 "Hello"',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.redis' },
|
||||
{ startIndex: 3, type: 'white.redis' },
|
||||
{ startIndex: 4, type: 'identifier.redis' },
|
||||
{ startIndex: 8, type: 'white.redis' },
|
||||
{ startIndex: 9, type: 'string.double.redis' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: 'SET key1 \'Hello\'',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.redis' },
|
||||
{ startIndex: 3, type: 'white.redis' },
|
||||
{ startIndex: 4, type: 'identifier.redis' },
|
||||
{ startIndex: 8, type: 'white.redis' },
|
||||
{ startIndex: 9, type: 'string.redis' },
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: "SET key1 'Hello'",
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.redis' },
|
||||
{ startIndex: 3, type: 'white.redis' },
|
||||
{ startIndex: 4, type: 'identifier.redis' },
|
||||
{ startIndex: 8, type: 'white.redis' },
|
||||
{ startIndex: 9, type: 'string.redis' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
// Commands
|
||||
|
||||
[{
|
||||
line: 'DEL key1 key2 key3',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.redis' },
|
||||
{ startIndex: 3, type: 'white.redis' },
|
||||
{ startIndex: 4, type: 'identifier.redis' },
|
||||
{ startIndex: 8, type: 'white.redis' },
|
||||
{ startIndex: 9, type: 'identifier.redis' },
|
||||
{ startIndex: 13, type: 'white.redis' },
|
||||
{ startIndex: 14, type: 'identifier.redis' },
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'DEL key1 key2 key3',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.redis' },
|
||||
{ startIndex: 3, type: 'white.redis' },
|
||||
{ startIndex: 4, type: 'identifier.redis' },
|
||||
{ startIndex: 8, type: 'white.redis' },
|
||||
{ startIndex: 9, type: 'identifier.redis' },
|
||||
{ startIndex: 13, type: 'white.redis' },
|
||||
{ startIndex: 14, type: 'identifier.redis' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: 'GEOADD Sicily 13.361389 38.115556 "Palermo" 15.087269 37.502669 "Catania"',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.redis' },
|
||||
{ startIndex: 6, type: 'white.redis' },
|
||||
{ startIndex: 7, type: 'identifier.redis' },
|
||||
{ startIndex: 13, type: 'white.redis' },
|
||||
{ startIndex: 14, type: 'number.redis' },
|
||||
{ startIndex: 23, type: 'white.redis' },
|
||||
{ startIndex: 24, type: 'number.redis' },
|
||||
{ startIndex: 33, type: 'white.redis' },
|
||||
{ startIndex: 34, type: 'string.double.redis' },
|
||||
{ startIndex: 43, type: 'white.redis' },
|
||||
{ startIndex: 44, type: 'number.redis' },
|
||||
{ startIndex: 53, type: 'white.redis' },
|
||||
{ startIndex: 54, type: 'number.redis' },
|
||||
{ startIndex: 63, type: 'white.redis' },
|
||||
{ startIndex: 64, type: 'string.double.redis' },
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line:
|
||||
'GEOADD Sicily 13.361389 38.115556 "Palermo" 15.087269 37.502669 "Catania"',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.redis' },
|
||||
{ startIndex: 6, type: 'white.redis' },
|
||||
{ startIndex: 7, type: 'identifier.redis' },
|
||||
{ startIndex: 13, type: 'white.redis' },
|
||||
{ startIndex: 14, type: 'number.redis' },
|
||||
{ startIndex: 23, type: 'white.redis' },
|
||||
{ startIndex: 24, type: 'number.redis' },
|
||||
{ startIndex: 33, type: 'white.redis' },
|
||||
{ startIndex: 34, type: 'string.double.redis' },
|
||||
{ startIndex: 43, type: 'white.redis' },
|
||||
{ startIndex: 44, type: 'number.redis' },
|
||||
{ startIndex: 53, type: 'white.redis' },
|
||||
{ startIndex: 54, type: 'number.redis' },
|
||||
{ startIndex: 63, type: 'white.redis' },
|
||||
{ startIndex: 64, type: 'string.double.redis' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
[{
|
||||
line: 'HGET myhash field1',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.redis' },
|
||||
{ startIndex: 4, type: 'white.redis' },
|
||||
{ startIndex: 5, type: 'identifier.redis' },
|
||||
{ startIndex: 11, type: 'white.redis' },
|
||||
{ startIndex: 12, type: 'identifier.redis' }
|
||||
]
|
||||
}],
|
||||
[
|
||||
{
|
||||
line: 'HGET myhash field1',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.redis' },
|
||||
{ startIndex: 4, type: 'white.redis' },
|
||||
{ startIndex: 5, type: 'identifier.redis' },
|
||||
{ startIndex: 11, type: 'white.redis' },
|
||||
{ startIndex: 12, type: 'identifier.redis' }
|
||||
]
|
||||
}
|
||||
]
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -19,14 +19,14 @@ export const conf: IRichLanguageConfiguration = {
|
|||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '"', close: '"' },
|
||||
{ open: '\'', close: '\'' },
|
||||
{ open: "'", close: "'" }
|
||||
],
|
||||
surroundingPairs: [
|
||||
{ open: '{', close: '}' },
|
||||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '"', close: '"' },
|
||||
{ open: '\'', close: '\'' },
|
||||
{ open: "'", close: "'" }
|
||||
]
|
||||
};
|
||||
|
||||
|
|
@ -41,24 +41,203 @@ export const language = <ILanguage>{
|
|||
],
|
||||
|
||||
keywords: [
|
||||
"APPEND", "AUTH", "BGREWRITEAOF", "BGSAVE", "BITCOUNT", "BITFIELD", "BITOP", "BITPOS", "BLPOP", "BRPOP", "BRPOPLPUSH",
|
||||
"CLIENT", "KILL", "LIST", "GETNAME", "PAUSE", "REPLY", "SETNAME", "CLUSTER", "ADDSLOTS", "COUNT-FAILURE-REPORTS",
|
||||
"COUNTKEYSINSLOT", "DELSLOTS", "FAILOVER", "FORGET", "GETKEYSINSLOT", "INFO", "KEYSLOT", "MEET", "NODES", "REPLICATE",
|
||||
"RESET", "SAVECONFIG", "SET-CONFIG-EPOCH", "SETSLOT", "SLAVES", "SLOTS", "COMMAND", "COUNT", "GETKEYS", "CONFIG", "GET",
|
||||
"REWRITE", "SET", "RESETSTAT", "DBSIZE", "DEBUG", "OBJECT", "SEGFAULT", "DECR", "DECRBY", "DEL", "DISCARD", "DUMP", "ECHO",
|
||||
"EVAL", "EVALSHA", "EXEC", "EXISTS", "EXPIRE", "EXPIREAT", "FLUSHALL", "FLUSHDB", "GEOADD", "GEOHASH", "GEOPOS", "GEODIST",
|
||||
"GEORADIUS", "GEORADIUSBYMEMBER", "GETBIT", "GETRANGE", "GETSET", "HDEL", "HEXISTS", "HGET", "HGETALL", "HINCRBY", "HINCRBYFLOAT",
|
||||
"HKEYS", "HLEN", "HMGET", "HMSET", "HSET", "HSETNX", "HSTRLEN", "HVALS", "INCR", "INCRBY", "INCRBYFLOAT", "KEYS", "LASTSAVE",
|
||||
"LINDEX", "LINSERT", "LLEN", "LPOP", "LPUSH", "LPUSHX", "LRANGE", "LREM", "LSET", "LTRIM", "MGET", "MIGRATE", "MONITOR",
|
||||
"MOVE", "MSET", "MSETNX", "MULTI", "PERSIST", "PEXPIRE", "PEXPIREAT", "PFADD", "PFCOUNT", "PFMERGE", "PING", "PSETEX",
|
||||
"PSUBSCRIBE", "PUBSUB", "PTTL", "PUBLISH", "PUNSUBSCRIBE", "QUIT", "RANDOMKEY", "READONLY", "READWRITE", "RENAME", "RENAMENX",
|
||||
"RESTORE", "ROLE", "RPOP", "RPOPLPUSH", "RPUSH", "RPUSHX", "SADD", "SAVE", "SCARD", "SCRIPT", "FLUSH", "LOAD", "SDIFF",
|
||||
"SDIFFSTORE", "SELECT", "SETBIT", "SETEX", "SETNX", "SETRANGE", "SHUTDOWN", "SINTER", "SINTERSTORE", "SISMEMBER", "SLAVEOF",
|
||||
"SLOWLOG", "SMEMBERS", "SMOVE", "SORT", "SPOP", "SRANDMEMBER", "SREM", "STRLEN", "SUBSCRIBE", "SUNION", "SUNIONSTORE", "SWAPDB",
|
||||
"SYNC", "TIME", "TOUCH", "TTL", "TYPE", "UNSUBSCRIBE", "UNLINK", "UNWATCH", "WAIT", "WATCH", "ZADD", "ZCARD", "ZCOUNT", "ZINCRBY",
|
||||
"ZINTERSTORE", "ZLEXCOUNT", "ZRANGE", "ZRANGEBYLEX", "ZREVRANGEBYLEX", "ZRANGEBYSCORE", "ZRANK", "ZREM", "ZREMRANGEBYLEX",
|
||||
"ZREMRANGEBYRANK", "ZREMRANGEBYSCORE", "ZREVRANGE", "ZREVRANGEBYSCORE", "ZREVRANK", "ZSCORE", "ZUNIONSTORE", "SCAN", "SSCAN",
|
||||
"HSCAN", "ZSCAN"
|
||||
'APPEND',
|
||||
'AUTH',
|
||||
'BGREWRITEAOF',
|
||||
'BGSAVE',
|
||||
'BITCOUNT',
|
||||
'BITFIELD',
|
||||
'BITOP',
|
||||
'BITPOS',
|
||||
'BLPOP',
|
||||
'BRPOP',
|
||||
'BRPOPLPUSH',
|
||||
'CLIENT',
|
||||
'KILL',
|
||||
'LIST',
|
||||
'GETNAME',
|
||||
'PAUSE',
|
||||
'REPLY',
|
||||
'SETNAME',
|
||||
'CLUSTER',
|
||||
'ADDSLOTS',
|
||||
'COUNT-FAILURE-REPORTS',
|
||||
'COUNTKEYSINSLOT',
|
||||
'DELSLOTS',
|
||||
'FAILOVER',
|
||||
'FORGET',
|
||||
'GETKEYSINSLOT',
|
||||
'INFO',
|
||||
'KEYSLOT',
|
||||
'MEET',
|
||||
'NODES',
|
||||
'REPLICATE',
|
||||
'RESET',
|
||||
'SAVECONFIG',
|
||||
'SET-CONFIG-EPOCH',
|
||||
'SETSLOT',
|
||||
'SLAVES',
|
||||
'SLOTS',
|
||||
'COMMAND',
|
||||
'COUNT',
|
||||
'GETKEYS',
|
||||
'CONFIG',
|
||||
'GET',
|
||||
'REWRITE',
|
||||
'SET',
|
||||
'RESETSTAT',
|
||||
'DBSIZE',
|
||||
'DEBUG',
|
||||
'OBJECT',
|
||||
'SEGFAULT',
|
||||
'DECR',
|
||||
'DECRBY',
|
||||
'DEL',
|
||||
'DISCARD',
|
||||
'DUMP',
|
||||
'ECHO',
|
||||
'EVAL',
|
||||
'EVALSHA',
|
||||
'EXEC',
|
||||
'EXISTS',
|
||||
'EXPIRE',
|
||||
'EXPIREAT',
|
||||
'FLUSHALL',
|
||||
'FLUSHDB',
|
||||
'GEOADD',
|
||||
'GEOHASH',
|
||||
'GEOPOS',
|
||||
'GEODIST',
|
||||
'GEORADIUS',
|
||||
'GEORADIUSBYMEMBER',
|
||||
'GETBIT',
|
||||
'GETRANGE',
|
||||
'GETSET',
|
||||
'HDEL',
|
||||
'HEXISTS',
|
||||
'HGET',
|
||||
'HGETALL',
|
||||
'HINCRBY',
|
||||
'HINCRBYFLOAT',
|
||||
'HKEYS',
|
||||
'HLEN',
|
||||
'HMGET',
|
||||
'HMSET',
|
||||
'HSET',
|
||||
'HSETNX',
|
||||
'HSTRLEN',
|
||||
'HVALS',
|
||||
'INCR',
|
||||
'INCRBY',
|
||||
'INCRBYFLOAT',
|
||||
'KEYS',
|
||||
'LASTSAVE',
|
||||
'LINDEX',
|
||||
'LINSERT',
|
||||
'LLEN',
|
||||
'LPOP',
|
||||
'LPUSH',
|
||||
'LPUSHX',
|
||||
'LRANGE',
|
||||
'LREM',
|
||||
'LSET',
|
||||
'LTRIM',
|
||||
'MGET',
|
||||
'MIGRATE',
|
||||
'MONITOR',
|
||||
'MOVE',
|
||||
'MSET',
|
||||
'MSETNX',
|
||||
'MULTI',
|
||||
'PERSIST',
|
||||
'PEXPIRE',
|
||||
'PEXPIREAT',
|
||||
'PFADD',
|
||||
'PFCOUNT',
|
||||
'PFMERGE',
|
||||
'PING',
|
||||
'PSETEX',
|
||||
'PSUBSCRIBE',
|
||||
'PUBSUB',
|
||||
'PTTL',
|
||||
'PUBLISH',
|
||||
'PUNSUBSCRIBE',
|
||||
'QUIT',
|
||||
'RANDOMKEY',
|
||||
'READONLY',
|
||||
'READWRITE',
|
||||
'RENAME',
|
||||
'RENAMENX',
|
||||
'RESTORE',
|
||||
'ROLE',
|
||||
'RPOP',
|
||||
'RPOPLPUSH',
|
||||
'RPUSH',
|
||||
'RPUSHX',
|
||||
'SADD',
|
||||
'SAVE',
|
||||
'SCARD',
|
||||
'SCRIPT',
|
||||
'FLUSH',
|
||||
'LOAD',
|
||||
'SDIFF',
|
||||
'SDIFFSTORE',
|
||||
'SELECT',
|
||||
'SETBIT',
|
||||
'SETEX',
|
||||
'SETNX',
|
||||
'SETRANGE',
|
||||
'SHUTDOWN',
|
||||
'SINTER',
|
||||
'SINTERSTORE',
|
||||
'SISMEMBER',
|
||||
'SLAVEOF',
|
||||
'SLOWLOG',
|
||||
'SMEMBERS',
|
||||
'SMOVE',
|
||||
'SORT',
|
||||
'SPOP',
|
||||
'SRANDMEMBER',
|
||||
'SREM',
|
||||
'STRLEN',
|
||||
'SUBSCRIBE',
|
||||
'SUNION',
|
||||
'SUNIONSTORE',
|
||||
'SWAPDB',
|
||||
'SYNC',
|
||||
'TIME',
|
||||
'TOUCH',
|
||||
'TTL',
|
||||
'TYPE',
|
||||
'UNSUBSCRIBE',
|
||||
'UNLINK',
|
||||
'UNWATCH',
|
||||
'WAIT',
|
||||
'WATCH',
|
||||
'ZADD',
|
||||
'ZCARD',
|
||||
'ZCOUNT',
|
||||
'ZINCRBY',
|
||||
'ZINTERSTORE',
|
||||
'ZLEXCOUNT',
|
||||
'ZRANGE',
|
||||
'ZRANGEBYLEX',
|
||||
'ZREVRANGEBYLEX',
|
||||
'ZRANGEBYSCORE',
|
||||
'ZRANK',
|
||||
'ZREM',
|
||||
'ZREMRANGEBYLEX',
|
||||
'ZREMRANGEBYRANK',
|
||||
'ZREMRANGEBYSCORE',
|
||||
'ZREVRANGE',
|
||||
'ZREVRANGEBYSCORE',
|
||||
'ZREVRANK',
|
||||
'ZSCORE',
|
||||
'ZUNIONSTORE',
|
||||
'SCAN',
|
||||
'SSCAN',
|
||||
'HSCAN',
|
||||
'ZSCAN'
|
||||
],
|
||||
operators: [
|
||||
// NOT SUPPORTED
|
||||
|
|
@ -81,27 +260,31 @@ export const language = <ILanguage>{
|
|||
{ include: '@scopes' },
|
||||
[/[;,.]/, 'delimiter'],
|
||||
[/[()]/, '@brackets'],
|
||||
[/[\w@#$]+/, {
|
||||
cases: {
|
||||
'@keywords': 'keyword',
|
||||
'@operators': 'operator',
|
||||
'@builtinVariables': 'predefined',
|
||||
'@builtinFunctions': 'predefined',
|
||||
'@default': 'identifier'
|
||||
[
|
||||
/[\w@#$]+/,
|
||||
{
|
||||
cases: {
|
||||
'@keywords': 'keyword',
|
||||
'@operators': 'operator',
|
||||
'@builtinVariables': 'predefined',
|
||||
'@builtinFunctions': 'predefined',
|
||||
'@default': 'identifier'
|
||||
}
|
||||
}
|
||||
}],
|
||||
[/[<>=!%&+\-*/|~^]/, 'operator'],
|
||||
],
|
||||
whitespace: [
|
||||
[/\s+/, 'white']
|
||||
],
|
||||
[/[<>=!%&+\-*/|~^]/, 'operator']
|
||||
],
|
||||
whitespace: [[/\s+/, 'white']],
|
||||
pseudoColumns: [
|
||||
[/[$][A-Za-z_][\w@#$]*/, {
|
||||
cases: {
|
||||
'@pseudoColumns': 'predefined',
|
||||
'@default': 'identifier'
|
||||
[
|
||||
/[$][A-Za-z_][\w@#$]*/,
|
||||
{
|
||||
cases: {
|
||||
'@pseudoColumns': 'predefined',
|
||||
'@default': 'identifier'
|
||||
}
|
||||
}
|
||||
}],
|
||||
]
|
||||
],
|
||||
numbers: [
|
||||
[/0[xX][0-9a-fA-F]*/, 'number'],
|
||||
|
|
@ -115,7 +298,7 @@ export const language = <ILanguage>{
|
|||
string: [
|
||||
[/[^']+/, 'string'],
|
||||
[/''/, 'string'],
|
||||
[/'/, { token: 'string', next: '@pop' }],
|
||||
[/'/, { token: 'string', next: '@pop' }]
|
||||
],
|
||||
stringDouble: [
|
||||
[/[^"]+/, 'string.double'],
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue