diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 00000000..e1b5c6fc --- /dev/null +++ b/.prettierrc @@ -0,0 +1,7 @@ +{ + "arrowParens": "always", + "singleQuote": true, + "trailingComma": "none", + "semi": true, + "useTabs": true +} diff --git a/.vscode/launch.json b/.vscode/launch.json index b3b84602..1600b481 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -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 + } + ] } diff --git a/LICENSE.md b/LICENSE.md index f8a94f6e..5ae193c9 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,21 +1,21 @@ -The MIT License (MIT) - -Copyright (c) Microsoft Corporation - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file +The MIT License (MIT) + +Copyright (c) Microsoft Corporation + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index 5b480bbe..91a9a92c 100644 --- a/README.md +++ b/README.md @@ -1,38 +1,39 @@ -# Monaco Languages [![Build Status](https://dev.azure.com/ms/monaco-languages/_apis/build/status/microsoft.monaco-languages?branchName=master)](https://dev.azure.com/ms/monaco-languages/_build/latest?definitionId=140&branchName=master) - -Colorization and configuration supports for multiple languages for the Monaco Editor: - -![monaco-languages](https://cloud.githubusercontent.com/assets/5047891/15938606/1fd4bac6-2e74-11e6-8839-d455da8bc8a7.gif) - -## Issues - -Please file issues concerning `monaco-languages` in the [`monaco-editor`-repository](https://github.com/Microsoft/monaco-editor/issues). - -## Installing - -This npm module is bundled and distributed in the [monaco-editor](https://www.npmjs.com/package/monaco-editor) npm module. - -## Dev: cheat sheet - -* 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 -```js - 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) +# Monaco Languages [![Build Status](https://dev.azure.com/ms/monaco-languages/_apis/build/status/microsoft.monaco-languages?branchName=master)](https://dev.azure.com/ms/monaco-languages/_build/latest?definitionId=140&branchName=master) + +Colorization and configuration supports for multiple languages for the Monaco Editor: + +![monaco-languages](https://cloud.githubusercontent.com/assets/5047891/15938606/1fd4bac6-2e74-11e6-8839-d455da8bc8a7.gif) + +## Issues + +Please file issues concerning `monaco-languages` in the [`monaco-editor`-repository](https://github.com/Microsoft/monaco-editor/issues). + +## Installing + +This npm module is bundled and distributed in the [monaco-editor](https://www.npmjs.com/package/monaco-editor) npm module. + +## Dev: cheat sheet + +- 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 + +```js +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) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 0da1e9ea..a9c406e4 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -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' diff --git a/package-lock.json b/package-lock.json index 2eec62b5..19381eb3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,1252 +1,1862 @@ { - "name": "monaco-languages", - "version": "1.10.0", - "lockfileVersion": 1, - "requires": true, - "dependencies": { - "@types/node": { - "version": "14.6.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-14.6.0.tgz", - "integrity": "sha512-mikldZQitV94akrc4sCcSjtJfsTKt4p+e/s0AGscVA6XArQ9kFclP+ZiYUMnq987rc6QlYxXv/EivqlfSLxpKA==", - "dev": true - }, - "@types/tape": { - "version": "4.13.0", - "resolved": "https://registry.npmjs.org/@types/tape/-/tape-4.13.0.tgz", - "integrity": "sha512-0V8cKowBdsiA9nbxAg7531sF2cdPZNiUogcfIUeUGm+bejUBE/bvibz3rH36iQP9bQjO/sOzFwU97/uC5mCyoA==", - "dev": true, - "requires": { - "@types/node": "*" - } - }, - "abab": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/abab/-/abab-2.0.4.tgz", - "integrity": "sha512-Eu9ELJWCz/c1e9gTiCY+FceWxcqzjYEbqMgtndnuSqZSUCOL73TWNK2mHfIj4Cw2E/ongOp+JISVNCmovt2KYQ==", - "dev": true - }, - "acorn": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.0.tgz", - "integrity": "sha512-+G7P8jJmCHr+S+cLfQxygbWhXy+8YTVGzAkpEbcLo2mLoL7tij/VG41QSHACSf5QgYRhMZYHuNc6drJaO0Da+w==", - "dev": true - }, - "acorn-globals": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/acorn-globals/-/acorn-globals-6.0.0.tgz", - "integrity": "sha512-ZQl7LOWaF5ePqqcX4hLuv/bLXYQNfNWw2c0/yX/TsPRKamzHcTGQnlCjHT3TsmkOUVEPS3crCxiPfdzE/Trlhg==", - "dev": true, - "requires": { - "acorn": "^7.1.1", - "acorn-walk": "^7.1.1" - } - }, - "acorn-walk": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-7.2.0.tgz", - "integrity": "sha512-OPdCF6GsMIP+Az+aWfAAOEt2/+iVDKE7oy6lJ098aoe59oAmK76qV6Gw60SbZ8jHuG2wH058GF4pLFbYamYrVA==", - "dev": true - }, - "ajv": { - "version": "6.12.4", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.4.tgz", - "integrity": "sha512-eienB2c9qVQs2KWexhkrdMLVDoIQCz5KSeLxwg9Lzk4DOfBtIK9PQwwufcsn1jjGuf9WZmqPMbGxOzfcuphJCQ==", - "dev": true, - "requires": { - "fast-deep-equal": "^3.1.1", - "fast-json-stable-stringify": "^2.0.0", - "json-schema-traverse": "^0.4.1", - "uri-js": "^4.2.2" - } - }, - "asn1": { - "version": "0.2.4", - "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz", - "integrity": "sha512-jxwzQpLQjSmWXgwaCZE9Nz+glAG01yF1QnWgbhGwHI5A6FRIEY6IVqtHhIepHqI7/kyEyQEagBC5mBEFlIYvdg==", - "dev": true, - "requires": { - "safer-buffer": "~2.1.0" - } - }, - "assert-plus": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", - "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", - "dev": true - }, - "asynckit": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=", - "dev": true - }, - "aws-sign2": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", - "integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=", - "dev": true - }, - "aws4": { - "version": "1.10.1", - "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.10.1.tgz", - "integrity": "sha512-zg7Hz2k5lI8kb7U32998pRRFin7zJlkfezGJjUc2heaD4Pw2wObakCDVzkKztTm/Ln7eiVvYsjqak0Ed4LkMDA==", - "dev": true - }, - "balanced-match": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", - "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", - "dev": true - }, - "bcrypt-pbkdf": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", - "integrity": "sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4=", - "dev": true, - "requires": { - "tweetnacl": "^0.14.3" - } - }, - "brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "dev": true, - "requires": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "browser-process-hrtime": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/browser-process-hrtime/-/browser-process-hrtime-1.0.0.tgz", - "integrity": "sha512-9o5UecI3GhkpM6DrXr69PblIuWxPKk9Y0jHBRhdocZ2y7YECBFCsHm79Pr3OyR2AvjhDkabFJaDJMYRazHgsow==", - "dev": true - }, - "buffer-from": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", - "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==", - "dev": true - }, - "caseless": { - "version": "0.12.0", - "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", - "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=", - "dev": true - }, - "combined-stream": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", - "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", - "dev": true, - "requires": { - "delayed-stream": "~1.0.0" - } - }, - "commander": { - "version": "2.20.3", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", - "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", - "dev": true - }, - "concat-map": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", - "dev": true - }, - "core-util-is": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", - "dev": true - }, - "cssom": { - "version": "0.4.4", - "resolved": "https://registry.npmjs.org/cssom/-/cssom-0.4.4.tgz", - "integrity": "sha512-p3pvU7r1MyyqbTk+WbNJIgJjG2VmTIaB10rI93LzVPrmDJKkzKYMtxxyAvQXR/NS6otuzveI7+7BBq3SjBS2mw==", - "dev": true - }, - "cssstyle": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/cssstyle/-/cssstyle-2.3.0.tgz", - "integrity": "sha512-AZL67abkUzIuvcHqk7c09cezpGNcxUxU4Ioi/05xHk4DQeTkWmGYftIE6ctU6AEt+Gn4n1lDStOtj7FKycP71A==", - "dev": true, - "requires": { - "cssom": "~0.3.6" - }, - "dependencies": { - "cssom": { - "version": "0.3.8", - "resolved": "https://registry.npmjs.org/cssom/-/cssom-0.3.8.tgz", - "integrity": "sha512-b0tGHbfegbhPJpxpiBPU2sCkigAqtM9O121le6bbOlgyV+NyGyCmVfJ6QW9eRjz8CpNfWEOYBIMIGRYkLwsIYg==", - "dev": true - } - } - }, - "dashdash": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", - "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", - "dev": true, - "requires": { - "assert-plus": "^1.0.0" - } - }, - "data-urls": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/data-urls/-/data-urls-2.0.0.tgz", - "integrity": "sha512-X5eWTSXO/BJmpdIKCRuKUgSCgAN0OwliVK3yPKbwIWU1Tdw5BRajxlzMidvh+gwko9AfQ9zIj52pzF91Q3YAvQ==", - "dev": true, - "requires": { - "abab": "^2.0.3", - "whatwg-mimetype": "^2.3.0", - "whatwg-url": "^8.0.0" - } - }, - "decimal.js": { - "version": "10.2.0", - "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.2.0.tgz", - "integrity": "sha512-vDPw+rDgn3bZe1+F/pyEwb1oMG2XTlRVgAa6B4KccTEpYgF8w6eQllVbQcfIJnZyvzFtFpxnpGtx8dd7DJp/Rw==", - "dev": true - }, - "deep-equal": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-1.1.1.tgz", - "integrity": "sha512-yd9c5AdiqVcR+JjcwUQb9DkhJc8ngNr0MahEBGvDiJw8puWab2yZlh+nkasOnZP+EGTAP6rRp2JzJhJZzvNF8g==", - "dev": true, - "requires": { - "is-arguments": "^1.0.4", - "is-date-object": "^1.0.1", - "is-regex": "^1.0.4", - "object-is": "^1.0.1", - "object-keys": "^1.1.1", - "regexp.prototype.flags": "^1.2.0" - } - }, - "deep-is": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", - "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=", - "dev": true - }, - "define-properties": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", - "integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==", - "dev": true, - "requires": { - "object-keys": "^1.0.12" - } - }, - "defined": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/defined/-/defined-1.0.0.tgz", - "integrity": "sha1-yY2bzvdWdBiOEQlpFRGZ45sfppM=", - "dev": true - }, - "delayed-stream": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", - "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", - "dev": true - }, - "domexception": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/domexception/-/domexception-2.0.1.tgz", - "integrity": "sha512-yxJ2mFy/sibVQlu5qHjOkf9J3K6zgmCxgJ94u2EdvDOV09H+32LtRswEcUsmUWN72pVLOEnTSRaIVVzVQgS0dg==", - "dev": true, - "requires": { - "webidl-conversions": "^5.0.0" - }, - "dependencies": { - "webidl-conversions": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-5.0.0.tgz", - "integrity": "sha512-VlZwKPCkYKxQgeSbH5EyngOmRp7Ww7I9rQLERETtf5ofd9pGeswWiOtogpEO850jziPRarreGxn5QIiTqpb2wA==", - "dev": true - } - } - }, - "dotignore": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/dotignore/-/dotignore-0.1.2.tgz", - "integrity": "sha512-UGGGWfSauusaVJC+8fgV+NVvBXkCTmVv7sk6nojDZZvuOUNGUy0Zk4UpHQD6EDjS0jpBwcACvH4eofvyzBcRDw==", - "dev": true, - "requires": { - "minimatch": "^3.0.4" - } - }, - "ecc-jsbn": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", - "integrity": "sha1-OoOpBOVDUyh4dMVkt1SThoSamMk=", - "dev": true, - "requires": { - "jsbn": "~0.1.0", - "safer-buffer": "^2.1.0" - } - }, - "es-abstract": { - "version": "1.17.6", - "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.17.6.tgz", - "integrity": "sha512-Fr89bON3WFyUi5EvAeI48QTWX0AyekGgLA8H+c+7fbfCkJwRWRMLd8CQedNEyJuoYYhmtEqY92pgte1FAhBlhw==", - "dev": true, - "requires": { - "es-to-primitive": "^1.2.1", - "function-bind": "^1.1.1", - "has": "^1.0.3", - "has-symbols": "^1.0.1", - "is-callable": "^1.2.0", - "is-regex": "^1.1.0", - "object-inspect": "^1.7.0", - "object-keys": "^1.1.1", - "object.assign": "^4.1.0", - "string.prototype.trimend": "^1.0.1", - "string.prototype.trimstart": "^1.0.1" - }, - "dependencies": { - "is-regex": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.1.tgz", - "integrity": "sha512-1+QkEcxiLlB7VEyFtyBg94e08OAsvq7FUBgApTq/w2ymCLyKJgDPsybBENVtA7XCQEgEXxKPonG+mvYRxh/LIg==", - "dev": true, - "requires": { - "has-symbols": "^1.0.1" - } - } - } - }, - "es-to-primitive": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz", - "integrity": "sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==", - "dev": true, - "requires": { - "is-callable": "^1.1.4", - "is-date-object": "^1.0.1", - "is-symbol": "^1.0.2" - } - }, - "escodegen": { - "version": "1.14.3", - "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-1.14.3.tgz", - "integrity": "sha512-qFcX0XJkdg+PB3xjZZG/wKSuT1PnQWx57+TVSjIMmILd2yC/6ByYElPwJnslDsuWuSAp4AwJGumarAAmJch5Kw==", - "dev": true, - "requires": { - "esprima": "^4.0.1", - "estraverse": "^4.2.0", - "esutils": "^2.0.2", - "optionator": "^0.8.1", - "source-map": "~0.6.1" - } - }, - "esprima": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", - "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", - "dev": true - }, - "estraverse": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", - "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", - "dev": true - }, - "esutils": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", - "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", - "dev": true - }, - "extend": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", - "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==", - "dev": true - }, - "extsprintf": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", - "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=", - "dev": true - }, - "fast-deep-equal": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", - "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", - "dev": true - }, - "fast-json-stable-stringify": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", - "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", - "dev": true - }, - "fast-levenshtein": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", - "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", - "dev": true - }, - "for-each": { - "version": "0.3.3", - "resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.3.tgz", - "integrity": "sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw==", - "dev": true, - "requires": { - "is-callable": "^1.1.3" - } - }, - "forever-agent": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", - "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=", - "dev": true - }, - "form-data": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz", - "integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==", - "dev": true, - "requires": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.6", - "mime-types": "^2.1.12" - } - }, - "fs.realpath": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", - "dev": true - }, - "function-bind": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", - "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", - "dev": true - }, - "getpass": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", - "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", - "dev": true, - "requires": { - "assert-plus": "^1.0.0" - } - }, - "glob": { - "version": "7.1.6", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", - "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", - "dev": true, - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - }, - "har-schema": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", - "integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=", - "dev": true - }, - "har-validator": { - "version": "5.1.5", - "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.5.tgz", - "integrity": "sha512-nmT2T0lljbxdQZfspsno9hgrG3Uir6Ks5afism62poxqBM6sDnMEuPmzTq8XN0OEwqKLLdh1jQI3qyE66Nzb3w==", - "dev": true, - "requires": { - "ajv": "^6.12.3", - "har-schema": "^2.0.0" - } - }, - "has": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", - "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", - "dev": true, - "requires": { - "function-bind": "^1.1.1" - } - }, - "has-symbols": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.1.tgz", - "integrity": "sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg==", - "dev": true - }, - "html-encoding-sniffer": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-2.0.1.tgz", - "integrity": "sha512-D5JbOMBIR/TVZkubHT+OyT2705QvogUW4IBn6nHd756OwieSF9aDYFj4dv6HHEVGYbHaLETa3WggZYWWMyy3ZQ==", - "dev": true, - "requires": { - "whatwg-encoding": "^1.0.5" - } - }, - "http-signature": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", - "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=", - "dev": true, - "requires": { - "assert-plus": "^1.0.0", - "jsprim": "^1.2.2", - "sshpk": "^1.7.0" - } - }, - "iconv-lite": { - "version": "0.4.24", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", - "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", - "dev": true, - "requires": { - "safer-buffer": ">= 2.1.2 < 3" - } - }, - "inflight": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", - "dev": true, - "requires": { - "once": "^1.3.0", - "wrappy": "1" - } - }, - "inherits": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", - "dev": true - }, - "ip-regex": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/ip-regex/-/ip-regex-2.1.0.tgz", - "integrity": "sha1-+ni/XS5pE8kRzp+BnuUUa7bYROk=", - "dev": true - }, - "is-arguments": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/is-arguments/-/is-arguments-1.0.4.tgz", - "integrity": "sha512-xPh0Rmt8NE65sNzvyUmWgI1tz3mKq74lGA0mL8LYZcoIzKOzDh6HmrYm3d18k60nHerC8A9Km8kYu87zfSFnLA==", - "dev": true - }, - "is-callable": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.0.tgz", - "integrity": "sha512-pyVD9AaGLxtg6srb2Ng6ynWJqkHU9bEM087AKck0w8QwDarTfNcpIYoU8x8Hv2Icm8u6kFJM18Dag8lyqGkviw==", - "dev": true - }, - "is-date-object": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.2.tgz", - "integrity": "sha512-USlDT524woQ08aoZFzh3/Z6ch9Y/EWXEHQ/AaRN0SkKq4t2Jw2R2339tSXmwuVoY7LLlBCbOIlx2myP/L5zk0g==", - "dev": true - }, - "is-potential-custom-element-name": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.0.tgz", - "integrity": "sha1-DFLlS8yjkbssSUsh6GJtczbG45c=", - "dev": true - }, - "is-regex": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.5.tgz", - "integrity": "sha512-vlKW17SNq44owv5AQR3Cq0bQPEb8+kF3UKZ2fiZNOWtztYE5i0CzCZxFDwO58qAOWtxdBRVO/V5Qin1wjCqFYQ==", - "dev": true, - "requires": { - "has": "^1.0.3" - } - }, - "is-symbol": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.3.tgz", - "integrity": "sha512-OwijhaRSgqvhm/0ZdAcXNZt9lYdKFpcRDT5ULUuYXPoT794UNOdU+gpT6Rzo7b4V2HUl/op6GqY894AZwv9faQ==", - "dev": true, - "requires": { - "has-symbols": "^1.0.1" - } - }, - "is-typedarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", - "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=", - "dev": true - }, - "isstream": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", - "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=", - "dev": true - }, - "jsbn": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", - "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=", - "dev": true - }, - "jsdom": { - "version": "16.4.0", - "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-16.4.0.tgz", - "integrity": "sha512-lYMm3wYdgPhrl7pDcRmvzPhhrGVBeVhPIqeHjzeiHN3DFmD1RBpbExbi8vU7BJdH8VAZYovR8DMt0PNNDM7k8w==", - "dev": true, - "requires": { - "abab": "^2.0.3", - "acorn": "^7.1.1", - "acorn-globals": "^6.0.0", - "cssom": "^0.4.4", - "cssstyle": "^2.2.0", - "data-urls": "^2.0.0", - "decimal.js": "^10.2.0", - "domexception": "^2.0.1", - "escodegen": "^1.14.1", - "html-encoding-sniffer": "^2.0.1", - "is-potential-custom-element-name": "^1.0.0", - "nwsapi": "^2.2.0", - "parse5": "5.1.1", - "request": "^2.88.2", - "request-promise-native": "^1.0.8", - "saxes": "^5.0.0", - "symbol-tree": "^3.2.4", - "tough-cookie": "^3.0.1", - "w3c-hr-time": "^1.0.2", - "w3c-xmlserializer": "^2.0.0", - "webidl-conversions": "^6.1.0", - "whatwg-encoding": "^1.0.5", - "whatwg-mimetype": "^2.3.0", - "whatwg-url": "^8.0.0", - "ws": "^7.2.3", - "xml-name-validator": "^3.0.0" - } - }, - "json-schema": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", - "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=", - "dev": true - }, - "json-schema-traverse": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", - "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", - "dev": true - }, - "json-stringify-safe": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", - "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=", - "dev": true - }, - "jsprim": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", - "integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=", - "dev": true, - "requires": { - "assert-plus": "1.0.0", - "extsprintf": "1.3.0", - "json-schema": "0.2.3", - "verror": "1.10.0" - } - }, - "levn": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", - "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", - "dev": true, - "requires": { - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2" - } - }, - "lodash": { - "version": "4.17.20", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.20.tgz", - "integrity": "sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==", - "dev": true - }, - "lodash.sortby": { - "version": "4.7.0", - "resolved": "https://registry.npmjs.org/lodash.sortby/-/lodash.sortby-4.7.0.tgz", - "integrity": "sha1-7dFMgk4sycHgsKG0K7UhBRakJDg=", - "dev": true - }, - "mime-db": { - "version": "1.44.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.44.0.tgz", - "integrity": "sha512-/NOTfLrsPBVeH7YtFPgsVWveuL+4SjjYxaQ1xtM1KMFj7HdxlBlxeyNLzhyJVx7r4rZGJAZ/6lkKCitSc/Nmpg==", - "dev": true - }, - "mime-types": { - "version": "2.1.27", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.27.tgz", - "integrity": "sha512-JIhqnCasI9yD+SsmkquHBxTSEuZdQX5BuQnS2Vc7puQQQ+8yiP5AY5uWhpdv4YL4VM5c6iliiYWPgJ/nJQLp7w==", - "dev": true, - "requires": { - "mime-db": "1.44.0" - } - }, - "minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", - "dev": true, - "requires": { - "brace-expansion": "^1.1.7" - } - }, - "minimist": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", - "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", - "dev": true - }, - "monaco-editor-core": { - "version": "0.20.0", - "resolved": "https://registry.npmjs.org/monaco-editor-core/-/monaco-editor-core-0.20.0.tgz", - "integrity": "sha512-4mdmfEejTvRZzrEIn70jqqNl3g15vnkRdTkJ8uMK4jiljntlwhiSc5vknZOLt1QM8za16C3tDrSl2mTL9ma2Sg==", - "dev": true - }, - "monaco-plugin-helpers": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/monaco-plugin-helpers/-/monaco-plugin-helpers-1.0.3.tgz", - "integrity": "sha512-6AYI3ONAy8ki74qG2JqtFrLdiJHQlgeO5l4Rwr0OMyIpGXhc94y5rZuFxOtgGkxgSrZfHSwOt/MulUNZ/mOQOw==", - "dev": true, - "requires": { - "typescript": "^2.7.2" - }, - "dependencies": { - "typescript": { - "version": "2.9.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-2.9.2.tgz", - "integrity": "sha512-Gr4p6nFNaoufRIY4NMdpQRNmgxVIGMs4Fcu/ujdYk3nAZqk7supzBE9idmvfZIlH/Cuj//dvi+019qEue9lV0w==", - "dev": true - } - } - }, - "nwsapi": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.2.0.tgz", - "integrity": "sha512-h2AatdwYH+JHiZpv7pt/gSX1XoRGb7L/qSIeuqA6GwYoF9w1vP1cw42TO0aI2pNyshRK5893hNSl+1//vHK7hQ==", - "dev": true - }, - "oauth-sign": { - "version": "0.9.0", - "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", - "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==", - "dev": true - }, - "object-inspect": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.7.0.tgz", - "integrity": "sha512-a7pEHdh1xKIAgTySUGgLMx/xwDZskN1Ud6egYYN3EdRW4ZMPNEDUTF+hwy2LUC+Bl+SyLXANnwz/jyh/qutKUw==", - "dev": true - }, - "object-is": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/object-is/-/object-is-1.1.2.tgz", - "integrity": "sha512-5lHCz+0uufF6wZ7CRFWJN3hp8Jqblpgve06U5CMQ3f//6iDjPr2PEo9MWCjEssDsa+UZEL4PkFpr+BMop6aKzQ==", - "dev": true, - "requires": { - "define-properties": "^1.1.3", - "es-abstract": "^1.17.5" - } - }, - "object-keys": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", - "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", - "dev": true - }, - "object.assign": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.0.tgz", - "integrity": "sha512-exHJeq6kBKj58mqGyTQ9DFvrZC/eR6OwxzoM9YRoGBqrXYonaFyGiFMuc9VZrXf7DarreEwMpurG3dd+CNyW5w==", - "dev": true, - "requires": { - "define-properties": "^1.1.2", - "function-bind": "^1.1.1", - "has-symbols": "^1.0.0", - "object-keys": "^1.0.11" - } - }, - "once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", - "dev": true, - "requires": { - "wrappy": "1" - } - }, - "optionator": { - "version": "0.8.3", - "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.3.tgz", - "integrity": "sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA==", - "dev": true, - "requires": { - "deep-is": "~0.1.3", - "fast-levenshtein": "~2.0.6", - "levn": "~0.3.0", - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2", - "word-wrap": "~1.2.3" - } - }, - "parse5": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/parse5/-/parse5-5.1.1.tgz", - "integrity": "sha512-ugq4DFI0Ptb+WWjAdOK16+u/nHfiIrcE+sh8kZMaM0WllQKLI9rOUq6c2b7cwPkXdzfQESqvoqK6ug7U/Yyzug==", - "dev": true - }, - "path-is-absolute": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", - "dev": true - }, - "path-parse": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", - "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", - "dev": true - }, - "performance-now": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", - "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=", - "dev": true - }, - "prelude-ls": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", - "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=", - "dev": true - }, - "psl": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/psl/-/psl-1.8.0.tgz", - "integrity": "sha512-RIdOzyoavK+hA18OGGWDqUTsCLhtA7IcZ/6NCs4fFJaHBDab+pDDmDIByWFRQJq2Cd7r1OoQxBGKOaztq+hjIQ==", - "dev": true - }, - "punycode": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", - "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", - "dev": true - }, - "qs": { - "version": "6.5.2", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", - "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==", - "dev": true - }, - "regexp.prototype.flags": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.3.0.tgz", - "integrity": "sha512-2+Q0C5g951OlYlJz6yu5/M33IcsESLlLfsyIaLJaG4FA2r4yP8MvVMJUUP/fVBkSpbbbZlS5gynbEWLipiiXiQ==", - "dev": true, - "requires": { - "define-properties": "^1.1.3", - "es-abstract": "^1.17.0-next.1" - } - }, - "request": { - "version": "2.88.2", - "resolved": "https://registry.npmjs.org/request/-/request-2.88.2.tgz", - "integrity": "sha512-MsvtOrfG9ZcrOwAW+Qi+F6HbD0CWXEh9ou77uOb7FM2WPhwT7smM833PzanhJLsgXjN89Ir6V2PczXNnMpwKhw==", - "dev": true, - "requires": { - "aws-sign2": "~0.7.0", - "aws4": "^1.8.0", - "caseless": "~0.12.0", - "combined-stream": "~1.0.6", - "extend": "~3.0.2", - "forever-agent": "~0.6.1", - "form-data": "~2.3.2", - "har-validator": "~5.1.3", - "http-signature": "~1.2.0", - "is-typedarray": "~1.0.0", - "isstream": "~0.1.2", - "json-stringify-safe": "~5.0.1", - "mime-types": "~2.1.19", - "oauth-sign": "~0.9.0", - "performance-now": "^2.1.0", - "qs": "~6.5.2", - "safe-buffer": "^5.1.2", - "tough-cookie": "~2.5.0", - "tunnel-agent": "^0.6.0", - "uuid": "^3.3.2" - }, - "dependencies": { - "tough-cookie": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.5.0.tgz", - "integrity": "sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g==", - "dev": true, - "requires": { - "psl": "^1.1.28", - "punycode": "^2.1.1" - } - } - } - }, - "request-promise-core": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/request-promise-core/-/request-promise-core-1.1.4.tgz", - "integrity": "sha512-TTbAfBBRdWD7aNNOoVOBH4pN/KigV6LyapYNNlAPA8JwbovRti1E88m3sYAwsLi5ryhPKsE9APwnjFTgdUjTpw==", - "dev": true, - "requires": { - "lodash": "^4.17.19" - } - }, - "request-promise-native": { - "version": "1.0.9", - "resolved": "https://registry.npmjs.org/request-promise-native/-/request-promise-native-1.0.9.tgz", - "integrity": "sha512-wcW+sIUiWnKgNY0dqCpOZkUbF/I+YPi+f09JZIDa39Ec+q82CpSYniDp+ISgTTbKmnpJWASeJBPZmoxH84wt3g==", - "dev": true, - "requires": { - "request-promise-core": "1.1.4", - "stealthy-require": "^1.1.1", - "tough-cookie": "^2.3.3" - }, - "dependencies": { - "tough-cookie": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.5.0.tgz", - "integrity": "sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g==", - "dev": true, - "requires": { - "psl": "^1.1.28", - "punycode": "^2.1.1" - } - } - } - }, - "requirejs": { - "version": "2.3.6", - "resolved": "https://registry.npmjs.org/requirejs/-/requirejs-2.3.6.tgz", - "integrity": "sha512-ipEzlWQe6RK3jkzikgCupiTbTvm4S0/CAU5GlgptkN5SO6F3u0UD0K18wy6ErDqiCyP4J4YYe1HuAShvsxePLg==", - "dev": true - }, - "resolve": { - "version": "1.17.0", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.17.0.tgz", - "integrity": "sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w==", - "dev": true, - "requires": { - "path-parse": "^1.0.6" - } - }, - "resumer": { - "version": "0.0.0", - "resolved": "https://registry.npmjs.org/resumer/-/resumer-0.0.0.tgz", - "integrity": "sha1-8ej0YeQGS6Oegq883CqMiT0HZ1k=", - "dev": true, - "requires": { - "through": "~2.3.4" - } - }, - "safe-buffer": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", - "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", - "dev": true - }, - "safer-buffer": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", - "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", - "dev": true - }, - "saxes": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/saxes/-/saxes-5.0.1.tgz", - "integrity": "sha512-5LBh1Tls8c9xgGjw3QrMwETmTMVk0oFgvrFSvWx62llR2hcEInrKNZ2GZCCuuy2lvWrdl5jhbpeqc5hRYKFOcw==", - "dev": true, - "requires": { - "xmlchars": "^2.2.0" - } - }, - "source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true - }, - "source-map-support": { - "version": "0.5.19", - "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.19.tgz", - "integrity": "sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw==", - "dev": true, - "requires": { - "buffer-from": "^1.0.0", - "source-map": "^0.6.0" - } - }, - "sshpk": { - "version": "1.16.1", - "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.16.1.tgz", - "integrity": "sha512-HXXqVUq7+pcKeLqqZj6mHFUMvXtOJt1uoUx09pFW6011inTMxqI8BA8PM95myrIyyKwdnzjdFjLiE6KBPVtJIg==", - "dev": true, - "requires": { - "asn1": "~0.2.3", - "assert-plus": "^1.0.0", - "bcrypt-pbkdf": "^1.0.0", - "dashdash": "^1.12.0", - "ecc-jsbn": "~0.1.1", - "getpass": "^0.1.1", - "jsbn": "~0.1.0", - "safer-buffer": "^2.0.2", - "tweetnacl": "~0.14.0" - } - }, - "stealthy-require": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/stealthy-require/-/stealthy-require-1.1.1.tgz", - "integrity": "sha1-NbCYdbT/SfJqd35QmzCQoyJr8ks=", - "dev": true - }, - "string.prototype.trim": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/string.prototype.trim/-/string.prototype.trim-1.2.1.tgz", - "integrity": "sha512-MjGFEeqixw47dAMFMtgUro/I0+wNqZB5GKXGt1fFr24u3TzDXCPu7J9Buppzoe3r/LqkSDLDDJzE15RGWDGAVw==", - "dev": true, - "requires": { - "define-properties": "^1.1.3", - "es-abstract": "^1.17.0-next.1", - "function-bind": "^1.1.1" - } - }, - "string.prototype.trimend": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/string.prototype.trimend/-/string.prototype.trimend-1.0.1.tgz", - "integrity": "sha512-LRPxFUaTtpqYsTeNKaFOw3R4bxIzWOnbQ837QfBylo8jIxtcbK/A/sMV7Q+OAV/vWo+7s25pOE10KYSjaSO06g==", - "dev": true, - "requires": { - "define-properties": "^1.1.3", - "es-abstract": "^1.17.5" - } - }, - "string.prototype.trimstart": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/string.prototype.trimstart/-/string.prototype.trimstart-1.0.1.tgz", - "integrity": "sha512-XxZn+QpvrBI1FOcg6dIpxUPgWCPuNXvMD72aaRaUQv1eD4e/Qy8i/hFTe0BUmD60p/QA6bh1avmuPTfNjqVWRw==", - "dev": true, - "requires": { - "define-properties": "^1.1.3", - "es-abstract": "^1.17.5" - } - }, - "symbol-tree": { - "version": "3.2.4", - "resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.4.tgz", - "integrity": "sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==", - "dev": true - }, - "tape": { - "version": "4.13.3", - "resolved": "https://registry.npmjs.org/tape/-/tape-4.13.3.tgz", - "integrity": "sha512-0/Y20PwRIUkQcTCSi4AASs+OANZZwqPKaipGCEwp10dQMipVvSZwUUCi01Y/OklIGyHKFhIcjock+DKnBfLAFw==", - "dev": true, - "requires": { - "deep-equal": "~1.1.1", - "defined": "~1.0.0", - "dotignore": "~0.1.2", - "for-each": "~0.3.3", - "function-bind": "~1.1.1", - "glob": "~7.1.6", - "has": "~1.0.3", - "inherits": "~2.0.4", - "is-regex": "~1.0.5", - "minimist": "~1.2.5", - "object-inspect": "~1.7.0", - "resolve": "~1.17.0", - "resumer": "~0.0.0", - "string.prototype.trim": "~1.2.1", - "through": "~2.3.8" - } - }, - "terser": { - "version": "4.8.0", - "resolved": "https://registry.npmjs.org/terser/-/terser-4.8.0.tgz", - "integrity": "sha512-EAPipTNeWsb/3wLPeup1tVPaXfIaU68xMnVdPafIL1TV05OhASArYyIfFvnvJCNrR2NIOvDVNNTFRa+Re2MWyw==", - "dev": true, - "requires": { - "commander": "^2.20.0", - "source-map": "~0.6.1", - "source-map-support": "~0.5.12" - } - }, - "through": { - "version": "2.3.8", - "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", - "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", - "dev": true - }, - "tough-cookie": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-3.0.1.tgz", - "integrity": "sha512-yQyJ0u4pZsv9D4clxO69OEjLWYw+jbgspjTue4lTQZLfV0c5l1VmK2y1JK8E9ahdpltPOaAThPcp5nKPUgSnsg==", - "dev": true, - "requires": { - "ip-regex": "^2.1.0", - "psl": "^1.1.28", - "punycode": "^2.1.1" - } - }, - "tr46": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/tr46/-/tr46-2.0.2.tgz", - "integrity": "sha512-3n1qG+/5kg+jrbTzwAykB5yRYtQCTqOGKq5U5PE3b0a1/mzo6snDhjGS0zJVJunO0NrT3Dg1MLy5TjWP/UJppg==", - "dev": true, - "requires": { - "punycode": "^2.1.1" - } - }, - "tunnel-agent": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", - "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", - "dev": true, - "requires": { - "safe-buffer": "^5.0.1" - } - }, - "tweetnacl": { - "version": "0.14.5", - "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", - "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=", - "dev": true - }, - "type-check": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", - "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", - "dev": true, - "requires": { - "prelude-ls": "~1.1.2" - } - }, - "typescript": { - "version": "3.7.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.5.tgz", - "integrity": "sha512-/P5lkRXkWHNAbcJIiHPfRoKqyd7bsyCma1hZNUGfn20qm64T6ZBlrzprymeu918H+mB/0rIg2gGK/BXkhhYgBw==", - "dev": true - }, - "uri-js": { - "version": "4.2.2", - "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz", - "integrity": "sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ==", - "dev": true, - "requires": { - "punycode": "^2.1.0" - } - }, - "uuid": { - "version": "3.4.0", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", - "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", - "dev": true - }, - "verror": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", - "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=", - "dev": true, - "requires": { - "assert-plus": "^1.0.0", - "core-util-is": "1.0.2", - "extsprintf": "^1.2.0" - } - }, - "w3c-hr-time": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/w3c-hr-time/-/w3c-hr-time-1.0.2.tgz", - "integrity": "sha512-z8P5DvDNjKDoFIHK7q8r8lackT6l+jo/Ye3HOle7l9nICP9lf1Ci25fy9vHd0JOWewkIFzXIEig3TdKT7JQ5fQ==", - "dev": true, - "requires": { - "browser-process-hrtime": "^1.0.0" - } - }, - "w3c-xmlserializer": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/w3c-xmlserializer/-/w3c-xmlserializer-2.0.0.tgz", - "integrity": "sha512-4tzD0mF8iSiMiNs30BiLO3EpfGLZUT2MSX/G+o7ZywDzliWQ3OPtTZ0PTC3B3ca1UAf4cJMHB+2Bf56EriJuRA==", - "dev": true, - "requires": { - "xml-name-validator": "^3.0.0" - } - }, - "webidl-conversions": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-6.1.0.tgz", - "integrity": "sha512-qBIvFLGiBpLjfwmYAaHPXsn+ho5xZnGvyGvsarywGNc8VyQJUMHJ8OBKGGrPER0okBeMDaan4mNBlgBROxuI8w==", - "dev": true - }, - "whatwg-encoding": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/whatwg-encoding/-/whatwg-encoding-1.0.5.tgz", - "integrity": "sha512-b5lim54JOPN9HtzvK9HFXvBma/rnfFeqsic0hSpjtDbVxR3dJKLc+KB4V6GgiGOvl7CY/KNh8rxSo9DKQrnUEw==", - "dev": true, - "requires": { - "iconv-lite": "0.4.24" - } - }, - "whatwg-mimetype": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-2.3.0.tgz", - "integrity": "sha512-M4yMwr6mAnQz76TbJm914+gPpB/nCwvZbJU28cUD6dR004SAxDLOOSUaB1JDRqLtaOV/vi0IC5lEAGFgrjGv/g==", - "dev": true - }, - "whatwg-url": { - "version": "8.2.1", - "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-8.2.1.tgz", - "integrity": "sha512-ZmVCr6nfBeaMxEHALLEGy0LszYjpJqf6PVNQUQ1qd9Et+q7Jpygd4rGGDXgHjD8e99yLFseD69msHDM4YwPZ4A==", - "dev": true, - "requires": { - "lodash.sortby": "^4.7.0", - "tr46": "^2.0.2", - "webidl-conversions": "^6.1.0" - } - }, - "word-wrap": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", - "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", - "dev": true - }, - "wrappy": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", - "dev": true - }, - "ws": { - "version": "7.3.1", - "resolved": "https://registry.npmjs.org/ws/-/ws-7.3.1.tgz", - "integrity": "sha512-D3RuNkynyHmEJIpD2qrgVkc9DQ23OrN/moAwZX4L8DfvszsJxpjQuUq3LMx6HoYji9fbIOBY18XWBsAux1ZZUA==", - "dev": true - }, - "xml-name-validator": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-3.0.0.tgz", - "integrity": "sha512-A5CUptxDsvxKJEU3yO6DuWBSJz/qizqzJKOMIfUJHETbBw/sFaDxgd6fxm1ewUaM0jZ444Fc5vC5ROYurg/4Pw==", - "dev": true - }, - "xmlchars": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/xmlchars/-/xmlchars-2.2.0.tgz", - "integrity": "sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==", - "dev": true - } - } + "name": "monaco-languages", + "version": "1.10.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@babel/code-frame": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.10.4.tgz", + "integrity": "sha512-vG6SvB6oYEhvgisZNFRmRCUkLz11c7rp+tbNTynGqc6mS1d5ATd/sGyV6W0KZZnXRKMTzZDRgQT3Ou9jhpAfUg==", + "dev": true, + "requires": { + "@babel/highlight": "^7.10.4" + } + }, + "@babel/helper-validator-identifier": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.10.4.tgz", + "integrity": "sha512-3U9y+43hz7ZM+rzG24Qe2mufW5KhvFg/NhnNph+i9mgCtdTCtMJuI1TMkrIUiK7Ix4PYlRF9I5dhqaLYA/ADXw==", + "dev": true + }, + "@babel/highlight": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.10.4.tgz", + "integrity": "sha512-i6rgnR/YgPEQzZZnbTHHuZdlE8qyoBNalD6F+q4vAFlcMEcqmkoG+mPqJYJCo63qPf74+Y1UZsl3l6f7/RIkmA==", + "dev": true, + "requires": { + "@babel/helper-validator-identifier": "^7.10.4", + "chalk": "^2.0.0", + "js-tokens": "^4.0.0" + }, + "dependencies": { + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "requires": { + "color-convert": "^1.9.0" + } + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", + "dev": true + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "dev": true + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + } + } + }, + "@types/color-name": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@types/color-name/-/color-name-1.1.1.tgz", + "integrity": "sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==", + "dev": true + }, + "@types/minimatch": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-3.0.3.tgz", + "integrity": "sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA==", + "dev": true + }, + "@types/node": { + "version": "14.6.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.6.0.tgz", + "integrity": "sha512-mikldZQitV94akrc4sCcSjtJfsTKt4p+e/s0AGscVA6XArQ9kFclP+ZiYUMnq987rc6QlYxXv/EivqlfSLxpKA==", + "dev": true + }, + "@types/parse-json": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@types/parse-json/-/parse-json-4.0.0.tgz", + "integrity": "sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA==", + "dev": true + }, + "@types/tape": { + "version": "4.13.0", + "resolved": "https://registry.npmjs.org/@types/tape/-/tape-4.13.0.tgz", + "integrity": "sha512-0V8cKowBdsiA9nbxAg7531sF2cdPZNiUogcfIUeUGm+bejUBE/bvibz3rH36iQP9bQjO/sOzFwU97/uC5mCyoA==", + "dev": true, + "requires": { + "@types/node": "*" + } + }, + "abab": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/abab/-/abab-2.0.4.tgz", + "integrity": "sha512-Eu9ELJWCz/c1e9gTiCY+FceWxcqzjYEbqMgtndnuSqZSUCOL73TWNK2mHfIj4Cw2E/ongOp+JISVNCmovt2KYQ==", + "dev": true + }, + "acorn": { + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.0.tgz", + "integrity": "sha512-+G7P8jJmCHr+S+cLfQxygbWhXy+8YTVGzAkpEbcLo2mLoL7tij/VG41QSHACSf5QgYRhMZYHuNc6drJaO0Da+w==", + "dev": true + }, + "acorn-globals": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/acorn-globals/-/acorn-globals-6.0.0.tgz", + "integrity": "sha512-ZQl7LOWaF5ePqqcX4hLuv/bLXYQNfNWw2c0/yX/TsPRKamzHcTGQnlCjHT3TsmkOUVEPS3crCxiPfdzE/Trlhg==", + "dev": true, + "requires": { + "acorn": "^7.1.1", + "acorn-walk": "^7.1.1" + } + }, + "acorn-walk": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-7.2.0.tgz", + "integrity": "sha512-OPdCF6GsMIP+Az+aWfAAOEt2/+iVDKE7oy6lJ098aoe59oAmK76qV6Gw60SbZ8jHuG2wH058GF4pLFbYamYrVA==", + "dev": true + }, + "ajv": { + "version": "6.12.4", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.4.tgz", + "integrity": "sha512-eienB2c9qVQs2KWexhkrdMLVDoIQCz5KSeLxwg9Lzk4DOfBtIK9PQwwufcsn1jjGuf9WZmqPMbGxOzfcuphJCQ==", + "dev": true, + "requires": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + } + }, + "ansi-styles": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz", + "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==", + "dev": true, + "requires": { + "@types/color-name": "^1.1.1", + "color-convert": "^2.0.1" + } + }, + "array-differ": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/array-differ/-/array-differ-3.0.0.tgz", + "integrity": "sha512-THtfYS6KtME/yIAhKjZ2ul7XI96lQGHRputJQHO80LAWQnuGP4iCIN8vdMRboGbIEYBwU33q8Tch1os2+X0kMg==", + "dev": true + }, + "array-union": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz", + "integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==", + "dev": true + }, + "arrify": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/arrify/-/arrify-2.0.1.tgz", + "integrity": "sha512-3duEwti880xqi4eAMN8AyR4a0ByT90zoYdLlevfrvU43vb0YZwZVfxOgxWrLXXXpyugL0hNZc9G6BiB5B3nUug==", + "dev": true + }, + "asn1": { + "version": "0.2.4", + "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz", + "integrity": "sha512-jxwzQpLQjSmWXgwaCZE9Nz+glAG01yF1QnWgbhGwHI5A6FRIEY6IVqtHhIepHqI7/kyEyQEagBC5mBEFlIYvdg==", + "dev": true, + "requires": { + "safer-buffer": "~2.1.0" + } + }, + "assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", + "dev": true + }, + "asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=", + "dev": true + }, + "aws-sign2": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", + "integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=", + "dev": true + }, + "aws4": { + "version": "1.10.1", + "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.10.1.tgz", + "integrity": "sha512-zg7Hz2k5lI8kb7U32998pRRFin7zJlkfezGJjUc2heaD4Pw2wObakCDVzkKztTm/Ln7eiVvYsjqak0Ed4LkMDA==", + "dev": true + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", + "dev": true + }, + "bcrypt-pbkdf": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", + "integrity": "sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4=", + "dev": true, + "requires": { + "tweetnacl": "^0.14.3" + } + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "browser-process-hrtime": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/browser-process-hrtime/-/browser-process-hrtime-1.0.0.tgz", + "integrity": "sha512-9o5UecI3GhkpM6DrXr69PblIuWxPKk9Y0jHBRhdocZ2y7YECBFCsHm79Pr3OyR2AvjhDkabFJaDJMYRazHgsow==", + "dev": true + }, + "buffer-from": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", + "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==", + "dev": true + }, + "callsites": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", + "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", + "dev": true + }, + "caseless": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", + "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=", + "dev": true + }, + "chalk": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", + "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", + "dev": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "ci-info": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-2.0.0.tgz", + "integrity": "sha512-5tK7EtrZ0N+OLFMthtqOj4fI2Jeb88C4CAZPu25LDVUgXJ0A3Js4PMGqrn0JU1W0Mh1/Z8wZzYPxqUrXeBboCQ==", + "dev": true + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "dev": true, + "requires": { + "delayed-stream": "~1.0.0" + } + }, + "commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", + "dev": true + }, + "compare-versions": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/compare-versions/-/compare-versions-3.6.0.tgz", + "integrity": "sha512-W6Af2Iw1z4CB7q4uU4hv646dW9GQuBM+YpC0UvUCWSD8w90SJjp+ujJuXaEMtAXBtSqGfMPuFOVn4/+FlaqfBA==", + "dev": true + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true + }, + "core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", + "dev": true + }, + "cosmiconfig": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-6.0.0.tgz", + "integrity": "sha512-xb3ZL6+L8b9JLLCx3ZdoZy4+2ECphCMo2PwqgP1tlfVq6M6YReyzBJtvWWtbDSpNr9hn96pkCiZqUcFEc+54Qg==", + "dev": true, + "requires": { + "@types/parse-json": "^4.0.0", + "import-fresh": "^3.1.0", + "parse-json": "^5.0.0", + "path-type": "^4.0.0", + "yaml": "^1.7.2" + } + }, + "cross-spawn": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "dev": true, + "requires": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + } + }, + "cssom": { + "version": "0.4.4", + "resolved": "https://registry.npmjs.org/cssom/-/cssom-0.4.4.tgz", + "integrity": "sha512-p3pvU7r1MyyqbTk+WbNJIgJjG2VmTIaB10rI93LzVPrmDJKkzKYMtxxyAvQXR/NS6otuzveI7+7BBq3SjBS2mw==", + "dev": true + }, + "cssstyle": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/cssstyle/-/cssstyle-2.3.0.tgz", + "integrity": "sha512-AZL67abkUzIuvcHqk7c09cezpGNcxUxU4Ioi/05xHk4DQeTkWmGYftIE6ctU6AEt+Gn4n1lDStOtj7FKycP71A==", + "dev": true, + "requires": { + "cssom": "~0.3.6" + }, + "dependencies": { + "cssom": { + "version": "0.3.8", + "resolved": "https://registry.npmjs.org/cssom/-/cssom-0.3.8.tgz", + "integrity": "sha512-b0tGHbfegbhPJpxpiBPU2sCkigAqtM9O121le6bbOlgyV+NyGyCmVfJ6QW9eRjz8CpNfWEOYBIMIGRYkLwsIYg==", + "dev": true + } + } + }, + "dashdash": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", + "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", + "dev": true, + "requires": { + "assert-plus": "^1.0.0" + } + }, + "data-urls": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/data-urls/-/data-urls-2.0.0.tgz", + "integrity": "sha512-X5eWTSXO/BJmpdIKCRuKUgSCgAN0OwliVK3yPKbwIWU1Tdw5BRajxlzMidvh+gwko9AfQ9zIj52pzF91Q3YAvQ==", + "dev": true, + "requires": { + "abab": "^2.0.3", + "whatwg-mimetype": "^2.3.0", + "whatwg-url": "^8.0.0" + } + }, + "decimal.js": { + "version": "10.2.0", + "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.2.0.tgz", + "integrity": "sha512-vDPw+rDgn3bZe1+F/pyEwb1oMG2XTlRVgAa6B4KccTEpYgF8w6eQllVbQcfIJnZyvzFtFpxnpGtx8dd7DJp/Rw==", + "dev": true + }, + "deep-equal": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-1.1.1.tgz", + "integrity": "sha512-yd9c5AdiqVcR+JjcwUQb9DkhJc8ngNr0MahEBGvDiJw8puWab2yZlh+nkasOnZP+EGTAP6rRp2JzJhJZzvNF8g==", + "dev": true, + "requires": { + "is-arguments": "^1.0.4", + "is-date-object": "^1.0.1", + "is-regex": "^1.0.4", + "object-is": "^1.0.1", + "object-keys": "^1.1.1", + "regexp.prototype.flags": "^1.2.0" + } + }, + "deep-is": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", + "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=", + "dev": true + }, + "define-properties": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", + "integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==", + "dev": true, + "requires": { + "object-keys": "^1.0.12" + } + }, + "defined": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/defined/-/defined-1.0.0.tgz", + "integrity": "sha1-yY2bzvdWdBiOEQlpFRGZ45sfppM=", + "dev": true + }, + "delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", + "dev": true + }, + "domexception": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/domexception/-/domexception-2.0.1.tgz", + "integrity": "sha512-yxJ2mFy/sibVQlu5qHjOkf9J3K6zgmCxgJ94u2EdvDOV09H+32LtRswEcUsmUWN72pVLOEnTSRaIVVzVQgS0dg==", + "dev": true, + "requires": { + "webidl-conversions": "^5.0.0" + }, + "dependencies": { + "webidl-conversions": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-5.0.0.tgz", + "integrity": "sha512-VlZwKPCkYKxQgeSbH5EyngOmRp7Ww7I9rQLERETtf5ofd9pGeswWiOtogpEO850jziPRarreGxn5QIiTqpb2wA==", + "dev": true + } + } + }, + "dotignore": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/dotignore/-/dotignore-0.1.2.tgz", + "integrity": "sha512-UGGGWfSauusaVJC+8fgV+NVvBXkCTmVv7sk6nojDZZvuOUNGUy0Zk4UpHQD6EDjS0jpBwcACvH4eofvyzBcRDw==", + "dev": true, + "requires": { + "minimatch": "^3.0.4" + } + }, + "ecc-jsbn": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", + "integrity": "sha1-OoOpBOVDUyh4dMVkt1SThoSamMk=", + "dev": true, + "requires": { + "jsbn": "~0.1.0", + "safer-buffer": "^2.1.0" + } + }, + "end-of-stream": { + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", + "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", + "dev": true, + "requires": { + "once": "^1.4.0" + } + }, + "error-ex": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", + "integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==", + "dev": true, + "requires": { + "is-arrayish": "^0.2.1" + } + }, + "es-abstract": { + "version": "1.17.6", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.17.6.tgz", + "integrity": "sha512-Fr89bON3WFyUi5EvAeI48QTWX0AyekGgLA8H+c+7fbfCkJwRWRMLd8CQedNEyJuoYYhmtEqY92pgte1FAhBlhw==", + "dev": true, + "requires": { + "es-to-primitive": "^1.2.1", + "function-bind": "^1.1.1", + "has": "^1.0.3", + "has-symbols": "^1.0.1", + "is-callable": "^1.2.0", + "is-regex": "^1.1.0", + "object-inspect": "^1.7.0", + "object-keys": "^1.1.1", + "object.assign": "^4.1.0", + "string.prototype.trimend": "^1.0.1", + "string.prototype.trimstart": "^1.0.1" + }, + "dependencies": { + "is-regex": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.1.tgz", + "integrity": "sha512-1+QkEcxiLlB7VEyFtyBg94e08OAsvq7FUBgApTq/w2ymCLyKJgDPsybBENVtA7XCQEgEXxKPonG+mvYRxh/LIg==", + "dev": true, + "requires": { + "has-symbols": "^1.0.1" + } + } + } + }, + "es-to-primitive": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz", + "integrity": "sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==", + "dev": true, + "requires": { + "is-callable": "^1.1.4", + "is-date-object": "^1.0.1", + "is-symbol": "^1.0.2" + } + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", + "dev": true + }, + "escodegen": { + "version": "1.14.3", + "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-1.14.3.tgz", + "integrity": "sha512-qFcX0XJkdg+PB3xjZZG/wKSuT1PnQWx57+TVSjIMmILd2yC/6ByYElPwJnslDsuWuSAp4AwJGumarAAmJch5Kw==", + "dev": true, + "requires": { + "esprima": "^4.0.1", + "estraverse": "^4.2.0", + "esutils": "^2.0.2", + "optionator": "^0.8.1", + "source-map": "~0.6.1" + } + }, + "esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "dev": true + }, + "estraverse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", + "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", + "dev": true + }, + "esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", + "dev": true + }, + "execa": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/execa/-/execa-4.0.3.tgz", + "integrity": "sha512-WFDXGHckXPWZX19t1kCsXzOpqX9LWYNqn4C+HqZlk/V0imTkzJZqf87ZBhvpHaftERYknpk0fjSylnXVlVgI0A==", + "dev": true, + "requires": { + "cross-spawn": "^7.0.0", + "get-stream": "^5.0.0", + "human-signals": "^1.1.1", + "is-stream": "^2.0.0", + "merge-stream": "^2.0.0", + "npm-run-path": "^4.0.0", + "onetime": "^5.1.0", + "signal-exit": "^3.0.2", + "strip-final-newline": "^2.0.0" + } + }, + "extend": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", + "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==", + "dev": true + }, + "extsprintf": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", + "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=", + "dev": true + }, + "fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "dev": true + }, + "fast-json-stable-stringify": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", + "dev": true + }, + "fast-levenshtein": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", + "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", + "dev": true + }, + "find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "dev": true, + "requires": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + } + }, + "find-versions": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/find-versions/-/find-versions-3.2.0.tgz", + "integrity": "sha512-P8WRou2S+oe222TOCHitLy8zj+SIsVJh52VP4lvXkaFVnOFFdoWv1H1Jjvel1aI6NCFOAaeAVm8qrI0odiLcww==", + "dev": true, + "requires": { + "semver-regex": "^2.0.0" + } + }, + "for-each": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.3.tgz", + "integrity": "sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw==", + "dev": true, + "requires": { + "is-callable": "^1.1.3" + } + }, + "forever-agent": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", + "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=", + "dev": true + }, + "form-data": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz", + "integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==", + "dev": true, + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.6", + "mime-types": "^2.1.12" + } + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "dev": true + }, + "function-bind": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", + "dev": true + }, + "get-stream": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-5.2.0.tgz", + "integrity": "sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA==", + "dev": true, + "requires": { + "pump": "^3.0.0" + } + }, + "getpass": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", + "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", + "dev": true, + "requires": { + "assert-plus": "^1.0.0" + } + }, + "glob": { + "version": "7.1.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", + "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "har-schema": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", + "integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=", + "dev": true + }, + "har-validator": { + "version": "5.1.5", + "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.5.tgz", + "integrity": "sha512-nmT2T0lljbxdQZfspsno9hgrG3Uir6Ks5afism62poxqBM6sDnMEuPmzTq8XN0OEwqKLLdh1jQI3qyE66Nzb3w==", + "dev": true, + "requires": { + "ajv": "^6.12.3", + "har-schema": "^2.0.0" + } + }, + "has": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", + "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", + "dev": true, + "requires": { + "function-bind": "^1.1.1" + } + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "has-symbols": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.1.tgz", + "integrity": "sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg==", + "dev": true + }, + "html-encoding-sniffer": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-2.0.1.tgz", + "integrity": "sha512-D5JbOMBIR/TVZkubHT+OyT2705QvogUW4IBn6nHd756OwieSF9aDYFj4dv6HHEVGYbHaLETa3WggZYWWMyy3ZQ==", + "dev": true, + "requires": { + "whatwg-encoding": "^1.0.5" + } + }, + "http-signature": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", + "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=", + "dev": true, + "requires": { + "assert-plus": "^1.0.0", + "jsprim": "^1.2.2", + "sshpk": "^1.7.0" + } + }, + "human-signals": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-1.1.1.tgz", + "integrity": "sha512-SEQu7vl8KjNL2eoGBLF3+wAjpsNfA9XMlXAYj/3EdaNfAlxKthD1xjEQfGOUhllCGGJVNY34bRr6lPINhNjyZw==", + "dev": true + }, + "husky": { + "version": "4.2.5", + "resolved": "https://registry.npmjs.org/husky/-/husky-4.2.5.tgz", + "integrity": "sha512-SYZ95AjKcX7goYVZtVZF2i6XiZcHknw50iXvY7b0MiGoj5RwdgRQNEHdb+gPDPCXKlzwrybjFjkL6FOj8uRhZQ==", + "dev": true, + "requires": { + "chalk": "^4.0.0", + "ci-info": "^2.0.0", + "compare-versions": "^3.6.0", + "cosmiconfig": "^6.0.0", + "find-versions": "^3.2.0", + "opencollective-postinstall": "^2.0.2", + "pkg-dir": "^4.2.0", + "please-upgrade-node": "^3.2.0", + "slash": "^3.0.0", + "which-pm-runs": "^1.0.0" + } + }, + "iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "dev": true, + "requires": { + "safer-buffer": ">= 2.1.2 < 3" + } + }, + "ignore": { + "version": "5.1.8", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.1.8.tgz", + "integrity": "sha512-BMpfD7PpiETpBl/A6S498BaIJ6Y/ABT93ETbby2fP00v4EbvPBXWEoaR1UBPKs3iR53pJY7EtZk5KACI57i1Uw==", + "dev": true + }, + "import-fresh": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.2.1.tgz", + "integrity": "sha512-6e1q1cnWP2RXD9/keSkxHScg508CdXqXWgWBaETNhyuBFz+kUZlKboh+ISK+bU++DmbHimVBrOz/zzPe0sZ3sQ==", + "dev": true, + "requires": { + "parent-module": "^1.0.0", + "resolve-from": "^4.0.0" + } + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dev": true, + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true + }, + "ip-regex": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/ip-regex/-/ip-regex-2.1.0.tgz", + "integrity": "sha1-+ni/XS5pE8kRzp+BnuUUa7bYROk=", + "dev": true + }, + "is-arguments": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/is-arguments/-/is-arguments-1.0.4.tgz", + "integrity": "sha512-xPh0Rmt8NE65sNzvyUmWgI1tz3mKq74lGA0mL8LYZcoIzKOzDh6HmrYm3d18k60nHerC8A9Km8kYu87zfSFnLA==", + "dev": true + }, + "is-arrayish": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", + "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=", + "dev": true + }, + "is-callable": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.0.tgz", + "integrity": "sha512-pyVD9AaGLxtg6srb2Ng6ynWJqkHU9bEM087AKck0w8QwDarTfNcpIYoU8x8Hv2Icm8u6kFJM18Dag8lyqGkviw==", + "dev": true + }, + "is-date-object": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.2.tgz", + "integrity": "sha512-USlDT524woQ08aoZFzh3/Z6ch9Y/EWXEHQ/AaRN0SkKq4t2Jw2R2339tSXmwuVoY7LLlBCbOIlx2myP/L5zk0g==", + "dev": true + }, + "is-potential-custom-element-name": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.0.tgz", + "integrity": "sha1-DFLlS8yjkbssSUsh6GJtczbG45c=", + "dev": true + }, + "is-regex": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.5.tgz", + "integrity": "sha512-vlKW17SNq44owv5AQR3Cq0bQPEb8+kF3UKZ2fiZNOWtztYE5i0CzCZxFDwO58qAOWtxdBRVO/V5Qin1wjCqFYQ==", + "dev": true, + "requires": { + "has": "^1.0.3" + } + }, + "is-stream": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.0.tgz", + "integrity": "sha512-XCoy+WlUr7d1+Z8GgSuXmpuUFC9fOhRXglJMx+dwLKTkL44Cjd4W1Z5P+BQZpr+cR93aGP4S/s7Ftw6Nd/kiEw==", + "dev": true + }, + "is-symbol": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.3.tgz", + "integrity": "sha512-OwijhaRSgqvhm/0ZdAcXNZt9lYdKFpcRDT5ULUuYXPoT794UNOdU+gpT6Rzo7b4V2HUl/op6GqY894AZwv9faQ==", + "dev": true, + "requires": { + "has-symbols": "^1.0.1" + } + }, + "is-typedarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", + "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=", + "dev": true + }, + "isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", + "dev": true + }, + "isstream": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", + "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=", + "dev": true + }, + "js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true + }, + "jsbn": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", + "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=", + "dev": true + }, + "jsdom": { + "version": "16.4.0", + "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-16.4.0.tgz", + "integrity": "sha512-lYMm3wYdgPhrl7pDcRmvzPhhrGVBeVhPIqeHjzeiHN3DFmD1RBpbExbi8vU7BJdH8VAZYovR8DMt0PNNDM7k8w==", + "dev": true, + "requires": { + "abab": "^2.0.3", + "acorn": "^7.1.1", + "acorn-globals": "^6.0.0", + "cssom": "^0.4.4", + "cssstyle": "^2.2.0", + "data-urls": "^2.0.0", + "decimal.js": "^10.2.0", + "domexception": "^2.0.1", + "escodegen": "^1.14.1", + "html-encoding-sniffer": "^2.0.1", + "is-potential-custom-element-name": "^1.0.0", + "nwsapi": "^2.2.0", + "parse5": "5.1.1", + "request": "^2.88.2", + "request-promise-native": "^1.0.8", + "saxes": "^5.0.0", + "symbol-tree": "^3.2.4", + "tough-cookie": "^3.0.1", + "w3c-hr-time": "^1.0.2", + "w3c-xmlserializer": "^2.0.0", + "webidl-conversions": "^6.1.0", + "whatwg-encoding": "^1.0.5", + "whatwg-mimetype": "^2.3.0", + "whatwg-url": "^8.0.0", + "ws": "^7.2.3", + "xml-name-validator": "^3.0.0" + } + }, + "json-parse-even-better-errors": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.0.tgz", + "integrity": "sha512-o3aP+RsWDJZayj1SbHNQAI8x0v3T3SKiGoZlNYfbUP1S3omJQ6i9CnqADqkSPaOAxwua4/1YWx5CM7oiChJt2Q==", + "dev": true + }, + "json-schema": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", + "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=", + "dev": true + }, + "json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true + }, + "json-stringify-safe": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", + "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=", + "dev": true + }, + "jsprim": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", + "integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=", + "dev": true, + "requires": { + "assert-plus": "1.0.0", + "extsprintf": "1.3.0", + "json-schema": "0.2.3", + "verror": "1.10.0" + } + }, + "levn": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", + "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", + "dev": true, + "requires": { + "prelude-ls": "~1.1.2", + "type-check": "~0.3.2" + } + }, + "lines-and-columns": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.1.6.tgz", + "integrity": "sha1-HADHQ7QzzQpOgHWPe2SldEDZ/wA=", + "dev": true + }, + "locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "dev": true, + "requires": { + "p-locate": "^4.1.0" + } + }, + "lodash": { + "version": "4.17.20", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.20.tgz", + "integrity": "sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==", + "dev": true + }, + "lodash.sortby": { + "version": "4.7.0", + "resolved": "https://registry.npmjs.org/lodash.sortby/-/lodash.sortby-4.7.0.tgz", + "integrity": "sha1-7dFMgk4sycHgsKG0K7UhBRakJDg=", + "dev": true + }, + "merge-stream": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", + "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==", + "dev": true + }, + "mime-db": { + "version": "1.44.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.44.0.tgz", + "integrity": "sha512-/NOTfLrsPBVeH7YtFPgsVWveuL+4SjjYxaQ1xtM1KMFj7HdxlBlxeyNLzhyJVx7r4rZGJAZ/6lkKCitSc/Nmpg==", + "dev": true + }, + "mime-types": { + "version": "2.1.27", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.27.tgz", + "integrity": "sha512-JIhqnCasI9yD+SsmkquHBxTSEuZdQX5BuQnS2Vc7puQQQ+8yiP5AY5uWhpdv4YL4VM5c6iliiYWPgJ/nJQLp7w==", + "dev": true, + "requires": { + "mime-db": "1.44.0" + } + }, + "mimic-fn": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", + "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", + "dev": true + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", + "dev": true + }, + "monaco-editor-core": { + "version": "0.20.0", + "resolved": "https://registry.npmjs.org/monaco-editor-core/-/monaco-editor-core-0.20.0.tgz", + "integrity": "sha512-4mdmfEejTvRZzrEIn70jqqNl3g15vnkRdTkJ8uMK4jiljntlwhiSc5vknZOLt1QM8za16C3tDrSl2mTL9ma2Sg==", + "dev": true + }, + "monaco-plugin-helpers": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/monaco-plugin-helpers/-/monaco-plugin-helpers-1.0.3.tgz", + "integrity": "sha512-6AYI3ONAy8ki74qG2JqtFrLdiJHQlgeO5l4Rwr0OMyIpGXhc94y5rZuFxOtgGkxgSrZfHSwOt/MulUNZ/mOQOw==", + "dev": true, + "requires": { + "typescript": "^2.7.2" + }, + "dependencies": { + "typescript": { + "version": "2.9.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-2.9.2.tgz", + "integrity": "sha512-Gr4p6nFNaoufRIY4NMdpQRNmgxVIGMs4Fcu/ujdYk3nAZqk7supzBE9idmvfZIlH/Cuj//dvi+019qEue9lV0w==", + "dev": true + } + } + }, + "mri": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/mri/-/mri-1.1.6.tgz", + "integrity": "sha512-oi1b3MfbyGa7FJMP9GmLTttni5JoICpYBRlq+x5V16fZbLsnL9N3wFqqIm/nIG43FjUFkFh9Epzp/kzUGUnJxQ==", + "dev": true + }, + "multimatch": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/multimatch/-/multimatch-4.0.0.tgz", + "integrity": "sha512-lDmx79y1z6i7RNx0ZGCPq1bzJ6ZoDDKbvh7jxr9SJcWLkShMzXrHbYVpTdnhNM5MXpDUxCQ4DgqVttVXlBgiBQ==", + "dev": true, + "requires": { + "@types/minimatch": "^3.0.3", + "array-differ": "^3.0.0", + "array-union": "^2.1.0", + "arrify": "^2.0.1", + "minimatch": "^3.0.4" + } + }, + "npm-run-path": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-4.0.1.tgz", + "integrity": "sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==", + "dev": true, + "requires": { + "path-key": "^3.0.0" + } + }, + "nwsapi": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.2.0.tgz", + "integrity": "sha512-h2AatdwYH+JHiZpv7pt/gSX1XoRGb7L/qSIeuqA6GwYoF9w1vP1cw42TO0aI2pNyshRK5893hNSl+1//vHK7hQ==", + "dev": true + }, + "oauth-sign": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", + "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==", + "dev": true + }, + "object-inspect": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.7.0.tgz", + "integrity": "sha512-a7pEHdh1xKIAgTySUGgLMx/xwDZskN1Ud6egYYN3EdRW4ZMPNEDUTF+hwy2LUC+Bl+SyLXANnwz/jyh/qutKUw==", + "dev": true + }, + "object-is": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/object-is/-/object-is-1.1.2.tgz", + "integrity": "sha512-5lHCz+0uufF6wZ7CRFWJN3hp8Jqblpgve06U5CMQ3f//6iDjPr2PEo9MWCjEssDsa+UZEL4PkFpr+BMop6aKzQ==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "es-abstract": "^1.17.5" + } + }, + "object-keys": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", + "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", + "dev": true + }, + "object.assign": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.0.tgz", + "integrity": "sha512-exHJeq6kBKj58mqGyTQ9DFvrZC/eR6OwxzoM9YRoGBqrXYonaFyGiFMuc9VZrXf7DarreEwMpurG3dd+CNyW5w==", + "dev": true, + "requires": { + "define-properties": "^1.1.2", + "function-bind": "^1.1.1", + "has-symbols": "^1.0.0", + "object-keys": "^1.0.11" + } + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dev": true, + "requires": { + "wrappy": "1" + } + }, + "onetime": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz", + "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==", + "dev": true, + "requires": { + "mimic-fn": "^2.1.0" + } + }, + "opencollective-postinstall": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/opencollective-postinstall/-/opencollective-postinstall-2.0.3.tgz", + "integrity": "sha512-8AV/sCtuzUeTo8gQK5qDZzARrulB3egtLzFgteqB2tcT4Mw7B8Kt7JcDHmltjz6FOAHsvTevk70gZEbhM4ZS9Q==", + "dev": true + }, + "optionator": { + "version": "0.8.3", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.3.tgz", + "integrity": "sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA==", + "dev": true, + "requires": { + "deep-is": "~0.1.3", + "fast-levenshtein": "~2.0.6", + "levn": "~0.3.0", + "prelude-ls": "~1.1.2", + "type-check": "~0.3.2", + "word-wrap": "~1.2.3" + } + }, + "p-limit": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "dev": true, + "requires": { + "p-try": "^2.0.0" + } + }, + "p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "dev": true, + "requires": { + "p-limit": "^2.2.0" + } + }, + "p-try": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", + "dev": true + }, + "parent-module": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", + "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", + "dev": true, + "requires": { + "callsites": "^3.0.0" + } + }, + "parse-json": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.1.0.tgz", + "integrity": "sha512-+mi/lmVVNKFNVyLXV31ERiy2CY5E1/F6QtJFEzoChPRwwngMNXRDQ9GJ5WdE2Z2P4AujsOi0/+2qHID68KwfIQ==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.0.0", + "error-ex": "^1.3.1", + "json-parse-even-better-errors": "^2.3.0", + "lines-and-columns": "^1.1.6" + } + }, + "parse5": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-5.1.1.tgz", + "integrity": "sha512-ugq4DFI0Ptb+WWjAdOK16+u/nHfiIrcE+sh8kZMaM0WllQKLI9rOUq6c2b7cwPkXdzfQESqvoqK6ug7U/Yyzug==", + "dev": true + }, + "path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true + }, + "path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true + }, + "path-parse": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", + "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", + "dev": true + }, + "path-type": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", + "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==", + "dev": true + }, + "performance-now": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", + "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=", + "dev": true + }, + "pkg-dir": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz", + "integrity": "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==", + "dev": true, + "requires": { + "find-up": "^4.0.0" + } + }, + "please-upgrade-node": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/please-upgrade-node/-/please-upgrade-node-3.2.0.tgz", + "integrity": "sha512-gQR3WpIgNIKwBMVLkpMUeR3e1/E1y42bqDQZfql+kDeXd8COYfM8PQA4X6y7a8u9Ua9FHmsrrmirW2vHs45hWg==", + "dev": true, + "requires": { + "semver-compare": "^1.0.0" + } + }, + "prelude-ls": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", + "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=", + "dev": true + }, + "prettier": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.1.1.tgz", + "integrity": "sha512-9bY+5ZWCfqj3ghYBLxApy2zf6m+NJo5GzmLTpr9FsApsfjriNnS2dahWReHMi7qNPhhHl9SYHJs2cHZLgexNIw==", + "dev": true + }, + "pretty-quick": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pretty-quick/-/pretty-quick-3.0.0.tgz", + "integrity": "sha512-oIXlGQUcUxt3XpoNfQECEWvH1Q9PtKfelF2pdp6UvC1CSQ5QcB7gUYKu0kuJGlm3LMBZzJaO/vbRkxA61pWlcg==", + "dev": true, + "requires": { + "chalk": "^3.0.0", + "execa": "^4.0.0", + "find-up": "^4.1.0", + "ignore": "^5.1.4", + "mri": "^1.1.5", + "multimatch": "^4.0.0" + }, + "dependencies": { + "chalk": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-3.0.0.tgz", + "integrity": "sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg==", + "dev": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + } + } + }, + "psl": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/psl/-/psl-1.8.0.tgz", + "integrity": "sha512-RIdOzyoavK+hA18OGGWDqUTsCLhtA7IcZ/6NCs4fFJaHBDab+pDDmDIByWFRQJq2Cd7r1OoQxBGKOaztq+hjIQ==", + "dev": true + }, + "pump": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", + "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==", + "dev": true, + "requires": { + "end-of-stream": "^1.1.0", + "once": "^1.3.1" + } + }, + "punycode": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", + "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", + "dev": true + }, + "qs": { + "version": "6.5.2", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", + "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==", + "dev": true + }, + "regexp.prototype.flags": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.3.0.tgz", + "integrity": "sha512-2+Q0C5g951OlYlJz6yu5/M33IcsESLlLfsyIaLJaG4FA2r4yP8MvVMJUUP/fVBkSpbbbZlS5gynbEWLipiiXiQ==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "es-abstract": "^1.17.0-next.1" + } + }, + "request": { + "version": "2.88.2", + "resolved": "https://registry.npmjs.org/request/-/request-2.88.2.tgz", + "integrity": "sha512-MsvtOrfG9ZcrOwAW+Qi+F6HbD0CWXEh9ou77uOb7FM2WPhwT7smM833PzanhJLsgXjN89Ir6V2PczXNnMpwKhw==", + "dev": true, + "requires": { + "aws-sign2": "~0.7.0", + "aws4": "^1.8.0", + "caseless": "~0.12.0", + "combined-stream": "~1.0.6", + "extend": "~3.0.2", + "forever-agent": "~0.6.1", + "form-data": "~2.3.2", + "har-validator": "~5.1.3", + "http-signature": "~1.2.0", + "is-typedarray": "~1.0.0", + "isstream": "~0.1.2", + "json-stringify-safe": "~5.0.1", + "mime-types": "~2.1.19", + "oauth-sign": "~0.9.0", + "performance-now": "^2.1.0", + "qs": "~6.5.2", + "safe-buffer": "^5.1.2", + "tough-cookie": "~2.5.0", + "tunnel-agent": "^0.6.0", + "uuid": "^3.3.2" + }, + "dependencies": { + "tough-cookie": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.5.0.tgz", + "integrity": "sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g==", + "dev": true, + "requires": { + "psl": "^1.1.28", + "punycode": "^2.1.1" + } + } + } + }, + "request-promise-core": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/request-promise-core/-/request-promise-core-1.1.4.tgz", + "integrity": "sha512-TTbAfBBRdWD7aNNOoVOBH4pN/KigV6LyapYNNlAPA8JwbovRti1E88m3sYAwsLi5ryhPKsE9APwnjFTgdUjTpw==", + "dev": true, + "requires": { + "lodash": "^4.17.19" + } + }, + "request-promise-native": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/request-promise-native/-/request-promise-native-1.0.9.tgz", + "integrity": "sha512-wcW+sIUiWnKgNY0dqCpOZkUbF/I+YPi+f09JZIDa39Ec+q82CpSYniDp+ISgTTbKmnpJWASeJBPZmoxH84wt3g==", + "dev": true, + "requires": { + "request-promise-core": "1.1.4", + "stealthy-require": "^1.1.1", + "tough-cookie": "^2.3.3" + }, + "dependencies": { + "tough-cookie": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.5.0.tgz", + "integrity": "sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g==", + "dev": true, + "requires": { + "psl": "^1.1.28", + "punycode": "^2.1.1" + } + } + } + }, + "requirejs": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/requirejs/-/requirejs-2.3.6.tgz", + "integrity": "sha512-ipEzlWQe6RK3jkzikgCupiTbTvm4S0/CAU5GlgptkN5SO6F3u0UD0K18wy6ErDqiCyP4J4YYe1HuAShvsxePLg==", + "dev": true + }, + "resolve": { + "version": "1.17.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.17.0.tgz", + "integrity": "sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w==", + "dev": true, + "requires": { + "path-parse": "^1.0.6" + } + }, + "resolve-from": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", + "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", + "dev": true + }, + "resumer": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/resumer/-/resumer-0.0.0.tgz", + "integrity": "sha1-8ej0YeQGS6Oegq883CqMiT0HZ1k=", + "dev": true, + "requires": { + "through": "~2.3.4" + } + }, + "safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "dev": true + }, + "safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "dev": true + }, + "saxes": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/saxes/-/saxes-5.0.1.tgz", + "integrity": "sha512-5LBh1Tls8c9xgGjw3QrMwETmTMVk0oFgvrFSvWx62llR2hcEInrKNZ2GZCCuuy2lvWrdl5jhbpeqc5hRYKFOcw==", + "dev": true, + "requires": { + "xmlchars": "^2.2.0" + } + }, + "semver-compare": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/semver-compare/-/semver-compare-1.0.0.tgz", + "integrity": "sha1-De4hahyUGrN+nvsXiPavxf9VN/w=", + "dev": true + }, + "semver-regex": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/semver-regex/-/semver-regex-2.0.0.tgz", + "integrity": "sha512-mUdIBBvdn0PLOeP3TEkMH7HHeUP3GjsXCwKarjv/kGmUFOYg1VqEemKhoQpWMu6X2I8kHeuVdGibLGkVK+/5Qw==", + "dev": true + }, + "shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "requires": { + "shebang-regex": "^3.0.0" + } + }, + "shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true + }, + "signal-exit": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.3.tgz", + "integrity": "sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA==", + "dev": true + }, + "slash": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", + "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", + "dev": true + }, + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true + }, + "source-map-support": { + "version": "0.5.19", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.19.tgz", + "integrity": "sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw==", + "dev": true, + "requires": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + } + }, + "sshpk": { + "version": "1.16.1", + "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.16.1.tgz", + "integrity": "sha512-HXXqVUq7+pcKeLqqZj6mHFUMvXtOJt1uoUx09pFW6011inTMxqI8BA8PM95myrIyyKwdnzjdFjLiE6KBPVtJIg==", + "dev": true, + "requires": { + "asn1": "~0.2.3", + "assert-plus": "^1.0.0", + "bcrypt-pbkdf": "^1.0.0", + "dashdash": "^1.12.0", + "ecc-jsbn": "~0.1.1", + "getpass": "^0.1.1", + "jsbn": "~0.1.0", + "safer-buffer": "^2.0.2", + "tweetnacl": "~0.14.0" + } + }, + "stealthy-require": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/stealthy-require/-/stealthy-require-1.1.1.tgz", + "integrity": "sha1-NbCYdbT/SfJqd35QmzCQoyJr8ks=", + "dev": true + }, + "string.prototype.trim": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/string.prototype.trim/-/string.prototype.trim-1.2.1.tgz", + "integrity": "sha512-MjGFEeqixw47dAMFMtgUro/I0+wNqZB5GKXGt1fFr24u3TzDXCPu7J9Buppzoe3r/LqkSDLDDJzE15RGWDGAVw==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "es-abstract": "^1.17.0-next.1", + "function-bind": "^1.1.1" + } + }, + "string.prototype.trimend": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/string.prototype.trimend/-/string.prototype.trimend-1.0.1.tgz", + "integrity": "sha512-LRPxFUaTtpqYsTeNKaFOw3R4bxIzWOnbQ837QfBylo8jIxtcbK/A/sMV7Q+OAV/vWo+7s25pOE10KYSjaSO06g==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "es-abstract": "^1.17.5" + } + }, + "string.prototype.trimstart": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/string.prototype.trimstart/-/string.prototype.trimstart-1.0.1.tgz", + "integrity": "sha512-XxZn+QpvrBI1FOcg6dIpxUPgWCPuNXvMD72aaRaUQv1eD4e/Qy8i/hFTe0BUmD60p/QA6bh1avmuPTfNjqVWRw==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "es-abstract": "^1.17.5" + } + }, + "strip-final-newline": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-2.0.0.tgz", + "integrity": "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==", + "dev": true + }, + "supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + }, + "symbol-tree": { + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.4.tgz", + "integrity": "sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==", + "dev": true + }, + "tape": { + "version": "4.13.3", + "resolved": "https://registry.npmjs.org/tape/-/tape-4.13.3.tgz", + "integrity": "sha512-0/Y20PwRIUkQcTCSi4AASs+OANZZwqPKaipGCEwp10dQMipVvSZwUUCi01Y/OklIGyHKFhIcjock+DKnBfLAFw==", + "dev": true, + "requires": { + "deep-equal": "~1.1.1", + "defined": "~1.0.0", + "dotignore": "~0.1.2", + "for-each": "~0.3.3", + "function-bind": "~1.1.1", + "glob": "~7.1.6", + "has": "~1.0.3", + "inherits": "~2.0.4", + "is-regex": "~1.0.5", + "minimist": "~1.2.5", + "object-inspect": "~1.7.0", + "resolve": "~1.17.0", + "resumer": "~0.0.0", + "string.prototype.trim": "~1.2.1", + "through": "~2.3.8" + } + }, + "terser": { + "version": "4.8.0", + "resolved": "https://registry.npmjs.org/terser/-/terser-4.8.0.tgz", + "integrity": "sha512-EAPipTNeWsb/3wLPeup1tVPaXfIaU68xMnVdPafIL1TV05OhASArYyIfFvnvJCNrR2NIOvDVNNTFRa+Re2MWyw==", + "dev": true, + "requires": { + "commander": "^2.20.0", + "source-map": "~0.6.1", + "source-map-support": "~0.5.12" + } + }, + "through": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", + "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", + "dev": true + }, + "tough-cookie": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-3.0.1.tgz", + "integrity": "sha512-yQyJ0u4pZsv9D4clxO69OEjLWYw+jbgspjTue4lTQZLfV0c5l1VmK2y1JK8E9ahdpltPOaAThPcp5nKPUgSnsg==", + "dev": true, + "requires": { + "ip-regex": "^2.1.0", + "psl": "^1.1.28", + "punycode": "^2.1.1" + } + }, + "tr46": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-2.0.2.tgz", + "integrity": "sha512-3n1qG+/5kg+jrbTzwAykB5yRYtQCTqOGKq5U5PE3b0a1/mzo6snDhjGS0zJVJunO0NrT3Dg1MLy5TjWP/UJppg==", + "dev": true, + "requires": { + "punycode": "^2.1.1" + } + }, + "tunnel-agent": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", + "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", + "dev": true, + "requires": { + "safe-buffer": "^5.0.1" + } + }, + "tweetnacl": { + "version": "0.14.5", + "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", + "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=", + "dev": true + }, + "type-check": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", + "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", + "dev": true, + "requires": { + "prelude-ls": "~1.1.2" + } + }, + "typescript": { + "version": "3.7.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.5.tgz", + "integrity": "sha512-/P5lkRXkWHNAbcJIiHPfRoKqyd7bsyCma1hZNUGfn20qm64T6ZBlrzprymeu918H+mB/0rIg2gGK/BXkhhYgBw==", + "dev": true + }, + "uri-js": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz", + "integrity": "sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ==", + "dev": true, + "requires": { + "punycode": "^2.1.0" + } + }, + "uuid": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", + "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", + "dev": true + }, + "verror": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", + "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=", + "dev": true, + "requires": { + "assert-plus": "^1.0.0", + "core-util-is": "1.0.2", + "extsprintf": "^1.2.0" + } + }, + "w3c-hr-time": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/w3c-hr-time/-/w3c-hr-time-1.0.2.tgz", + "integrity": "sha512-z8P5DvDNjKDoFIHK7q8r8lackT6l+jo/Ye3HOle7l9nICP9lf1Ci25fy9vHd0JOWewkIFzXIEig3TdKT7JQ5fQ==", + "dev": true, + "requires": { + "browser-process-hrtime": "^1.0.0" + } + }, + "w3c-xmlserializer": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/w3c-xmlserializer/-/w3c-xmlserializer-2.0.0.tgz", + "integrity": "sha512-4tzD0mF8iSiMiNs30BiLO3EpfGLZUT2MSX/G+o7ZywDzliWQ3OPtTZ0PTC3B3ca1UAf4cJMHB+2Bf56EriJuRA==", + "dev": true, + "requires": { + "xml-name-validator": "^3.0.0" + } + }, + "webidl-conversions": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-6.1.0.tgz", + "integrity": "sha512-qBIvFLGiBpLjfwmYAaHPXsn+ho5xZnGvyGvsarywGNc8VyQJUMHJ8OBKGGrPER0okBeMDaan4mNBlgBROxuI8w==", + "dev": true + }, + "whatwg-encoding": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/whatwg-encoding/-/whatwg-encoding-1.0.5.tgz", + "integrity": "sha512-b5lim54JOPN9HtzvK9HFXvBma/rnfFeqsic0hSpjtDbVxR3dJKLc+KB4V6GgiGOvl7CY/KNh8rxSo9DKQrnUEw==", + "dev": true, + "requires": { + "iconv-lite": "0.4.24" + } + }, + "whatwg-mimetype": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-2.3.0.tgz", + "integrity": "sha512-M4yMwr6mAnQz76TbJm914+gPpB/nCwvZbJU28cUD6dR004SAxDLOOSUaB1JDRqLtaOV/vi0IC5lEAGFgrjGv/g==", + "dev": true + }, + "whatwg-url": { + "version": "8.2.1", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-8.2.1.tgz", + "integrity": "sha512-ZmVCr6nfBeaMxEHALLEGy0LszYjpJqf6PVNQUQ1qd9Et+q7Jpygd4rGGDXgHjD8e99yLFseD69msHDM4YwPZ4A==", + "dev": true, + "requires": { + "lodash.sortby": "^4.7.0", + "tr46": "^2.0.2", + "webidl-conversions": "^6.1.0" + } + }, + "which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "requires": { + "isexe": "^2.0.0" + } + }, + "which-pm-runs": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/which-pm-runs/-/which-pm-runs-1.0.0.tgz", + "integrity": "sha1-Zws6+8VS4LVd9rd4DKdGFfI60cs=", + "dev": true + }, + "word-wrap": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", + "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", + "dev": true + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true + }, + "ws": { + "version": "7.3.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.3.1.tgz", + "integrity": "sha512-D3RuNkynyHmEJIpD2qrgVkc9DQ23OrN/moAwZX4L8DfvszsJxpjQuUq3LMx6HoYji9fbIOBY18XWBsAux1ZZUA==", + "dev": true + }, + "xml-name-validator": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-3.0.0.tgz", + "integrity": "sha512-A5CUptxDsvxKJEU3yO6DuWBSJz/qizqzJKOMIfUJHETbBw/sFaDxgd6fxm1ewUaM0jZ444Fc5vC5ROYurg/4Pw==", + "dev": true + }, + "xmlchars": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/xmlchars/-/xmlchars-2.2.0.tgz", + "integrity": "sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==", + "dev": true + }, + "yaml": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.0.tgz", + "integrity": "sha512-yr2icI4glYaNG+KWONODapy2/jDdMSDnrONSjblABjD9B4Z5LgiircSt8m8sRZFNi08kG9Sm0uSHtEmP3zaEGg==", + "dev": true + } + } } diff --git a/package.json b/package.json index 739473eb..44cb9e1c 100644 --- a/package.json +++ b/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" + } + } } diff --git a/scripts/bundle.js b/scripts/bundle.js index 50ba178f..b5a3883c 100644 --- a/scripts/bundle.js +++ b/scripts/bundle.js @@ -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); + } + ); } diff --git a/src/_.contribution.ts b/src/_.contribution.ts index f0e7b2db..f357cf16 100644 --- a/src/_.contribution.ts +++ b/src/_.contribution.ts @@ -5,7 +5,8 @@ 'use strict'; // Allow for running under nodejs/requirejs in tests -const _monaco: typeof monaco = (typeof monaco === 'undefined' ? (self).monaco : monaco); +const _monaco: typeof monaco = + typeof monaco === 'undefined' ? (self).monaco : monaco; interface ILang extends monaco.languages.ILanguageExtensionPoint { loader: () => Promise; @@ -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 { 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); }); }); diff --git a/src/abap/abap.test.ts b/src/abap/abap.test.ts index fcb8a143..45a82f50 100644 --- a/src/abap/abap.test.ts +++ b/src/abap/abap.test.ts @@ -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 .', - 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 .', + 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' } + ] + } + ] ]); diff --git a/src/abap/abap.ts b/src/abap/abap.ts index f664c218..e4925f43 100644 --- a/src/abap/abap.ts +++ b/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 = { +export const language = { 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: /[=>/, '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'] + ] + } +}; diff --git a/src/apex/apex.contribution.ts b/src/apex/apex.contribution.ts index 921873df..bdc2aa1e 100644 --- a/src/apex/apex.contribution.ts +++ b/src/apex/apex.contribution.ts @@ -1,15 +1,15 @@ -/*--------------------------------------------------------------------------------------------- - * 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'; - -registerLanguage({ - id: 'apex', - extensions: ['.cls'], - aliases: ['Apex', 'apex'], - mimetypes: ['text/x-apex-source', 'text/x-apex'], - loader: () => import('./apex') -}); +/*--------------------------------------------------------------------------------------------- + * 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'; + +registerLanguage({ + id: 'apex', + extensions: ['.cls'], + aliases: ['Apex', 'apex'], + mimetypes: ['text/x-apex-source', 'text/x-apex'], + loader: () => import('./apex') +}); diff --git a/src/apex/apex.test.ts b/src/apex/apex.test.ts index 5f9f6c8f..690eeb9d 100644 --- a/src/apex/apex.test.ts +++ b/src/apex/apex.test.ts @@ -1,651 +1,704 @@ -/*--------------------------------------------------------------------------------------------- - * 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'; - -testTokenization('apex', [ - // Comments - single line - [{ - line: '//', - tokens: [ - { startIndex: 0, type: 'comment.apex' } - ] - }], - - [{ - line: ' // a comment', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 4, type: 'comment.apex' } - ] - }], - - // Broken nested tokens due to invalid comment tokenization - [{ - line: '/* //*/ a', - tokens: [ - { startIndex: 0, type: 'comment.apex' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'identifier.apex' } - ] - }], - - [{ - line: '// a comment', - tokens: [ - { startIndex: 0, type: 'comment.apex' } - ] - }], - - [{ - line: '//sticky comment', - tokens: [ - { startIndex: 0, type: 'comment.apex' } - ] - }], - - [{ - line: '/almost a comment', - tokens: [ - { startIndex: 0, type: 'delimiter.apex' }, - { startIndex: 1, type: 'identifier.apex' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'identifier.apex' }, - { startIndex: 9, type: '' }, - { startIndex: 10, type: 'identifier.apex' } - ] - }], - - [{ - line: '1 / 2; /* comment', - tokens: [ - { startIndex: 0, type: 'number.apex' }, - { startIndex: 1, type: '' }, - { startIndex: 2, type: 'delimiter.apex' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'number.apex' }, - { startIndex: 5, type: 'delimiter.apex' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'comment.apex' } - ] - }], - - [{ - line: 'int x = 1; // my comment // is a nice one', - tokens: [ - { startIndex: 0, type: 'keyword.int.apex' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'identifier.apex' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'delimiter.apex' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'number.apex' }, - { startIndex: 9, type: 'delimiter.apex' }, - { startIndex: 10, type: '' }, - { startIndex: 11, type: 'comment.apex' } - ] - }], - - // Comments - range comment, single line - [{ - line: '/* a simple comment */', - tokens: [ - { startIndex: 0, type: 'comment.apex' } - ] - }], - - [{ - line: 'int x = /* a simple comment */ 1;', - tokens: [ - { startIndex: 0, type: 'keyword.int.apex' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'identifier.apex' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'delimiter.apex' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'comment.apex' }, - { startIndex: 30, type: '' }, - { startIndex: 31, type: 'number.apex' }, - { startIndex: 32, type: 'delimiter.apex' } - ] - }], - - [{ - line: 'int x = /* comment */ 1; */', - tokens: [ - { startIndex: 0, type: 'keyword.int.apex' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'identifier.apex' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'delimiter.apex' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'comment.apex' }, - { startIndex: 21, type: '' }, - { startIndex: 22, type: 'number.apex' }, - { startIndex: 23, type: 'delimiter.apex' }, - { startIndex: 24, type: '' } - ] - }], - - [{ - line: 'x = /**/;', - tokens: [ - { startIndex: 0, type: 'identifier.apex' }, - { startIndex: 1, type: '' }, - { startIndex: 2, type: 'delimiter.apex' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'comment.apex' }, - { startIndex: 8, type: 'delimiter.apex' } - ] - }], - - [{ - line: 'x = /*/;', - tokens: [ - { startIndex: 0, type: 'identifier.apex' }, - { startIndex: 1, type: '' }, - { startIndex: 2, type: 'delimiter.apex' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'comment.apex' } - ] - }], - - // Comments - range comment, multiple lines - [{ - line: '/* start of multiline comment', - tokens: [ - { startIndex: 0, type: 'comment.apex' } - ] - }, { - line: 'a comment between without a star', - tokens: [ - { startIndex: 0, type: 'comment.apex' } - ] - }, { - line: 'end of multiline comment*/', - tokens: [ - { startIndex: 0, type: 'comment.apex' } - ] - }], - - [{ - line: 'int x = /* start a comment', - tokens: [ - { startIndex: 0, type: 'keyword.int.apex' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'identifier.apex' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'delimiter.apex' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'comment.apex' } - ] - }, { - line: ' a ', - tokens: [ - { startIndex: 0, type: 'comment.apex' } - ] - }, { - line: 'and end it */ 2;', - tokens: [ - { startIndex: 0, type: 'comment.apex' }, - { startIndex: 13, type: '' }, - { startIndex: 14, type: 'number.apex' }, - { startIndex: 15, type: 'delimiter.apex' } - ] - }], - - // Comments - apex doc, multiple lines - [{ - line: '/** start of Apex Doc', - tokens: [ - { startIndex: 0, type: 'comment.doc.apex' } - ] - }, { - line: 'a comment between without a star', - tokens: [ - { startIndex: 0, type: 'comment.doc.apex' } - ] - }, { - line: 'end of multiline comment*/', - tokens: [ - { startIndex: 0, type: 'comment.doc.apex' } - ] - }], - - // Keywords - [{ - line: 'package test; class Program { static void main(String[] args) {} } }', - tokens: [ - { startIndex: 0, type: 'keyword.package.apex' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'identifier.apex' }, - { startIndex: 12, type: 'delimiter.apex' }, - { startIndex: 13, type: '' }, - { startIndex: 14, type: 'keyword.class.apex' }, - { startIndex: 19, type: '' }, - { startIndex: 20, type: 'type.identifier.apex' }, - { startIndex: 27, type: '' }, - { startIndex: 28, type: 'delimiter.curly.apex' }, - { startIndex: 29, type: '' }, - { startIndex: 30, type: 'keyword.static.apex' }, - { startIndex: 36, type: '' }, - { startIndex: 37, type: 'keyword.void.apex' }, - { startIndex: 41, type: '' }, - { startIndex: 42, type: 'identifier.apex' }, - { startIndex: 46, type: 'delimiter.parenthesis.apex' }, - { startIndex: 47, type: 'type.identifier.apex' }, - { startIndex: 53, type: 'delimiter.square.apex' }, - { startIndex: 55, type: '' }, - { startIndex: 56, type: 'identifier.apex' }, - { startIndex: 60, type: 'delimiter.parenthesis.apex' }, - { startIndex: 61, type: '' }, - { startIndex: 62, type: 'delimiter.curly.apex' }, - { startIndex: 64, type: '' }, - { startIndex: 65, type: 'delimiter.curly.apex' }, - { startIndex: 66, type: '' }, - { startIndex: 67, type: 'delimiter.curly.apex' } - ] - }], - - // Keywords with case variations - [{ - line: 'Package test; CLASS Program { Static void main(String[] args) {} } }', - tokens: [ - { startIndex: 0, type: 'keyword.Package.apex' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'identifier.apex' }, - { startIndex: 12, type: 'delimiter.apex' }, - { startIndex: 13, type: '' }, - { startIndex: 14, type: 'keyword.CLASS.apex' }, - { startIndex: 19, type: '' }, - { startIndex: 20, type: 'type.identifier.apex' }, - { startIndex: 27, type: '' }, - { startIndex: 28, type: 'delimiter.curly.apex' }, - { startIndex: 29, type: '' }, - { startIndex: 30, type: 'keyword.Static.apex' }, - { startIndex: 36, type: '' }, - { startIndex: 37, type: 'keyword.void.apex' }, - { startIndex: 41, type: '' }, - { startIndex: 42, type: 'identifier.apex' }, - { startIndex: 46, type: 'delimiter.parenthesis.apex' }, - { startIndex: 47, type: 'type.identifier.apex' }, - { startIndex: 53, type: 'delimiter.square.apex' }, - { startIndex: 55, type: '' }, - { startIndex: 56, type: 'identifier.apex' }, - { startIndex: 60, type: 'delimiter.parenthesis.apex' }, - { startIndex: 61, type: '' }, - { startIndex: 62, type: 'delimiter.curly.apex' }, - { startIndex: 64, type: '' }, - { startIndex: 65, type: 'delimiter.curly.apex' }, - { startIndex: 66, type: '' }, - { startIndex: 67, type: 'delimiter.curly.apex' } - ] - }], - - // Numbers - [{ - line: '0', - tokens: [ - { startIndex: 0, type: 'number.apex' } - ] - }], - - [{ - line: '0.10', - tokens: [ - { startIndex: 0, type: 'number.float.apex' } - ] - }], - - [{ - line: '0x', - tokens: [ - { startIndex: 0, type: 'number.apex' }, - { startIndex: 1, type: 'identifier.apex' } - ] - }], - - [{ - line: '10e3', - tokens: [ - { startIndex: 0, type: 'number.float.apex' } - ] - }], - - [{ - line: '10f', - tokens: [ - { startIndex: 0, type: 'number.float.apex' } - ] - }], - - [{ - line: '23.5', - tokens: [ - { startIndex: 0, type: 'number.float.apex' } - ] - }], - - [{ - line: '23.5e3', - tokens: [ - { startIndex: 0, type: 'number.float.apex' } - ] - }], - - [{ - line: '23.5e-3', - tokens: [ - { startIndex: 0, type: 'number.float.apex' } - ] - }], - - [{ - line: '23.5E3', - tokens: [ - { startIndex: 0, type: 'number.float.apex' } - ] - }], - - [{ - line: '23.5E-3', - tokens: [ - { startIndex: 0, type: 'number.float.apex' } - ] - }], - - [{ - line: '23.5F', - tokens: [ - { startIndex: 0, type: 'number.float.apex' } - ] - }], - - [{ - line: '23.5f', - tokens: [ - { startIndex: 0, type: 'number.float.apex' } - ] - }], - - [{ - line: '23.5D', - tokens: [ - { startIndex: 0, type: 'number.float.apex' } - ] - }], - - [{ - line: '23.5d', - tokens: [ - { startIndex: 0, type: 'number.float.apex' } - ] - }], - - [{ - line: '1.72E3D', - tokens: [ - { startIndex: 0, type: 'number.float.apex' } - ] - }], - - [{ - line: '1.72E3d', - tokens: [ - { startIndex: 0, type: 'number.float.apex' } - ] - }], - - [{ - line: '1.72E-3d', - tokens: [ - { startIndex: 0, type: 'number.float.apex' } - ] - }], - - [{ - line: '1.72e3D', - tokens: [ - { startIndex: 0, type: 'number.float.apex' } - ] - }], - - [{ - line: '1.72e3d', - tokens: [ - { startIndex: 0, type: 'number.float.apex' } - ] - }], - - [{ - line: '1.72e-3d', - tokens: [ - { startIndex: 0, type: 'number.float.apex' } - ] - }], - - [{ - line: '23L', - tokens: [ - { startIndex: 0, type: 'number.apex' } - ] - }], - - [{ - line: '23l', - tokens: [ - { startIndex: 0, type: 'number.apex' } - ] - }], - - [{ - line: '0_52', - tokens: [ - { startIndex: 0, type: 'number.apex' } - ] - }], - - [{ - line: '5_2', - tokens: [ - { startIndex: 0, type: 'number.apex' } - ] - }], - - [{ - line: '5_______2', - tokens: [ - { startIndex: 0, type: 'number.apex' } - ] - }], - - [{ - line: '3_.1415F', - tokens: [ - { startIndex: 0, type: 'number.apex' }, - { startIndex: 1, type: 'identifier.apex' }, - { startIndex: 2, type: 'delimiter.apex' }, - { startIndex: 3, type: 'number.float.apex' } - ] - }], - - [{ - line: '3._1415F', - tokens: [ - { startIndex: 0, type: 'number.apex' }, - { startIndex: 1, type: 'delimiter.apex' }, - { startIndex: 2, type: 'identifier.apex' } - ] - }], - - [{ - line: '999_99_9999_L', - tokens: [ - { startIndex: 0, type: 'number.apex' }, - { startIndex: 11, type: 'identifier.apex' } - ] - }], - - [{ - line: '52_', - tokens: [ - { startIndex: 0, type: 'number.apex' }, - { startIndex: 2, type: 'identifier.apex' } - ] - }], - - [{ - line: '0_x52', - tokens: [ - { startIndex: 0, type: 'number.apex' }, - { startIndex: 1, type: 'identifier.apex' } - ] - }], - - [{ - line: '0x_52', - tokens: [ - { startIndex: 0, type: 'number.apex' }, - { startIndex: 1, type: 'identifier.apex' } - ] - }], - - [{ - line: '23.5L', - tokens: [ - { startIndex: 0, type: 'number.float.apex' }, - { startIndex: 4, type: 'type.identifier.apex' } - ] - }], - - [{ - line: '0+0', - tokens: [ - { startIndex: 0, type: 'number.apex' }, - { startIndex: 1, type: 'delimiter.apex' }, - { startIndex: 2, type: 'number.apex' } - ] - }], - - [{ - line: '100+10', - tokens: [ - { startIndex: 0, type: 'number.apex' }, - { startIndex: 3, type: 'delimiter.apex' }, - { startIndex: 4, type: 'number.apex' } - ] - }], - - [{ - line: '0 + 0', - tokens: [ - { startIndex: 0, type: 'number.apex' }, - { startIndex: 1, type: '' }, - { startIndex: 2, type: 'delimiter.apex' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'number.apex' } - ] - }], - - // single line Strings - [{ - line: 'String s = "I\'m an Apex String";', - tokens: [ - { startIndex: 0, type: 'type.identifier.apex' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'identifier.apex' }, - { startIndex: 8, type: '' }, - { startIndex: 9, type: 'delimiter.apex' }, - { startIndex: 10, type: '' }, - { startIndex: 11, type: 'string.apex' }, - { startIndex: 31, type: 'delimiter.apex' } - ] - }], - - [{ - line: 'String s = "concatenated" + " String" ;', - tokens: [ - { startIndex: 0, type: 'type.identifier.apex' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'identifier.apex' }, - { startIndex: 8, type: '' }, - { startIndex: 9, type: 'delimiter.apex' }, - { startIndex: 10, type: '' }, - { startIndex: 11, type: 'string.apex' }, - { startIndex: 25, type: '' }, - { startIndex: 26, type: 'delimiter.apex' }, - { startIndex: 27, type: '' }, - { startIndex: 28, type: 'string.apex' }, - { startIndex: 37, type: '' }, - { startIndex: 38, type: 'delimiter.apex' } - ] - }], - - [{ - line: '"quote in a string"', - tokens: [ - { startIndex: 0, type: 'string.apex' } - ] - }], - - [{ - line: '"escaping \\"quotes\\" is cool"', - tokens: [ - { startIndex: 0, type: 'string.apex' }, - { startIndex: 10, type: 'string.escape.apex' }, - { startIndex: 12, type: 'string.apex' }, - { startIndex: 18, type: 'string.escape.apex' }, - { startIndex: 20, type: 'string.apex' } - ] - }], - - [{ - line: '"\\"', - tokens: [ - { startIndex: 0, type: 'string.invalid.apex' } - ] - }], - - // Annotations - [{ - line: '@', - tokens: [ - { startIndex: 0, type: '' } - ] - }], - - [{ - line: '@Override', - tokens: [ - { startIndex: 0, type: 'annotation.apex' } - ] - }], - - [{ - line: '@SuppressWarnings(value = "aString")', - tokens: [ - { startIndex: 0, type: 'annotation.apex' }, - { startIndex: 17, type: 'delimiter.parenthesis.apex' }, - { startIndex: 18, type: 'identifier.apex' }, - { startIndex: 23, type: '' }, - { startIndex: 24, type: 'delimiter.apex' }, - { startIndex: 25, type: '' }, - { startIndex: 26, type: 'string.apex' }, - { startIndex: 35, type: 'delimiter.parenthesis.apex' } - ] - }], - - [{ - line: '@ AnnotationWithKeywordAfter private', - tokens: [ - { startIndex: 0, type: 'annotation.apex' }, - { startIndex: 28, type: '' }, - { startIndex: 29, type: 'keyword.private.apex' } - ] - }] -]); - +/*--------------------------------------------------------------------------------------------- + * 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'; + +testTokenization('apex', [ + // Comments - single line + [ + { + line: '//', + tokens: [{ startIndex: 0, type: 'comment.apex' }] + } + ], + + [ + { + line: ' // a comment', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 4, type: 'comment.apex' } + ] + } + ], + + // Broken nested tokens due to invalid comment tokenization + [ + { + line: '/* //*/ a', + tokens: [ + { startIndex: 0, type: 'comment.apex' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'identifier.apex' } + ] + } + ], + + [ + { + line: '// a comment', + tokens: [{ startIndex: 0, type: 'comment.apex' }] + } + ], + + [ + { + line: '//sticky comment', + tokens: [{ startIndex: 0, type: 'comment.apex' }] + } + ], + + [ + { + line: '/almost a comment', + tokens: [ + { startIndex: 0, type: 'delimiter.apex' }, + { startIndex: 1, type: 'identifier.apex' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'identifier.apex' }, + { startIndex: 9, type: '' }, + { startIndex: 10, type: 'identifier.apex' } + ] + } + ], + + [ + { + line: '1 / 2; /* comment', + tokens: [ + { startIndex: 0, type: 'number.apex' }, + { startIndex: 1, type: '' }, + { startIndex: 2, type: 'delimiter.apex' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'number.apex' }, + { startIndex: 5, type: 'delimiter.apex' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'comment.apex' } + ] + } + ], + + [ + { + line: 'int x = 1; // my comment // is a nice one', + tokens: [ + { startIndex: 0, type: 'keyword.int.apex' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'identifier.apex' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'delimiter.apex' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'number.apex' }, + { startIndex: 9, type: 'delimiter.apex' }, + { startIndex: 10, type: '' }, + { startIndex: 11, type: 'comment.apex' } + ] + } + ], + + // Comments - range comment, single line + [ + { + line: '/* a simple comment */', + tokens: [{ startIndex: 0, type: 'comment.apex' }] + } + ], + + [ + { + line: 'int x = /* a simple comment */ 1;', + tokens: [ + { startIndex: 0, type: 'keyword.int.apex' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'identifier.apex' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'delimiter.apex' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'comment.apex' }, + { startIndex: 30, type: '' }, + { startIndex: 31, type: 'number.apex' }, + { startIndex: 32, type: 'delimiter.apex' } + ] + } + ], + + [ + { + line: 'int x = /* comment */ 1; */', + tokens: [ + { startIndex: 0, type: 'keyword.int.apex' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'identifier.apex' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'delimiter.apex' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'comment.apex' }, + { startIndex: 21, type: '' }, + { startIndex: 22, type: 'number.apex' }, + { startIndex: 23, type: 'delimiter.apex' }, + { startIndex: 24, type: '' } + ] + } + ], + + [ + { + line: 'x = /**/;', + tokens: [ + { startIndex: 0, type: 'identifier.apex' }, + { startIndex: 1, type: '' }, + { startIndex: 2, type: 'delimiter.apex' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'comment.apex' }, + { startIndex: 8, type: 'delimiter.apex' } + ] + } + ], + + [ + { + line: 'x = /*/;', + tokens: [ + { startIndex: 0, type: 'identifier.apex' }, + { startIndex: 1, type: '' }, + { startIndex: 2, type: 'delimiter.apex' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'comment.apex' } + ] + } + ], + + // Comments - range comment, multiple lines + [ + { + line: '/* start of multiline comment', + tokens: [{ startIndex: 0, type: 'comment.apex' }] + }, + { + line: 'a comment between without a star', + tokens: [{ startIndex: 0, type: 'comment.apex' }] + }, + { + line: 'end of multiline comment*/', + tokens: [{ startIndex: 0, type: 'comment.apex' }] + } + ], + + [ + { + line: 'int x = /* start a comment', + tokens: [ + { startIndex: 0, type: 'keyword.int.apex' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'identifier.apex' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'delimiter.apex' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'comment.apex' } + ] + }, + { + line: ' a ', + tokens: [{ startIndex: 0, type: 'comment.apex' }] + }, + { + line: 'and end it */ 2;', + tokens: [ + { startIndex: 0, type: 'comment.apex' }, + { startIndex: 13, type: '' }, + { startIndex: 14, type: 'number.apex' }, + { startIndex: 15, type: 'delimiter.apex' } + ] + } + ], + + // Comments - apex doc, multiple lines + [ + { + line: '/** start of Apex Doc', + tokens: [{ startIndex: 0, type: 'comment.doc.apex' }] + }, + { + line: 'a comment between without a star', + tokens: [{ startIndex: 0, type: 'comment.doc.apex' }] + }, + { + line: 'end of multiline comment*/', + tokens: [{ startIndex: 0, type: 'comment.doc.apex' }] + } + ], + + // Keywords + [ + { + line: + 'package test; class Program { static void main(String[] args) {} } }', + tokens: [ + { startIndex: 0, type: 'keyword.package.apex' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'identifier.apex' }, + { startIndex: 12, type: 'delimiter.apex' }, + { startIndex: 13, type: '' }, + { startIndex: 14, type: 'keyword.class.apex' }, + { startIndex: 19, type: '' }, + { startIndex: 20, type: 'type.identifier.apex' }, + { startIndex: 27, type: '' }, + { startIndex: 28, type: 'delimiter.curly.apex' }, + { startIndex: 29, type: '' }, + { startIndex: 30, type: 'keyword.static.apex' }, + { startIndex: 36, type: '' }, + { startIndex: 37, type: 'keyword.void.apex' }, + { startIndex: 41, type: '' }, + { startIndex: 42, type: 'identifier.apex' }, + { startIndex: 46, type: 'delimiter.parenthesis.apex' }, + { startIndex: 47, type: 'type.identifier.apex' }, + { startIndex: 53, type: 'delimiter.square.apex' }, + { startIndex: 55, type: '' }, + { startIndex: 56, type: 'identifier.apex' }, + { startIndex: 60, type: 'delimiter.parenthesis.apex' }, + { startIndex: 61, type: '' }, + { startIndex: 62, type: 'delimiter.curly.apex' }, + { startIndex: 64, type: '' }, + { startIndex: 65, type: 'delimiter.curly.apex' }, + { startIndex: 66, type: '' }, + { startIndex: 67, type: 'delimiter.curly.apex' } + ] + } + ], + + // Keywords with case variations + [ + { + line: + 'Package test; CLASS Program { Static void main(String[] args) {} } }', + tokens: [ + { startIndex: 0, type: 'keyword.Package.apex' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'identifier.apex' }, + { startIndex: 12, type: 'delimiter.apex' }, + { startIndex: 13, type: '' }, + { startIndex: 14, type: 'keyword.CLASS.apex' }, + { startIndex: 19, type: '' }, + { startIndex: 20, type: 'type.identifier.apex' }, + { startIndex: 27, type: '' }, + { startIndex: 28, type: 'delimiter.curly.apex' }, + { startIndex: 29, type: '' }, + { startIndex: 30, type: 'keyword.Static.apex' }, + { startIndex: 36, type: '' }, + { startIndex: 37, type: 'keyword.void.apex' }, + { startIndex: 41, type: '' }, + { startIndex: 42, type: 'identifier.apex' }, + { startIndex: 46, type: 'delimiter.parenthesis.apex' }, + { startIndex: 47, type: 'type.identifier.apex' }, + { startIndex: 53, type: 'delimiter.square.apex' }, + { startIndex: 55, type: '' }, + { startIndex: 56, type: 'identifier.apex' }, + { startIndex: 60, type: 'delimiter.parenthesis.apex' }, + { startIndex: 61, type: '' }, + { startIndex: 62, type: 'delimiter.curly.apex' }, + { startIndex: 64, type: '' }, + { startIndex: 65, type: 'delimiter.curly.apex' }, + { startIndex: 66, type: '' }, + { startIndex: 67, type: 'delimiter.curly.apex' } + ] + } + ], + + // Numbers + [ + { + line: '0', + tokens: [{ startIndex: 0, type: 'number.apex' }] + } + ], + + [ + { + line: '0.10', + tokens: [{ startIndex: 0, type: 'number.float.apex' }] + } + ], + + [ + { + line: '0x', + tokens: [ + { startIndex: 0, type: 'number.apex' }, + { startIndex: 1, type: 'identifier.apex' } + ] + } + ], + + [ + { + line: '10e3', + tokens: [{ startIndex: 0, type: 'number.float.apex' }] + } + ], + + [ + { + line: '10f', + tokens: [{ startIndex: 0, type: 'number.float.apex' }] + } + ], + + [ + { + line: '23.5', + tokens: [{ startIndex: 0, type: 'number.float.apex' }] + } + ], + + [ + { + line: '23.5e3', + tokens: [{ startIndex: 0, type: 'number.float.apex' }] + } + ], + + [ + { + line: '23.5e-3', + tokens: [{ startIndex: 0, type: 'number.float.apex' }] + } + ], + + [ + { + line: '23.5E3', + tokens: [{ startIndex: 0, type: 'number.float.apex' }] + } + ], + + [ + { + line: '23.5E-3', + tokens: [{ startIndex: 0, type: 'number.float.apex' }] + } + ], + + [ + { + line: '23.5F', + tokens: [{ startIndex: 0, type: 'number.float.apex' }] + } + ], + + [ + { + line: '23.5f', + tokens: [{ startIndex: 0, type: 'number.float.apex' }] + } + ], + + [ + { + line: '23.5D', + tokens: [{ startIndex: 0, type: 'number.float.apex' }] + } + ], + + [ + { + line: '23.5d', + tokens: [{ startIndex: 0, type: 'number.float.apex' }] + } + ], + + [ + { + line: '1.72E3D', + tokens: [{ startIndex: 0, type: 'number.float.apex' }] + } + ], + + [ + { + line: '1.72E3d', + tokens: [{ startIndex: 0, type: 'number.float.apex' }] + } + ], + + [ + { + line: '1.72E-3d', + tokens: [{ startIndex: 0, type: 'number.float.apex' }] + } + ], + + [ + { + line: '1.72e3D', + tokens: [{ startIndex: 0, type: 'number.float.apex' }] + } + ], + + [ + { + line: '1.72e3d', + tokens: [{ startIndex: 0, type: 'number.float.apex' }] + } + ], + + [ + { + line: '1.72e-3d', + tokens: [{ startIndex: 0, type: 'number.float.apex' }] + } + ], + + [ + { + line: '23L', + tokens: [{ startIndex: 0, type: 'number.apex' }] + } + ], + + [ + { + line: '23l', + tokens: [{ startIndex: 0, type: 'number.apex' }] + } + ], + + [ + { + line: '0_52', + tokens: [{ startIndex: 0, type: 'number.apex' }] + } + ], + + [ + { + line: '5_2', + tokens: [{ startIndex: 0, type: 'number.apex' }] + } + ], + + [ + { + line: '5_______2', + tokens: [{ startIndex: 0, type: 'number.apex' }] + } + ], + + [ + { + line: '3_.1415F', + tokens: [ + { startIndex: 0, type: 'number.apex' }, + { startIndex: 1, type: 'identifier.apex' }, + { startIndex: 2, type: 'delimiter.apex' }, + { startIndex: 3, type: 'number.float.apex' } + ] + } + ], + + [ + { + line: '3._1415F', + tokens: [ + { startIndex: 0, type: 'number.apex' }, + { startIndex: 1, type: 'delimiter.apex' }, + { startIndex: 2, type: 'identifier.apex' } + ] + } + ], + + [ + { + line: '999_99_9999_L', + tokens: [ + { startIndex: 0, type: 'number.apex' }, + { startIndex: 11, type: 'identifier.apex' } + ] + } + ], + + [ + { + line: '52_', + tokens: [ + { startIndex: 0, type: 'number.apex' }, + { startIndex: 2, type: 'identifier.apex' } + ] + } + ], + + [ + { + line: '0_x52', + tokens: [ + { startIndex: 0, type: 'number.apex' }, + { startIndex: 1, type: 'identifier.apex' } + ] + } + ], + + [ + { + line: '0x_52', + tokens: [ + { startIndex: 0, type: 'number.apex' }, + { startIndex: 1, type: 'identifier.apex' } + ] + } + ], + + [ + { + line: '23.5L', + tokens: [ + { startIndex: 0, type: 'number.float.apex' }, + { startIndex: 4, type: 'type.identifier.apex' } + ] + } + ], + + [ + { + line: '0+0', + tokens: [ + { startIndex: 0, type: 'number.apex' }, + { startIndex: 1, type: 'delimiter.apex' }, + { startIndex: 2, type: 'number.apex' } + ] + } + ], + + [ + { + line: '100+10', + tokens: [ + { startIndex: 0, type: 'number.apex' }, + { startIndex: 3, type: 'delimiter.apex' }, + { startIndex: 4, type: 'number.apex' } + ] + } + ], + + [ + { + line: '0 + 0', + tokens: [ + { startIndex: 0, type: 'number.apex' }, + { startIndex: 1, type: '' }, + { startIndex: 2, type: 'delimiter.apex' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'number.apex' } + ] + } + ], + + // single line Strings + [ + { + line: 'String s = "I\'m an Apex String";', + tokens: [ + { startIndex: 0, type: 'type.identifier.apex' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'identifier.apex' }, + { startIndex: 8, type: '' }, + { startIndex: 9, type: 'delimiter.apex' }, + { startIndex: 10, type: '' }, + { startIndex: 11, type: 'string.apex' }, + { startIndex: 31, type: 'delimiter.apex' } + ] + } + ], + + [ + { + line: 'String s = "concatenated" + " String" ;', + tokens: [ + { startIndex: 0, type: 'type.identifier.apex' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'identifier.apex' }, + { startIndex: 8, type: '' }, + { startIndex: 9, type: 'delimiter.apex' }, + { startIndex: 10, type: '' }, + { startIndex: 11, type: 'string.apex' }, + { startIndex: 25, type: '' }, + { startIndex: 26, type: 'delimiter.apex' }, + { startIndex: 27, type: '' }, + { startIndex: 28, type: 'string.apex' }, + { startIndex: 37, type: '' }, + { startIndex: 38, type: 'delimiter.apex' } + ] + } + ], + + [ + { + line: '"quote in a string"', + tokens: [{ startIndex: 0, type: 'string.apex' }] + } + ], + + [ + { + line: '"escaping \\"quotes\\" is cool"', + tokens: [ + { startIndex: 0, type: 'string.apex' }, + { startIndex: 10, type: 'string.escape.apex' }, + { startIndex: 12, type: 'string.apex' }, + { startIndex: 18, type: 'string.escape.apex' }, + { startIndex: 20, type: 'string.apex' } + ] + } + ], + + [ + { + line: '"\\"', + tokens: [{ startIndex: 0, type: 'string.invalid.apex' }] + } + ], + + // Annotations + [ + { + line: '@', + tokens: [{ startIndex: 0, type: '' }] + } + ], + + [ + { + line: '@Override', + tokens: [{ startIndex: 0, type: 'annotation.apex' }] + } + ], + + [ + { + line: '@SuppressWarnings(value = "aString")', + tokens: [ + { startIndex: 0, type: 'annotation.apex' }, + { startIndex: 17, type: 'delimiter.parenthesis.apex' }, + { startIndex: 18, type: 'identifier.apex' }, + { startIndex: 23, type: '' }, + { startIndex: 24, type: 'delimiter.apex' }, + { startIndex: 25, type: '' }, + { startIndex: 26, type: 'string.apex' }, + { startIndex: 35, type: 'delimiter.parenthesis.apex' } + ] + } + ], + + [ + { + line: '@ AnnotationWithKeywordAfter private', + tokens: [ + { startIndex: 0, type: 'annotation.apex' }, + { startIndex: 28, type: '' }, + { startIndex: 29, type: 'keyword.private.apex' } + ] + } + ] +]); diff --git a/src/apex/apex.ts b/src/apex/apex.ts index a152ca5f..727f533c 100644 --- a/src/apex/apex.ts +++ b/src/apex/apex.ts @@ -1,310 +1,365 @@ -/*--------------------------------------------------------------------------------------------- - * 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 IRichLanguageConfiguration = monaco.languages.LanguageConfiguration; -import ILanguage = monaco.languages.IMonarchLanguage; - -export const conf: IRichLanguageConfiguration = { - // the default separators except `@$` - wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g, - comments: { - lineComment: '//', - blockComment: ['/*', '*/'], - }, - brackets: [ - ['{', '}'], - ['[', ']'], - ['(', ')'], - ], - autoClosingPairs: [ - { 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*//\\s*(?:(?:#?region\\b)|(?:))") - } - } -}; - -const keywords = [ - 'abstract', - 'activate', - 'and', - 'any', - 'array', - 'as', - 'asc', - 'assert', - 'autonomous', - 'begin', - 'bigdecimal', - 'blob', - 'boolean', - 'break', - 'bulk', - 'by', - 'case', - 'cast', - 'catch', - 'char', - 'class', - 'collect', - 'commit', - 'const', - 'continue', - 'convertcurrency', - 'decimal', - 'default', - 'delete', - 'desc', - 'do', - 'double', - 'else', - 'end', - 'enum', - 'exception', - 'exit', - 'export', - 'extends', - 'false', - 'final', - 'finally', - 'float', - 'for', - 'from', - 'future', - 'get', - 'global', - 'goto', - 'group', - 'having', - 'hint', - 'if', - 'implements', - 'import', - 'in', - 'inner', - 'insert', - 'instanceof', - 'int', - 'interface', - 'into', - 'join', - 'last_90_days', - 'last_month', - 'last_n_days', - 'last_week', - 'like', - 'limit', - 'list', - 'long', - 'loop', - 'map', - 'merge', - 'native', - 'new', - 'next_90_days', - 'next_month', - 'next_n_days', - 'next_week', - 'not', - 'null', - 'nulls', - 'number', - 'object', - 'of', - 'on', - 'or', - 'outer', - 'override', - 'package', - 'parallel', - 'pragma', - 'private', - 'protected', - 'public', - 'retrieve', - 'return', - 'returning', - 'rollback', - 'savepoint', - 'search', - 'select', - 'set', - 'short', - 'sort', - 'stat', - 'static', - 'strictfp', - 'super', - 'switch', - 'synchronized', - 'system', - 'testmethod', - 'then', - 'this', - 'this_month', - 'this_week', - 'throw', - 'throws', - 'today', - 'tolabel', - 'tomorrow', - 'transaction', - 'transient', - 'trigger', - 'true', - 'try', - 'type', - 'undelete', - 'update', - 'upsert', - 'using', - 'virtual', - 'void', - 'volatile', - 'webservice', - 'when', - 'where', - 'while', - 'yesterday' -]; - -// 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); - -let keywordsWithCaseVariations: string[] = []; -keywords.forEach(lowercase => { - keywordsWithCaseVariations.push(lowercase); - keywordsWithCaseVariations.push(lowercase.toUpperCase()); - keywordsWithCaseVariations.push(uppercaseFirstLetter(lowercase)); -}) - -export const language = { - defaultToken: '', - tokenPostfix: '.apex', - - keywords: keywordsWithCaseVariations, - - operators: [ - '=', '>', '<', '!', '~', '?', ':', - '==', '<=', '>=', '!=', '&&', '||', '++', '--', - '+', '-', '*', '/', '&', '|', '^', '%', '<<', - '>>', '>>>', '+=', '-=', '*=', '/=', '&=', '|=', - '^=', '%=', '<<=', '>>=', '>>>=' - ], - - // we include these common regular expressions - symbols: /[=>](?!@symbols)/, '@brackets'], - [/@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)[fFdD]/, 'number.float'], - [/(@digits)[lL]?/, 'number'], - - // delimiter: after number because of .\d floats - [/[;,.]/, 'delimiter'], - - // strings - [/"([^"\\]|\\.)*$/, 'string.invalid' ], // non-teminated string - [/'([^'\\]|\\.)*$/, 'string.invalid' ], // non-teminated string - [/"/, 'string', '@string."' ], - [/'/, 'string', '@string.\'' ], - - - // characters - [/'[^\\']'/, 'string'], - [/(')(@escapes)(')/, ['string', 'string.escape', 'string']], - [/'/, 'string.invalid'] - ], - - whitespace: [ - [/[ \t\r\n]+/, ''], - [/\/\*\*(?!\/)/, 'comment.doc', '@apexdoc'], - [/\/\*/, 'comment', '@comment'], - [/\/\/.*$/, 'comment'], - ], - - comment: [ - [/[^\/*]+/, 'comment'], - // [/\/\*/, 'comment', '@push' ], // nested comment not allowed :-( - // [/\/\*/, 'comment.invalid' ], // this breaks block comments in the shape of /* //*/ - [/\*\//, 'comment', '@pop'], - [/[\/*]/, 'comment'] - ], - - //Identical copy of comment above, except for the addition of .doc - apexdoc: [ - [/[^\/*]+/, 'comment.doc'], - [/\*\//, 'comment.doc', '@pop'], - [/[\/*]/, 'comment.doc'] - ], - - string: [ - [/[^\\"']+/, 'string'], - [/@escapes/, 'string.escape'], - [/\\./, 'string.escape.invalid'], - [/["']/, { cases: { '$#==$S2' : { token: 'string', next: '@pop' }, - '@default': 'string' }} ] - ], - }, -}; +/*--------------------------------------------------------------------------------------------- + * 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 IRichLanguageConfiguration = monaco.languages.LanguageConfiguration; +import ILanguage = monaco.languages.IMonarchLanguage; + +export const conf: IRichLanguageConfiguration = { + // the default separators except `@$` + wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g, + comments: { + lineComment: '//', + blockComment: ['/*', '*/'] + }, + brackets: [ + ['{', '}'], + ['[', ']'], + ['(', ')'] + ], + autoClosingPairs: [ + { 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*//\\s*(?:(?:#?region\\b)|(?:))' + ) + } + } +}; + +const keywords = [ + 'abstract', + 'activate', + 'and', + 'any', + 'array', + 'as', + 'asc', + 'assert', + 'autonomous', + 'begin', + 'bigdecimal', + 'blob', + 'boolean', + 'break', + 'bulk', + 'by', + 'case', + 'cast', + 'catch', + 'char', + 'class', + 'collect', + 'commit', + 'const', + 'continue', + 'convertcurrency', + 'decimal', + 'default', + 'delete', + 'desc', + 'do', + 'double', + 'else', + 'end', + 'enum', + 'exception', + 'exit', + 'export', + 'extends', + 'false', + 'final', + 'finally', + 'float', + 'for', + 'from', + 'future', + 'get', + 'global', + 'goto', + 'group', + 'having', + 'hint', + 'if', + 'implements', + 'import', + 'in', + 'inner', + 'insert', + 'instanceof', + 'int', + 'interface', + 'into', + 'join', + 'last_90_days', + 'last_month', + 'last_n_days', + 'last_week', + 'like', + 'limit', + 'list', + 'long', + 'loop', + 'map', + 'merge', + 'native', + 'new', + 'next_90_days', + 'next_month', + 'next_n_days', + 'next_week', + 'not', + 'null', + 'nulls', + 'number', + 'object', + 'of', + 'on', + 'or', + 'outer', + 'override', + 'package', + 'parallel', + 'pragma', + 'private', + 'protected', + 'public', + 'retrieve', + 'return', + 'returning', + 'rollback', + 'savepoint', + 'search', + 'select', + 'set', + 'short', + 'sort', + 'stat', + 'static', + 'strictfp', + 'super', + 'switch', + 'synchronized', + 'system', + 'testmethod', + 'then', + 'this', + 'this_month', + 'this_week', + 'throw', + 'throws', + 'today', + 'tolabel', + 'tomorrow', + 'transaction', + 'transient', + 'trigger', + 'true', + 'try', + 'type', + 'undelete', + 'update', + 'upsert', + 'using', + 'virtual', + 'void', + 'volatile', + 'webservice', + 'when', + 'where', + 'while', + 'yesterday' +]; + +// 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); + +let keywordsWithCaseVariations: string[] = []; +keywords.forEach((lowercase) => { + keywordsWithCaseVariations.push(lowercase); + keywordsWithCaseVariations.push(lowercase.toUpperCase()); + keywordsWithCaseVariations.push(uppercaseFirstLetter(lowercase)); +}); + +export const language = { + defaultToken: '', + tokenPostfix: '.apex', + + keywords: keywordsWithCaseVariations, + + operators: [ + '=', + '>', + '<', + '!', + '~', + '?', + ':', + '==', + '<=', + '>=', + '!=', + '&&', + '||', + '++', + '--', + '+', + '-', + '*', + '/', + '&', + '|', + '^', + '%', + '<<', + '>>', + '>>>', + '+=', + '-=', + '*=', + '/=', + '&=', + '|=', + '^=', + '%=', + '<<=', + '>>=', + '>>>=' + ], + + // we include these common regular expressions + symbols: /[=>](?!@symbols)/, '@brackets'], + [ + /@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)[fFdD]/, 'number.float'], + [/(@digits)[lL]?/, 'number'], + + // delimiter: after number because of .\d floats + [/[;,.]/, 'delimiter'], + + // strings + [/"([^"\\]|\\.)*$/, 'string.invalid'], // non-teminated string + [/'([^'\\]|\\.)*$/, 'string.invalid'], // non-teminated string + [/"/, 'string', '@string."'], + [/'/, 'string', "@string.'"], + + // characters + [/'[^\\']'/, 'string'], + [/(')(@escapes)(')/, ['string', 'string.escape', 'string']], + [/'/, 'string.invalid'] + ], + + whitespace: [ + [/[ \t\r\n]+/, ''], + [/\/\*\*(?!\/)/, 'comment.doc', '@apexdoc'], + [/\/\*/, 'comment', '@comment'], + [/\/\/.*$/, 'comment'] + ], + + comment: [ + [/[^\/*]+/, 'comment'], + // [/\/\*/, 'comment', '@push' ], // nested comment not allowed :-( + // [/\/\*/, 'comment.invalid' ], // this breaks block comments in the shape of /* //*/ + [/\*\//, 'comment', '@pop'], + [/[\/*]/, 'comment'] + ], + + //Identical copy of comment above, except for the addition of .doc + apexdoc: [ + [/[^\/*]+/, 'comment.doc'], + [/\*\//, 'comment.doc', '@pop'], + [/[\/*]/, 'comment.doc'] + ], + + string: [ + [/[^\\"']+/, 'string'], + [/@escapes/, 'string.escape'], + [/\\./, 'string.escape.invalid'], + [ + /["']/, + { + cases: { + '$#==$S2': { token: 'string', next: '@pop' }, + '@default': 'string' + } + } + ] + ] + } +}; diff --git a/src/azcli/azcli.test.ts b/src/azcli/azcli.test.ts index d1ae3bd3..fc22928a 100644 --- a/src/azcli/azcli.test.ts +++ b/src/azcli/azcli.test.ts @@ -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' }] + } + ] ]); diff --git a/src/azcli/azcli.ts b/src/azcli/azcli.ts index 62bf5740..1b8bda6b 100644 --- a/src/azcli/azcli.ts +++ b/src/azcli/azcli.ts @@ -10,7 +10,7 @@ import ILanguage = monaco.languages.IMonarchLanguage; export const conf: IRichLanguageConfiguration = { comments: { - lineComment: '#', + lineComment: '#' } }; @@ -23,43 +23,58 @@ export const language = { 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' } + } } - }] + ] ] } }; diff --git a/src/bat/bat.test.ts b/src/bat/bat.test.ts index 06d3e26a..dba77e38 100644 --- a/src/bat/bat.test.ts +++ b/src/bat/bat.test.ts @@ -1,384 +1,398 @@ -/*--------------------------------------------------------------------------------------------- - * 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'; - -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: '' } - ] - }], - - // Comments - single line - [{ - 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: 'comment.bat' } - ] - }], - - [{ - line: 'REMnot a comment', - tokens: [ - { startIndex: 0, type: '' } - ] - }], - - // number - [{ - line: '0', - tokens: [ - { startIndex: 0, type: 'number.bat' } - ] - }], - - [{ - line: '0.0', - tokens: [ - { startIndex: 0, type: 'number.float.bat' } - ] - }], - - [{ - line: '0x123', - tokens: [ - { startIndex: 0, type: 'number.hex.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: '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: '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' } - ] - }], - - // 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: '"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 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' } - ] - }] -]); +/*--------------------------------------------------------------------------------------------- + * 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'; + +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: '' } + ] + } + ], + + // Comments - single line + [ + { + 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: 'comment.bat' }] + } + ], + + [ + { + line: 'REMnot a comment', + tokens: [{ startIndex: 0, type: '' }] + } + ], + + // number + [ + { + line: '0', + tokens: [{ startIndex: 0, type: 'number.bat' }] + } + ], + + [ + { + line: '0.0', + tokens: [{ startIndex: 0, type: 'number.float.bat' }] + } + ], + + [ + { + line: '0x123', + tokens: [{ startIndex: 0, type: 'number.hex.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: '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: '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' } + ] + } + ], + + // 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: '"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 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' }] + } + ] +]); diff --git a/src/bat/bat.ts b/src/bat/bat.ts index 69408bab..692c6571 100644 --- a/src/bat/bat.ts +++ b/src/bat/bat.ts @@ -1,119 +1,126 @@ -/*--------------------------------------------------------------------------------------------- - * 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 IRichLanguageConfiguration = monaco.languages.LanguageConfiguration; -import ILanguage = monaco.languages.IMonarchLanguage; - -export const conf: IRichLanguageConfiguration = { - comments: { - lineComment: 'REM' - }, - brackets: [ - ['{', '}'], - ['[', ']'], - ['(', ')'] - ], - autoClosingPairs: [ - { open: '{', close: '}' }, - { open: '[', close: ']' }, - { open: '(', close: ')' }, - { open: '"', close: '"' }, - ], - surroundingPairs: [ - { open: '[', close: ']' }, - { open: '(', close: ')' }, - { open: '"', close: '"' }, - ], - folding: { - markers: { - start: new RegExp("^\\s*(::\\s*|REM\\s+)#region"), - end: new RegExp("^\\s*(::\\s*|REM\\s+)#endregion") - } - } -}; - -export const language = { - defaultToken: '', - ignoreCase: true, - tokenPostfix: '.bat', - - brackets: [ - { token: 'delimiter.bracket', open: '{', close: '}' }, - { token: 'delimiter.parenthesis', open: '(', close: ')' }, - { token: 'delimiter.square', open: '[', close: ']' } - ], - - keywords: /call|defined|echo|errorlevel|exist|for|goto|if|pause|set|shift|start|title|not|pushd|popd/, - - // we include these common regular expressions - symbols: /[=>{ + defaultToken: '', + ignoreCase: true, + tokenPostfix: '.bat', + + brackets: [ + { token: 'delimiter.bracket', open: '{', close: '}' }, + { token: 'delimiter.parenthesis', open: '(', close: ')' }, + { token: 'delimiter.square', open: '[', close: ']' } + ], + + keywords: /call|defined|echo|errorlevel|exist|for|goto|if|pause|set|shift|start|title|not|pushd|popd/, + + // we include these common regular expressions + symbols: /[=>'], + ['<', '>'] ], 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 = { ], 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 = { 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 = { // 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 = { [/[;,.]/, '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'] + ] + } }; diff --git a/src/clojure/clojure.test.ts b/src/clojure/clojure.test.ts index 8f756b92..e1f3daac 100644 --- a/src/clojure/clojure.test.ts +++ b/src/clojure/clojure.test.ts @@ -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' } ] } ] diff --git a/src/clojure/clojure.ts b/src/clojure/clojure.ts index c8089c4f..db56d16b 100644 --- a/src/clojure/clojure.ts +++ b/src/clojure/clojure.ts @@ -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 = { @@ -40,9 +40,9 @@ export const language = { 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 = { 'set!', 'throw', 'try', - 'var', + 'var' ], coreSymbols: [ '*', - '*\'', + "*'", '*1', '*2', '*3', @@ -117,9 +117,9 @@ export const language = { '*verbose-defrecords*', '*warn-on-reflection*', '+', - '+\'', + "+'", '-', - '-\'', + "-'", '->', '->>', '->ArrayChunk', @@ -259,7 +259,7 @@ export const language = { 'create-struct', 'cycle', 'dec', - 'dec\'', + "dec'", 'decimal?', 'declare', 'dedupe', @@ -381,7 +381,7 @@ export const language = { 'import', 'in-ns', 'inc', - 'inc\'', + "inc'", 'indexed?', 'init-proxy', 'inst-ms', @@ -728,13 +728,13 @@ export const language = { '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 = { [/@characters/, 'string'], // strings - {include: '@string'}, + { include: '@string' }, // brackets [/[()\[\]{}]/, '@brackets'], @@ -755,38 +755,38 @@ export const language = { [/[#'@^`~]/, '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'] - ], - }, + ] + } }; diff --git a/src/coffee/coffee.test.ts b/src/coffee/coffee.test.ts index 51b2ad01..8f821412 100644 --- a/src/coffee/coffee.test.ts +++ b/src/coffee/coffee.test.ts @@ -9,2234 +9,2359 @@ import { testTokenization } from '../test/testRunner'; testTokenization('coffeescript', [ // Comments - [{ - line: '#', - tokens: [ - { startIndex: 0, type: 'comment.coffee' } - ] - }], + [ + { + line: '#', + tokens: [{ startIndex: 0, type: 'comment.coffee' }] + } + ], - [{ - line: ' # a comment', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 4, type: 'comment.coffee' } - ] - }], + [ + { + line: ' # a comment', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 4, type: 'comment.coffee' } + ] + } + ], - [{ - line: '# a comment', - tokens: [ - { startIndex: 0, type: 'comment.coffee' } - ] - }], + [ + { + line: '# a comment', + tokens: [{ startIndex: 0, type: 'comment.coffee' }] + } + ], - [{ - line: '#sticky comment', - tokens: [ - { startIndex: 0, type: 'comment.coffee' } - ] - }], + [ + { + line: '#sticky comment', + tokens: [{ startIndex: 0, type: 'comment.coffee' }] + } + ], - [{ - line: 'x = 1 # my comment # is a nice one', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'delimiter.coffee' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'number.coffee' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'comment.coffee' } - ] - }], + [ + { + line: 'x = 1 # my comment # is a nice one', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'delimiter.coffee' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'number.coffee' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'comment.coffee' } + ] + } + ], - [{ - line: 'x = 1e #is a exponent number', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'delimiter.coffee' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'number.float.coffee' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'comment.coffee' } - ] - }], + [ + { + line: 'x = 1e #is a exponent number', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'delimiter.coffee' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'number.float.coffee' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'comment.coffee' } + ] + } + ], - [{ - line: 'x = 0x1F #is a hex number', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'delimiter.coffee' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'number.hex.coffee' }, - { startIndex: 8, type: '' }, - { startIndex: 9, type: 'comment.coffee' } - ] - }], + [ + { + line: 'x = 0x1F #is a hex number', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'delimiter.coffee' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'number.hex.coffee' }, + { startIndex: 8, type: '' }, + { startIndex: 9, type: 'comment.coffee' } + ] + } + ], // Keywords - [{ - line: 'new x = switch()', - tokens: [ - { startIndex: 0, type: 'keyword.new.coffee' }, - { startIndex: 3, type: '' }, - { startIndex: 6, type: 'delimiter.coffee' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'keyword.switch.coffee' }, - { startIndex: 14, type: 'delimiter.parenthesis.coffee' } - ] - }], + [ + { + line: 'new x = switch()', + tokens: [ + { startIndex: 0, type: 'keyword.new.coffee' }, + { startIndex: 3, type: '' }, + { startIndex: 6, type: 'delimiter.coffee' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'keyword.switch.coffee' }, + { startIndex: 14, type: 'delimiter.parenthesis.coffee' } + ] + } + ], - [{ - line: '@test [do]', - tokens: [ - { startIndex: 0, type: 'variable.predefined.coffee' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'delimiter.square.coffee' }, - { startIndex: 7, type: 'keyword.do.coffee' }, - { startIndex: 9, type: 'delimiter.square.coffee' } - ] - }], + [ + { + line: '@test [do]', + tokens: [ + { startIndex: 0, type: 'variable.predefined.coffee' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'delimiter.square.coffee' }, + { startIndex: 7, type: 'keyword.do.coffee' }, + { startIndex: 9, type: 'delimiter.square.coffee' } + ] + } + ], - [{ - line: 'this do', - tokens: [ - { startIndex: 0, type: 'variable.predefined.coffee' }, - { startIndex: 4, type: '' }, - { startIndex: 5, type: 'keyword.do.coffee' } - ] - }], + [ + { + line: 'this do', + tokens: [ + { startIndex: 0, type: 'variable.predefined.coffee' }, + { startIndex: 4, type: '' }, + { startIndex: 5, type: 'keyword.do.coffee' } + ] + } + ], - [{ - line: ' new ', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 4, type: 'keyword.new.coffee' }, - { startIndex: 7, type: '' } - ] - }], + [ + { + line: ' new ', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 4, type: 'keyword.new.coffee' }, + { startIndex: 7, type: '' } + ] + } + ], // Comments - range comment, single line - [{ - line: '### a simple comment ###', - tokens: [ - { startIndex: 0, type: 'comment.coffee' } - ] - }], + [ + { + line: '### a simple comment ###', + tokens: [{ startIndex: 0, type: 'comment.coffee' }] + } + ], - [{ - line: 'new x = ### a simple comment ### 1', - tokens: [ - { startIndex: 0, type: 'keyword.new.coffee' }, - { startIndex: 3, type: '' }, - { startIndex: 6, type: 'delimiter.coffee' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'comment.coffee' }, - { startIndex: 32, type: '' }, - { startIndex: 33, type: 'number.coffee' } - ] - }], + [ + { + line: 'new x = ### a simple comment ### 1', + tokens: [ + { startIndex: 0, type: 'keyword.new.coffee' }, + { startIndex: 3, type: '' }, + { startIndex: 6, type: 'delimiter.coffee' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'comment.coffee' }, + { startIndex: 32, type: '' }, + { startIndex: 33, type: 'number.coffee' } + ] + } + ], - [{ - line: 'new x = ### comment ### 1 ###', - tokens: [ - { startIndex: 0, type: 'keyword.new.coffee' }, - { startIndex: 3, type: '' }, - { startIndex: 6, type: 'delimiter.coffee' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'comment.coffee' }, - { startIndex: 23, type: '' }, - { startIndex: 24, type: 'number.coffee' }, - { startIndex: 25, type: '' }, - { startIndex: 26, type: 'comment.coffee' } - ] - }], + [ + { + line: 'new x = ### comment ### 1 ###', + tokens: [ + { startIndex: 0, type: 'keyword.new.coffee' }, + { startIndex: 3, type: '' }, + { startIndex: 6, type: 'delimiter.coffee' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'comment.coffee' }, + { startIndex: 23, type: '' }, + { startIndex: 24, type: 'number.coffee' }, + { startIndex: 25, type: '' }, + { startIndex: 26, type: 'comment.coffee' } + ] + } + ], - [{ - line: 'x = ######s', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'delimiter.coffee' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'comment.coffee' }, - { startIndex: 10, type: '' } - ] - }], + [ + { + line: 'x = ######s', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'delimiter.coffee' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'comment.coffee' }, + { startIndex: 10, type: '' } + ] + } + ], - [{ - line: 'x = ###/', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'delimiter.coffee' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'comment.coffee' } - ] - }], + [ + { + line: 'x = ###/', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'delimiter.coffee' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'comment.coffee' } + ] + } + ], // Comments - range comment, multi lines - [{ - line: '### a multiline comment', - tokens: [ - { startIndex: 0, type: 'comment.coffee' } - ] - }, { - line: 'can actually span', - tokens: [ - { startIndex: 0, type: 'comment.coffee' } - ] - }, { - line: 'multiple lines ###', - tokens: [ - { startIndex: 0, type: 'comment.coffee' } - ] - }], + [ + { + line: '### a multiline comment', + tokens: [{ startIndex: 0, type: 'comment.coffee' }] + }, + { + line: 'can actually span', + tokens: [{ startIndex: 0, type: 'comment.coffee' }] + }, + { + line: 'multiple lines ###', + tokens: [{ startIndex: 0, type: 'comment.coffee' }] + } + ], - [{ - line: 'new x = ### start a comment', - tokens: [ - { startIndex: 0, type: 'keyword.new.coffee' }, - { startIndex: 3, type: '' }, - { startIndex: 6, type: 'delimiter.coffee' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'comment.coffee' } - ] - }, { - line: ' a ', - tokens: [ - { startIndex: 0, type: 'comment.coffee' } - ] - }, { - line: 'and end it ### new a = 2;', - tokens: [ - { startIndex: 0, type: 'comment.coffee' }, - { startIndex: 14, type: '' }, - { startIndex: 15, type: 'keyword.new.coffee' }, - { startIndex: 18, type: '' }, - { startIndex: 21, type: 'delimiter.coffee' }, - { startIndex: 22, type: '' }, - { startIndex: 23, type: 'number.coffee' }, - { startIndex: 24, type: '' } - ] - }], + [ + { + line: 'new x = ### start a comment', + tokens: [ + { startIndex: 0, type: 'keyword.new.coffee' }, + { startIndex: 3, type: '' }, + { startIndex: 6, type: 'delimiter.coffee' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'comment.coffee' } + ] + }, + { + line: ' a ', + tokens: [{ startIndex: 0, type: 'comment.coffee' }] + }, + { + line: 'and end it ### new a = 2;', + tokens: [ + { startIndex: 0, type: 'comment.coffee' }, + { startIndex: 14, type: '' }, + { startIndex: 15, type: 'keyword.new.coffee' }, + { startIndex: 18, type: '' }, + { startIndex: 21, type: 'delimiter.coffee' }, + { startIndex: 22, type: '' }, + { startIndex: 23, type: 'number.coffee' }, + { startIndex: 24, type: '' } + ] + } + ], // Block Strings - [{ - line: 'b(\'\'\'asdads\'\'\')', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 1, type: 'delimiter.parenthesis.coffee' }, - { startIndex: 2, type: 'string.coffee' }, - { startIndex: 14, type: 'delimiter.parenthesis.coffee' } - ] - }], + [ + { + line: "b('''asdads''')", + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 1, type: 'delimiter.parenthesis.coffee' }, + { startIndex: 2, type: 'string.coffee' }, + { startIndex: 14, type: 'delimiter.parenthesis.coffee' } + ] + } + ], - [{ - line: 'foo(""" var i = \'foo\'; """)', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 3, type: 'delimiter.parenthesis.coffee' }, - { startIndex: 4, type: 'string.coffee' }, - { startIndex: 26, type: 'delimiter.parenthesis.coffee' } - ] - }], + [ + { + line: 'foo(""" var i = \'foo\'; """)', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 3, type: 'delimiter.parenthesis.coffee' }, + { startIndex: 4, type: 'string.coffee' }, + { startIndex: 26, type: 'delimiter.parenthesis.coffee' } + ] + } + ], // Strings - [{ - line: 'for a = \'a\';', - tokens: [ - { startIndex: 0, type: 'keyword.for.coffee' }, - { startIndex: 3, type: '' }, - { startIndex: 6, type: 'delimiter.coffee' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'string.coffee' }, - { startIndex: 11, type: '' } - ] - }], + [ + { + line: "for a = 'a';", + tokens: [ + { startIndex: 0, type: 'keyword.for.coffee' }, + { startIndex: 3, type: '' }, + { startIndex: 6, type: 'delimiter.coffee' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'string.coffee' }, + { startIndex: 11, type: '' } + ] + } + ], - [{ - line: '"use strict";', - tokens: [ - { startIndex: 0, type: 'string.coffee' }, - { startIndex: 12, type: '' } - ] - }], + [ + { + line: '"use strict";', + tokens: [ + { startIndex: 0, type: 'string.coffee' }, + { startIndex: 12, type: '' } + ] + } + ], - [{ - line: 'b = a + " \'cool\' "', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'delimiter.coffee' }, - { startIndex: 3, type: '' }, - { startIndex: 6, type: 'delimiter.coffee' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'string.coffee' } - ] - }], + [ + { + line: 'b = a + " \'cool\' "', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'delimiter.coffee' }, + { startIndex: 3, type: '' }, + { startIndex: 6, type: 'delimiter.coffee' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'string.coffee' } + ] + } + ], - [{ - line: '"escaping \\"quotes\\" is cool"', - tokens: [ - { startIndex: 0, type: 'string.coffee' }, - { startIndex: 10, type: 'string.escape.coffee' }, - { startIndex: 12, type: 'string.coffee' }, - { startIndex: 18, type: 'string.escape.coffee' }, - { startIndex: 20, type: 'string.coffee' } - ] - }], + [ + { + line: '"escaping \\"quotes\\" is cool"', + tokens: [ + { startIndex: 0, type: 'string.coffee' }, + { startIndex: 10, type: 'string.escape.coffee' }, + { startIndex: 12, type: 'string.coffee' }, + { startIndex: 18, type: 'string.escape.coffee' }, + { startIndex: 20, type: 'string.coffee' } + ] + } + ], - [{ - line: '\'\'\'', - tokens: [ - { startIndex: 0, type: 'string.coffee' } - ] - }], + [ + { + line: "'''", + tokens: [{ startIndex: 0, type: 'string.coffee' }] + } + ], - [{ - line: '\'\\\'\'', - tokens: [ - { startIndex: 0, type: 'string.coffee' }, - { startIndex: 1, type: 'string.escape.coffee' }, - { startIndex: 3, type: 'string.coffee' } - ] - }], + [ + { + line: "'\\''", + tokens: [ + { startIndex: 0, type: 'string.coffee' }, + { startIndex: 1, type: 'string.escape.coffee' }, + { startIndex: 3, type: 'string.coffee' } + ] + } + ], - [{ - line: '\'be careful \\not to escape\'', - tokens: [ - { startIndex: 0, type: 'string.coffee' }, - { startIndex: 12, type: 'string.escape.coffee' }, - { startIndex: 14, type: 'string.coffee' } - ] - }], + [ + { + line: "'be careful \\not to escape'", + tokens: [ + { startIndex: 0, type: 'string.coffee' }, + { startIndex: 12, type: 'string.escape.coffee' }, + { startIndex: 14, type: 'string.coffee' } + ] + } + ], // Strings - multiline - [{ - line: '\'a multiline string', - tokens: [ - { startIndex: 0, type: 'string.coffee' } - ] - }, { - line: 'second line', - tokens: [ - { startIndex: 0, type: 'string.coffee' } - ] - }], + [ + { + line: "'a multiline string", + tokens: [{ startIndex: 0, type: 'string.coffee' }] + }, + { + line: 'second line', + tokens: [{ startIndex: 0, type: 'string.coffee' }] + } + ], // Strings - with nested code - [{ - line: '"for a = \'a\'; #{ new } works"', - tokens: [ - { startIndex: 0, type: 'string.coffee' }, - { startIndex: 16, type: '' }, - { startIndex: 17, type: 'keyword.new.coffee' }, - { startIndex: 20, type: '' }, - { startIndex: 21, type: 'string.coffee' } - ] - }], + [ + { + line: '"for a = \'a\'; #{ new } works"', + tokens: [ + { startIndex: 0, type: 'string.coffee' }, + { startIndex: 16, type: '' }, + { startIndex: 17, type: 'keyword.new.coffee' }, + { startIndex: 20, type: '' }, + { startIndex: 21, type: 'string.coffee' } + ] + } + ], - [{ - line: '"a comment with nested code #{ 2 / 3 } works"', - tokens: [ - { startIndex: 0, type: 'string.coffee' }, - { startIndex: 30, type: '' }, - { startIndex: 31, type: 'number.coffee' }, - { startIndex: 32, type: '' }, - { startIndex: 33, type: 'delimiter.coffee' }, - { startIndex: 34, type: '' }, - { startIndex: 35, type: 'number.coffee' }, - { startIndex: 36, type: '' }, - { startIndex: 37, type: 'string.coffee' } - ] - }], + [ + { + line: '"a comment with nested code #{ 2 / 3 } works"', + tokens: [ + { startIndex: 0, type: 'string.coffee' }, + { startIndex: 30, type: '' }, + { startIndex: 31, type: 'number.coffee' }, + { startIndex: 32, type: '' }, + { startIndex: 33, type: 'delimiter.coffee' }, + { startIndex: 34, type: '' }, + { startIndex: 35, type: 'number.coffee' }, + { startIndex: 36, type: '' }, + { startIndex: 37, type: 'string.coffee' } + ] + } + ], // Numbers - [{ - line: '0', - tokens: [ - { startIndex: 0, type: 'number.coffee' } - ] - }], + [ + { + line: '0', + tokens: [{ startIndex: 0, type: 'number.coffee' }] + } + ], - [{ - line: ' 0', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 1, type: 'number.coffee' } - ] - }], + [ + { + line: ' 0', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 1, type: 'number.coffee' } + ] + } + ], - [{ - line: ' 0 ', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 1, type: 'number.coffee' }, - { startIndex: 2, type: '' } - ] - }], + [ + { + line: ' 0 ', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 1, type: 'number.coffee' }, + { startIndex: 2, type: '' } + ] + } + ], - [{ - line: '0 ', - tokens: [ - { startIndex: 0, type: 'number.coffee' }, - { startIndex: 1, type: '' } - ] - }], + [ + { + line: '0 ', + tokens: [ + { startIndex: 0, type: 'number.coffee' }, + { startIndex: 1, type: '' } + ] + } + ], - [{ - line: '0+0', - tokens: [ - { startIndex: 0, type: 'number.coffee' }, - { startIndex: 1, type: 'delimiter.coffee' }, - { startIndex: 2, type: 'number.coffee' } - ] - }], + [ + { + line: '0+0', + tokens: [ + { startIndex: 0, type: 'number.coffee' }, + { startIndex: 1, type: 'delimiter.coffee' }, + { startIndex: 2, type: 'number.coffee' } + ] + } + ], - [{ - line: '100+10', - tokens: [ - { startIndex: 0, type: 'number.coffee' }, - { startIndex: 3, type: 'delimiter.coffee' }, - { startIndex: 4, type: 'number.coffee' } - ] - }], + [ + { + line: '100+10', + tokens: [ + { startIndex: 0, type: 'number.coffee' }, + { startIndex: 3, type: 'delimiter.coffee' }, + { startIndex: 4, type: 'number.coffee' } + ] + } + ], - [{ - line: '0 + 0', - tokens: [ - { startIndex: 0, type: 'number.coffee' }, - { startIndex: 1, type: '' }, - { startIndex: 2, type: 'delimiter.coffee' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'number.coffee' } - ] - }], + [ + { + line: '0 + 0', + tokens: [ + { startIndex: 0, type: 'number.coffee' }, + { startIndex: 1, type: '' }, + { startIndex: 2, type: 'delimiter.coffee' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'number.coffee' } + ] + } + ], - [{ - line: '0123', - tokens: [ - { startIndex: 0, type: 'number.octal.coffee' } - ] - }], + [ + { + line: '0123', + tokens: [{ startIndex: 0, type: 'number.octal.coffee' }] + } + ], - [{ - line: '01239', - tokens: [ - { startIndex: 0, type: 'number.coffee' } - ] - }], + [ + { + line: '01239', + tokens: [{ startIndex: 0, type: 'number.coffee' }] + } + ], - [{ - line: '0x123', - tokens: [ - { startIndex: 0, type: 'number.hex.coffee' } - ] - }], + [ + { + line: '0x123', + tokens: [{ startIndex: 0, type: 'number.hex.coffee' }] + } + ], - [{ - line: '[1,2,3]', - tokens: [ - { startIndex: 0, type: 'delimiter.square.coffee' }, - { startIndex: 1, type: 'number.coffee' }, - { startIndex: 2, type: 'delimiter.coffee' }, - { startIndex: 3, type: 'number.coffee' }, - { startIndex: 4, type: 'delimiter.coffee' }, - { startIndex: 5, type: 'number.coffee' }, - { startIndex: 6, type: 'delimiter.square.coffee' } - ] - }], + [ + { + line: '[1,2,3]', + tokens: [ + { startIndex: 0, type: 'delimiter.square.coffee' }, + { startIndex: 1, type: 'number.coffee' }, + { startIndex: 2, type: 'delimiter.coffee' }, + { startIndex: 3, type: 'number.coffee' }, + { startIndex: 4, type: 'delimiter.coffee' }, + { startIndex: 5, type: 'number.coffee' }, + { startIndex: 6, type: 'delimiter.square.coffee' } + ] + } + ], - [{ - line: 'foo(123);', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 3, type: 'delimiter.parenthesis.coffee' }, - { startIndex: 4, type: 'number.coffee' }, - { startIndex: 7, type: 'delimiter.parenthesis.coffee' }, - { startIndex: 8, type: '' } - ] - }], + [ + { + line: 'foo(123);', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 3, type: 'delimiter.parenthesis.coffee' }, + { startIndex: 4, type: 'number.coffee' }, + { startIndex: 7, type: 'delimiter.parenthesis.coffee' }, + { startIndex: 8, type: '' } + ] + } + ], - [{ - line: '(a:(b:[]))', - tokens: [ - { startIndex: 0, type: 'delimiter.parenthesis.coffee' }, - { startIndex: 1, type: '' }, - { startIndex: 2, type: 'delimiter.coffee' }, - { startIndex: 3, type: 'delimiter.parenthesis.coffee' }, - { startIndex: 4, type: '' }, - { startIndex: 5, type: 'delimiter.coffee' }, - { startIndex: 6, type: 'delimiter.square.coffee' }, - { startIndex: 8, type: 'delimiter.parenthesis.coffee' } - ] - }], + [ + { + line: '(a:(b:[]))', + tokens: [ + { startIndex: 0, type: 'delimiter.parenthesis.coffee' }, + { startIndex: 1, type: '' }, + { startIndex: 2, type: 'delimiter.coffee' }, + { startIndex: 3, type: 'delimiter.parenthesis.coffee' }, + { startIndex: 4, type: '' }, + { startIndex: 5, type: 'delimiter.coffee' }, + { startIndex: 6, type: 'delimiter.square.coffee' }, + { startIndex: 8, type: 'delimiter.parenthesis.coffee' } + ] + } + ], - [{ - line: 'x = \'[{()}]\'', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'delimiter.coffee' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'string.coffee' } - ] - }], + [ + { + line: "x = '[{()}]'", + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'delimiter.coffee' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'string.coffee' } + ] + } + ], // Regular Expressions - [{ - line: '#', - tokens: [ - { startIndex: 0, type: 'comment.coffee' } - ] - }], + [ + { + line: '#', + tokens: [{ startIndex: 0, type: 'comment.coffee' }] + } + ], - [{ - line: '/ /', - tokens: [ - { startIndex: 0, type: 'regexp.coffee' } - ] - }], + [ + { + line: '/ /', + tokens: [{ startIndex: 0, type: 'regexp.coffee' }] + } + ], - [{ - line: '/abc\\/asd/', - tokens: [ - { startIndex: 0, type: 'regexp.coffee' } - ] - }], + [ + { + line: '/abc\\/asd/', + tokens: [{ startIndex: 0, type: 'regexp.coffee' }] + } + ], - [{ - line: 'new r = /sweet"regular exp" \\/ cool/;', - tokens: [ - { startIndex: 0, type: 'keyword.new.coffee' }, - { startIndex: 3, type: '' }, - { startIndex: 6, type: 'delimiter.coffee' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'regexp.coffee' }, - { startIndex: 36, type: '' } - ] - }], + [ + { + line: 'new r = /sweet"regular exp" \\/ cool/;', + tokens: [ + { startIndex: 0, type: 'keyword.new.coffee' }, + { startIndex: 3, type: '' }, + { startIndex: 6, type: 'delimiter.coffee' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'regexp.coffee' }, + { startIndex: 36, type: '' } + ] + } + ], - [{ - line: '5 / 3;', - tokens: [ - { startIndex: 0, type: 'number.coffee' }, - { startIndex: 1, type: '' }, - { startIndex: 2, type: 'delimiter.coffee' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'number.coffee' }, - { startIndex: 5, type: '' } - ] - }], + [ + { + line: '5 / 3;', + tokens: [ + { startIndex: 0, type: 'number.coffee' }, + { startIndex: 1, type: '' }, + { startIndex: 2, type: 'delimiter.coffee' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'number.coffee' }, + { startIndex: 5, type: '' } + ] + } + ], // Regex - range regex, multi lines - [{ - line: '/// a multiline regex', - tokens: [ - { startIndex: 0, type: 'regexp.coffee' } - ] - }, { - line: 'can actually span', - tokens: [ - { startIndex: 0, type: 'regexp.coffee' } - ] - }, { - line: 'multiplelines with # comments', - tokens: [ - { startIndex: 0, type: 'regexp.coffee' }, - { startIndex: 19, type: 'comment.coffee' } - ] - }, { - line: 'multiple lines ///', - tokens: [ - { startIndex: 0, type: 'regexp.coffee' } - ] - }], + [ + { + line: '/// a multiline regex', + tokens: [{ startIndex: 0, type: 'regexp.coffee' }] + }, + { + line: 'can actually span', + tokens: [{ startIndex: 0, type: 'regexp.coffee' }] + }, + { + line: 'multiplelines with # comments', + tokens: [ + { startIndex: 0, type: 'regexp.coffee' }, + { startIndex: 19, type: 'comment.coffee' } + ] + }, + { + line: 'multiple lines ///', + tokens: [{ startIndex: 0, type: 'regexp.coffee' }] + } + ], // Regex - multi lines followed by #comment - [{ - line: '///', - tokens: [ - { startIndex: 0, type: 'regexp.coffee' } - ] - }, { - line: '#comment', - tokens: [ - { startIndex: 0, type: 'comment.coffee' } - ] - }], + [ + { + line: '///', + tokens: [{ startIndex: 0, type: 'regexp.coffee' }] + }, + { + line: '#comment', + tokens: [{ startIndex: 0, type: 'comment.coffee' }] + } + ], // Advanced regular expressions - [{ - line: '1 / 2; # comment', - tokens: [ - { startIndex: 0, type: 'number.coffee' }, - { startIndex: 1, type: '' }, - { startIndex: 2, type: 'delimiter.coffee' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'number.coffee' }, - { startIndex: 5, type: '' }, - { startIndex: 7, type: 'comment.coffee' } - ] - }], + [ + { + line: '1 / 2; # comment', + tokens: [ + { startIndex: 0, type: 'number.coffee' }, + { startIndex: 1, type: '' }, + { startIndex: 2, type: 'delimiter.coffee' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'number.coffee' }, + { startIndex: 5, type: '' }, + { startIndex: 7, type: 'comment.coffee' } + ] + } + ], - [{ - line: '1 / 2 / x / b;', - tokens: [ - { startIndex: 0, type: 'number.coffee' }, - { startIndex: 1, type: '' }, - { startIndex: 2, type: 'delimiter.coffee' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'number.coffee' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'delimiter.coffee' }, - { startIndex: 7, type: '' }, - { startIndex: 10, type: 'delimiter.coffee' }, - { startIndex: 11, type: '' } - ] - }], + [ + { + line: '1 / 2 / x / b;', + tokens: [ + { startIndex: 0, type: 'number.coffee' }, + { startIndex: 1, type: '' }, + { startIndex: 2, type: 'delimiter.coffee' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'number.coffee' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'delimiter.coffee' }, + { startIndex: 7, type: '' }, + { startIndex: 10, type: 'delimiter.coffee' }, + { startIndex: 11, type: '' } + ] + } + ], - [{ - line: 'a /ads/ b;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'delimiter.coffee' }, - { startIndex: 3, type: '' }, - { startIndex: 6, type: 'delimiter.coffee' }, - { startIndex: 7, type: '' } - ] - }], + [ + { + line: 'a /ads/ b;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'delimiter.coffee' }, + { startIndex: 3, type: '' }, + { startIndex: 6, type: 'delimiter.coffee' }, + { startIndex: 7, type: '' } + ] + } + ], - [{ - line: 'x = /foo/.test(\'\')', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'delimiter.coffee' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'regexp.coffee' }, - { startIndex: 9, type: 'delimiter.coffee' }, - { startIndex: 10, type: '' }, - { startIndex: 14, type: 'delimiter.parenthesis.coffee' }, - { startIndex: 15, type: 'string.coffee' }, - { startIndex: 17, type: 'delimiter.parenthesis.coffee' } - ] - }], + [ + { + line: "x = /foo/.test('')", + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'delimiter.coffee' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'regexp.coffee' }, + { startIndex: 9, type: 'delimiter.coffee' }, + { startIndex: 10, type: '' }, + { startIndex: 14, type: 'delimiter.parenthesis.coffee' }, + { startIndex: 15, type: 'string.coffee' }, + { startIndex: 17, type: 'delimiter.parenthesis.coffee' } + ] + } + ], - [{ - line: 'x = 1 + f(2 / 3, /foo/)', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'delimiter.coffee' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'number.coffee' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'delimiter.coffee' }, - { startIndex: 7, type: '' }, - { startIndex: 9, type: 'delimiter.parenthesis.coffee' }, - { startIndex: 10, type: 'number.coffee' }, - { startIndex: 11, type: '' }, - { startIndex: 12, type: 'delimiter.coffee' }, - { startIndex: 13, type: '' }, - { startIndex: 14, type: 'number.coffee' }, - { startIndex: 15, type: 'delimiter.coffee' }, - { startIndex: 16, type: '' }, - { startIndex: 17, type: 'regexp.coffee' }, - { startIndex: 22, type: 'delimiter.parenthesis.coffee' } - ] - }], + [ + { + line: 'x = 1 + f(2 / 3, /foo/)', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'delimiter.coffee' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'number.coffee' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'delimiter.coffee' }, + { startIndex: 7, type: '' }, + { startIndex: 9, type: 'delimiter.parenthesis.coffee' }, + { startIndex: 10, type: 'number.coffee' }, + { startIndex: 11, type: '' }, + { startIndex: 12, type: 'delimiter.coffee' }, + { startIndex: 13, type: '' }, + { startIndex: 14, type: 'number.coffee' }, + { startIndex: 15, type: 'delimiter.coffee' }, + { startIndex: 16, type: '' }, + { startIndex: 17, type: 'regexp.coffee' }, + { startIndex: 22, type: 'delimiter.parenthesis.coffee' } + ] + } + ], - [{ - line: '1/(2/3)/2/3;', - tokens: [ - { startIndex: 0, type: 'number.coffee' }, - { startIndex: 1, type: 'delimiter.coffee' }, - { startIndex: 2, type: 'delimiter.parenthesis.coffee' }, - { startIndex: 3, type: 'number.coffee' }, - { startIndex: 4, type: 'delimiter.coffee' }, - { startIndex: 5, type: 'number.coffee' }, - { startIndex: 6, type: 'delimiter.parenthesis.coffee' }, - { startIndex: 7, type: 'delimiter.coffee' }, - { startIndex: 8, type: 'number.coffee' }, - { startIndex: 9, type: 'delimiter.coffee' }, - { startIndex: 10, type: 'number.coffee' }, - { startIndex: 11, type: '' } - ] - }], + [ + { + line: '1/(2/3)/2/3;', + tokens: [ + { startIndex: 0, type: 'number.coffee' }, + { startIndex: 1, type: 'delimiter.coffee' }, + { startIndex: 2, type: 'delimiter.parenthesis.coffee' }, + { startIndex: 3, type: 'number.coffee' }, + { startIndex: 4, type: 'delimiter.coffee' }, + { startIndex: 5, type: 'number.coffee' }, + { startIndex: 6, type: 'delimiter.parenthesis.coffee' }, + { startIndex: 7, type: 'delimiter.coffee' }, + { startIndex: 8, type: 'number.coffee' }, + { startIndex: 9, type: 'delimiter.coffee' }, + { startIndex: 10, type: 'number.coffee' }, + { startIndex: 11, type: '' } + ] + } + ], - [{ - line: '{ key: 123 }', - tokens: [ - { startIndex: 0, type: 'delimiter.curly.coffee' }, - { startIndex: 1, type: '' }, - { startIndex: 5, type: 'delimiter.coffee' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'number.coffee' }, - { startIndex: 10, type: '' }, - { startIndex: 11, type: 'delimiter.curly.coffee' } - ] - }], + [ + { + line: '{ key: 123 }', + tokens: [ + { startIndex: 0, type: 'delimiter.curly.coffee' }, + { startIndex: 1, type: '' }, + { startIndex: 5, type: 'delimiter.coffee' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'number.coffee' }, + { startIndex: 10, type: '' }, + { startIndex: 11, type: 'delimiter.curly.coffee' } + ] + } + ], - [{ - line: '[1,2,3]', - tokens: [ - { startIndex: 0, type: 'delimiter.square.coffee' }, - { startIndex: 1, type: 'number.coffee' }, - { startIndex: 2, type: 'delimiter.coffee' }, - { startIndex: 3, type: 'number.coffee' }, - { startIndex: 4, type: 'delimiter.coffee' }, - { startIndex: 5, type: 'number.coffee' }, - { startIndex: 6, type: 'delimiter.square.coffee' } - ] - }], + [ + { + line: '[1,2,3]', + tokens: [ + { startIndex: 0, type: 'delimiter.square.coffee' }, + { startIndex: 1, type: 'number.coffee' }, + { startIndex: 2, type: 'delimiter.coffee' }, + { startIndex: 3, type: 'number.coffee' }, + { startIndex: 4, type: 'delimiter.coffee' }, + { startIndex: 5, type: 'number.coffee' }, + { startIndex: 6, type: 'delimiter.square.coffee' } + ] + } + ], - [{ - line: 'foo(123);', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 3, type: 'delimiter.parenthesis.coffee' }, - { startIndex: 4, type: 'number.coffee' }, - { startIndex: 7, type: 'delimiter.parenthesis.coffee' }, - { startIndex: 8, type: '' } - ] - }], + [ + { + line: 'foo(123);', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 3, type: 'delimiter.parenthesis.coffee' }, + { startIndex: 4, type: 'number.coffee' }, + { startIndex: 7, type: 'delimiter.parenthesis.coffee' }, + { startIndex: 8, type: '' } + ] + } + ], - [{ - line: '{a:{b:[]}}', - tokens: [ - { startIndex: 0, type: 'delimiter.curly.coffee' }, - { startIndex: 1, type: '' }, - { startIndex: 2, type: 'delimiter.coffee' }, - { startIndex: 3, type: 'delimiter.curly.coffee' }, - { startIndex: 4, type: '' }, - { startIndex: 5, type: 'delimiter.coffee' }, - { startIndex: 6, type: 'delimiter.square.coffee' }, - { startIndex: 8, type: 'delimiter.curly.coffee' } - ] - }], + [ + { + line: '{a:{b:[]}}', + tokens: [ + { startIndex: 0, type: 'delimiter.curly.coffee' }, + { startIndex: 1, type: '' }, + { startIndex: 2, type: 'delimiter.coffee' }, + { startIndex: 3, type: 'delimiter.curly.coffee' }, + { startIndex: 4, type: '' }, + { startIndex: 5, type: 'delimiter.coffee' }, + { startIndex: 6, type: 'delimiter.square.coffee' }, + { startIndex: 8, type: 'delimiter.curly.coffee' } + ] + } + ], - [{ - line: 'x = \'[{()}]\'', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'delimiter.coffee' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'string.coffee' } - ] - }], + [ + { + line: "x = '[{()}]'", + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'delimiter.coffee' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'string.coffee' } + ] + } + ], // syntax highligting issue with {} - bug 16176 - [{ - line: '"/api/v2/course/#{ $stateParams.courseId }/grading/student/#{$stateParams.studentId}",', - tokens: [ - { startIndex: 0, type: 'string.coffee' }, - { startIndex: 18, type: '' }, - { startIndex: 31, type: 'delimiter.coffee' }, - { startIndex: 32, type: '' }, - { startIndex: 41, type: 'string.coffee' }, - { startIndex: 61, type: '' }, - { startIndex: 73, type: 'delimiter.coffee' }, - { startIndex: 74, type: '' }, - { startIndex: 83, type: 'string.coffee' }, - { startIndex: 85, type: 'delimiter.coffee' } - ] - }], + [ + { + line: + '"/api/v2/course/#{ $stateParams.courseId }/grading/student/#{$stateParams.studentId}",', + tokens: [ + { startIndex: 0, type: 'string.coffee' }, + { startIndex: 18, type: '' }, + { startIndex: 31, type: 'delimiter.coffee' }, + { startIndex: 32, type: '' }, + { startIndex: 41, type: 'string.coffee' }, + { startIndex: 61, type: '' }, + { startIndex: 73, type: 'delimiter.coffee' }, + { startIndex: 74, type: '' }, + { startIndex: 83, type: 'string.coffee' }, + { startIndex: 85, type: 'delimiter.coffee' } + ] + } + ], // Generated from sample - [{ - line: '# Assignment:', - tokens: [ - { startIndex: 0, type: 'comment.coffee' } - ] - }, { - line: 'number = 42', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 9, type: 'delimiter.coffee' }, - { startIndex: 10, type: '' }, - { startIndex: 11, type: 'number.coffee' } - ] - }, { - line: 'opposite = true', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 9, type: 'delimiter.coffee' }, - { startIndex: 10, type: '' }, - { startIndex: 11, type: 'keyword.true.coffee' } - ] - }, { - line: '', - tokens: [ - - ] - }, { - line: '# Conditions:', - tokens: [ - { startIndex: 0, type: 'comment.coffee' } - ] - }, { - line: 'number = -42 if opposite', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 7, type: 'delimiter.coffee' }, - { startIndex: 8, type: '' }, - { startIndex: 9, type: 'delimiter.coffee' }, - { startIndex: 10, type: 'number.coffee' }, - { startIndex: 12, type: '' }, - { startIndex: 13, type: 'keyword.if.coffee' }, - { startIndex: 15, type: '' } - ] - }, { - line: '', - tokens: [ - - ] - }, { - line: '# Functions:', - tokens: [ - { startIndex: 0, type: 'comment.coffee' } - ] - }, { - line: 'square = (x) -> x * x', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 7, type: 'delimiter.coffee' }, - { startIndex: 8, type: '' }, - { startIndex: 9, type: 'delimiter.parenthesis.coffee' }, - { startIndex: 10, type: '' }, - { startIndex: 11, type: 'delimiter.parenthesis.coffee' }, - { startIndex: 12, type: '' }, - { startIndex: 13, type: 'delimiter.coffee' }, - { startIndex: 15, type: '' }, - { startIndex: 18, type: 'delimiter.coffee' }, - { startIndex: 19, type: '' } - ] - }, { - line: '', - tokens: [ - - ] - }, { - line: '# Arrays:', - tokens: [ - { startIndex: 0, type: 'comment.coffee' } - ] - }, { - line: 'list = [1, 2, 3, 4, 5]', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 5, type: 'delimiter.coffee' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'delimiter.square.coffee' }, - { startIndex: 8, type: 'number.coffee' }, - { startIndex: 9, type: 'delimiter.coffee' }, - { startIndex: 10, type: '' }, - { startIndex: 11, type: 'number.coffee' }, - { startIndex: 12, type: 'delimiter.coffee' }, - { startIndex: 13, type: '' }, - { startIndex: 14, type: 'number.coffee' }, - { startIndex: 15, type: 'delimiter.coffee' }, - { startIndex: 16, type: '' }, - { startIndex: 17, type: 'number.coffee' }, - { startIndex: 18, type: 'delimiter.coffee' }, - { startIndex: 19, type: '' }, - { startIndex: 20, type: 'number.coffee' }, - { startIndex: 21, type: 'delimiter.square.coffee' } - ] - }, { - line: '', - tokens: [ - - ] - }, { - line: '# Objects:', - tokens: [ - { startIndex: 0, type: 'comment.coffee' } - ] - }, { - line: 'math =', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 5, type: 'delimiter.coffee' } - ] - }, { - line: ' root: Math.sqrt', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 6, type: 'delimiter.coffee' }, - { startIndex: 7, type: '' }, - { startIndex: 14, type: 'delimiter.coffee' }, - { startIndex: 15, type: '' } - ] - }, { - line: ' square: square', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 8, type: 'delimiter.coffee' }, - { startIndex: 9, type: '' } - ] - }, { - line: ' cube: (x) -> x * square x', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 6, type: 'delimiter.coffee' }, - { startIndex: 7, type: '' }, - { startIndex: 10, type: 'delimiter.parenthesis.coffee' }, - { startIndex: 11, type: '' }, - { startIndex: 12, type: 'delimiter.parenthesis.coffee' }, - { startIndex: 13, type: '' }, - { startIndex: 14, type: 'delimiter.coffee' }, - { startIndex: 16, type: '' }, - { startIndex: 19, type: 'delimiter.coffee' }, - { startIndex: 20, type: '' } - ] - }, { - line: '', - tokens: [ - - ] - }, { - line: '# Splats:', - tokens: [ - { startIndex: 0, type: 'comment.coffee' } - ] - }, { - line: 'race = (winner, runners...) ->', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 5, type: 'delimiter.coffee' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'delimiter.parenthesis.coffee' }, - { startIndex: 8, type: '' }, - { startIndex: 14, type: 'delimiter.coffee' }, - { startIndex: 15, type: '' }, - { startIndex: 23, type: 'delimiter.coffee' }, - { startIndex: 26, type: 'delimiter.parenthesis.coffee' }, - { startIndex: 27, type: '' }, - { startIndex: 28, type: 'delimiter.coffee' } - ] - }, { - line: ' print winner, runners', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 14, type: 'delimiter.coffee' }, - { startIndex: 15, type: '' } - ] - }, { - line: '', - tokens: [ - - ] - }, { - line: '# Existence:', - tokens: [ - { startIndex: 0, type: 'comment.coffee' } - ] - }, { - line: 'alert "I knew it!" if elvis?', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 6, type: 'string.coffee' }, - { startIndex: 18, type: '' }, - { startIndex: 19, type: 'keyword.if.coffee' }, - { startIndex: 21, type: '' }, - { startIndex: 27, type: 'delimiter.coffee' } - ] - }, { - line: '', - tokens: [ - - ] - }, { - line: '# Array comprehensions:', - tokens: [ - { startIndex: 0, type: 'comment.coffee' } - ] - }, { - line: 'cubes = (math.cube num for num in list)', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 6, type: 'delimiter.coffee' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'delimiter.parenthesis.coffee' }, - { startIndex: 9, type: '' }, - { startIndex: 13, type: 'delimiter.coffee' }, - { startIndex: 14, type: '' }, - { startIndex: 23, type: 'keyword.for.coffee' }, - { startIndex: 26, type: '' }, - { startIndex: 31, type: 'keyword.in.coffee' }, - { startIndex: 33, type: '' }, - { startIndex: 38, type: 'delimiter.parenthesis.coffee' } - ] - }, { - line: '', - tokens: [ - - ] - }, { - line: 'fill = (container, liquid = "coffee") ->', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 5, type: 'delimiter.coffee' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'delimiter.parenthesis.coffee' }, - { startIndex: 8, type: '' }, - { startIndex: 17, type: 'delimiter.coffee' }, - { startIndex: 18, type: '' }, - { startIndex: 26, type: 'delimiter.coffee' }, - { startIndex: 27, type: '' }, - { startIndex: 28, type: 'string.coffee' }, - { startIndex: 36, type: 'delimiter.parenthesis.coffee' }, - { startIndex: 37, type: '' }, - { startIndex: 38, type: 'delimiter.coffee' } - ] - }, { - line: ' "Filling the #{container} with #{liquid}..."', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'string.coffee' }, - { startIndex: 17, type: '' }, - { startIndex: 26, type: 'string.coffee' }, - { startIndex: 35, type: '' }, - { startIndex: 41, type: 'string.coffee' } - ] - }, { - line: '', - tokens: [ - - ] - }, { - line: 'ong = ["do", "re", "mi", "fa", "so"]', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 4, type: 'delimiter.coffee' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'delimiter.square.coffee' }, - { startIndex: 7, type: 'string.coffee' }, - { startIndex: 11, type: 'delimiter.coffee' }, - { startIndex: 12, type: '' }, - { startIndex: 13, type: 'string.coffee' }, - { startIndex: 17, type: 'delimiter.coffee' }, - { startIndex: 18, type: '' }, - { startIndex: 19, type: 'string.coffee' }, - { startIndex: 23, type: 'delimiter.coffee' }, - { startIndex: 24, type: '' }, - { startIndex: 25, type: 'string.coffee' }, - { startIndex: 29, type: 'delimiter.coffee' }, - { startIndex: 30, type: '' }, - { startIndex: 31, type: 'string.coffee' }, - { startIndex: 35, type: 'delimiter.square.coffee' } - ] - }, { - line: '', - tokens: [ - - ] - }, { - line: 'singers = {Jagger: "Rock", Elvis: "Roll"}', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 8, type: 'delimiter.coffee' }, - { startIndex: 9, type: '' }, - { startIndex: 10, type: 'delimiter.curly.coffee' }, - { startIndex: 11, type: '' }, - { startIndex: 17, type: 'delimiter.coffee' }, - { startIndex: 18, type: '' }, - { startIndex: 19, type: 'string.coffee' }, - { startIndex: 25, type: 'delimiter.coffee' }, - { startIndex: 26, type: '' }, - { startIndex: 32, type: 'delimiter.coffee' }, - { startIndex: 33, type: '' }, - { startIndex: 34, type: 'string.coffee' }, - { startIndex: 40, type: 'delimiter.curly.coffee' } - ] - }, { - line: '', - tokens: [ - - ] - }, { - line: 'bitlist = [', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 8, type: 'delimiter.coffee' }, - { startIndex: 9, type: '' }, - { startIndex: 10, type: 'delimiter.square.coffee' } - ] - }, { - line: ' 1, 0, 1', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'number.coffee' }, - { startIndex: 3, type: 'delimiter.coffee' }, - { startIndex: 4, type: '' }, - { startIndex: 5, type: 'number.coffee' }, - { startIndex: 6, type: 'delimiter.coffee' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'number.coffee' } - ] - }, { - line: ' 0, 0, 1', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'number.coffee' }, - { startIndex: 3, type: 'delimiter.coffee' }, - { startIndex: 4, type: '' }, - { startIndex: 5, type: 'number.coffee' }, - { startIndex: 6, type: 'delimiter.coffee' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'number.coffee' } - ] - }, { - line: ' 1, 1, 0', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'number.coffee' }, - { startIndex: 3, type: 'delimiter.coffee' }, - { startIndex: 4, type: '' }, - { startIndex: 5, type: 'number.coffee' }, - { startIndex: 6, type: 'delimiter.coffee' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'number.coffee' } - ] - }, { - line: ']', - tokens: [ - { startIndex: 0, type: 'delimiter.square.coffee' } - ] - }, { - line: '', - tokens: [ - - ] - }, { - line: 'kids =', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 5, type: 'delimiter.coffee' } - ] - }, { - line: ' brother:', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 9, type: 'delimiter.coffee' } - ] - }, { - line: ' name: "Max"', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 8, type: 'delimiter.coffee' }, - { startIndex: 9, type: '' }, - { startIndex: 10, type: 'string.coffee' } - ] - }, { - line: ' age: 11', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 7, type: 'delimiter.coffee' }, - { startIndex: 8, type: '' }, - { startIndex: 10, type: 'number.coffee' } - ] - }, { - line: ' sister:', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 8, type: 'delimiter.coffee' } - ] - }, { - line: ' name: "Ida"', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 8, type: 'delimiter.coffee' }, - { startIndex: 9, type: '' }, - { startIndex: 10, type: 'string.coffee' } - ] - }, { - line: ' age: 9', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 7, type: 'delimiter.coffee' }, - { startIndex: 8, type: '' }, - { startIndex: 10, type: 'number.coffee' } - ] - }, { - line: '', - tokens: [ - - ] - }, { - line: '$(\'.account\').attr class: \'active\'', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 1, type: 'delimiter.parenthesis.coffee' }, - { startIndex: 2, type: 'string.coffee' }, - { startIndex: 12, type: 'delimiter.parenthesis.coffee' }, - { startIndex: 13, type: 'delimiter.coffee' }, - { startIndex: 14, type: '' }, - { startIndex: 19, type: 'keyword.class.coffee' }, - { startIndex: 24, type: 'delimiter.coffee' }, - { startIndex: 25, type: '' }, - { startIndex: 26, type: 'string.coffee' } - ] - }, { - line: 'log object.class', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 10, type: 'delimiter.coffee' }, - { startIndex: 11, type: 'keyword.class.coffee' } - ] - }, { - line: '', - tokens: [ - - ] - }, { - line: 'outer = 1', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 6, type: 'delimiter.coffee' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'number.coffee' } - ] - }, { - line: 'changeNumbers = ->', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 14, type: 'delimiter.coffee' }, - { startIndex: 15, type: '' }, - { startIndex: 16, type: 'delimiter.coffee' } - ] - }, { - line: 'inner = -1', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 6, type: 'delimiter.coffee' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'delimiter.coffee' }, - { startIndex: 9, type: 'number.coffee' } - ] - }, { - line: 'outer = 10', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 6, type: 'delimiter.coffee' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'number.coffee' } - ] - }, { - line: 'inner = changeNumbers()', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 6, type: 'delimiter.coffee' }, - { startIndex: 7, type: '' }, - { startIndex: 21, type: 'delimiter.parenthesis.coffee' } - ] - }, { - line: '', - tokens: [ - - ] - }, { - line: 'mood = greatlyImproved if singing', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 5, type: 'delimiter.coffee' }, - { startIndex: 6, type: '' }, - { startIndex: 23, type: 'keyword.if.coffee' }, - { startIndex: 25, type: '' } - ] - }, { - line: '', - tokens: [ - - ] - }, { - line: 'if happy and knowsIt', - tokens: [ - { startIndex: 0, type: 'keyword.if.coffee' }, - { startIndex: 2, type: '' }, - { startIndex: 9, type: 'keyword.and.coffee' }, - { startIndex: 12, type: '' } - ] - }, { - line: ' clapsHands()', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 12, type: 'delimiter.parenthesis.coffee' } - ] - }, { - line: ' chaChaCha()', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 11, type: 'delimiter.parenthesis.coffee' } - ] - }, { - line: 'else', - tokens: [ - { startIndex: 0, type: 'keyword.else.coffee' } - ] - }, { - line: ' showIt()', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 8, type: 'delimiter.parenthesis.coffee' } - ] - }, { - line: '', - tokens: [ - - ] - }, { - line: 'date = if friday then sue else jill', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 5, type: 'delimiter.coffee' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'keyword.if.coffee' }, - { startIndex: 9, type: '' }, - { startIndex: 17, type: 'keyword.then.coffee' }, - { startIndex: 21, type: '' }, - { startIndex: 26, type: 'keyword.else.coffee' }, - { startIndex: 30, type: '' } - ] - }, { - line: '', - tokens: [ - - ] - }, { - line: 'options or= defaults', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 8, type: 'keyword.or.coffee' }, - { startIndex: 10, type: 'delimiter.coffee' }, - { startIndex: 11, type: '' } - ] - }, { - line: '', - tokens: [ - - ] - }, { - line: '# Eat lunch.', - tokens: [ - { startIndex: 0, type: 'comment.coffee' } - ] - }, { - line: 'eat food for food in [\'toast\', \'cheese\', \'wine\']', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 9, type: 'keyword.for.coffee' }, - { startIndex: 12, type: '' }, - { startIndex: 18, type: 'keyword.in.coffee' }, - { startIndex: 20, type: '' }, - { startIndex: 21, type: 'delimiter.square.coffee' }, - { startIndex: 22, type: 'string.coffee' }, - { startIndex: 29, type: 'delimiter.coffee' }, - { startIndex: 30, type: '' }, - { startIndex: 31, type: 'string.coffee' }, - { startIndex: 39, type: 'delimiter.coffee' }, - { startIndex: 40, type: '' }, - { startIndex: 41, type: 'string.coffee' }, - { startIndex: 47, type: 'delimiter.square.coffee' } - ] - }, { - line: '', - tokens: [ - - ] - }, { - line: '# Fine five course dining.', - tokens: [ - { startIndex: 0, type: 'comment.coffee' } - ] - }, { - line: 'courses = [\'greens\', \'caviar\', \'truffles\', \'roast\', \'cake\']', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 8, type: 'delimiter.coffee' }, - { startIndex: 9, type: '' }, - { startIndex: 10, type: 'delimiter.square.coffee' }, - { startIndex: 11, type: 'string.coffee' }, - { startIndex: 19, type: 'delimiter.coffee' }, - { startIndex: 20, type: '' }, - { startIndex: 21, type: 'string.coffee' }, - { startIndex: 29, type: 'delimiter.coffee' }, - { startIndex: 30, type: '' }, - { startIndex: 31, type: 'string.coffee' }, - { startIndex: 41, type: 'delimiter.coffee' }, - { startIndex: 42, type: '' }, - { startIndex: 43, type: 'string.coffee' }, - { startIndex: 50, type: 'delimiter.coffee' }, - { startIndex: 51, type: '' }, - { startIndex: 52, type: 'string.coffee' }, - { startIndex: 58, type: 'delimiter.square.coffee' } - ] - }, { - line: 'menu i + 1, dish for dish, i in courses', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 7, type: 'delimiter.coffee' }, - { startIndex: 8, type: '' }, - { startIndex: 9, type: 'number.coffee' }, - { startIndex: 10, type: 'delimiter.coffee' }, - { startIndex: 11, type: '' }, - { startIndex: 17, type: 'keyword.for.coffee' }, - { startIndex: 20, type: '' }, - { startIndex: 25, type: 'delimiter.coffee' }, - { startIndex: 26, type: '' }, - { startIndex: 29, type: 'keyword.in.coffee' }, - { startIndex: 31, type: '' } - ] - }, { - line: '', - tokens: [ - - ] - }, { - line: '# Health conscious meal.', - tokens: [ - { startIndex: 0, type: 'comment.coffee' } - ] - }, { - line: 'foods = [\'broccoli\', \'spinach\', \'chocolate\']', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 6, type: 'delimiter.coffee' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'delimiter.square.coffee' }, - { startIndex: 9, type: 'string.coffee' }, - { startIndex: 19, type: 'delimiter.coffee' }, - { startIndex: 20, type: '' }, - { startIndex: 21, type: 'string.coffee' }, - { startIndex: 30, type: 'delimiter.coffee' }, - { startIndex: 31, type: '' }, - { startIndex: 32, type: 'string.coffee' }, - { startIndex: 43, type: 'delimiter.square.coffee' } - ] - }, { - line: 'eat food for food in foods when food isnt \'chocolate\'', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 9, type: 'keyword.for.coffee' }, - { startIndex: 12, type: '' }, - { startIndex: 18, type: 'keyword.in.coffee' }, - { startIndex: 20, type: '' }, - { startIndex: 27, type: 'keyword.when.coffee' }, - { startIndex: 31, type: '' }, - { startIndex: 37, type: 'keyword.isnt.coffee' }, - { startIndex: 41, type: '' }, - { startIndex: 42, type: 'string.coffee' } - ] - }, { - line: '', - tokens: [ - - ] - }, { - line: 'countdown = (num for num in [10..1])', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 10, type: 'delimiter.coffee' }, - { startIndex: 11, type: '' }, - { startIndex: 12, type: 'delimiter.parenthesis.coffee' }, - { startIndex: 13, type: '' }, - { startIndex: 17, type: 'keyword.for.coffee' }, - { startIndex: 20, type: '' }, - { startIndex: 25, type: 'keyword.in.coffee' }, - { startIndex: 27, type: '' }, - { startIndex: 28, type: 'delimiter.square.coffee' }, - { startIndex: 29, type: 'number.coffee' }, - { startIndex: 31, type: 'delimiter.coffee' }, - { startIndex: 33, type: 'number.coffee' }, - { startIndex: 34, type: 'delimiter.square.coffee' }, - { startIndex: 35, type: 'delimiter.parenthesis.coffee' } - ] - }, { - line: '', - tokens: [ - - ] - }, { - line: 'yearsOld = max: 10, ida: 9, tim: 11', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 9, type: 'delimiter.coffee' }, - { startIndex: 10, type: '' }, - { startIndex: 14, type: 'delimiter.coffee' }, - { startIndex: 15, type: '' }, - { startIndex: 16, type: 'number.coffee' }, - { startIndex: 18, type: 'delimiter.coffee' }, - { startIndex: 19, type: '' }, - { startIndex: 23, type: 'delimiter.coffee' }, - { startIndex: 24, type: '' }, - { startIndex: 25, type: 'number.coffee' }, - { startIndex: 26, type: 'delimiter.coffee' }, - { startIndex: 27, type: '' }, - { startIndex: 31, type: 'delimiter.coffee' }, - { startIndex: 32, type: '' }, - { startIndex: 33, type: 'number.coffee' } - ] - }, { - line: '', - tokens: [ - - ] - }, { - line: 'ages = for child, age of yearsOld', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 5, type: 'delimiter.coffee' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'keyword.for.coffee' }, - { startIndex: 10, type: '' }, - { startIndex: 16, type: 'delimiter.coffee' }, - { startIndex: 17, type: '' }, - { startIndex: 22, type: 'keyword.of.coffee' }, - { startIndex: 24, type: '' } - ] - }, { - line: ' "#{child} is #{age}"', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'string.coffee' }, - { startIndex: 5, type: '' }, - { startIndex: 10, type: 'string.coffee' }, - { startIndex: 17, type: '' }, - { startIndex: 20, type: 'string.coffee' } - ] - }, { - line: '', - tokens: [ - - ] - }, { - line: '# Econ 101', - tokens: [ - { startIndex: 0, type: 'comment.coffee' } - ] - }, { - line: 'if this.studyingEconomics', - tokens: [ - { startIndex: 0, type: 'keyword.if.coffee' }, - { startIndex: 2, type: '' }, - { startIndex: 3, type: 'variable.predefined.coffee' }, - { startIndex: 7, type: 'delimiter.coffee' }, - { startIndex: 8, type: '' } - ] - }, { - line: ' buy() while supply > demand', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 5, type: 'delimiter.parenthesis.coffee' }, - { startIndex: 7, type: '' }, - { startIndex: 9, type: 'keyword.while.coffee' }, - { startIndex: 14, type: '' }, - { startIndex: 22, type: 'delimiter.coffee' }, - { startIndex: 23, type: '' } - ] - }, { - line: ' sell() until supply > demand', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 6, type: 'delimiter.parenthesis.coffee' }, - { startIndex: 8, type: '' }, - { startIndex: 9, type: 'keyword.until.coffee' }, - { startIndex: 14, type: '' }, - { startIndex: 22, type: 'delimiter.coffee' }, - { startIndex: 23, type: '' } - ] - }, { - line: '', - tokens: [ - - ] - }, { - line: '# Nursery Rhyme', - tokens: [ - { startIndex: 0, type: 'comment.coffee' } - ] - }, { - line: 'num = 6', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 4, type: 'delimiter.coffee' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'number.coffee' } - ] - }, { - line: 'lyrics = while num -= 1', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 7, type: 'delimiter.coffee' }, - { startIndex: 8, type: '' }, - { startIndex: 9, type: 'keyword.while.coffee' }, - { startIndex: 14, type: '' }, - { startIndex: 19, type: 'delimiter.coffee' }, - { startIndex: 21, type: '' }, - { startIndex: 22, type: 'number.coffee' } - ] - }, { - line: ' "#{num} little monkeys, jumping on the bed.', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'string.coffee' }, - { startIndex: 5, type: '' }, - { startIndex: 8, type: 'string.coffee' } - ] - }, { - line: ' One fell out and bumped his head."', - tokens: [ - { startIndex: 0, type: 'string.coffee' } - ] - }, { - line: ' ', - tokens: [ - { startIndex: 0, type: '' } - ] - }, { - line: '# Everything is an Expression (at least, as much as possible)', - tokens: [ - { startIndex: 0, type: 'comment.coffee' } - ] - }, { - line: 'grade = (student) ->', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 6, type: 'delimiter.coffee' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'delimiter.parenthesis.coffee' }, - { startIndex: 9, type: '' }, - { startIndex: 16, type: 'delimiter.parenthesis.coffee' }, - { startIndex: 17, type: '' }, - { startIndex: 18, type: 'delimiter.coffee' } - ] - }, { - line: ' if student.excellentWork', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'keyword.if.coffee' }, - { startIndex: 4, type: '' }, - { startIndex: 12, type: 'delimiter.coffee' }, - { startIndex: 13, type: '' } - ] - }, { - line: ' "A+"', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 4, type: 'string.coffee' } - ] - }, { - line: ' else if student.okayStuff', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'keyword.else.coffee' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'keyword.if.coffee' }, - { startIndex: 9, type: '' }, - { startIndex: 17, type: 'delimiter.coffee' }, - { startIndex: 18, type: '' } - ] - }, { - line: ' if student.triedHard then "B" else "B-"', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 4, type: 'keyword.if.coffee' }, - { startIndex: 6, type: '' }, - { startIndex: 14, type: 'delimiter.coffee' }, - { startIndex: 15, type: '' }, - { startIndex: 25, type: 'keyword.then.coffee' }, - { startIndex: 29, type: '' }, - { startIndex: 30, type: 'string.coffee' }, - { startIndex: 33, type: '' }, - { startIndex: 34, type: 'keyword.else.coffee' }, - { startIndex: 38, type: '' }, - { startIndex: 39, type: 'string.coffee' } - ] - }, { - line: ' else', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'keyword.else.coffee' } - ] - }, { - line: ' "C"', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 4, type: 'string.coffee' } - ] - }, { - line: '', - tokens: [ - - ] - }, { - line: 'eldest = if 24 > 21 then "Liz" else "Ike"', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 7, type: 'delimiter.coffee' }, - { startIndex: 8, type: '' }, - { startIndex: 9, type: 'keyword.if.coffee' }, - { startIndex: 11, type: '' }, - { startIndex: 12, type: 'number.coffee' }, - { startIndex: 14, type: '' }, - { startIndex: 15, type: 'delimiter.coffee' }, - { startIndex: 16, type: '' }, - { startIndex: 17, type: 'number.coffee' }, - { startIndex: 19, type: '' }, - { startIndex: 20, type: 'keyword.then.coffee' }, - { startIndex: 24, type: '' }, - { startIndex: 25, type: 'string.coffee' }, - { startIndex: 30, type: '' }, - { startIndex: 31, type: 'keyword.else.coffee' }, - { startIndex: 35, type: '' }, - { startIndex: 36, type: 'string.coffee' } - ] - }, { - line: '', - tokens: [ - - ] - }, { - line: '#Classes, Inheritance and Super', - tokens: [ - { startIndex: 0, type: 'comment.coffee' } - ] - }, { - line: 'class Animal', - tokens: [ - { startIndex: 0, type: 'keyword.class.coffee' }, - { startIndex: 5, type: '' } - ] - }, { - line: ' constructor: (@name) ->', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 13, type: 'delimiter.coffee' }, - { startIndex: 14, type: '' }, - { startIndex: 15, type: 'delimiter.parenthesis.coffee' }, - { startIndex: 16, type: 'variable.predefined.coffee' }, - { startIndex: 21, type: 'delimiter.parenthesis.coffee' }, - { startIndex: 22, type: '' }, - { startIndex: 23, type: 'delimiter.coffee' } - ] - }, { - line: '', - tokens: [ - - ] - }, { - line: ' move: (meters) ->', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 6, type: 'delimiter.coffee' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'delimiter.parenthesis.coffee' }, - { startIndex: 9, type: '' }, - { startIndex: 15, type: 'delimiter.parenthesis.coffee' }, - { startIndex: 16, type: '' }, - { startIndex: 17, type: 'delimiter.coffee' } - ] - }, { - line: ' alert @name + " moved #{meters}m."', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 10, type: 'variable.predefined.coffee' }, - { startIndex: 15, type: '' }, - { startIndex: 16, type: 'delimiter.coffee' }, - { startIndex: 17, type: '' }, - { startIndex: 18, type: 'string.coffee' }, - { startIndex: 28, type: '' }, - { startIndex: 34, type: 'string.coffee' } - ] - }, { - line: '', - tokens: [ - - ] - }, { - line: 'class Snake extends Animal', - tokens: [ - { startIndex: 0, type: 'keyword.class.coffee' }, - { startIndex: 5, type: '' }, - { startIndex: 12, type: 'keyword.extends.coffee' }, - { startIndex: 19, type: '' } - ] - }, { - line: ' move: ->', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 6, type: 'delimiter.coffee' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'delimiter.coffee' } - ] - }, { - line: ' alert "Slithering..."', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 10, type: 'string.coffee' } - ] - }, { - line: ' super 5', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 4, type: 'keyword.super.coffee' }, - { startIndex: 9, type: '' }, - { startIndex: 10, type: 'number.coffee' } - ] - }, { - line: '', - tokens: [ - - ] - }, { - line: 'class Horse extends Animal', - tokens: [ - { startIndex: 0, type: 'keyword.class.coffee' }, - { startIndex: 5, type: '' }, - { startIndex: 12, type: 'keyword.extends.coffee' }, - { startIndex: 19, type: '' } - ] - }, { - line: ' move: ->', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 6, type: 'delimiter.coffee' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'delimiter.coffee' } - ] - }, { - line: ' alert "Galloping..."', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 10, type: 'string.coffee' } - ] - }, { - line: ' super 45', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 4, type: 'keyword.super.coffee' }, - { startIndex: 9, type: '' }, - { startIndex: 10, type: 'number.coffee' } - ] - }, { - line: '', - tokens: [ - - ] - }, { - line: 'sam = new Snake "Sammy the Python"', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 4, type: 'delimiter.coffee' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'keyword.new.coffee' }, - { startIndex: 9, type: '' }, - { startIndex: 16, type: 'string.coffee' } - ] - }, { - line: 'tom = new Horse "Tommy the Palomino"', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 4, type: 'delimiter.coffee' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'keyword.new.coffee' }, - { startIndex: 9, type: '' }, - { startIndex: 16, type: 'string.coffee' } - ] - }, { - line: '', - tokens: [ - - ] - }, { - line: 'sam.move()', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 3, type: 'delimiter.coffee' }, - { startIndex: 4, type: '' }, - { startIndex: 8, type: 'delimiter.parenthesis.coffee' } - ] - }, { - line: 'tom.move()', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 3, type: 'delimiter.coffee' }, - { startIndex: 4, type: '' }, - { startIndex: 8, type: 'delimiter.parenthesis.coffee' } - ] - }, { - line: '', - tokens: [ - - ] - }, { - line: '#Function binding', - tokens: [ - { startIndex: 0, type: 'comment.coffee' } - ] - }, { - line: 'Account = (customer, cart) ->', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 8, type: 'delimiter.coffee' }, - { startIndex: 9, type: '' }, - { startIndex: 10, type: 'delimiter.parenthesis.coffee' }, - { startIndex: 11, type: '' }, - { startIndex: 19, type: 'delimiter.coffee' }, - { startIndex: 20, type: '' }, - { startIndex: 25, type: 'delimiter.parenthesis.coffee' }, - { startIndex: 26, type: '' }, - { startIndex: 27, type: 'delimiter.coffee' } - ] - }, { - line: ' @customer = customer', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'variable.predefined.coffee' }, - { startIndex: 11, type: '' }, - { startIndex: 12, type: 'delimiter.coffee' }, - { startIndex: 13, type: '' } - ] - }, { - line: ' @cart = cart', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'variable.predefined.coffee' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'delimiter.coffee' }, - { startIndex: 9, type: '' } - ] - }, { - line: '', - tokens: [ - - ] - }, { - line: ' $(\'.shopping_cart\').bind \'click\', (event) =>', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 3, type: 'delimiter.parenthesis.coffee' }, - { startIndex: 4, type: 'string.coffee' }, - { startIndex: 20, type: 'delimiter.parenthesis.coffee' }, - { startIndex: 21, type: 'delimiter.coffee' }, - { startIndex: 22, type: '' }, - { startIndex: 27, type: 'string.coffee' }, - { startIndex: 34, type: 'delimiter.coffee' }, - { startIndex: 35, type: '' }, - { startIndex: 36, type: 'delimiter.parenthesis.coffee' }, - { startIndex: 37, type: '' }, - { startIndex: 42, type: 'delimiter.parenthesis.coffee' }, - { startIndex: 43, type: '' }, - { startIndex: 44, type: 'delimiter.coffee' } - ] - }, { - line: ' @customer.purchase @cart', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 4, type: 'variable.predefined.coffee' }, - { startIndex: 13, type: 'delimiter.coffee' }, - { startIndex: 14, type: '' }, - { startIndex: 23, type: 'variable.predefined.coffee' } - ] - }, { - line: '', - tokens: [ - - ] - }, { - line: '#Switch/When/Else ', - tokens: [ - { startIndex: 0, type: 'comment.coffee' } - ] - }, { - line: 'switch day', - tokens: [ - { startIndex: 0, type: 'keyword.switch.coffee' }, - { startIndex: 6, type: '' } - ] - }, { - line: ' when "Mon" then go work', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'keyword.when.coffee' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'string.coffee' }, - { startIndex: 12, type: '' }, - { startIndex: 13, type: 'keyword.then.coffee' }, - { startIndex: 17, type: '' } - ] - }, { - line: ' when "Tue" then go relax', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'keyword.when.coffee' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'string.coffee' }, - { startIndex: 12, type: '' }, - { startIndex: 13, type: 'keyword.then.coffee' }, - { startIndex: 17, type: '' } - ] - }, { - line: ' when "Thu" then go iceFishing', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'keyword.when.coffee' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'string.coffee' }, - { startIndex: 12, type: '' }, - { startIndex: 13, type: 'keyword.then.coffee' }, - { startIndex: 17, type: '' } - ] - }, { - line: ' when "Fri", "Sat"', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'keyword.when.coffee' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'string.coffee' }, - { startIndex: 12, type: 'delimiter.coffee' }, - { startIndex: 13, type: '' }, - { startIndex: 14, type: 'string.coffee' } - ] - }, { - line: ' if day is bingoDay', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 4, type: 'keyword.if.coffee' }, - { startIndex: 6, type: '' }, - { startIndex: 11, type: 'keyword.is.coffee' }, - { startIndex: 13, type: '' } - ] - }, { - line: ' go bingo', - tokens: [ - { startIndex: 0, type: '' } - ] - }, { - line: ' go dancing', - tokens: [ - { startIndex: 0, type: '' } - ] - }, { - line: ' when "Sun" then go church', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'keyword.when.coffee' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'string.coffee' }, - { startIndex: 12, type: '' }, - { startIndex: 13, type: 'keyword.then.coffee' }, - { startIndex: 17, type: '' } - ] - }, { - line: ' else go work', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'keyword.else.coffee' }, - { startIndex: 6, type: '' } - ] - }, { - line: ' ', - tokens: [ - { startIndex: 0, type: '' } - ] - }, { - line: '#Try/Catch/Finally', - tokens: [ - { startIndex: 0, type: 'comment.coffee' } - ] - }, { - line: 'try', - tokens: [ - { startIndex: 0, type: 'keyword.try.coffee' } - ] - }, { - line: ' allHellBreaksLoose()', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 20, type: 'delimiter.parenthesis.coffee' } - ] - }, { - line: ' catsAndDogsLivingTogether()', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 27, type: 'delimiter.parenthesis.coffee' } - ] - }, { - line: 'catch error', - tokens: [ - { startIndex: 0, type: 'keyword.catch.coffee' }, - { startIndex: 5, type: '' } - ] - }, { - line: ' print error', - tokens: [ - { startIndex: 0, type: '' } - ] - }, { - line: 'finally', - tokens: [ - { startIndex: 0, type: 'keyword.finally.coffee' } - ] - }, { - line: ' cleanUp()', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 9, type: 'delimiter.parenthesis.coffee' } - ] - }, { - line: '', - tokens: [ - - ] - }, { - line: '#String Interpolation and Block Comments', - tokens: [ - { startIndex: 0, type: 'comment.coffee' } - ] - }, { - line: 'author = "Wittgenstein"', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 7, type: 'delimiter.coffee' }, - { startIndex: 8, type: '' }, - { startIndex: 9, type: 'string.coffee' } - ] - }, { - line: 'quote = "A picture is a fact. -- #{ author }"', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 7, type: 'delimiter.coffee' }, - { startIndex: 8, type: '' }, - { startIndex: 9, type: 'string.coffee' }, - { startIndex: 36, type: '' }, - { startIndex: 44, type: 'string.coffee' } - ] - }, { - line: '', - tokens: [ - - ] - }, { - line: 'sentence = "#{ 22 / 7 } is a decent approximation of p"', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 9, type: 'delimiter.coffee' }, - { startIndex: 10, type: '' }, - { startIndex: 11, type: 'string.coffee' }, - { startIndex: 14, type: '' }, - { startIndex: 15, type: 'number.coffee' }, - { startIndex: 17, type: '' }, - { startIndex: 18, type: 'delimiter.coffee' }, - { startIndex: 19, type: '' }, - { startIndex: 20, type: 'number.coffee' }, - { startIndex: 21, type: '' }, - { startIndex: 22, type: 'string.coffee' } - ] - }, { - line: '', - tokens: [ - - ] - }, { - line: 'mobyDick = "Call me Ishmael. Some years ago --', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 9, type: 'delimiter.coffee' }, - { startIndex: 10, type: '' }, - { startIndex: 11, type: 'string.coffee' } - ] - }, { - line: ' never mind how long precisely -- having little', - tokens: [ - { startIndex: 0, type: 'string.coffee' } - ] - }, { - line: ' or no money in my purse, and nothing particular', - tokens: [ - { startIndex: 0, type: 'string.coffee' } - ] - }, { - line: ' to interest me on shore, I thought I would sail', - tokens: [ - { startIndex: 0, type: 'string.coffee' } - ] - }, { - line: ' about a little and see the watery part of the', - tokens: [ - { startIndex: 0, type: 'string.coffee' } - ] - }, { - line: ' world..."', - tokens: [ - { startIndex: 0, type: 'string.coffee' } - ] - }, { - line: '', - tokens: [ - - ] - }, { - line: '#Extended Regular Expressions', - tokens: [ - { startIndex: 0, type: 'comment.coffee' } - ] - }, { - line: 'OPERATOR = /// ^ (', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 9, type: 'delimiter.coffee' }, - { startIndex: 10, type: '' }, - { startIndex: 11, type: 'regexp.coffee' } - ] - }, { - line: ' ?: [-=]> # function', - tokens: [ - { startIndex: 0, type: 'regexp.coffee' }, - { startIndex: 23, type: 'comment.coffee' } - ] - }, { - line: ' | [-+*/%<>&|^!?=]= # compound assign / compare', - tokens: [ - { startIndex: 0, type: 'regexp.coffee' }, - { startIndex: 23, type: 'comment.coffee' } - ] - }, { - line: ' | >>>=? # zero-fill right shift', - tokens: [ - { startIndex: 0, type: 'regexp.coffee' }, - { startIndex: 23, type: 'comment.coffee' } - ] - }, { - line: ' | ([-+:])\\1 # doubles', - tokens: [ - { startIndex: 0, type: 'regexp.coffee' }, - { startIndex: 23, type: 'comment.coffee' } - ] - }, { - line: ' | ([&|<>])\\2=? # logic / shift', - tokens: [ - { startIndex: 0, type: 'regexp.coffee' }, - { startIndex: 23, type: 'comment.coffee' } - ] - }, { - line: ' | \\?\\. # soak access', - tokens: [ - { startIndex: 0, type: 'regexp.coffee' }, - { startIndex: 23, type: 'comment.coffee' } - ] - }, { - line: ' | \\.{2,3} # range or splat', - tokens: [ - { startIndex: 0, type: 'regexp.coffee' }, - { startIndex: 23, type: 'comment.coffee' } - ] - }, { - line: ') ///', - tokens: [ - { startIndex: 0, type: 'regexp.coffee' } - ] - }, { - line: '', - tokens: [ - - ] - }] + [ + { + line: '# Assignment:', + tokens: [{ startIndex: 0, type: 'comment.coffee' }] + }, + { + line: 'number = 42', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 9, type: 'delimiter.coffee' }, + { startIndex: 10, type: '' }, + { startIndex: 11, type: 'number.coffee' } + ] + }, + { + line: 'opposite = true', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 9, type: 'delimiter.coffee' }, + { startIndex: 10, type: '' }, + { startIndex: 11, type: 'keyword.true.coffee' } + ] + }, + { + line: '', + tokens: [] + }, + { + line: '# Conditions:', + tokens: [{ startIndex: 0, type: 'comment.coffee' }] + }, + { + line: 'number = -42 if opposite', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 7, type: 'delimiter.coffee' }, + { startIndex: 8, type: '' }, + { startIndex: 9, type: 'delimiter.coffee' }, + { startIndex: 10, type: 'number.coffee' }, + { startIndex: 12, type: '' }, + { startIndex: 13, type: 'keyword.if.coffee' }, + { startIndex: 15, type: '' } + ] + }, + { + line: '', + tokens: [] + }, + { + line: '# Functions:', + tokens: [{ startIndex: 0, type: 'comment.coffee' }] + }, + { + line: 'square = (x) -> x * x', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 7, type: 'delimiter.coffee' }, + { startIndex: 8, type: '' }, + { startIndex: 9, type: 'delimiter.parenthesis.coffee' }, + { startIndex: 10, type: '' }, + { startIndex: 11, type: 'delimiter.parenthesis.coffee' }, + { startIndex: 12, type: '' }, + { startIndex: 13, type: 'delimiter.coffee' }, + { startIndex: 15, type: '' }, + { startIndex: 18, type: 'delimiter.coffee' }, + { startIndex: 19, type: '' } + ] + }, + { + line: '', + tokens: [] + }, + { + line: '# Arrays:', + tokens: [{ startIndex: 0, type: 'comment.coffee' }] + }, + { + line: 'list = [1, 2, 3, 4, 5]', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 5, type: 'delimiter.coffee' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'delimiter.square.coffee' }, + { startIndex: 8, type: 'number.coffee' }, + { startIndex: 9, type: 'delimiter.coffee' }, + { startIndex: 10, type: '' }, + { startIndex: 11, type: 'number.coffee' }, + { startIndex: 12, type: 'delimiter.coffee' }, + { startIndex: 13, type: '' }, + { startIndex: 14, type: 'number.coffee' }, + { startIndex: 15, type: 'delimiter.coffee' }, + { startIndex: 16, type: '' }, + { startIndex: 17, type: 'number.coffee' }, + { startIndex: 18, type: 'delimiter.coffee' }, + { startIndex: 19, type: '' }, + { startIndex: 20, type: 'number.coffee' }, + { startIndex: 21, type: 'delimiter.square.coffee' } + ] + }, + { + line: '', + tokens: [] + }, + { + line: '# Objects:', + tokens: [{ startIndex: 0, type: 'comment.coffee' }] + }, + { + line: 'math =', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 5, type: 'delimiter.coffee' } + ] + }, + { + line: ' root: Math.sqrt', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 6, type: 'delimiter.coffee' }, + { startIndex: 7, type: '' }, + { startIndex: 14, type: 'delimiter.coffee' }, + { startIndex: 15, type: '' } + ] + }, + { + line: ' square: square', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 8, type: 'delimiter.coffee' }, + { startIndex: 9, type: '' } + ] + }, + { + line: ' cube: (x) -> x * square x', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 6, type: 'delimiter.coffee' }, + { startIndex: 7, type: '' }, + { startIndex: 10, type: 'delimiter.parenthesis.coffee' }, + { startIndex: 11, type: '' }, + { startIndex: 12, type: 'delimiter.parenthesis.coffee' }, + { startIndex: 13, type: '' }, + { startIndex: 14, type: 'delimiter.coffee' }, + { startIndex: 16, type: '' }, + { startIndex: 19, type: 'delimiter.coffee' }, + { startIndex: 20, type: '' } + ] + }, + { + line: '', + tokens: [] + }, + { + line: '# Splats:', + tokens: [{ startIndex: 0, type: 'comment.coffee' }] + }, + { + line: 'race = (winner, runners...) ->', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 5, type: 'delimiter.coffee' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'delimiter.parenthesis.coffee' }, + { startIndex: 8, type: '' }, + { startIndex: 14, type: 'delimiter.coffee' }, + { startIndex: 15, type: '' }, + { startIndex: 23, type: 'delimiter.coffee' }, + { startIndex: 26, type: 'delimiter.parenthesis.coffee' }, + { startIndex: 27, type: '' }, + { startIndex: 28, type: 'delimiter.coffee' } + ] + }, + { + line: ' print winner, runners', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 14, type: 'delimiter.coffee' }, + { startIndex: 15, type: '' } + ] + }, + { + line: '', + tokens: [] + }, + { + line: '# Existence:', + tokens: [{ startIndex: 0, type: 'comment.coffee' }] + }, + { + line: 'alert "I knew it!" if elvis?', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 6, type: 'string.coffee' }, + { startIndex: 18, type: '' }, + { startIndex: 19, type: 'keyword.if.coffee' }, + { startIndex: 21, type: '' }, + { startIndex: 27, type: 'delimiter.coffee' } + ] + }, + { + line: '', + tokens: [] + }, + { + line: '# Array comprehensions:', + tokens: [{ startIndex: 0, type: 'comment.coffee' }] + }, + { + line: 'cubes = (math.cube num for num in list)', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 6, type: 'delimiter.coffee' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'delimiter.parenthesis.coffee' }, + { startIndex: 9, type: '' }, + { startIndex: 13, type: 'delimiter.coffee' }, + { startIndex: 14, type: '' }, + { startIndex: 23, type: 'keyword.for.coffee' }, + { startIndex: 26, type: '' }, + { startIndex: 31, type: 'keyword.in.coffee' }, + { startIndex: 33, type: '' }, + { startIndex: 38, type: 'delimiter.parenthesis.coffee' } + ] + }, + { + line: '', + tokens: [] + }, + { + line: 'fill = (container, liquid = "coffee") ->', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 5, type: 'delimiter.coffee' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'delimiter.parenthesis.coffee' }, + { startIndex: 8, type: '' }, + { startIndex: 17, type: 'delimiter.coffee' }, + { startIndex: 18, type: '' }, + { startIndex: 26, type: 'delimiter.coffee' }, + { startIndex: 27, type: '' }, + { startIndex: 28, type: 'string.coffee' }, + { startIndex: 36, type: 'delimiter.parenthesis.coffee' }, + { startIndex: 37, type: '' }, + { startIndex: 38, type: 'delimiter.coffee' } + ] + }, + { + line: ' "Filling the #{container} with #{liquid}..."', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'string.coffee' }, + { startIndex: 17, type: '' }, + { startIndex: 26, type: 'string.coffee' }, + { startIndex: 35, type: '' }, + { startIndex: 41, type: 'string.coffee' } + ] + }, + { + line: '', + tokens: [] + }, + { + line: 'ong = ["do", "re", "mi", "fa", "so"]', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 4, type: 'delimiter.coffee' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'delimiter.square.coffee' }, + { startIndex: 7, type: 'string.coffee' }, + { startIndex: 11, type: 'delimiter.coffee' }, + { startIndex: 12, type: '' }, + { startIndex: 13, type: 'string.coffee' }, + { startIndex: 17, type: 'delimiter.coffee' }, + { startIndex: 18, type: '' }, + { startIndex: 19, type: 'string.coffee' }, + { startIndex: 23, type: 'delimiter.coffee' }, + { startIndex: 24, type: '' }, + { startIndex: 25, type: 'string.coffee' }, + { startIndex: 29, type: 'delimiter.coffee' }, + { startIndex: 30, type: '' }, + { startIndex: 31, type: 'string.coffee' }, + { startIndex: 35, type: 'delimiter.square.coffee' } + ] + }, + { + line: '', + tokens: [] + }, + { + line: 'singers = {Jagger: "Rock", Elvis: "Roll"}', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 8, type: 'delimiter.coffee' }, + { startIndex: 9, type: '' }, + { startIndex: 10, type: 'delimiter.curly.coffee' }, + { startIndex: 11, type: '' }, + { startIndex: 17, type: 'delimiter.coffee' }, + { startIndex: 18, type: '' }, + { startIndex: 19, type: 'string.coffee' }, + { startIndex: 25, type: 'delimiter.coffee' }, + { startIndex: 26, type: '' }, + { startIndex: 32, type: 'delimiter.coffee' }, + { startIndex: 33, type: '' }, + { startIndex: 34, type: 'string.coffee' }, + { startIndex: 40, type: 'delimiter.curly.coffee' } + ] + }, + { + line: '', + tokens: [] + }, + { + line: 'bitlist = [', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 8, type: 'delimiter.coffee' }, + { startIndex: 9, type: '' }, + { startIndex: 10, type: 'delimiter.square.coffee' } + ] + }, + { + line: ' 1, 0, 1', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'number.coffee' }, + { startIndex: 3, type: 'delimiter.coffee' }, + { startIndex: 4, type: '' }, + { startIndex: 5, type: 'number.coffee' }, + { startIndex: 6, type: 'delimiter.coffee' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'number.coffee' } + ] + }, + { + line: ' 0, 0, 1', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'number.coffee' }, + { startIndex: 3, type: 'delimiter.coffee' }, + { startIndex: 4, type: '' }, + { startIndex: 5, type: 'number.coffee' }, + { startIndex: 6, type: 'delimiter.coffee' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'number.coffee' } + ] + }, + { + line: ' 1, 1, 0', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'number.coffee' }, + { startIndex: 3, type: 'delimiter.coffee' }, + { startIndex: 4, type: '' }, + { startIndex: 5, type: 'number.coffee' }, + { startIndex: 6, type: 'delimiter.coffee' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'number.coffee' } + ] + }, + { + line: ']', + tokens: [{ startIndex: 0, type: 'delimiter.square.coffee' }] + }, + { + line: '', + tokens: [] + }, + { + line: 'kids =', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 5, type: 'delimiter.coffee' } + ] + }, + { + line: ' brother:', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 9, type: 'delimiter.coffee' } + ] + }, + { + line: ' name: "Max"', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 8, type: 'delimiter.coffee' }, + { startIndex: 9, type: '' }, + { startIndex: 10, type: 'string.coffee' } + ] + }, + { + line: ' age: 11', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 7, type: 'delimiter.coffee' }, + { startIndex: 8, type: '' }, + { startIndex: 10, type: 'number.coffee' } + ] + }, + { + line: ' sister:', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 8, type: 'delimiter.coffee' } + ] + }, + { + line: ' name: "Ida"', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 8, type: 'delimiter.coffee' }, + { startIndex: 9, type: '' }, + { startIndex: 10, type: 'string.coffee' } + ] + }, + { + line: ' age: 9', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 7, type: 'delimiter.coffee' }, + { startIndex: 8, type: '' }, + { startIndex: 10, type: 'number.coffee' } + ] + }, + { + line: '', + tokens: [] + }, + { + line: "$('.account').attr class: 'active'", + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 1, type: 'delimiter.parenthesis.coffee' }, + { startIndex: 2, type: 'string.coffee' }, + { startIndex: 12, type: 'delimiter.parenthesis.coffee' }, + { startIndex: 13, type: 'delimiter.coffee' }, + { startIndex: 14, type: '' }, + { startIndex: 19, type: 'keyword.class.coffee' }, + { startIndex: 24, type: 'delimiter.coffee' }, + { startIndex: 25, type: '' }, + { startIndex: 26, type: 'string.coffee' } + ] + }, + { + line: 'log object.class', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 10, type: 'delimiter.coffee' }, + { startIndex: 11, type: 'keyword.class.coffee' } + ] + }, + { + line: '', + tokens: [] + }, + { + line: 'outer = 1', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 6, type: 'delimiter.coffee' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'number.coffee' } + ] + }, + { + line: 'changeNumbers = ->', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 14, type: 'delimiter.coffee' }, + { startIndex: 15, type: '' }, + { startIndex: 16, type: 'delimiter.coffee' } + ] + }, + { + line: 'inner = -1', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 6, type: 'delimiter.coffee' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'delimiter.coffee' }, + { startIndex: 9, type: 'number.coffee' } + ] + }, + { + line: 'outer = 10', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 6, type: 'delimiter.coffee' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'number.coffee' } + ] + }, + { + line: 'inner = changeNumbers()', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 6, type: 'delimiter.coffee' }, + { startIndex: 7, type: '' }, + { startIndex: 21, type: 'delimiter.parenthesis.coffee' } + ] + }, + { + line: '', + tokens: [] + }, + { + line: 'mood = greatlyImproved if singing', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 5, type: 'delimiter.coffee' }, + { startIndex: 6, type: '' }, + { startIndex: 23, type: 'keyword.if.coffee' }, + { startIndex: 25, type: '' } + ] + }, + { + line: '', + tokens: [] + }, + { + line: 'if happy and knowsIt', + tokens: [ + { startIndex: 0, type: 'keyword.if.coffee' }, + { startIndex: 2, type: '' }, + { startIndex: 9, type: 'keyword.and.coffee' }, + { startIndex: 12, type: '' } + ] + }, + { + line: ' clapsHands()', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 12, type: 'delimiter.parenthesis.coffee' } + ] + }, + { + line: ' chaChaCha()', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 11, type: 'delimiter.parenthesis.coffee' } + ] + }, + { + line: 'else', + tokens: [{ startIndex: 0, type: 'keyword.else.coffee' }] + }, + { + line: ' showIt()', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 8, type: 'delimiter.parenthesis.coffee' } + ] + }, + { + line: '', + tokens: [] + }, + { + line: 'date = if friday then sue else jill', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 5, type: 'delimiter.coffee' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'keyword.if.coffee' }, + { startIndex: 9, type: '' }, + { startIndex: 17, type: 'keyword.then.coffee' }, + { startIndex: 21, type: '' }, + { startIndex: 26, type: 'keyword.else.coffee' }, + { startIndex: 30, type: '' } + ] + }, + { + line: '', + tokens: [] + }, + { + line: 'options or= defaults', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 8, type: 'keyword.or.coffee' }, + { startIndex: 10, type: 'delimiter.coffee' }, + { startIndex: 11, type: '' } + ] + }, + { + line: '', + tokens: [] + }, + { + line: '# Eat lunch.', + tokens: [{ startIndex: 0, type: 'comment.coffee' }] + }, + { + line: "eat food for food in ['toast', 'cheese', 'wine']", + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 9, type: 'keyword.for.coffee' }, + { startIndex: 12, type: '' }, + { startIndex: 18, type: 'keyword.in.coffee' }, + { startIndex: 20, type: '' }, + { startIndex: 21, type: 'delimiter.square.coffee' }, + { startIndex: 22, type: 'string.coffee' }, + { startIndex: 29, type: 'delimiter.coffee' }, + { startIndex: 30, type: '' }, + { startIndex: 31, type: 'string.coffee' }, + { startIndex: 39, type: 'delimiter.coffee' }, + { startIndex: 40, type: '' }, + { startIndex: 41, type: 'string.coffee' }, + { startIndex: 47, type: 'delimiter.square.coffee' } + ] + }, + { + line: '', + tokens: [] + }, + { + line: '# Fine five course dining.', + tokens: [{ startIndex: 0, type: 'comment.coffee' }] + }, + { + line: "courses = ['greens', 'caviar', 'truffles', 'roast', 'cake']", + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 8, type: 'delimiter.coffee' }, + { startIndex: 9, type: '' }, + { startIndex: 10, type: 'delimiter.square.coffee' }, + { startIndex: 11, type: 'string.coffee' }, + { startIndex: 19, type: 'delimiter.coffee' }, + { startIndex: 20, type: '' }, + { startIndex: 21, type: 'string.coffee' }, + { startIndex: 29, type: 'delimiter.coffee' }, + { startIndex: 30, type: '' }, + { startIndex: 31, type: 'string.coffee' }, + { startIndex: 41, type: 'delimiter.coffee' }, + { startIndex: 42, type: '' }, + { startIndex: 43, type: 'string.coffee' }, + { startIndex: 50, type: 'delimiter.coffee' }, + { startIndex: 51, type: '' }, + { startIndex: 52, type: 'string.coffee' }, + { startIndex: 58, type: 'delimiter.square.coffee' } + ] + }, + { + line: 'menu i + 1, dish for dish, i in courses', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 7, type: 'delimiter.coffee' }, + { startIndex: 8, type: '' }, + { startIndex: 9, type: 'number.coffee' }, + { startIndex: 10, type: 'delimiter.coffee' }, + { startIndex: 11, type: '' }, + { startIndex: 17, type: 'keyword.for.coffee' }, + { startIndex: 20, type: '' }, + { startIndex: 25, type: 'delimiter.coffee' }, + { startIndex: 26, type: '' }, + { startIndex: 29, type: 'keyword.in.coffee' }, + { startIndex: 31, type: '' } + ] + }, + { + line: '', + tokens: [] + }, + { + line: '# Health conscious meal.', + tokens: [{ startIndex: 0, type: 'comment.coffee' }] + }, + { + line: "foods = ['broccoli', 'spinach', 'chocolate']", + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 6, type: 'delimiter.coffee' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'delimiter.square.coffee' }, + { startIndex: 9, type: 'string.coffee' }, + { startIndex: 19, type: 'delimiter.coffee' }, + { startIndex: 20, type: '' }, + { startIndex: 21, type: 'string.coffee' }, + { startIndex: 30, type: 'delimiter.coffee' }, + { startIndex: 31, type: '' }, + { startIndex: 32, type: 'string.coffee' }, + { startIndex: 43, type: 'delimiter.square.coffee' } + ] + }, + { + line: "eat food for food in foods when food isnt 'chocolate'", + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 9, type: 'keyword.for.coffee' }, + { startIndex: 12, type: '' }, + { startIndex: 18, type: 'keyword.in.coffee' }, + { startIndex: 20, type: '' }, + { startIndex: 27, type: 'keyword.when.coffee' }, + { startIndex: 31, type: '' }, + { startIndex: 37, type: 'keyword.isnt.coffee' }, + { startIndex: 41, type: '' }, + { startIndex: 42, type: 'string.coffee' } + ] + }, + { + line: '', + tokens: [] + }, + { + line: 'countdown = (num for num in [10..1])', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 10, type: 'delimiter.coffee' }, + { startIndex: 11, type: '' }, + { startIndex: 12, type: 'delimiter.parenthesis.coffee' }, + { startIndex: 13, type: '' }, + { startIndex: 17, type: 'keyword.for.coffee' }, + { startIndex: 20, type: '' }, + { startIndex: 25, type: 'keyword.in.coffee' }, + { startIndex: 27, type: '' }, + { startIndex: 28, type: 'delimiter.square.coffee' }, + { startIndex: 29, type: 'number.coffee' }, + { startIndex: 31, type: 'delimiter.coffee' }, + { startIndex: 33, type: 'number.coffee' }, + { startIndex: 34, type: 'delimiter.square.coffee' }, + { startIndex: 35, type: 'delimiter.parenthesis.coffee' } + ] + }, + { + line: '', + tokens: [] + }, + { + line: 'yearsOld = max: 10, ida: 9, tim: 11', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 9, type: 'delimiter.coffee' }, + { startIndex: 10, type: '' }, + { startIndex: 14, type: 'delimiter.coffee' }, + { startIndex: 15, type: '' }, + { startIndex: 16, type: 'number.coffee' }, + { startIndex: 18, type: 'delimiter.coffee' }, + { startIndex: 19, type: '' }, + { startIndex: 23, type: 'delimiter.coffee' }, + { startIndex: 24, type: '' }, + { startIndex: 25, type: 'number.coffee' }, + { startIndex: 26, type: 'delimiter.coffee' }, + { startIndex: 27, type: '' }, + { startIndex: 31, type: 'delimiter.coffee' }, + { startIndex: 32, type: '' }, + { startIndex: 33, type: 'number.coffee' } + ] + }, + { + line: '', + tokens: [] + }, + { + line: 'ages = for child, age of yearsOld', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 5, type: 'delimiter.coffee' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'keyword.for.coffee' }, + { startIndex: 10, type: '' }, + { startIndex: 16, type: 'delimiter.coffee' }, + { startIndex: 17, type: '' }, + { startIndex: 22, type: 'keyword.of.coffee' }, + { startIndex: 24, type: '' } + ] + }, + { + line: ' "#{child} is #{age}"', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'string.coffee' }, + { startIndex: 5, type: '' }, + { startIndex: 10, type: 'string.coffee' }, + { startIndex: 17, type: '' }, + { startIndex: 20, type: 'string.coffee' } + ] + }, + { + line: '', + tokens: [] + }, + { + line: '# Econ 101', + tokens: [{ startIndex: 0, type: 'comment.coffee' }] + }, + { + line: 'if this.studyingEconomics', + tokens: [ + { startIndex: 0, type: 'keyword.if.coffee' }, + { startIndex: 2, type: '' }, + { startIndex: 3, type: 'variable.predefined.coffee' }, + { startIndex: 7, type: 'delimiter.coffee' }, + { startIndex: 8, type: '' } + ] + }, + { + line: ' buy() while supply > demand', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 5, type: 'delimiter.parenthesis.coffee' }, + { startIndex: 7, type: '' }, + { startIndex: 9, type: 'keyword.while.coffee' }, + { startIndex: 14, type: '' }, + { startIndex: 22, type: 'delimiter.coffee' }, + { startIndex: 23, type: '' } + ] + }, + { + line: ' sell() until supply > demand', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 6, type: 'delimiter.parenthesis.coffee' }, + { startIndex: 8, type: '' }, + { startIndex: 9, type: 'keyword.until.coffee' }, + { startIndex: 14, type: '' }, + { startIndex: 22, type: 'delimiter.coffee' }, + { startIndex: 23, type: '' } + ] + }, + { + line: '', + tokens: [] + }, + { + line: '# Nursery Rhyme', + tokens: [{ startIndex: 0, type: 'comment.coffee' }] + }, + { + line: 'num = 6', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 4, type: 'delimiter.coffee' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'number.coffee' } + ] + }, + { + line: 'lyrics = while num -= 1', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 7, type: 'delimiter.coffee' }, + { startIndex: 8, type: '' }, + { startIndex: 9, type: 'keyword.while.coffee' }, + { startIndex: 14, type: '' }, + { startIndex: 19, type: 'delimiter.coffee' }, + { startIndex: 21, type: '' }, + { startIndex: 22, type: 'number.coffee' } + ] + }, + { + line: ' "#{num} little monkeys, jumping on the bed.', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'string.coffee' }, + { startIndex: 5, type: '' }, + { startIndex: 8, type: 'string.coffee' } + ] + }, + { + line: ' One fell out and bumped his head."', + tokens: [{ startIndex: 0, type: 'string.coffee' }] + }, + { + line: ' ', + tokens: [{ startIndex: 0, type: '' }] + }, + { + line: + '# Everything is an Expression (at least, as much as possible)', + tokens: [{ startIndex: 0, type: 'comment.coffee' }] + }, + { + line: 'grade = (student) ->', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 6, type: 'delimiter.coffee' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'delimiter.parenthesis.coffee' }, + { startIndex: 9, type: '' }, + { startIndex: 16, type: 'delimiter.parenthesis.coffee' }, + { startIndex: 17, type: '' }, + { startIndex: 18, type: 'delimiter.coffee' } + ] + }, + { + line: ' if student.excellentWork', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'keyword.if.coffee' }, + { startIndex: 4, type: '' }, + { startIndex: 12, type: 'delimiter.coffee' }, + { startIndex: 13, type: '' } + ] + }, + { + line: ' "A+"', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 4, type: 'string.coffee' } + ] + }, + { + line: ' else if student.okayStuff', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'keyword.else.coffee' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'keyword.if.coffee' }, + { startIndex: 9, type: '' }, + { startIndex: 17, type: 'delimiter.coffee' }, + { startIndex: 18, type: '' } + ] + }, + { + line: ' if student.triedHard then "B" else "B-"', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 4, type: 'keyword.if.coffee' }, + { startIndex: 6, type: '' }, + { startIndex: 14, type: 'delimiter.coffee' }, + { startIndex: 15, type: '' }, + { startIndex: 25, type: 'keyword.then.coffee' }, + { startIndex: 29, type: '' }, + { startIndex: 30, type: 'string.coffee' }, + { startIndex: 33, type: '' }, + { startIndex: 34, type: 'keyword.else.coffee' }, + { startIndex: 38, type: '' }, + { startIndex: 39, type: 'string.coffee' } + ] + }, + { + line: ' else', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'keyword.else.coffee' } + ] + }, + { + line: ' "C"', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 4, type: 'string.coffee' } + ] + }, + { + line: '', + tokens: [] + }, + { + line: 'eldest = if 24 > 21 then "Liz" else "Ike"', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 7, type: 'delimiter.coffee' }, + { startIndex: 8, type: '' }, + { startIndex: 9, type: 'keyword.if.coffee' }, + { startIndex: 11, type: '' }, + { startIndex: 12, type: 'number.coffee' }, + { startIndex: 14, type: '' }, + { startIndex: 15, type: 'delimiter.coffee' }, + { startIndex: 16, type: '' }, + { startIndex: 17, type: 'number.coffee' }, + { startIndex: 19, type: '' }, + { startIndex: 20, type: 'keyword.then.coffee' }, + { startIndex: 24, type: '' }, + { startIndex: 25, type: 'string.coffee' }, + { startIndex: 30, type: '' }, + { startIndex: 31, type: 'keyword.else.coffee' }, + { startIndex: 35, type: '' }, + { startIndex: 36, type: 'string.coffee' } + ] + }, + { + line: '', + tokens: [] + }, + { + line: '#Classes, Inheritance and Super', + tokens: [{ startIndex: 0, type: 'comment.coffee' }] + }, + { + line: 'class Animal', + tokens: [ + { startIndex: 0, type: 'keyword.class.coffee' }, + { startIndex: 5, type: '' } + ] + }, + { + line: ' constructor: (@name) ->', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 13, type: 'delimiter.coffee' }, + { startIndex: 14, type: '' }, + { startIndex: 15, type: 'delimiter.parenthesis.coffee' }, + { startIndex: 16, type: 'variable.predefined.coffee' }, + { startIndex: 21, type: 'delimiter.parenthesis.coffee' }, + { startIndex: 22, type: '' }, + { startIndex: 23, type: 'delimiter.coffee' } + ] + }, + { + line: '', + tokens: [] + }, + { + line: ' move: (meters) ->', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 6, type: 'delimiter.coffee' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'delimiter.parenthesis.coffee' }, + { startIndex: 9, type: '' }, + { startIndex: 15, type: 'delimiter.parenthesis.coffee' }, + { startIndex: 16, type: '' }, + { startIndex: 17, type: 'delimiter.coffee' } + ] + }, + { + line: ' alert @name + " moved #{meters}m."', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 10, type: 'variable.predefined.coffee' }, + { startIndex: 15, type: '' }, + { startIndex: 16, type: 'delimiter.coffee' }, + { startIndex: 17, type: '' }, + { startIndex: 18, type: 'string.coffee' }, + { startIndex: 28, type: '' }, + { startIndex: 34, type: 'string.coffee' } + ] + }, + { + line: '', + tokens: [] + }, + { + line: 'class Snake extends Animal', + tokens: [ + { startIndex: 0, type: 'keyword.class.coffee' }, + { startIndex: 5, type: '' }, + { startIndex: 12, type: 'keyword.extends.coffee' }, + { startIndex: 19, type: '' } + ] + }, + { + line: ' move: ->', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 6, type: 'delimiter.coffee' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'delimiter.coffee' } + ] + }, + { + line: ' alert "Slithering..."', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 10, type: 'string.coffee' } + ] + }, + { + line: ' super 5', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 4, type: 'keyword.super.coffee' }, + { startIndex: 9, type: '' }, + { startIndex: 10, type: 'number.coffee' } + ] + }, + { + line: '', + tokens: [] + }, + { + line: 'class Horse extends Animal', + tokens: [ + { startIndex: 0, type: 'keyword.class.coffee' }, + { startIndex: 5, type: '' }, + { startIndex: 12, type: 'keyword.extends.coffee' }, + { startIndex: 19, type: '' } + ] + }, + { + line: ' move: ->', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 6, type: 'delimiter.coffee' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'delimiter.coffee' } + ] + }, + { + line: ' alert "Galloping..."', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 10, type: 'string.coffee' } + ] + }, + { + line: ' super 45', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 4, type: 'keyword.super.coffee' }, + { startIndex: 9, type: '' }, + { startIndex: 10, type: 'number.coffee' } + ] + }, + { + line: '', + tokens: [] + }, + { + line: 'sam = new Snake "Sammy the Python"', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 4, type: 'delimiter.coffee' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.new.coffee' }, + { startIndex: 9, type: '' }, + { startIndex: 16, type: 'string.coffee' } + ] + }, + { + line: 'tom = new Horse "Tommy the Palomino"', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 4, type: 'delimiter.coffee' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.new.coffee' }, + { startIndex: 9, type: '' }, + { startIndex: 16, type: 'string.coffee' } + ] + }, + { + line: '', + tokens: [] + }, + { + line: 'sam.move()', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 3, type: 'delimiter.coffee' }, + { startIndex: 4, type: '' }, + { startIndex: 8, type: 'delimiter.parenthesis.coffee' } + ] + }, + { + line: 'tom.move()', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 3, type: 'delimiter.coffee' }, + { startIndex: 4, type: '' }, + { startIndex: 8, type: 'delimiter.parenthesis.coffee' } + ] + }, + { + line: '', + tokens: [] + }, + { + line: '#Function binding', + tokens: [{ startIndex: 0, type: 'comment.coffee' }] + }, + { + line: 'Account = (customer, cart) ->', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 8, type: 'delimiter.coffee' }, + { startIndex: 9, type: '' }, + { startIndex: 10, type: 'delimiter.parenthesis.coffee' }, + { startIndex: 11, type: '' }, + { startIndex: 19, type: 'delimiter.coffee' }, + { startIndex: 20, type: '' }, + { startIndex: 25, type: 'delimiter.parenthesis.coffee' }, + { startIndex: 26, type: '' }, + { startIndex: 27, type: 'delimiter.coffee' } + ] + }, + { + line: ' @customer = customer', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'variable.predefined.coffee' }, + { startIndex: 11, type: '' }, + { startIndex: 12, type: 'delimiter.coffee' }, + { startIndex: 13, type: '' } + ] + }, + { + line: ' @cart = cart', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'variable.predefined.coffee' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'delimiter.coffee' }, + { startIndex: 9, type: '' } + ] + }, + { + line: '', + tokens: [] + }, + { + line: " $('.shopping_cart').bind 'click', (event) =>", + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 3, type: 'delimiter.parenthesis.coffee' }, + { startIndex: 4, type: 'string.coffee' }, + { startIndex: 20, type: 'delimiter.parenthesis.coffee' }, + { startIndex: 21, type: 'delimiter.coffee' }, + { startIndex: 22, type: '' }, + { startIndex: 27, type: 'string.coffee' }, + { startIndex: 34, type: 'delimiter.coffee' }, + { startIndex: 35, type: '' }, + { startIndex: 36, type: 'delimiter.parenthesis.coffee' }, + { startIndex: 37, type: '' }, + { startIndex: 42, type: 'delimiter.parenthesis.coffee' }, + { startIndex: 43, type: '' }, + { startIndex: 44, type: 'delimiter.coffee' } + ] + }, + { + line: ' @customer.purchase @cart', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 4, type: 'variable.predefined.coffee' }, + { startIndex: 13, type: 'delimiter.coffee' }, + { startIndex: 14, type: '' }, + { startIndex: 23, type: 'variable.predefined.coffee' } + ] + }, + { + line: '', + tokens: [] + }, + { + line: '#Switch/When/Else ', + tokens: [{ startIndex: 0, type: 'comment.coffee' }] + }, + { + line: 'switch day', + tokens: [ + { startIndex: 0, type: 'keyword.switch.coffee' }, + { startIndex: 6, type: '' } + ] + }, + { + line: ' when "Mon" then go work', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'keyword.when.coffee' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'string.coffee' }, + { startIndex: 12, type: '' }, + { startIndex: 13, type: 'keyword.then.coffee' }, + { startIndex: 17, type: '' } + ] + }, + { + line: ' when "Tue" then go relax', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'keyword.when.coffee' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'string.coffee' }, + { startIndex: 12, type: '' }, + { startIndex: 13, type: 'keyword.then.coffee' }, + { startIndex: 17, type: '' } + ] + }, + { + line: ' when "Thu" then go iceFishing', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'keyword.when.coffee' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'string.coffee' }, + { startIndex: 12, type: '' }, + { startIndex: 13, type: 'keyword.then.coffee' }, + { startIndex: 17, type: '' } + ] + }, + { + line: ' when "Fri", "Sat"', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'keyword.when.coffee' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'string.coffee' }, + { startIndex: 12, type: 'delimiter.coffee' }, + { startIndex: 13, type: '' }, + { startIndex: 14, type: 'string.coffee' } + ] + }, + { + line: ' if day is bingoDay', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 4, type: 'keyword.if.coffee' }, + { startIndex: 6, type: '' }, + { startIndex: 11, type: 'keyword.is.coffee' }, + { startIndex: 13, type: '' } + ] + }, + { + line: ' go bingo', + tokens: [{ startIndex: 0, type: '' }] + }, + { + line: ' go dancing', + tokens: [{ startIndex: 0, type: '' }] + }, + { + line: ' when "Sun" then go church', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'keyword.when.coffee' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'string.coffee' }, + { startIndex: 12, type: '' }, + { startIndex: 13, type: 'keyword.then.coffee' }, + { startIndex: 17, type: '' } + ] + }, + { + line: ' else go work', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'keyword.else.coffee' }, + { startIndex: 6, type: '' } + ] + }, + { + line: ' ', + tokens: [{ startIndex: 0, type: '' }] + }, + { + line: '#Try/Catch/Finally', + tokens: [{ startIndex: 0, type: 'comment.coffee' }] + }, + { + line: 'try', + tokens: [{ startIndex: 0, type: 'keyword.try.coffee' }] + }, + { + line: ' allHellBreaksLoose()', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 20, type: 'delimiter.parenthesis.coffee' } + ] + }, + { + line: ' catsAndDogsLivingTogether()', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 27, type: 'delimiter.parenthesis.coffee' } + ] + }, + { + line: 'catch error', + tokens: [ + { startIndex: 0, type: 'keyword.catch.coffee' }, + { startIndex: 5, type: '' } + ] + }, + { + line: ' print error', + tokens: [{ startIndex: 0, type: '' }] + }, + { + line: 'finally', + tokens: [{ startIndex: 0, type: 'keyword.finally.coffee' }] + }, + { + line: ' cleanUp()', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 9, type: 'delimiter.parenthesis.coffee' } + ] + }, + { + line: '', + tokens: [] + }, + { + line: '#String Interpolation and Block Comments', + tokens: [{ startIndex: 0, type: 'comment.coffee' }] + }, + { + line: 'author = "Wittgenstein"', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 7, type: 'delimiter.coffee' }, + { startIndex: 8, type: '' }, + { startIndex: 9, type: 'string.coffee' } + ] + }, + { + line: 'quote = "A picture is a fact. -- #{ author }"', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 7, type: 'delimiter.coffee' }, + { startIndex: 8, type: '' }, + { startIndex: 9, type: 'string.coffee' }, + { startIndex: 36, type: '' }, + { startIndex: 44, type: 'string.coffee' } + ] + }, + { + line: '', + tokens: [] + }, + { + line: 'sentence = "#{ 22 / 7 } is a decent approximation of p"', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 9, type: 'delimiter.coffee' }, + { startIndex: 10, type: '' }, + { startIndex: 11, type: 'string.coffee' }, + { startIndex: 14, type: '' }, + { startIndex: 15, type: 'number.coffee' }, + { startIndex: 17, type: '' }, + { startIndex: 18, type: 'delimiter.coffee' }, + { startIndex: 19, type: '' }, + { startIndex: 20, type: 'number.coffee' }, + { startIndex: 21, type: '' }, + { startIndex: 22, type: 'string.coffee' } + ] + }, + { + line: '', + tokens: [] + }, + { + line: 'mobyDick = "Call me Ishmael. Some years ago --', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 9, type: 'delimiter.coffee' }, + { startIndex: 10, type: '' }, + { startIndex: 11, type: 'string.coffee' } + ] + }, + { + line: ' never mind how long precisely -- having little', + tokens: [{ startIndex: 0, type: 'string.coffee' }] + }, + { + line: ' or no money in my purse, and nothing particular', + tokens: [{ startIndex: 0, type: 'string.coffee' }] + }, + { + line: ' to interest me on shore, I thought I would sail', + tokens: [{ startIndex: 0, type: 'string.coffee' }] + }, + { + line: ' about a little and see the watery part of the', + tokens: [{ startIndex: 0, type: 'string.coffee' }] + }, + { + line: ' world..."', + tokens: [{ startIndex: 0, type: 'string.coffee' }] + }, + { + line: '', + tokens: [] + }, + { + line: '#Extended Regular Expressions', + tokens: [{ startIndex: 0, type: 'comment.coffee' }] + }, + { + line: 'OPERATOR = /// ^ (', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 9, type: 'delimiter.coffee' }, + { startIndex: 10, type: '' }, + { startIndex: 11, type: 'regexp.coffee' } + ] + }, + { + line: ' ?: [-=]> # function', + tokens: [ + { startIndex: 0, type: 'regexp.coffee' }, + { startIndex: 23, type: 'comment.coffee' } + ] + }, + { + line: ' | [-+*/%<>&|^!?=]= # compound assign / compare', + tokens: [ + { startIndex: 0, type: 'regexp.coffee' }, + { startIndex: 23, type: 'comment.coffee' } + ] + }, + { + line: ' | >>>=? # zero-fill right shift', + tokens: [ + { startIndex: 0, type: 'regexp.coffee' }, + { startIndex: 23, type: 'comment.coffee' } + ] + }, + { + line: ' | ([-+:])\\1 # doubles', + tokens: [ + { startIndex: 0, type: 'regexp.coffee' }, + { startIndex: 23, type: 'comment.coffee' } + ] + }, + { + line: ' | ([&|<>])\\2=? # logic / shift', + tokens: [ + { startIndex: 0, type: 'regexp.coffee' }, + { startIndex: 23, type: 'comment.coffee' } + ] + }, + { + line: ' | \\?\\. # soak access', + tokens: [ + { startIndex: 0, type: 'regexp.coffee' }, + { startIndex: 23, type: 'comment.coffee' } + ] + }, + { + line: ' | \\.{2,3} # range or splat', + tokens: [ + { startIndex: 0, type: 'regexp.coffee' }, + { startIndex: 23, type: 'comment.coffee' } + ] + }, + { + line: ') ///', + tokens: [{ startIndex: 0, type: 'regexp.coffee' }] + }, + { + line: '', + tokens: [] + } + ] ]); diff --git a/src/coffee/coffee.ts b/src/coffee/coffee.ts index e64cd1ca..f40eb2b3 100644 --- a/src/coffee/coffee.ts +++ b/src/coffee/coffee.ts @@ -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 = { 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 = { // 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 = { [/(\{)(\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 = { // 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 = { [/\./, '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 = { ], comment: [ - [/[^#]+/, 'comment',], + [/[^#]+/, 'comment'], [/###/, 'comment', '@pop'], - [/#/, 'comment'], + [/#/, 'comment'] ], hereregexp: [ @@ -192,7 +254,7 @@ export const language = { [/\\./, 'regexp'], [/#.*$/, 'comment'], ['///[igm]*', { token: 'regexp', next: '@pop' }], - [/\//, 'regexp'], - ], - }, + [/\//, 'regexp'] + ] + } }; diff --git a/src/cpp/cpp.test.ts b/src/cpp/cpp.test.ts index a06892f0..d4448c17 100644 --- a/src/cpp/cpp.test.ts +++ b/src/cpp/cpp.test.ts @@ -9,782 +9,824 @@ import { testTokenization } from '../test/testRunner'; testTokenization('cpp', [ // Keywords - [{ - line: 'int _tmain(int argc, _TCHAR* argv[])', - tokens: [ - { startIndex: 0, type: 'keyword.int.cpp' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'identifier.cpp' }, - { startIndex: 10, type: 'delimiter.parenthesis.cpp' }, - { startIndex: 11, type: 'keyword.int.cpp' }, - { startIndex: 14, type: '' }, - { startIndex: 15, type: 'identifier.cpp' }, - { startIndex: 19, type: 'delimiter.cpp' }, - { startIndex: 20, type: '' }, - { startIndex: 21, type: 'identifier.cpp' }, - { startIndex: 27, type: 'delimiter.cpp' }, - { startIndex: 28, type: '' }, - { startIndex: 29, type: 'identifier.cpp' }, - { startIndex: 33, type: 'delimiter.square.cpp' }, - { startIndex: 35, type: 'delimiter.parenthesis.cpp' } - ] - }], + [ + { + line: 'int _tmain(int argc, _TCHAR* argv[])', + tokens: [ + { startIndex: 0, type: 'keyword.int.cpp' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'identifier.cpp' }, + { startIndex: 10, type: 'delimiter.parenthesis.cpp' }, + { startIndex: 11, type: 'keyword.int.cpp' }, + { startIndex: 14, type: '' }, + { startIndex: 15, type: 'identifier.cpp' }, + { startIndex: 19, type: 'delimiter.cpp' }, + { startIndex: 20, type: '' }, + { startIndex: 21, type: 'identifier.cpp' }, + { startIndex: 27, type: 'delimiter.cpp' }, + { startIndex: 28, type: '' }, + { startIndex: 29, type: 'identifier.cpp' }, + { startIndex: 33, type: 'delimiter.square.cpp' }, + { startIndex: 35, type: 'delimiter.parenthesis.cpp' } + ] + } + ], // Comments - single line - [{ - line: '//', - tokens: [ - { startIndex: 0, type: 'comment.cpp' } - ] - }], + [ + { + line: '//', + tokens: [{ startIndex: 0, type: 'comment.cpp' }] + } + ], - [{ - line: ' // a comment', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 4, type: 'comment.cpp' } - ] - }], + [ + { + line: ' // a comment', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 4, type: 'comment.cpp' } + ] + } + ], - [{ - line: '// a comment', - tokens: [ - { startIndex: 0, type: 'comment.cpp' } - ] - }], + [ + { + line: '// a comment', + tokens: [{ startIndex: 0, type: 'comment.cpp' }] + } + ], - [{ - line: '//sticky comment', - tokens: [ - { startIndex: 0, type: 'comment.cpp' } - ] - }], + [ + { + line: '//sticky comment', + tokens: [{ startIndex: 0, type: 'comment.cpp' }] + } + ], - [{ - line: '/almost a comment', - tokens: [ - { startIndex: 0, type: 'delimiter.cpp' }, - { startIndex: 1, type: 'identifier.cpp' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'identifier.cpp' }, - { startIndex: 9, type: '' }, - { startIndex: 10, type: 'identifier.cpp' } - ] - }], + [ + { + line: '/almost a comment', + tokens: [ + { startIndex: 0, type: 'delimiter.cpp' }, + { startIndex: 1, type: 'identifier.cpp' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'identifier.cpp' }, + { startIndex: 9, type: '' }, + { startIndex: 10, type: 'identifier.cpp' } + ] + } + ], - [{ - line: '/* //*/ a', - tokens: [ - { startIndex: 0, type: 'comment.cpp' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'identifier.cpp' } - ] - }], + [ + { + line: '/* //*/ a', + tokens: [ + { startIndex: 0, type: 'comment.cpp' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'identifier.cpp' } + ] + } + ], - [{ - line: '1 / 2; /* comment', - tokens: [ - { startIndex: 0, type: 'number.cpp' }, - { startIndex: 1, type: '' }, - { startIndex: 2, type: 'delimiter.cpp' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'number.cpp' }, - { startIndex: 5, type: 'delimiter.cpp' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'comment.cpp' } - ] - }], + [ + { + line: '1 / 2; /* comment', + tokens: [ + { startIndex: 0, type: 'number.cpp' }, + { startIndex: 1, type: '' }, + { startIndex: 2, type: 'delimiter.cpp' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'number.cpp' }, + { startIndex: 5, type: 'delimiter.cpp' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'comment.cpp' } + ] + } + ], - [{ - line: 'int x = 1; // my comment // is a nice one', - tokens: [ - { startIndex: 0, type: 'keyword.int.cpp' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'identifier.cpp' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'delimiter.cpp' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'number.cpp' }, - { startIndex: 9, type: 'delimiter.cpp' }, - { startIndex: 10, type: '' }, - { startIndex: 11, type: 'comment.cpp' } - ] - }], + [ + { + line: 'int x = 1; // my comment // is a nice one', + tokens: [ + { startIndex: 0, type: 'keyword.int.cpp' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'identifier.cpp' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'delimiter.cpp' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'number.cpp' }, + { startIndex: 9, type: 'delimiter.cpp' }, + { startIndex: 10, type: '' }, + { startIndex: 11, type: 'comment.cpp' } + ] + } + ], // Comments - range comment, single line - [{ - line: '/* a simple comment */', - tokens: [ - { startIndex: 0, type: 'comment.cpp' } - ] - }], + [ + { + line: '/* a simple comment */', + tokens: [{ startIndex: 0, type: 'comment.cpp' }] + } + ], - [{ - line: 'int x = /* a simple comment */ 1;', - tokens: [ - { startIndex: 0, type: 'keyword.int.cpp' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'identifier.cpp' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'delimiter.cpp' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'comment.cpp' }, - { startIndex: 30, type: '' }, - { startIndex: 31, type: 'number.cpp' }, - { startIndex: 32, type: 'delimiter.cpp' } - ] - }], + [ + { + line: 'int x = /* a simple comment */ 1;', + tokens: [ + { startIndex: 0, type: 'keyword.int.cpp' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'identifier.cpp' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'delimiter.cpp' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'comment.cpp' }, + { startIndex: 30, type: '' }, + { startIndex: 31, type: 'number.cpp' }, + { startIndex: 32, type: 'delimiter.cpp' } + ] + } + ], - [{ - line: 'int x = /* comment */ 1; */', - tokens: [ - { startIndex: 0, type: 'keyword.int.cpp' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'identifier.cpp' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'delimiter.cpp' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'comment.cpp' }, - { startIndex: 21, type: '' }, - { startIndex: 22, type: 'number.cpp' }, - { startIndex: 23, type: 'delimiter.cpp' }, - { startIndex: 24, type: '' } - ] - }], + [ + { + line: 'int x = /* comment */ 1; */', + tokens: [ + { startIndex: 0, type: 'keyword.int.cpp' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'identifier.cpp' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'delimiter.cpp' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'comment.cpp' }, + { startIndex: 21, type: '' }, + { startIndex: 22, type: 'number.cpp' }, + { startIndex: 23, type: 'delimiter.cpp' }, + { startIndex: 24, type: '' } + ] + } + ], - [{ - line: 'x = /**/;', - tokens: [ - { startIndex: 0, type: 'identifier.cpp' }, - { startIndex: 1, type: '' }, - { startIndex: 2, type: 'delimiter.cpp' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'comment.cpp' }, - { startIndex: 8, type: 'delimiter.cpp' } - ] - }], + [ + { + line: 'x = /**/;', + tokens: [ + { startIndex: 0, type: 'identifier.cpp' }, + { startIndex: 1, type: '' }, + { startIndex: 2, type: 'delimiter.cpp' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'comment.cpp' }, + { startIndex: 8, type: 'delimiter.cpp' } + ] + } + ], - [{ - line: 'x = /*/;', - tokens: [ - { startIndex: 0, type: 'identifier.cpp' }, - { startIndex: 1, type: '' }, - { startIndex: 2, type: 'delimiter.cpp' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'comment.cpp' } - ] - }], + [ + { + line: 'x = /*/;', + tokens: [ + { startIndex: 0, type: 'identifier.cpp' }, + { startIndex: 1, type: '' }, + { startIndex: 2, type: 'delimiter.cpp' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'comment.cpp' } + ] + } + ], // Numbers - [{ - line: '0', - tokens: [ - { startIndex: 0, type: 'number.cpp' } - ] - }], + [ + { + line: '0', + tokens: [{ startIndex: 0, type: 'number.cpp' }] + } + ], - [{ - line: '12l', - tokens: [ - { startIndex: 0, type: 'number.cpp' } - ] - }], + [ + { + line: '12l', + tokens: [{ startIndex: 0, type: 'number.cpp' }] + } + ], - [{ - line: '34U', - tokens: [ - { startIndex: 0, type: 'number.cpp' } - ] - }], + [ + { + line: '34U', + tokens: [{ startIndex: 0, type: 'number.cpp' }] + } + ], - [{ - line: '55LL', - tokens: [ - { startIndex: 0, type: 'number.cpp' } - ] - }], + [ + { + line: '55LL', + tokens: [{ startIndex: 0, type: 'number.cpp' }] + } + ], - [{ - line: '34ul', - tokens: [ - { startIndex: 0, type: 'number.cpp' } - ] - }], + [ + { + line: '34ul', + tokens: [{ startIndex: 0, type: 'number.cpp' }] + } + ], - [{ - line: '55llU', - tokens: [ - { startIndex: 0, type: 'number.cpp' } - ] - }], + [ + { + line: '55llU', + tokens: [{ startIndex: 0, type: 'number.cpp' }] + } + ], - [{ - line: '5\'5llU', - tokens: [ - { startIndex: 0, type: 'number.cpp' } - ] - }], + [ + { + line: "5'5llU", + tokens: [{ startIndex: 0, type: 'number.cpp' }] + } + ], - [{ - line: '100\'000\'000', - tokens: [ - { startIndex: 0, type: 'number.cpp' } - ] - }], + [ + { + line: "100'000'000", + tokens: [{ startIndex: 0, type: 'number.cpp' }] + } + ], - [{ - line: '0x100\'aafllU', - tokens: [ - { startIndex: 0, type: 'number.hex.cpp' } - ] - }], + [ + { + line: "0x100'aafllU", + tokens: [{ startIndex: 0, type: 'number.hex.cpp' }] + } + ], - [{ - line: '0342\'325', - tokens: [ - { startIndex: 0, type: 'number.octal.cpp' } - ] - }], + [ + { + line: "0342'325", + tokens: [{ startIndex: 0, type: 'number.octal.cpp' }] + } + ], - [{ - line: '0x123', - tokens: [ - { startIndex: 0, type: 'number.hex.cpp' } - ] - }], + [ + { + line: '0x123', + tokens: [{ startIndex: 0, type: 'number.hex.cpp' }] + } + ], - [{ - line: '23.5', - tokens: [ - { startIndex: 0, type: 'number.float.cpp' } - ] - }], + [ + { + line: '23.5', + tokens: [{ startIndex: 0, type: 'number.float.cpp' }] + } + ], - [{ - line: '23.5e3', - tokens: [ - { startIndex: 0, type: 'number.float.cpp' } - ] - }], + [ + { + line: '23.5e3', + tokens: [{ startIndex: 0, type: 'number.float.cpp' }] + } + ], - [{ - line: '23.5E3', - tokens: [ - { startIndex: 0, type: 'number.float.cpp' } - ] - }], + [ + { + line: '23.5E3', + tokens: [{ startIndex: 0, type: 'number.float.cpp' }] + } + ], - [{ - line: '23.5F', - tokens: [ - { startIndex: 0, type: 'number.float.cpp' } - ] - }], + [ + { + line: '23.5F', + tokens: [{ startIndex: 0, type: 'number.float.cpp' }] + } + ], - [{ - line: '23.5f', - tokens: [ - { startIndex: 0, type: 'number.float.cpp' } - ] - }], + [ + { + line: '23.5f', + tokens: [{ startIndex: 0, type: 'number.float.cpp' }] + } + ], - [{ - line: '1.72E3F', - tokens: [ - { startIndex: 0, type: 'number.float.cpp' } - ] - }], + [ + { + line: '1.72E3F', + tokens: [{ startIndex: 0, type: 'number.float.cpp' }] + } + ], - [{ - line: '1.72E3f', - tokens: [ - { startIndex: 0, type: 'number.float.cpp' } - ] - }], + [ + { + line: '1.72E3f', + tokens: [{ startIndex: 0, type: 'number.float.cpp' }] + } + ], - [{ - line: '1.72e3F', - tokens: [ - { startIndex: 0, type: 'number.float.cpp' } - ] - }], + [ + { + line: '1.72e3F', + tokens: [{ startIndex: 0, type: 'number.float.cpp' }] + } + ], - [{ - line: '1.72e3f', - tokens: [ - { startIndex: 0, type: 'number.float.cpp' } - ] - }], + [ + { + line: '1.72e3f', + tokens: [{ startIndex: 0, type: 'number.float.cpp' }] + } + ], - [{ - line: '23.5L', - tokens: [ - { startIndex: 0, type: 'number.float.cpp' } - ] - }], + [ + { + line: '23.5L', + tokens: [{ startIndex: 0, type: 'number.float.cpp' }] + } + ], - [{ - line: '23.5l', - tokens: [ - { startIndex: 0, type: 'number.float.cpp' } - ] - }], + [ + { + line: '23.5l', + tokens: [{ startIndex: 0, type: 'number.float.cpp' }] + } + ], - [{ - line: '1.72E3L', - tokens: [ - { startIndex: 0, type: 'number.float.cpp' } - ] - }], + [ + { + line: '1.72E3L', + tokens: [{ startIndex: 0, type: 'number.float.cpp' }] + } + ], - [{ - line: '1.72E3l', - tokens: [ - { startIndex: 0, type: 'number.float.cpp' } - ] - }], + [ + { + line: '1.72E3l', + tokens: [{ startIndex: 0, type: 'number.float.cpp' }] + } + ], - [{ - line: '1.72e3L', - tokens: [ - { startIndex: 0, type: 'number.float.cpp' } - ] - }], + [ + { + line: '1.72e3L', + tokens: [{ startIndex: 0, type: 'number.float.cpp' }] + } + ], - [{ - line: '1.72e3l', - tokens: [ - { startIndex: 0, type: 'number.float.cpp' } - ] - }], + [ + { + line: '1.72e3l', + tokens: [{ startIndex: 0, type: 'number.float.cpp' }] + } + ], - [{ - line: '0+0', - tokens: [ - { startIndex: 0, type: 'number.cpp' }, - { startIndex: 1, type: 'delimiter.cpp' }, - { startIndex: 2, type: 'number.cpp' } - ] - }], + [ + { + line: '0+0', + tokens: [ + { startIndex: 0, type: 'number.cpp' }, + { startIndex: 1, type: 'delimiter.cpp' }, + { startIndex: 2, type: 'number.cpp' } + ] + } + ], - [{ - line: '100+10', - tokens: [ - { startIndex: 0, type: 'number.cpp' }, - { startIndex: 3, type: 'delimiter.cpp' }, - { startIndex: 4, type: 'number.cpp' } - ] - }], + [ + { + line: '100+10', + tokens: [ + { startIndex: 0, type: 'number.cpp' }, + { startIndex: 3, type: 'delimiter.cpp' }, + { startIndex: 4, type: 'number.cpp' } + ] + } + ], - [{ - line: '0 + 0', - tokens: [ - { startIndex: 0, type: 'number.cpp' }, - { startIndex: 1, type: '' }, - { startIndex: 2, type: 'delimiter.cpp' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'number.cpp' } - ] - }], + [ + { + line: '0 + 0', + tokens: [ + { startIndex: 0, type: 'number.cpp' }, + { startIndex: 1, type: '' }, + { startIndex: 2, type: 'delimiter.cpp' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'number.cpp' } + ] + } + ], // Monarch Generated - [{ - line: '#include', - tokens: [ - { startIndex: 0, type: 'keyword.directive.include.cpp' }, - { startIndex: 8, type: 'keyword.directive.include.begin.cpp' }, - { startIndex: 9, type: 'string.include.identifier.cpp' }, - { startIndex: 17, type: 'keyword.directive.include.end.cpp' } - ] - }, { - line: '#include "/path/to/my/file.h"', - tokens: [ - { startIndex: 0, type: 'keyword.directive.include.cpp' }, - { startIndex: 8, type: '' }, - { startIndex: 9, type: 'keyword.directive.include.begin.cpp' }, - { startIndex: 10, type: 'string.include.identifier.cpp' }, - { startIndex: 28, type: 'keyword.directive.include.end.cpp' } - ] - }, { - line: '', - tokens: [ - - ] - }, { - line: '#ifdef VAR', - tokens: [ - { startIndex: 0, type: 'keyword.cpp' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'identifier.cpp' } - ] - }, { - line: '#define SUM(A,B) (A) + (B)', - tokens: [ - { startIndex: 0, type: 'keyword.cpp' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'identifier.cpp' }, - { startIndex: 11, type: 'delimiter.parenthesis.cpp' }, - { startIndex: 12, type: 'identifier.cpp' }, - { startIndex: 13, type: 'delimiter.cpp' }, - { startIndex: 14, type: 'identifier.cpp' }, - { startIndex: 15, type: 'delimiter.parenthesis.cpp' }, - { startIndex: 16, type: '' }, - { startIndex: 17, type: 'delimiter.parenthesis.cpp' }, - { startIndex: 18, type: 'identifier.cpp' }, - { startIndex: 19, type: 'delimiter.parenthesis.cpp' }, - { startIndex: 20, type: '' }, - { startIndex: 21, type: 'delimiter.cpp' }, - { startIndex: 22, type: '' }, - { startIndex: 23, type: 'delimiter.parenthesis.cpp' }, - { startIndex: 24, type: 'identifier.cpp' }, - { startIndex: 25, type: 'delimiter.parenthesis.cpp' } - ] - }, { - line: '', - tokens: [ - - ] - }, { - line: 'int main(int argc, char** argv)', - tokens: [ - { startIndex: 0, type: 'keyword.int.cpp' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'identifier.cpp' }, - { startIndex: 8, type: 'delimiter.parenthesis.cpp' }, - { startIndex: 9, type: 'keyword.int.cpp' }, - { startIndex: 12, type: '' }, - { startIndex: 13, type: 'identifier.cpp' }, - { startIndex: 17, type: 'delimiter.cpp' }, - { startIndex: 18, type: '' }, - { startIndex: 19, type: 'keyword.char.cpp' }, - { startIndex: 23, type: '' }, - { startIndex: 26, type: 'identifier.cpp' }, - { startIndex: 30, type: 'delimiter.parenthesis.cpp' } - ] - }, { - line: '{', - tokens: [ - { startIndex: 0, type: 'delimiter.curly.cpp' } - ] - }, { - line: ' return 0;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 1, type: 'keyword.return.cpp' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'number.cpp' }, - { startIndex: 9, type: 'delimiter.cpp' } - ] - }, { - line: '}', - tokens: [ - { startIndex: 0, type: 'delimiter.curly.cpp' } - ] - }, { - line: '', - tokens: [ - - ] - }, { - line: 'namespace TestSpace', - tokens: [ - { startIndex: 0, type: 'keyword.namespace.cpp' }, - { startIndex: 9, type: '' }, - { startIndex: 10, type: 'identifier.cpp' } - ] - }, { - line: '{', - tokens: [ - { startIndex: 0, type: 'delimiter.curly.cpp' } - ] - }, { - line: ' using Asdf.CDE;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 1, type: 'keyword.using.cpp' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'identifier.cpp' }, - { startIndex: 11, type: 'delimiter.cpp' }, - { startIndex: 12, type: 'identifier.cpp' }, - { startIndex: 15, type: 'delimiter.cpp' } - ] - }, { - line: ' template ', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 1, type: 'keyword.template.cpp' }, - { startIndex: 9, type: '' }, - { startIndex: 10, type: 'delimiter.angle.cpp' }, - { startIndex: 11, type: 'keyword.typename.cpp' }, - { startIndex: 19, type: '' }, - { startIndex: 20, type: 'identifier.cpp' }, - { startIndex: 21, type: 'delimiter.angle.cpp' } - ] - }, { - line: ' class CoolClass : protected BaseClass', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 1, type: 'keyword.class.cpp' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'identifier.cpp' }, - { startIndex: 16, type: '' }, - { startIndex: 17, type: 'delimiter.cpp' }, - { startIndex: 18, type: '' }, - { startIndex: 19, type: 'keyword.protected.cpp' }, - { startIndex: 28, type: '' }, - { startIndex: 29, type: 'identifier.cpp' } - ] - }, { - line: ' {', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 1, type: 'delimiter.curly.cpp' } - ] - }, { - line: ' private:', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'keyword.private.cpp' }, - { startIndex: 9, type: 'delimiter.cpp' } - ] - }, { - line: ' ', - tokens: [ - { startIndex: 0, type: '' } - ] - }, { - line: ' static T field;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'keyword.static.cpp' }, - { startIndex: 8, type: '' }, - { startIndex: 9, type: 'identifier.cpp' }, - { startIndex: 10, type: '' }, - { startIndex: 11, type: 'identifier.cpp' }, - { startIndex: 16, type: 'delimiter.cpp' } - ] - }, { - line: ' ', - tokens: [ - { startIndex: 0, type: '' } - ] - }, { - line: ' public:', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'keyword.public.cpp' }, - { startIndex: 8, type: 'delimiter.cpp' } - ] - }, { - line: ' ', - tokens: [ - { startIndex: 0, type: '' } - ] - }, { - line: ' [[deprecated]]', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'annotation.cpp' } - ] - }, { - line: ' foo method() const override', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'identifier.cpp' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'identifier.cpp' }, - { startIndex: 12, type: 'delimiter.parenthesis.cpp' }, - { startIndex: 14, type: '' }, - { startIndex: 15, type: 'keyword.const.cpp' }, - { startIndex: 20, type: '' }, - { startIndex: 21, type: 'keyword.override.cpp' } - ] - }, { - line: ' {', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'delimiter.curly.cpp' } - ] - }, { - line: ' auto s = new Bar();', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 3, type: 'keyword.auto.cpp' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'identifier.cpp' }, - { startIndex: 9, type: '' }, - { startIndex: 10, type: 'delimiter.cpp' }, - { startIndex: 11, type: '' }, - { startIndex: 12, type: 'keyword.new.cpp' }, - { startIndex: 15, type: '' }, - { startIndex: 16, type: 'identifier.cpp' }, - { startIndex: 19, type: 'delimiter.parenthesis.cpp' }, - { startIndex: 21, type: 'delimiter.cpp' } - ] - }, { - line: ' ', - tokens: [ - { startIndex: 0, type: '' } - ] - }, { - line: ' if (s.field) {', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 3, type: 'keyword.if.cpp' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'delimiter.parenthesis.cpp' }, - { startIndex: 7, type: 'identifier.cpp' }, - { startIndex: 8, type: 'delimiter.cpp' }, - { startIndex: 9, type: 'identifier.cpp' }, - { startIndex: 14, type: 'delimiter.parenthesis.cpp' }, - { startIndex: 15, type: '' }, - { startIndex: 16, type: 'delimiter.curly.cpp' } - ] - }, { - line: ' for(const auto & b : s.field) {', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 4, type: 'keyword.for.cpp' }, - { startIndex: 7, type: 'delimiter.parenthesis.cpp' }, - { startIndex: 8, type: 'keyword.const.cpp' }, - { startIndex: 13, type: '' }, - { startIndex: 14, type: 'keyword.auto.cpp' }, - { startIndex: 18, type: '' }, - { startIndex: 19, type: 'delimiter.cpp' }, - { startIndex: 20, type: '' }, - { startIndex: 21, type: 'identifier.cpp' }, - { startIndex: 22, type: '' }, - { startIndex: 23, type: 'delimiter.cpp' }, - { startIndex: 24, type: '' }, - { startIndex: 25, type: 'identifier.cpp' }, - { startIndex: 26, type: 'delimiter.cpp' }, - { startIndex: 27, type: 'identifier.cpp' }, - { startIndex: 32, type: 'delimiter.parenthesis.cpp' }, - { startIndex: 33, type: '' }, - { startIndex: 34, type: 'delimiter.curly.cpp' } - ] - }, { - line: ' break;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 5, type: 'keyword.break.cpp' }, - { startIndex: 10, type: 'delimiter.cpp' } - ] - }, { - line: ' }', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 4, type: 'delimiter.curly.cpp' } - ] - }, { - line: ' }', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 3, type: 'delimiter.curly.cpp' } - ] - }, { - line: ' }', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'delimiter.curly.cpp' } - ] - }, { - line: ' ', - tokens: [ - { startIndex: 0, type: '' } - ] - }, { - line: ' std::string s = "hello wordld\\n";', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'identifier.cpp' }, - { startIndex: 5, type: '' }, - { startIndex: 7, type: 'identifier.cpp' }, - { startIndex: 13, type: '' }, - { startIndex: 14, type: 'identifier.cpp' }, - { startIndex: 15, type: '' }, - { startIndex: 16, type: 'delimiter.cpp' }, - { startIndex: 17, type: '' }, - { startIndex: 18, type: 'string.cpp' }, - { startIndex: 31, type: 'string.escape.cpp' }, - { startIndex: 33, type: 'string.cpp' }, - { startIndex: 34, type: 'delimiter.cpp' } - ] - }, { - line: ' ', - tokens: [ - { startIndex: 0, type: '' } - ] - }, { - line: ' int number = 123\'123\'123Ull;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'keyword.int.cpp' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'identifier.cpp' }, - { startIndex: 12, type: '' }, - { startIndex: 13, type: 'delimiter.cpp' }, - { startIndex: 14, type: '' }, - { startIndex: 15, type: 'number.cpp' }, - { startIndex: 29, type: 'delimiter.cpp' } - ] - }, { - line: ' }', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 1, type: 'delimiter.curly.cpp' } - ] - }, { - line: '}', - tokens: [ - { startIndex: 0, type: 'delimiter.curly.cpp' } - ] - }, { - line: '', - tokens: [ - - ] - }, { - line: '#endif', - tokens: [ - { startIndex: 0, type: 'keyword.cpp' } - ] - }, { - line: '# ifdef VAR', - tokens: [ - { startIndex: 0, type: 'keyword.cpp' }, - { startIndex: 10, type: '' }, - { startIndex: 11, type: 'identifier.cpp' } - ] - }, { - line: '# define SUM(A,B) (A) + (B)', - tokens: [ - { startIndex: 0, type: 'keyword.cpp' }, - { startIndex: 8, type: '' }, - { startIndex: 9, type: 'identifier.cpp' }, - { startIndex: 12, type: 'delimiter.parenthesis.cpp' }, - { startIndex: 13, type: 'identifier.cpp' }, - { startIndex: 14, type: 'delimiter.cpp' }, - { startIndex: 15, type: 'identifier.cpp' }, - { startIndex: 16, type: 'delimiter.parenthesis.cpp' }, - { startIndex: 17, type: '' }, - { startIndex: 18, type: 'delimiter.parenthesis.cpp' }, - { startIndex: 19, type: 'identifier.cpp' }, - { startIndex: 20, type: 'delimiter.parenthesis.cpp' }, - { startIndex: 21, type: '' }, - { startIndex: 22, type: 'delimiter.cpp' }, - { startIndex: 23, type: '' }, - { startIndex: 24, type: 'delimiter.parenthesis.cpp' }, - { startIndex: 25, type: 'identifier.cpp' }, - { startIndex: 26, type: 'delimiter.parenthesis.cpp' } - ] - }, { - line: 'uR"V0G0N(abc)V0G0N"def', - tokens: [ - { startIndex: 0, type: 'string.raw.begin.cpp' }, - { startIndex: 9, type: 'string.raw.cpp' }, - { startIndex: 12, type: 'string.raw.end.cpp' }, - { startIndex: 19, type: 'identifier.cpp' } - ] - }] + [ + { + line: '#include', + tokens: [ + { startIndex: 0, type: 'keyword.directive.include.cpp' }, + { startIndex: 8, type: 'keyword.directive.include.begin.cpp' }, + { startIndex: 9, type: 'string.include.identifier.cpp' }, + { startIndex: 17, type: 'keyword.directive.include.end.cpp' } + ] + }, + { + line: '#include "/path/to/my/file.h"', + tokens: [ + { startIndex: 0, type: 'keyword.directive.include.cpp' }, + { startIndex: 8, type: '' }, + { startIndex: 9, type: 'keyword.directive.include.begin.cpp' }, + { startIndex: 10, type: 'string.include.identifier.cpp' }, + { startIndex: 28, type: 'keyword.directive.include.end.cpp' } + ] + }, + { + line: '', + tokens: [] + }, + { + line: '#ifdef VAR', + tokens: [ + { startIndex: 0, type: 'keyword.cpp' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'identifier.cpp' } + ] + }, + { + line: '#define SUM(A,B) (A) + (B)', + tokens: [ + { startIndex: 0, type: 'keyword.cpp' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'identifier.cpp' }, + { startIndex: 11, type: 'delimiter.parenthesis.cpp' }, + { startIndex: 12, type: 'identifier.cpp' }, + { startIndex: 13, type: 'delimiter.cpp' }, + { startIndex: 14, type: 'identifier.cpp' }, + { startIndex: 15, type: 'delimiter.parenthesis.cpp' }, + { startIndex: 16, type: '' }, + { startIndex: 17, type: 'delimiter.parenthesis.cpp' }, + { startIndex: 18, type: 'identifier.cpp' }, + { startIndex: 19, type: 'delimiter.parenthesis.cpp' }, + { startIndex: 20, type: '' }, + { startIndex: 21, type: 'delimiter.cpp' }, + { startIndex: 22, type: '' }, + { startIndex: 23, type: 'delimiter.parenthesis.cpp' }, + { startIndex: 24, type: 'identifier.cpp' }, + { startIndex: 25, type: 'delimiter.parenthesis.cpp' } + ] + }, + { + line: '', + tokens: [] + }, + { + line: 'int main(int argc, char** argv)', + tokens: [ + { startIndex: 0, type: 'keyword.int.cpp' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'identifier.cpp' }, + { startIndex: 8, type: 'delimiter.parenthesis.cpp' }, + { startIndex: 9, type: 'keyword.int.cpp' }, + { startIndex: 12, type: '' }, + { startIndex: 13, type: 'identifier.cpp' }, + { startIndex: 17, type: 'delimiter.cpp' }, + { startIndex: 18, type: '' }, + { startIndex: 19, type: 'keyword.char.cpp' }, + { startIndex: 23, type: '' }, + { startIndex: 26, type: 'identifier.cpp' }, + { startIndex: 30, type: 'delimiter.parenthesis.cpp' } + ] + }, + { + line: '{', + tokens: [{ startIndex: 0, type: 'delimiter.curly.cpp' }] + }, + { + line: ' return 0;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 1, type: 'keyword.return.cpp' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'number.cpp' }, + { startIndex: 9, type: 'delimiter.cpp' } + ] + }, + { + line: '}', + tokens: [{ startIndex: 0, type: 'delimiter.curly.cpp' }] + }, + { + line: '', + tokens: [] + }, + { + line: 'namespace TestSpace', + tokens: [ + { startIndex: 0, type: 'keyword.namespace.cpp' }, + { startIndex: 9, type: '' }, + { startIndex: 10, type: 'identifier.cpp' } + ] + }, + { + line: '{', + tokens: [{ startIndex: 0, type: 'delimiter.curly.cpp' }] + }, + { + line: ' using Asdf.CDE;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 1, type: 'keyword.using.cpp' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'identifier.cpp' }, + { startIndex: 11, type: 'delimiter.cpp' }, + { startIndex: 12, type: 'identifier.cpp' }, + { startIndex: 15, type: 'delimiter.cpp' } + ] + }, + { + line: ' template ', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 1, type: 'keyword.template.cpp' }, + { startIndex: 9, type: '' }, + { startIndex: 10, type: 'delimiter.angle.cpp' }, + { startIndex: 11, type: 'keyword.typename.cpp' }, + { startIndex: 19, type: '' }, + { startIndex: 20, type: 'identifier.cpp' }, + { startIndex: 21, type: 'delimiter.angle.cpp' } + ] + }, + { + line: ' class CoolClass : protected BaseClass', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 1, type: 'keyword.class.cpp' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'identifier.cpp' }, + { startIndex: 16, type: '' }, + { startIndex: 17, type: 'delimiter.cpp' }, + { startIndex: 18, type: '' }, + { startIndex: 19, type: 'keyword.protected.cpp' }, + { startIndex: 28, type: '' }, + { startIndex: 29, type: 'identifier.cpp' } + ] + }, + { + line: ' {', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 1, type: 'delimiter.curly.cpp' } + ] + }, + { + line: ' private:', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'keyword.private.cpp' }, + { startIndex: 9, type: 'delimiter.cpp' } + ] + }, + { + line: ' ', + tokens: [{ startIndex: 0, type: '' }] + }, + { + line: ' static T field;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'keyword.static.cpp' }, + { startIndex: 8, type: '' }, + { startIndex: 9, type: 'identifier.cpp' }, + { startIndex: 10, type: '' }, + { startIndex: 11, type: 'identifier.cpp' }, + { startIndex: 16, type: 'delimiter.cpp' } + ] + }, + { + line: ' ', + tokens: [{ startIndex: 0, type: '' }] + }, + { + line: ' public:', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'keyword.public.cpp' }, + { startIndex: 8, type: 'delimiter.cpp' } + ] + }, + { + line: ' ', + tokens: [{ startIndex: 0, type: '' }] + }, + { + line: ' [[deprecated]]', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'annotation.cpp' } + ] + }, + { + line: ' foo method() const override', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'identifier.cpp' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'identifier.cpp' }, + { startIndex: 12, type: 'delimiter.parenthesis.cpp' }, + { startIndex: 14, type: '' }, + { startIndex: 15, type: 'keyword.const.cpp' }, + { startIndex: 20, type: '' }, + { startIndex: 21, type: 'keyword.override.cpp' } + ] + }, + { + line: ' {', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'delimiter.curly.cpp' } + ] + }, + { + line: ' auto s = new Bar();', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 3, type: 'keyword.auto.cpp' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'identifier.cpp' }, + { startIndex: 9, type: '' }, + { startIndex: 10, type: 'delimiter.cpp' }, + { startIndex: 11, type: '' }, + { startIndex: 12, type: 'keyword.new.cpp' }, + { startIndex: 15, type: '' }, + { startIndex: 16, type: 'identifier.cpp' }, + { startIndex: 19, type: 'delimiter.parenthesis.cpp' }, + { startIndex: 21, type: 'delimiter.cpp' } + ] + }, + { + line: ' ', + tokens: [{ startIndex: 0, type: '' }] + }, + { + line: ' if (s.field) {', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 3, type: 'keyword.if.cpp' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'delimiter.parenthesis.cpp' }, + { startIndex: 7, type: 'identifier.cpp' }, + { startIndex: 8, type: 'delimiter.cpp' }, + { startIndex: 9, type: 'identifier.cpp' }, + { startIndex: 14, type: 'delimiter.parenthesis.cpp' }, + { startIndex: 15, type: '' }, + { startIndex: 16, type: 'delimiter.curly.cpp' } + ] + }, + { + line: ' for(const auto & b : s.field) {', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 4, type: 'keyword.for.cpp' }, + { startIndex: 7, type: 'delimiter.parenthesis.cpp' }, + { startIndex: 8, type: 'keyword.const.cpp' }, + { startIndex: 13, type: '' }, + { startIndex: 14, type: 'keyword.auto.cpp' }, + { startIndex: 18, type: '' }, + { startIndex: 19, type: 'delimiter.cpp' }, + { startIndex: 20, type: '' }, + { startIndex: 21, type: 'identifier.cpp' }, + { startIndex: 22, type: '' }, + { startIndex: 23, type: 'delimiter.cpp' }, + { startIndex: 24, type: '' }, + { startIndex: 25, type: 'identifier.cpp' }, + { startIndex: 26, type: 'delimiter.cpp' }, + { startIndex: 27, type: 'identifier.cpp' }, + { startIndex: 32, type: 'delimiter.parenthesis.cpp' }, + { startIndex: 33, type: '' }, + { startIndex: 34, type: 'delimiter.curly.cpp' } + ] + }, + { + line: ' break;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 5, type: 'keyword.break.cpp' }, + { startIndex: 10, type: 'delimiter.cpp' } + ] + }, + { + line: ' }', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 4, type: 'delimiter.curly.cpp' } + ] + }, + { + line: ' }', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 3, type: 'delimiter.curly.cpp' } + ] + }, + { + line: ' }', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'delimiter.curly.cpp' } + ] + }, + { + line: ' ', + tokens: [{ startIndex: 0, type: '' }] + }, + { + line: ' std::string s = "hello wordld\\n";', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'identifier.cpp' }, + { startIndex: 5, type: '' }, + { startIndex: 7, type: 'identifier.cpp' }, + { startIndex: 13, type: '' }, + { startIndex: 14, type: 'identifier.cpp' }, + { startIndex: 15, type: '' }, + { startIndex: 16, type: 'delimiter.cpp' }, + { startIndex: 17, type: '' }, + { startIndex: 18, type: 'string.cpp' }, + { startIndex: 31, type: 'string.escape.cpp' }, + { startIndex: 33, type: 'string.cpp' }, + { startIndex: 34, type: 'delimiter.cpp' } + ] + }, + { + line: ' ', + tokens: [{ startIndex: 0, type: '' }] + }, + { + line: " int number = 123'123'123Ull;", + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'keyword.int.cpp' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'identifier.cpp' }, + { startIndex: 12, type: '' }, + { startIndex: 13, type: 'delimiter.cpp' }, + { startIndex: 14, type: '' }, + { startIndex: 15, type: 'number.cpp' }, + { startIndex: 29, type: 'delimiter.cpp' } + ] + }, + { + line: ' }', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 1, type: 'delimiter.curly.cpp' } + ] + }, + { + line: '}', + tokens: [{ startIndex: 0, type: 'delimiter.curly.cpp' }] + }, + { + line: '', + tokens: [] + }, + { + line: '#endif', + tokens: [{ startIndex: 0, type: 'keyword.cpp' }] + }, + { + line: '# ifdef VAR', + tokens: [ + { startIndex: 0, type: 'keyword.cpp' }, + { startIndex: 10, type: '' }, + { startIndex: 11, type: 'identifier.cpp' } + ] + }, + { + line: '# define SUM(A,B) (A) + (B)', + tokens: [ + { startIndex: 0, type: 'keyword.cpp' }, + { startIndex: 8, type: '' }, + { startIndex: 9, type: 'identifier.cpp' }, + { startIndex: 12, type: 'delimiter.parenthesis.cpp' }, + { startIndex: 13, type: 'identifier.cpp' }, + { startIndex: 14, type: 'delimiter.cpp' }, + { startIndex: 15, type: 'identifier.cpp' }, + { startIndex: 16, type: 'delimiter.parenthesis.cpp' }, + { startIndex: 17, type: '' }, + { startIndex: 18, type: 'delimiter.parenthesis.cpp' }, + { startIndex: 19, type: 'identifier.cpp' }, + { startIndex: 20, type: 'delimiter.parenthesis.cpp' }, + { startIndex: 21, type: '' }, + { startIndex: 22, type: 'delimiter.cpp' }, + { startIndex: 23, type: '' }, + { startIndex: 24, type: 'delimiter.parenthesis.cpp' }, + { startIndex: 25, type: 'identifier.cpp' }, + { startIndex: 26, type: 'delimiter.parenthesis.cpp' } + ] + }, + { + line: 'uR"V0G0N(abc)V0G0N"def', + tokens: [ + { startIndex: 0, type: 'string.raw.begin.cpp' }, + { startIndex: 9, type: 'string.raw.cpp' }, + { startIndex: 12, type: 'string.raw.end.cpp' }, + { startIndex: 19, type: 'identifier.cpp' } + ] + } + ] ]); diff --git a/src/cpp/cpp.ts b/src/cpp/cpp.ts index 7683f63e..4c19cdc2 100644 --- a/src/cpp/cpp.ts +++ b/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 = { '_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 = { ], operators: [ - '=', '>', '<', '!', '~', '?', ':', - '==', '<=', '>=', '!=', '&&', '||', '++', '--', - '+', '-', '*', '/', '&', '|', '^', '%', '<<', - '>>', '>>>', '+=', '-=', '*=', '/=', '&=', '|=', - '^=', '%=', '<<=', '>>=', '>>>=' + '=', + '>', + '<', + '!', + '~', + '?', + ':', + '==', + '<=', + '>=', + '!=', + '&&', + '||', + '++', + '--', + '+', + '-', + '*', + '/', + '&', + '|', + '^', + '%', + '<<', + '>>', + '>>>', + '+=', + '-=', + '*=', + '/=', + '&=', + '|=', + '^=', + '%=', + '<<=', + '>>=', + '>>>=' ], // we include these common regular expressions @@ -252,15 +284,21 @@ export const language = { 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 = { // [[ 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 = { // 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 = { [/[;,.]/, 'delimiter'], // strings - [/"([^"\\]|\\.)*$/, 'string.invalid'], // non-teminated string + [/"([^"\\]|\\.)*$/, 'string.invalid'], // non-teminated string [/"/, 'string', '@string'], // characters @@ -309,7 +353,7 @@ export const language = { [/[ \t\r\n]+/, ''], [/\/\*\*(?!\/)/, 'comment.doc', '@doccomment'], [/\/\*/, 'comment', '@comment'], - [/\/\/.*$/, 'comment'], + [/\/\/.*$/, 'comment'] ], comment: [ @@ -332,10 +376,22 @@ export const language = { ], 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 = { ], 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' } + ] + ] ] - }, + } }; diff --git a/src/csharp/csharp.test.ts b/src/csharp/csharp.test.ts index 4ca578a3..f184cc1b 100644 --- a/src/csharp/csharp.test.ts +++ b/src/csharp/csharp.test.ts @@ -8,907 +8,973 @@ import { testTokenization } from '../test/testRunner'; testTokenization('csharp', [ - // Generated from sample - [{ - line: 'using System;', - tokens: [ - { startIndex: 0, type: 'keyword.using.cs' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'namespace.cs' }, - { startIndex: 12, type: 'delimiter.cs' } - ] - }, { - line: 'using System.Collections.Generic;', - tokens: [ - { startIndex: 0, type: 'keyword.using.cs' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'namespace.cs' }, - { startIndex: 12, type: 'delimiter.cs' }, - { startIndex: 13, type: 'namespace.cs' }, - { startIndex: 24, type: 'delimiter.cs' }, - { startIndex: 25, type: 'namespace.cs' }, - { startIndex: 32, type: 'delimiter.cs' } - ] - }, { - line: 'using System.Diagnostics;', - tokens: [ - { startIndex: 0, type: 'keyword.using.cs' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'namespace.cs' }, - { startIndex: 12, type: 'delimiter.cs' }, - { startIndex: 13, type: 'namespace.cs' }, - { startIndex: 24, type: 'delimiter.cs' } - ] - }, { - line: 'using System.Linq;', - tokens: [ - { startIndex: 0, type: 'keyword.using.cs' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'namespace.cs' }, - { startIndex: 12, type: 'delimiter.cs' }, - { startIndex: 13, type: 'namespace.cs' }, - { startIndex: 17, type: 'delimiter.cs' } - ] - }, { - line: 'using System.Text;', - tokens: [ - { startIndex: 0, type: 'keyword.using.cs' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'namespace.cs' }, - { startIndex: 12, type: 'delimiter.cs' }, - { startIndex: 13, type: 'namespace.cs' }, - { startIndex: 17, type: 'delimiter.cs' } - ] - }, { - line: 'using System.Threading.Tasks;', - tokens: [ - { startIndex: 0, type: 'keyword.using.cs' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'namespace.cs' }, - { startIndex: 12, type: 'delimiter.cs' }, - { startIndex: 13, type: 'namespace.cs' }, - { startIndex: 22, type: 'delimiter.cs' }, - { startIndex: 23, type: 'namespace.cs' }, - { startIndex: 28, type: 'delimiter.cs' } - ] - }, { - line: '', - tokens: [ - - ] - }, { - line: 'namespace VS', - tokens: [ - { startIndex: 0, type: 'keyword.namespace.cs' }, - { startIndex: 9, type: '' }, - { startIndex: 10, type: 'namespace.cs' } - ] - }, { - line: '{', - tokens: [ - { startIndex: 0, type: 'delimiter.curly.cs' } - ] - }, { - line: ' class Program', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 1, type: 'keyword.class.cs' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'identifier.cs' } - ] - }, { - line: ' {', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 1, type: 'delimiter.curly.cs' } - ] - }, { - line: ' static void Main(string[] args)', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'keyword.static.cs' }, - { startIndex: 8, type: '' }, - { startIndex: 9, type: 'keyword.void.cs' }, - { startIndex: 13, type: '' }, - { startIndex: 14, type: 'identifier.cs' }, - { startIndex: 18, type: 'delimiter.parenthesis.cs' }, - { startIndex: 19, type: 'keyword.string.cs' }, - { startIndex: 25, type: 'delimiter.square.cs' }, - { startIndex: 27, type: '' }, - { startIndex: 28, type: 'identifier.cs' }, - { startIndex: 32, type: 'delimiter.parenthesis.cs' } - ] - }, { - line: ' {', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'delimiter.curly.cs' } - ] - }, { - line: ' ProcessStartInfo si = new ProcessStartInfo();', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 3, type: 'identifier.cs' }, - { startIndex: 19, type: '' }, - { startIndex: 20, type: 'identifier.cs' }, - { startIndex: 22, type: '' }, - { startIndex: 23, type: 'delimiter.cs' }, - { startIndex: 24, type: '' }, - { startIndex: 25, type: 'keyword.new.cs' }, - { startIndex: 28, type: '' }, - { startIndex: 29, type: 'identifier.cs' }, - { startIndex: 45, type: 'delimiter.parenthesis.cs' }, - { startIndex: 47, type: 'delimiter.cs' } - ] - }, { - line: ' float load= 3.2e02f;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 3, type: 'keyword.float.cs' }, - { startIndex: 8, type: '' }, - { startIndex: 9, type: 'identifier.cs' }, - { startIndex: 13, type: 'delimiter.cs' }, - { startIndex: 14, type: '' }, - { startIndex: 15, type: 'number.float.cs' }, - { startIndex: 22, type: 'delimiter.cs' } - ] - }, { - line: '', - tokens: [ - - ] - }, { - line: ' si.FileName = @"tools\\\\node.exe";', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 3, type: 'identifier.cs' }, - { startIndex: 5, type: 'delimiter.cs' }, - { startIndex: 6, type: 'identifier.cs' }, - { startIndex: 14, type: '' }, - { startIndex: 15, type: 'delimiter.cs' }, - { startIndex: 16, type: '' }, - { startIndex: 17, type: 'string.quote.cs' }, - { startIndex: 19, type: 'string.cs' }, - { startIndex: 34, type: 'string.quote.cs' }, - { startIndex: 35, type: 'delimiter.cs' } - ] - }, { - line: ' si.Arguments = "tools\\\\simpl3server.js";', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 3, type: 'identifier.cs' }, - { startIndex: 5, type: 'delimiter.cs' }, - { startIndex: 6, type: 'identifier.cs' }, - { startIndex: 15, type: '' }, - { startIndex: 16, type: 'delimiter.cs' }, - { startIndex: 17, type: '' }, - { startIndex: 18, type: 'string.quote.cs' }, - { startIndex: 19, type: 'string.cs' }, - { startIndex: 24, type: 'string.escape.cs' }, - { startIndex: 26, type: 'string.cs' }, - { startIndex: 41, type: 'string.quote.cs' }, - { startIndex: 42, type: 'delimiter.cs' } - ] - }, { - line: ' ', - tokens: [ - { startIndex: 0, type: '' } - ] - }, { - line: ' string someString = $"hello{outside+variable}the string again {{ escaped";', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 3, type: 'keyword.string.cs' }, - { startIndex: 9, type: '' }, - { startIndex: 10, type: 'identifier.cs' }, - { startIndex: 20, type: '' }, - { startIndex: 21, type: 'delimiter.cs' }, - { startIndex: 22, type: '' }, - { startIndex: 23, type: 'string.quote.cs' }, - { startIndex: 25, type: 'string.cs' }, - { startIndex: 30, type: 'string.quote.cs' }, - { startIndex: 31, type: 'identifier.cs' }, - { startIndex: 38, type: 'delimiter.cs' }, - { startIndex: 39, type: 'identifier.cs' }, - { startIndex: 47, type: 'string.quote.cs' }, - { startIndex: 48, type: 'string.cs' }, - { startIndex: 65, type: 'string.escape.cs' }, - { startIndex: 67, type: 'string.cs' }, - { startIndex: 75, type: 'string.quote.cs' }, - { startIndex: 76, type: 'delimiter.cs' } - ] - }, { - line: ' var @string = 5;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 3, type: 'keyword.var.cs' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'identifier.cs' }, - { startIndex: 14, type: '' }, - { startIndex: 15, type: 'delimiter.cs' }, - { startIndex: 16, type: '' }, - { startIndex: 17, type: 'number.cs' }, - { startIndex: 18, type: 'delimiter.cs' } - ] - }, { - line: ' ', - tokens: [ - { startIndex: 0, type: '' } - ] - }, { - line: ' if (x == 4)', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 3, type: 'keyword.if.cs' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'delimiter.parenthesis.cs' }, - { startIndex: 7, type: 'identifier.cs' }, - { startIndex: 8, type: '' }, - { startIndex: 9, type: 'delimiter.cs' }, - { startIndex: 11, type: '' }, - { startIndex: 12, type: 'number.cs' }, - { startIndex: 13, type: 'delimiter.parenthesis.cs' } - ] - }, { - line: ' {', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 3, type: 'delimiter.curly.cs' } - ] - }, { - line: ' for (int i = 4; i<10; i++)', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 4, type: 'keyword.for.cs' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'delimiter.parenthesis.cs' }, - { startIndex: 9, type: 'keyword.int.cs' }, - { startIndex: 12, type: '' }, - { startIndex: 13, type: 'identifier.cs' }, - { startIndex: 14, type: '' }, - { startIndex: 15, type: 'delimiter.cs' }, - { startIndex: 16, type: '' }, - { startIndex: 17, type: 'number.cs' }, - { startIndex: 18, type: 'delimiter.cs' }, - { startIndex: 19, type: '' }, - { startIndex: 20, type: 'identifier.cs' }, - { startIndex: 21, type: 'delimiter.angle.cs' }, - { startIndex: 22, type: 'number.cs' }, - { startIndex: 24, type: 'delimiter.cs' }, - { startIndex: 25, type: '' }, - { startIndex: 26, type: 'identifier.cs' }, - { startIndex: 27, type: 'delimiter.cs' }, - { startIndex: 29, type: 'delimiter.parenthesis.cs' } - ] - }, { - line: ' {', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 4, type: 'delimiter.curly.cs' } - ] - }, { - line: ' var d = i;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 5, type: 'keyword.var.cs' }, - { startIndex: 8, type: '' }, - { startIndex: 9, type: 'identifier.cs' }, - { startIndex: 10, type: '' }, - { startIndex: 11, type: 'delimiter.cs' }, - { startIndex: 12, type: '' }, - { startIndex: 13, type: 'identifier.cs' }, - { startIndex: 14, type: 'delimiter.cs' } - ] - }, { - line: ' }', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 4, type: 'delimiter.curly.cs' } - ] - }, { - line: ' }', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 3, type: 'delimiter.curly.cs' } - ] - }, { - line: ' else', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 3, type: 'keyword.else.cs' } - ] - }, { - line: ' {', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 3, type: 'delimiter.curly.cs' } - ] - }, { - line: ' return;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 4, type: 'keyword.return.cs' }, - { startIndex: 10, type: 'delimiter.cs' } - ] - }, { - line: ' }', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 3, type: 'delimiter.curly.cs' } - ] - }, { - line: ' ', - tokens: [ - { startIndex: 0, type: '' } - ] - }, { - line: '', - tokens: [ - - ] - }, { - line: ' Process.Start(si);', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 3, type: 'identifier.cs' }, - { startIndex: 10, type: 'delimiter.cs' }, - { startIndex: 11, type: 'identifier.cs' }, - { startIndex: 16, type: 'delimiter.parenthesis.cs' }, - { startIndex: 17, type: 'identifier.cs' }, - { startIndex: 19, type: 'delimiter.parenthesis.cs' }, - { startIndex: 20, type: 'delimiter.cs' } - ] - }, { - line: ' }', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'delimiter.curly.cs' } - ] - }, { - line: ' }', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 1, type: 'delimiter.curly.cs' } - ] - }, { - line: '}', - tokens: [ - { startIndex: 0, type: 'delimiter.curly.cs' } - ] - }, { - line: '', - tokens: [ - - ] - }, { - line: '#pragma region /MapLayer/*Image* /// ', - tokens: [ - { startIndex: 0, type: 'namespace.cpp.cs' } - ] - }, { - line: 'namespace ShouldNotBeAComment {}', - tokens: [ - { startIndex: 0, type: 'keyword.namespace.cs' }, - { startIndex: 9, type: '' }, - { startIndex: 10, type: 'namespace.cs' }, - { startIndex: 29, type: '' }, - { startIndex: 30, type: 'delimiter.curly.cs' } - ] - }, { - line: '#pragma endregion Region_1', - tokens: [ - { startIndex: 0, type: 'namespace.cpp.cs' } - ] - }], + [ + { + line: 'using System;', + tokens: [ + { startIndex: 0, type: 'keyword.using.cs' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'namespace.cs' }, + { startIndex: 12, type: 'delimiter.cs' } + ] + }, + { + line: 'using System.Collections.Generic;', + tokens: [ + { startIndex: 0, type: 'keyword.using.cs' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'namespace.cs' }, + { startIndex: 12, type: 'delimiter.cs' }, + { startIndex: 13, type: 'namespace.cs' }, + { startIndex: 24, type: 'delimiter.cs' }, + { startIndex: 25, type: 'namespace.cs' }, + { startIndex: 32, type: 'delimiter.cs' } + ] + }, + { + line: 'using System.Diagnostics;', + tokens: [ + { startIndex: 0, type: 'keyword.using.cs' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'namespace.cs' }, + { startIndex: 12, type: 'delimiter.cs' }, + { startIndex: 13, type: 'namespace.cs' }, + { startIndex: 24, type: 'delimiter.cs' } + ] + }, + { + line: 'using System.Linq;', + tokens: [ + { startIndex: 0, type: 'keyword.using.cs' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'namespace.cs' }, + { startIndex: 12, type: 'delimiter.cs' }, + { startIndex: 13, type: 'namespace.cs' }, + { startIndex: 17, type: 'delimiter.cs' } + ] + }, + { + line: 'using System.Text;', + tokens: [ + { startIndex: 0, type: 'keyword.using.cs' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'namespace.cs' }, + { startIndex: 12, type: 'delimiter.cs' }, + { startIndex: 13, type: 'namespace.cs' }, + { startIndex: 17, type: 'delimiter.cs' } + ] + }, + { + line: 'using System.Threading.Tasks;', + tokens: [ + { startIndex: 0, type: 'keyword.using.cs' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'namespace.cs' }, + { startIndex: 12, type: 'delimiter.cs' }, + { startIndex: 13, type: 'namespace.cs' }, + { startIndex: 22, type: 'delimiter.cs' }, + { startIndex: 23, type: 'namespace.cs' }, + { startIndex: 28, type: 'delimiter.cs' } + ] + }, + { + line: '', + tokens: [] + }, + { + line: 'namespace VS', + tokens: [ + { startIndex: 0, type: 'keyword.namespace.cs' }, + { startIndex: 9, type: '' }, + { startIndex: 10, type: 'namespace.cs' } + ] + }, + { + line: '{', + tokens: [{ startIndex: 0, type: 'delimiter.curly.cs' }] + }, + { + line: ' class Program', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 1, type: 'keyword.class.cs' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'identifier.cs' } + ] + }, + { + line: ' {', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 1, type: 'delimiter.curly.cs' } + ] + }, + { + line: ' static void Main(string[] args)', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'keyword.static.cs' }, + { startIndex: 8, type: '' }, + { startIndex: 9, type: 'keyword.void.cs' }, + { startIndex: 13, type: '' }, + { startIndex: 14, type: 'identifier.cs' }, + { startIndex: 18, type: 'delimiter.parenthesis.cs' }, + { startIndex: 19, type: 'keyword.string.cs' }, + { startIndex: 25, type: 'delimiter.square.cs' }, + { startIndex: 27, type: '' }, + { startIndex: 28, type: 'identifier.cs' }, + { startIndex: 32, type: 'delimiter.parenthesis.cs' } + ] + }, + { + line: ' {', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'delimiter.curly.cs' } + ] + }, + { + line: ' ProcessStartInfo si = new ProcessStartInfo();', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 3, type: 'identifier.cs' }, + { startIndex: 19, type: '' }, + { startIndex: 20, type: 'identifier.cs' }, + { startIndex: 22, type: '' }, + { startIndex: 23, type: 'delimiter.cs' }, + { startIndex: 24, type: '' }, + { startIndex: 25, type: 'keyword.new.cs' }, + { startIndex: 28, type: '' }, + { startIndex: 29, type: 'identifier.cs' }, + { startIndex: 45, type: 'delimiter.parenthesis.cs' }, + { startIndex: 47, type: 'delimiter.cs' } + ] + }, + { + line: ' float load= 3.2e02f;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 3, type: 'keyword.float.cs' }, + { startIndex: 8, type: '' }, + { startIndex: 9, type: 'identifier.cs' }, + { startIndex: 13, type: 'delimiter.cs' }, + { startIndex: 14, type: '' }, + { startIndex: 15, type: 'number.float.cs' }, + { startIndex: 22, type: 'delimiter.cs' } + ] + }, + { + line: '', + tokens: [] + }, + { + line: ' si.FileName = @"tools\\\\node.exe";', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 3, type: 'identifier.cs' }, + { startIndex: 5, type: 'delimiter.cs' }, + { startIndex: 6, type: 'identifier.cs' }, + { startIndex: 14, type: '' }, + { startIndex: 15, type: 'delimiter.cs' }, + { startIndex: 16, type: '' }, + { startIndex: 17, type: 'string.quote.cs' }, + { startIndex: 19, type: 'string.cs' }, + { startIndex: 34, type: 'string.quote.cs' }, + { startIndex: 35, type: 'delimiter.cs' } + ] + }, + { + line: ' si.Arguments = "tools\\\\simpl3server.js";', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 3, type: 'identifier.cs' }, + { startIndex: 5, type: 'delimiter.cs' }, + { startIndex: 6, type: 'identifier.cs' }, + { startIndex: 15, type: '' }, + { startIndex: 16, type: 'delimiter.cs' }, + { startIndex: 17, type: '' }, + { startIndex: 18, type: 'string.quote.cs' }, + { startIndex: 19, type: 'string.cs' }, + { startIndex: 24, type: 'string.escape.cs' }, + { startIndex: 26, type: 'string.cs' }, + { startIndex: 41, type: 'string.quote.cs' }, + { startIndex: 42, type: 'delimiter.cs' } + ] + }, + { + line: ' ', + tokens: [{ startIndex: 0, type: '' }] + }, + { + line: + ' string someString = $"hello{outside+variable}the string again {{ escaped";', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 3, type: 'keyword.string.cs' }, + { startIndex: 9, type: '' }, + { startIndex: 10, type: 'identifier.cs' }, + { startIndex: 20, type: '' }, + { startIndex: 21, type: 'delimiter.cs' }, + { startIndex: 22, type: '' }, + { startIndex: 23, type: 'string.quote.cs' }, + { startIndex: 25, type: 'string.cs' }, + { startIndex: 30, type: 'string.quote.cs' }, + { startIndex: 31, type: 'identifier.cs' }, + { startIndex: 38, type: 'delimiter.cs' }, + { startIndex: 39, type: 'identifier.cs' }, + { startIndex: 47, type: 'string.quote.cs' }, + { startIndex: 48, type: 'string.cs' }, + { startIndex: 65, type: 'string.escape.cs' }, + { startIndex: 67, type: 'string.cs' }, + { startIndex: 75, type: 'string.quote.cs' }, + { startIndex: 76, type: 'delimiter.cs' } + ] + }, + { + line: ' var @string = 5;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 3, type: 'keyword.var.cs' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'identifier.cs' }, + { startIndex: 14, type: '' }, + { startIndex: 15, type: 'delimiter.cs' }, + { startIndex: 16, type: '' }, + { startIndex: 17, type: 'number.cs' }, + { startIndex: 18, type: 'delimiter.cs' } + ] + }, + { + line: ' ', + tokens: [{ startIndex: 0, type: '' }] + }, + { + line: ' if (x == 4)', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 3, type: 'keyword.if.cs' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'delimiter.parenthesis.cs' }, + { startIndex: 7, type: 'identifier.cs' }, + { startIndex: 8, type: '' }, + { startIndex: 9, type: 'delimiter.cs' }, + { startIndex: 11, type: '' }, + { startIndex: 12, type: 'number.cs' }, + { startIndex: 13, type: 'delimiter.parenthesis.cs' } + ] + }, + { + line: ' {', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 3, type: 'delimiter.curly.cs' } + ] + }, + { + line: ' for (int i = 4; i<10; i++)', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 4, type: 'keyword.for.cs' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'delimiter.parenthesis.cs' }, + { startIndex: 9, type: 'keyword.int.cs' }, + { startIndex: 12, type: '' }, + { startIndex: 13, type: 'identifier.cs' }, + { startIndex: 14, type: '' }, + { startIndex: 15, type: 'delimiter.cs' }, + { startIndex: 16, type: '' }, + { startIndex: 17, type: 'number.cs' }, + { startIndex: 18, type: 'delimiter.cs' }, + { startIndex: 19, type: '' }, + { startIndex: 20, type: 'identifier.cs' }, + { startIndex: 21, type: 'delimiter.angle.cs' }, + { startIndex: 22, type: 'number.cs' }, + { startIndex: 24, type: 'delimiter.cs' }, + { startIndex: 25, type: '' }, + { startIndex: 26, type: 'identifier.cs' }, + { startIndex: 27, type: 'delimiter.cs' }, + { startIndex: 29, type: 'delimiter.parenthesis.cs' } + ] + }, + { + line: ' {', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 4, type: 'delimiter.curly.cs' } + ] + }, + { + line: ' var d = i;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 5, type: 'keyword.var.cs' }, + { startIndex: 8, type: '' }, + { startIndex: 9, type: 'identifier.cs' }, + { startIndex: 10, type: '' }, + { startIndex: 11, type: 'delimiter.cs' }, + { startIndex: 12, type: '' }, + { startIndex: 13, type: 'identifier.cs' }, + { startIndex: 14, type: 'delimiter.cs' } + ] + }, + { + line: ' }', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 4, type: 'delimiter.curly.cs' } + ] + }, + { + line: ' }', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 3, type: 'delimiter.curly.cs' } + ] + }, + { + line: ' else', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 3, type: 'keyword.else.cs' } + ] + }, + { + line: ' {', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 3, type: 'delimiter.curly.cs' } + ] + }, + { + line: ' return;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 4, type: 'keyword.return.cs' }, + { startIndex: 10, type: 'delimiter.cs' } + ] + }, + { + line: ' }', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 3, type: 'delimiter.curly.cs' } + ] + }, + { + line: ' ', + tokens: [{ startIndex: 0, type: '' }] + }, + { + line: '', + tokens: [] + }, + { + line: ' Process.Start(si);', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 3, type: 'identifier.cs' }, + { startIndex: 10, type: 'delimiter.cs' }, + { startIndex: 11, type: 'identifier.cs' }, + { startIndex: 16, type: 'delimiter.parenthesis.cs' }, + { startIndex: 17, type: 'identifier.cs' }, + { startIndex: 19, type: 'delimiter.parenthesis.cs' }, + { startIndex: 20, type: 'delimiter.cs' } + ] + }, + { + line: ' }', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'delimiter.curly.cs' } + ] + }, + { + line: ' }', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 1, type: 'delimiter.curly.cs' } + ] + }, + { + line: '}', + tokens: [{ startIndex: 0, type: 'delimiter.curly.cs' }] + }, + { + line: '', + tokens: [] + }, + { + line: '#pragma region /MapLayer/*Image* /// ', + tokens: [{ startIndex: 0, type: 'namespace.cpp.cs' }] + }, + { + line: 'namespace ShouldNotBeAComment {}', + tokens: [ + { startIndex: 0, type: 'keyword.namespace.cs' }, + { startIndex: 9, type: '' }, + { startIndex: 10, type: 'namespace.cs' }, + { startIndex: 29, type: '' }, + { startIndex: 30, type: 'delimiter.curly.cs' } + ] + }, + { + line: '#pragma endregion Region_1', + tokens: [{ startIndex: 0, type: 'namespace.cpp.cs' }] + } + ], // Keywords - [{ - line: 'namespace VS { class Program { static void Main(string[] args) {} } }', - tokens: [ - { startIndex: 0, type: 'keyword.namespace.cs' }, - { startIndex: 9, type: '' }, - { startIndex: 10, type: 'namespace.cs' }, - { startIndex: 12, type: '' }, - { startIndex: 13, type: 'delimiter.curly.cs' }, - { startIndex: 14, type: '' }, - { startIndex: 15, type: 'keyword.class.cs' }, - { startIndex: 20, type: '' }, - { startIndex: 21, type: 'identifier.cs' }, - { startIndex: 28, type: '' }, - { startIndex: 29, type: 'delimiter.curly.cs' }, - { startIndex: 30, type: '' }, - { startIndex: 31, type: 'keyword.static.cs' }, - { startIndex: 37, type: '' }, - { startIndex: 38, type: 'keyword.void.cs' }, - { startIndex: 42, type: '' }, - { startIndex: 43, type: 'identifier.cs' }, - { startIndex: 47, type: 'delimiter.parenthesis.cs' }, - { startIndex: 48, type: 'keyword.string.cs' }, - { startIndex: 54, type: 'delimiter.square.cs' }, - { startIndex: 56, type: '' }, - { startIndex: 57, type: 'identifier.cs' }, - { startIndex: 61, type: 'delimiter.parenthesis.cs' }, - { startIndex: 62, type: '' }, - { startIndex: 63, type: 'delimiter.curly.cs' }, - { startIndex: 65, type: '' }, - { startIndex: 66, type: 'delimiter.curly.cs' }, - { startIndex: 67, type: '' }, - { startIndex: 68, type: 'delimiter.curly.cs' } - ] - }], + [ + { + line: + 'namespace VS { class Program { static void Main(string[] args) {} } }', + tokens: [ + { startIndex: 0, type: 'keyword.namespace.cs' }, + { startIndex: 9, type: '' }, + { startIndex: 10, type: 'namespace.cs' }, + { startIndex: 12, type: '' }, + { startIndex: 13, type: 'delimiter.curly.cs' }, + { startIndex: 14, type: '' }, + { startIndex: 15, type: 'keyword.class.cs' }, + { startIndex: 20, type: '' }, + { startIndex: 21, type: 'identifier.cs' }, + { startIndex: 28, type: '' }, + { startIndex: 29, type: 'delimiter.curly.cs' }, + { startIndex: 30, type: '' }, + { startIndex: 31, type: 'keyword.static.cs' }, + { startIndex: 37, type: '' }, + { startIndex: 38, type: 'keyword.void.cs' }, + { startIndex: 42, type: '' }, + { startIndex: 43, type: 'identifier.cs' }, + { startIndex: 47, type: 'delimiter.parenthesis.cs' }, + { startIndex: 48, type: 'keyword.string.cs' }, + { startIndex: 54, type: 'delimiter.square.cs' }, + { startIndex: 56, type: '' }, + { startIndex: 57, type: 'identifier.cs' }, + { startIndex: 61, type: 'delimiter.parenthesis.cs' }, + { startIndex: 62, type: '' }, + { startIndex: 63, type: 'delimiter.curly.cs' }, + { startIndex: 65, type: '' }, + { startIndex: 66, type: 'delimiter.curly.cs' }, + { startIndex: 67, type: '' }, + { startIndex: 68, type: 'delimiter.curly.cs' } + ] + } + ], // Comments - single line - [{ - line: '//', - tokens: [ - { startIndex: 0, type: 'comment.cs' } - ] - }], + [ + { + line: '//', + tokens: [{ startIndex: 0, type: 'comment.cs' }] + } + ], - [{ - line: ' // a comment', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 4, type: 'comment.cs' } - ] - }], + [ + { + line: ' // a comment', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 4, type: 'comment.cs' } + ] + } + ], - [{ - line: '// a comment', - tokens: [ - { startIndex: 0, type: 'comment.cs' } - ] - }], + [ + { + line: '// a comment', + tokens: [{ startIndex: 0, type: 'comment.cs' }] + } + ], - [{ - line: '//sticky comment', - tokens: [ - { startIndex: 0, type: 'comment.cs' } - ] - }], + [ + { + line: '//sticky comment', + tokens: [{ startIndex: 0, type: 'comment.cs' }] + } + ], - [{ - line: '/almost a comment', - tokens: [ - { startIndex: 0, type: 'delimiter.cs' }, - { startIndex: 1, type: 'identifier.cs' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'identifier.cs' }, - { startIndex: 9, type: '' }, - { startIndex: 10, type: 'identifier.cs' } - ] - }], + [ + { + line: '/almost a comment', + tokens: [ + { startIndex: 0, type: 'delimiter.cs' }, + { startIndex: 1, type: 'identifier.cs' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'identifier.cs' }, + { startIndex: 9, type: '' }, + { startIndex: 10, type: 'identifier.cs' } + ] + } + ], - [{ - line: '1 / 2; /* comment', - tokens: [ - { startIndex: 0, type: 'number.cs' }, - { startIndex: 1, type: '' }, - { startIndex: 2, type: 'delimiter.cs' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'number.cs' }, - { startIndex: 5, type: 'delimiter.cs' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'comment.cs' } - ] - }], + [ + { + line: '1 / 2; /* comment', + tokens: [ + { startIndex: 0, type: 'number.cs' }, + { startIndex: 1, type: '' }, + { startIndex: 2, type: 'delimiter.cs' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'number.cs' }, + { startIndex: 5, type: 'delimiter.cs' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'comment.cs' } + ] + } + ], - [{ - line: 'var x = 1; // my comment // is a nice one', - tokens: [ - { startIndex: 0, type: 'keyword.var.cs' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'identifier.cs' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'delimiter.cs' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'number.cs' }, - { startIndex: 9, type: 'delimiter.cs' }, - { startIndex: 10, type: '' }, - { startIndex: 11, type: 'comment.cs' } - ] - }], + [ + { + line: 'var x = 1; // my comment // is a nice one', + tokens: [ + { startIndex: 0, type: 'keyword.var.cs' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'identifier.cs' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'delimiter.cs' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'number.cs' }, + { startIndex: 9, type: 'delimiter.cs' }, + { startIndex: 10, type: '' }, + { startIndex: 11, type: 'comment.cs' } + ] + } + ], // Comments - range comment, single line - [{ - line: '/* a simple comment */', - tokens: [ - { startIndex: 0, type: 'comment.cs' } - ] - }], + [ + { + line: '/* a simple comment */', + tokens: [{ startIndex: 0, type: 'comment.cs' }] + } + ], - [{ - line: 'var x = /* a simple comment */ 1;', - tokens: [ - { startIndex: 0, type: 'keyword.var.cs' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'identifier.cs' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'delimiter.cs' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'comment.cs' }, - { startIndex: 30, type: '' }, - { startIndex: 31, type: 'number.cs' }, - { startIndex: 32, type: 'delimiter.cs' } - ] - }], + [ + { + line: 'var x = /* a simple comment */ 1;', + tokens: [ + { startIndex: 0, type: 'keyword.var.cs' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'identifier.cs' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'delimiter.cs' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'comment.cs' }, + { startIndex: 30, type: '' }, + { startIndex: 31, type: 'number.cs' }, + { startIndex: 32, type: 'delimiter.cs' } + ] + } + ], - [{ - line: 'var x = /* comment */ 1; */', - tokens: [ - { startIndex: 0, type: 'keyword.var.cs' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'identifier.cs' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'delimiter.cs' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'comment.cs' }, - { startIndex: 21, type: '' }, - { startIndex: 22, type: 'number.cs' }, - { startIndex: 23, type: 'delimiter.cs' }, - { startIndex: 24, type: '' } - ] - }], + [ + { + line: 'var x = /* comment */ 1; */', + tokens: [ + { startIndex: 0, type: 'keyword.var.cs' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'identifier.cs' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'delimiter.cs' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'comment.cs' }, + { startIndex: 21, type: '' }, + { startIndex: 22, type: 'number.cs' }, + { startIndex: 23, type: 'delimiter.cs' }, + { startIndex: 24, type: '' } + ] + } + ], - [{ - line: 'x = /**/;', - tokens: [ - { startIndex: 0, type: 'identifier.cs' }, - { startIndex: 1, type: '' }, - { startIndex: 2, type: 'delimiter.cs' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'comment.cs' }, - { startIndex: 8, type: 'delimiter.cs' } - ] - }], + [ + { + line: 'x = /**/;', + tokens: [ + { startIndex: 0, type: 'identifier.cs' }, + { startIndex: 1, type: '' }, + { startIndex: 2, type: 'delimiter.cs' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'comment.cs' }, + { startIndex: 8, type: 'delimiter.cs' } + ] + } + ], - [{ - line: 'x = /*/;', - tokens: [ - { startIndex: 0, type: 'identifier.cs' }, - { startIndex: 1, type: '' }, - { startIndex: 2, type: 'delimiter.cs' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'comment.cs' } - ] - }], + [ + { + line: 'x = /*/;', + tokens: [ + { startIndex: 0, type: 'identifier.cs' }, + { startIndex: 1, type: '' }, + { startIndex: 2, type: 'delimiter.cs' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'comment.cs' } + ] + } + ], // Numbers - [{ - line: '0', - tokens: [ - { startIndex: 0, type: 'number.cs' } - ] - }], + [ + { + line: '0', + tokens: [{ startIndex: 0, type: 'number.cs' }] + } + ], - [{ - line: '123_456', - tokens: [ - { startIndex: 0, type: 'number.cs' } - ] - }], + [ + { + line: '123_456', + tokens: [{ startIndex: 0, type: 'number.cs' }] + } + ], - [{ - line: '0x', - tokens: [ - { startIndex: 0, type: 'number.cs' }, - { startIndex: 1, type: 'identifier.cs' } - ] - }], + [ + { + line: '0x', + tokens: [ + { startIndex: 0, type: 'number.cs' }, + { startIndex: 1, type: 'identifier.cs' } + ] + } + ], - [{ - line: '0b', - tokens: [ - { startIndex: 0, type: 'number.cs' }, - { startIndex: 1, type: 'identifier.cs' } - ] - }], + [ + { + line: '0b', + tokens: [ + { startIndex: 0, type: 'number.cs' }, + { startIndex: 1, type: 'identifier.cs' } + ] + } + ], - [{ - line: '0x123', - tokens: [ - { startIndex: 0, type: 'number.hex.cs' } - ] - }], + [ + { + line: '0x123', + tokens: [{ startIndex: 0, type: 'number.hex.cs' }] + } + ], - [{ - line: '0x123_456', - tokens: [ - { startIndex: 0, type: 'number.hex.cs' } - ] - }], + [ + { + line: '0x123_456', + tokens: [{ startIndex: 0, type: 'number.hex.cs' }] + } + ], - [{ - line: '0b101', - tokens: [ - { startIndex: 0, type: 'number.hex.cs' } - ] - }], + [ + { + line: '0b101', + tokens: [{ startIndex: 0, type: 'number.hex.cs' }] + } + ], - [{ - line: '0b1010_0001', - tokens: [ - { startIndex: 0, type: 'number.hex.cs' } - ] - }], + [ + { + line: '0b1010_0001', + tokens: [{ startIndex: 0, type: 'number.hex.cs' }] + } + ], - [{ - line: '23.5', - tokens: [ - { startIndex: 0, type: 'number.float.cs' } - ] - }], + [ + { + line: '23.5', + tokens: [{ startIndex: 0, type: 'number.float.cs' }] + } + ], - [{ - line: '1_23.5', - tokens: [ - { startIndex: 0, type: 'number.float.cs' } - ] - }], + [ + { + line: '1_23.5', + tokens: [{ startIndex: 0, type: 'number.float.cs' }] + } + ], - [{ - line: '23.5e3', - tokens: [ - { startIndex: 0, type: 'number.float.cs' } - ] - }], + [ + { + line: '23.5e3', + tokens: [{ startIndex: 0, type: 'number.float.cs' }] + } + ], - [{ - line: '23.5E3', - tokens: [ - { startIndex: 0, type: 'number.float.cs' } - ] - }], + [ + { + line: '23.5E3', + tokens: [{ startIndex: 0, type: 'number.float.cs' }] + } + ], - [{ - line: '23.5F', - tokens: [ - { startIndex: 0, type: 'number.float.cs' } - ] - }], + [ + { + line: '23.5F', + tokens: [{ startIndex: 0, type: 'number.float.cs' }] + } + ], - [{ - line: '23.5f', - tokens: [ - { startIndex: 0, type: 'number.float.cs' } - ] - }], + [ + { + line: '23.5f', + tokens: [{ startIndex: 0, type: 'number.float.cs' }] + } + ], - [{ - line: '2_3.5f', - tokens: [ - { startIndex: 0, type: 'number.float.cs' } - ] - }], + [ + { + line: '2_3.5f', + tokens: [{ startIndex: 0, type: 'number.float.cs' }] + } + ], - [{ - line: '1.72E3F', - tokens: [ - { startIndex: 0, type: 'number.float.cs' } - ] - }], + [ + { + line: '1.72E3F', + tokens: [{ startIndex: 0, type: 'number.float.cs' }] + } + ], - [{ - line: '1.72E3f', - tokens: [ - { startIndex: 0, type: 'number.float.cs' } - ] - }], + [ + { + line: '1.72E3f', + tokens: [{ startIndex: 0, type: 'number.float.cs' }] + } + ], - [{ - line: '1.72e3F', - tokens: [ - { startIndex: 0, type: 'number.float.cs' } - ] - }], + [ + { + line: '1.72e3F', + tokens: [{ startIndex: 0, type: 'number.float.cs' }] + } + ], - [{ - line: '1.72e3f', - tokens: [ - { startIndex: 0, type: 'number.float.cs' } - ] - }], + [ + { + line: '1.72e3f', + tokens: [{ startIndex: 0, type: 'number.float.cs' }] + } + ], - [{ - line: '23.5D', - tokens: [ - { startIndex: 0, type: 'number.float.cs' } - ] - }], + [ + { + line: '23.5D', + tokens: [{ startIndex: 0, type: 'number.float.cs' }] + } + ], - [{ - line: '456_123.5D', - tokens: [ - { startIndex: 0, type: 'number.float.cs' } - ] - }], + [ + { + line: '456_123.5D', + tokens: [{ startIndex: 0, type: 'number.float.cs' }] + } + ], - [{ - line: '23.5d', - tokens: [ - { startIndex: 0, type: 'number.float.cs' } - ] - }], + [ + { + line: '23.5d', + tokens: [{ startIndex: 0, type: 'number.float.cs' }] + } + ], - [{ - line: '1.72E3D', - tokens: [ - { startIndex: 0, type: 'number.float.cs' } - ] - }], + [ + { + line: '1.72E3D', + tokens: [{ startIndex: 0, type: 'number.float.cs' }] + } + ], - [{ - line: '1.72E3d', - tokens: [ - { startIndex: 0, type: 'number.float.cs' } - ] - }], + [ + { + line: '1.72E3d', + tokens: [{ startIndex: 0, type: 'number.float.cs' }] + } + ], - [{ - line: '1.720_123E3d', - tokens: [ - { startIndex: 0, type: 'number.float.cs' } - ] - }], + [ + { + line: '1.720_123E3d', + tokens: [{ startIndex: 0, type: 'number.float.cs' }] + } + ], - [{ - line: '1.72e3D', - tokens: [ - { startIndex: 0, type: 'number.float.cs' } - ] - }], + [ + { + line: '1.72e3D', + tokens: [{ startIndex: 0, type: 'number.float.cs' }] + } + ], - [{ - line: '1.72e3d', - tokens: [ - { startIndex: 0, type: 'number.float.cs' } - ] - }], + [ + { + line: '1.72e3d', + tokens: [{ startIndex: 0, type: 'number.float.cs' }] + } + ], - [{ - line: '0+0', - tokens: [ - { startIndex: 0, type: 'number.cs' }, - { startIndex: 1, type: 'delimiter.cs' }, - { startIndex: 2, type: 'number.cs' } - ] - }], + [ + { + line: '0+0', + tokens: [ + { startIndex: 0, type: 'number.cs' }, + { startIndex: 1, type: 'delimiter.cs' }, + { startIndex: 2, type: 'number.cs' } + ] + } + ], - [{ - line: '100+10', - tokens: [ - { startIndex: 0, type: 'number.cs' }, - { startIndex: 3, type: 'delimiter.cs' }, - { startIndex: 4, type: 'number.cs' } - ] - }], + [ + { + line: '100+10', + tokens: [ + { startIndex: 0, type: 'number.cs' }, + { startIndex: 3, type: 'delimiter.cs' }, + { startIndex: 4, type: 'number.cs' } + ] + } + ], - [{ - line: '0 + 0', - tokens: [ - { startIndex: 0, type: 'number.cs' }, - { startIndex: 1, type: '' }, - { startIndex: 2, type: 'delimiter.cs' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'number.cs' } - ] - }], + [ + { + line: '0 + 0', + tokens: [ + { startIndex: 0, type: 'number.cs' }, + { startIndex: 1, type: '' }, + { startIndex: 2, type: 'delimiter.cs' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'number.cs' } + ] + } + ], // Strings - [{ - line: 'x = "string";', - tokens: [ - { startIndex: 0, type: 'identifier.cs' }, - { startIndex: 1, type: '' }, - { startIndex: 2, type: 'delimiter.cs' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'string.quote.cs' }, - { startIndex: 5, type: 'string.cs' }, - { startIndex: 11, type: 'string.quote.cs' }, - { startIndex: 12, type: 'delimiter.cs' } - ] - }], + [ + { + line: 'x = "string";', + tokens: [ + { startIndex: 0, type: 'identifier.cs' }, + { startIndex: 1, type: '' }, + { startIndex: 2, type: 'delimiter.cs' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'string.quote.cs' }, + { startIndex: 5, type: 'string.cs' }, + { startIndex: 11, type: 'string.quote.cs' }, + { startIndex: 12, type: 'delimiter.cs' } + ] + } + ], - [{ - line: 'x = "stri\\"ng";', - tokens: [ - { startIndex: 0, type: 'identifier.cs' }, - { startIndex: 1, type: '' }, - { startIndex: 2, type: 'delimiter.cs' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'string.quote.cs' }, - { startIndex: 5, type: 'string.cs' }, - { startIndex: 9, type: 'string.escape.cs' }, - { startIndex: 11, type: 'string.cs' }, - { startIndex: 13, type: 'string.quote.cs' }, - { startIndex: 14, type: 'delimiter.cs' } - ] - }], + [ + { + line: 'x = "stri\\"ng";', + tokens: [ + { startIndex: 0, type: 'identifier.cs' }, + { startIndex: 1, type: '' }, + { startIndex: 2, type: 'delimiter.cs' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'string.quote.cs' }, + { startIndex: 5, type: 'string.cs' }, + { startIndex: 9, type: 'string.escape.cs' }, + { startIndex: 11, type: 'string.cs' }, + { startIndex: 13, type: 'string.quote.cs' }, + { startIndex: 14, type: 'delimiter.cs' } + ] + } + ], // Verbatim Strings - [{ - line: 'x = @"verbatimstring";', - tokens: [ - { startIndex: 0, type: 'identifier.cs' }, - { startIndex: 1, type: '' }, - { startIndex: 2, type: 'delimiter.cs' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'string.quote.cs' }, - { startIndex: 6, type: 'string.cs' }, - { startIndex: 20, type: 'string.quote.cs' }, - { startIndex: 21, type: 'delimiter.cs' } - ] - }], + [ + { + line: 'x = @"verbatimstring";', + tokens: [ + { startIndex: 0, type: 'identifier.cs' }, + { startIndex: 1, type: '' }, + { startIndex: 2, type: 'delimiter.cs' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'string.quote.cs' }, + { startIndex: 6, type: 'string.cs' }, + { startIndex: 20, type: 'string.quote.cs' }, + { startIndex: 21, type: 'delimiter.cs' } + ] + } + ], - [{ - line: 'x = @"verbatim""string";', - tokens: [ - { startIndex: 0, type: 'identifier.cs' }, - { startIndex: 1, type: '' }, - { startIndex: 2, type: 'delimiter.cs' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'string.quote.cs' }, - { startIndex: 6, type: 'string.cs' }, - { startIndex: 14, type: 'string.escape.cs' }, - { startIndex: 16, type: 'string.cs' }, - { startIndex: 22, type: 'string.quote.cs' }, - { startIndex: 23, type: 'delimiter.cs' } - ] - }], + [ + { + line: 'x = @"verbatim""string";', + tokens: [ + { startIndex: 0, type: 'identifier.cs' }, + { startIndex: 1, type: '' }, + { startIndex: 2, type: 'delimiter.cs' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'string.quote.cs' }, + { startIndex: 6, type: 'string.cs' }, + { startIndex: 14, type: 'string.escape.cs' }, + { startIndex: 16, type: 'string.cs' }, + { startIndex: 22, type: 'string.quote.cs' }, + { startIndex: 23, type: 'delimiter.cs' } + ] + } + ], - [{ - line: 'x = @"verbatim\\string\\";', - tokens: [ - { startIndex: 0, type: 'identifier.cs' }, - { startIndex: 1, type: '' }, - { startIndex: 2, type: 'delimiter.cs' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'string.quote.cs' }, - { startIndex: 6, type: 'string.cs' }, - { startIndex: 22, type: 'string.quote.cs' }, - { startIndex: 23, type: 'delimiter.cs' } - ] - }], + [ + { + line: 'x = @"verbatim\\string\\";', + tokens: [ + { startIndex: 0, type: 'identifier.cs' }, + { startIndex: 1, type: '' }, + { startIndex: 2, type: 'delimiter.cs' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'string.quote.cs' }, + { startIndex: 6, type: 'string.cs' }, + { startIndex: 22, type: 'string.quote.cs' }, + { startIndex: 23, type: 'delimiter.cs' } + ] + } + ], - [{ - line: 'x = @"verbatim', - tokens: [ - { startIndex: 0, type: 'identifier.cs' }, - { startIndex: 1, type: '' }, - { startIndex: 2, type: 'delimiter.cs' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'string.quote.cs' }, - { startIndex: 6, type: 'string.cs' } - ] - }, { - line: 'string";', - tokens: [ - { startIndex: 0, type: 'string.cs' }, - { startIndex: 6, type: 'string.quote.cs' }, - { startIndex: 7, type: 'delimiter.cs' } - ] - }], + [ + { + line: 'x = @"verbatim', + tokens: [ + { startIndex: 0, type: 'identifier.cs' }, + { startIndex: 1, type: '' }, + { startIndex: 2, type: 'delimiter.cs' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'string.quote.cs' }, + { startIndex: 6, type: 'string.cs' } + ] + }, + { + line: 'string";', + tokens: [ + { startIndex: 0, type: 'string.cs' }, + { startIndex: 6, type: 'string.quote.cs' }, + { startIndex: 7, type: 'delimiter.cs' } + ] + } + ], - [{ - line: 'x = $@"verbatim {interpolated} string{{}}"" ";', - tokens: [ - { startIndex: 0, type: "identifier.cs" }, - { startIndex: 1, type: "" }, - { startIndex: 2, type: "delimiter.cs" }, - { startIndex: 3, type: "" }, - { startIndex: 4, type: "string.quote.cs" }, - { startIndex: 7, type: "string.cs" }, - { startIndex: 16, type: "string.quote.cs" }, - { startIndex: 17, type: "identifier.cs" }, - { startIndex: 29, type: "string.quote.cs" }, - { startIndex: 30, type: "string.cs" }, - { startIndex: 37, type: "string.escape.cs" }, - { startIndex: 39, type: "string.cs" }, - { startIndex: 41, type: "string.escape.cs" }, - { startIndex: 43, type: "string.cs" }, - { startIndex: 44, type: "string.quote.cs" }, - { startIndex: 45, type: "delimiter.cs" }, - ] - }], + [ + { + line: 'x = $@"verbatim {interpolated} string{{}}"" ";', + tokens: [ + { startIndex: 0, type: 'identifier.cs' }, + { startIndex: 1, type: '' }, + { startIndex: 2, type: 'delimiter.cs' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'string.quote.cs' }, + { startIndex: 7, type: 'string.cs' }, + { startIndex: 16, type: 'string.quote.cs' }, + { startIndex: 17, type: 'identifier.cs' }, + { startIndex: 29, type: 'string.quote.cs' }, + { startIndex: 30, type: 'string.cs' }, + { startIndex: 37, type: 'string.escape.cs' }, + { startIndex: 39, type: 'string.cs' }, + { startIndex: 41, type: 'string.escape.cs' }, + { startIndex: 43, type: 'string.cs' }, + { startIndex: 44, type: 'string.quote.cs' }, + { startIndex: 45, type: 'delimiter.cs' } + ] + } + ] ]); diff --git a/src/csharp/csharp.ts b/src/csharp/csharp.ts index 00747ed7..0bb1091b 100644 --- a/src/csharp/csharp.ts +++ b/src/csharp/csharp.ts @@ -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 = { ], 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: /[=>{ // 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 = { [/[;,.]/, '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 = { ], 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 = { [/^[ \t\v\f]*#\w.*$/, 'namespace.cpp'], [/[ \t\v\f\r\n]+/, ''], [/\/\*/, 'comment', '@comment'], - [/\/\/.*$/, 'comment'], - ], - }, + [/\/\/.*$/, 'comment'] + ] + } }; diff --git a/src/csp/csp.ts b/src/csp/csp.ts index 5225bd89..b92a9626 100644 --- a/src/csp/csp.ts +++ b/src/csp/csp.ts @@ -21,41 +21,41 @@ export const language = { typeKeywords: [], tokenPostfix: '.csp', operators: [], - symbols: /[=>{ 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 = { ], 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 = { 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 = { 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 = { stringendquote: [ ['\\\\.', 'string'], - ['\'', { token: 'string', next: '@pop' }], + ["'", { token: 'string', next: '@pop' }], [/[^\\']+/, 'string'], ['.', 'string'] ] diff --git a/src/dart/dart.test.ts b/src/dart/dart.test.ts index dfe6a5f6..2ce6c15f 100644 --- a/src/dart/dart.test.ts +++ b/src/dart/dart.test.ts @@ -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' }] } ] ]); diff --git a/src/dart/dart.ts b/src/dart/dart.ts index 10b2166f..0fc57d11 100644 --- a/src/dart/dart.ts +++ b/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 = { - 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 = { // 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 = { /[a-z_$][\w$]*/, { cases: { - "@typeKeywords": "type.identifier", - "@keywords": "keyword", - "@default": "identifier" + '@typeKeywords': 'type.identifier', + '@keywords': 'keyword', + '@default': 'identifier' } } ], - [ - /(?](?!@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 = { [ /(\{)(\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'] - ], + ] } }; diff --git a/src/dockerfile/dockerfile.test.ts b/src/dockerfile/dockerfile.test.ts index 68d32b4f..3c8da893 100644 --- a/src/dockerfile/dockerfile.test.ts +++ b/src/dockerfile/dockerfile.test.ts @@ -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' } + ] + } + ] ]); diff --git a/src/dockerfile/dockerfile.ts b/src/dockerfile/dockerfile.ts index 78acd724..e723a267 100644 --- a/src/dockerfile/dockerfile.ts +++ b/src/dockerfile/dockerfile.ts @@ -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 = { { 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 = { [/"/, '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 = { [/$/, 'string', '@popall'] ], dblStringBody: [ - [/[^\\\$"]/, { - cases: { - '@eos': { token: 'string', next: '@popall' }, - '@default': 'string' + [ + /[^\\\$"]/, + { + cases: { + '@eos': { token: 'string', next: '@popall' }, + '@default': 'string' + } } - }], + ], [/\\./, 'string.escape'], [/"$/, 'string', '@popall'], diff --git a/src/fsharp/fsharp.test.ts b/src/fsharp/fsharp.test.ts index c542c833..a38c5fe4 100644 --- a/src/fsharp/fsharp.test.ts +++ b/src/fsharp/fsharp.test.ts @@ -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' } + ] + } + ] ]); diff --git a/src/fsharp/fsharp.ts b/src/fsharp/fsharp.ts index 7e08d720..4878e6fd 100644 --- a/src/fsharp/fsharp.ts +++ b/src/fsharp/fsharp.ts @@ -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 = { 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 = { 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 = { [/[;,.]/, 'delimiter'], // strings - [/"([^"\\]|\\.)*$/, 'string.invalid'], // non-teminated string + [/"([^"\\]|\\.)*$/, 'string.invalid'], // non-teminated string [/"""/, 'string', '@string."""'], [/"/, 'string', '@string."'], @@ -128,7 +209,7 @@ export const language = { whitespace: [ [/[ \t\r\n]+/, ''], [/\(\*(?!\))/, 'comment', '@comment'], - [/\/\/.*$/, 'comment'], + [/\/\/.*$/, 'comment'] ], comment: [ @@ -143,18 +224,21 @@ export const language = { [/[^\\"]+/, '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' }] - ], - }, + ] + } }; diff --git a/src/go/go.test.ts b/src/go/go.test.ts index 3fa373cb..b7b44eff 100644 --- a/src/go/go.test.ts +++ b/src/go/go.test.ts @@ -9,1284 +9,1486 @@ import { testTokenization } from '../test/testRunner'; testTokenization('go', [ // Tests - [{ - line: '/* Block comment. */', - tokens: [ - { startIndex: 0, type: 'comment.go' } - ] - }], - - [{ - line: '/* //*/ a', - tokens: [ - { startIndex: 0, type: 'comment.go' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'identifier.go' } - ] - }], - - [{ - line: '// Inline comment.', - tokens: [ - { startIndex: 0, type: 'comment.go' } - ] - }], - - [{ - line: '', - tokens: [ - - ] - }], - - [{ - line: 'import {', - tokens: [ - { startIndex: 0, type: 'keyword.import.go' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'delimiter.curly.go' } - ] - }], - - [{ - line: ' "io"', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'string.go' } - ] - }], - - [{ - line: '}', - tokens: [ - { startIndex: 0, type: 'delimiter.curly.go' } - ] - }], - - [{ - line: '', - tokens: [ - - ] - }], - - [{ - line: 'type name struct {', - tokens: [ - { startIndex: 0, type: 'keyword.type.go' }, - { startIndex: 4, type: '' }, - { startIndex: 5, type: 'identifier.go' }, - { startIndex: 9, type: '' }, - { startIndex: 10, type: 'keyword.struct.go' }, - { startIndex: 16, type: '' }, - { startIndex: 17, type: 'delimiter.curly.go' } - ] - }], - - [{ - line: ' firstname string', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'identifier.go' }, - { startIndex: 11, type: '' }, - { startIndex: 12, type: 'keyword.string.go' } - ] - }], - - [{ - line: ' lastname string', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'identifier.go' }, - { startIndex: 10, type: '' }, - { startIndex: 11, type: 'keyword.string.go' } - ] - }], - - [{ - line: '}', - tokens: [ - { startIndex: 0, type: 'delimiter.curly.go' } - ] - }], - - [{ - line: '', - tokens: [ - - ] - }], - - [{ - line: 'func testTypes() {', - tokens: [ - { startIndex: 0, type: 'keyword.func.go' }, - { startIndex: 4, type: '' }, - { startIndex: 5, type: 'identifier.go' }, - { startIndex: 14, type: 'delimiter.parenthesis.go' }, - { startIndex: 16, type: '' }, - { startIndex: 17, type: 'delimiter.curly.go' } - ] - }], - - [{ - line: ' a int;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'identifier.go' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'keyword.int.go' }, - { startIndex: 7, type: 'delimiter.go' } - ] - }], - - [{ - line: ' b uint;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'identifier.go' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'keyword.uint.go' }, - { startIndex: 8, type: 'delimiter.go' } - ] - }], - - [{ - line: ' c uintptr;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'identifier.go' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'keyword.uintptr.go' }, - { startIndex: 11, type: 'delimiter.go' } - ] - }], - - [{ - line: ' d string;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'identifier.go' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'keyword.string.go' }, - { startIndex: 10, type: 'delimiter.go' } - ] - }], - - [{ - line: ' e byte;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'identifier.go' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'keyword.byte.go' }, - { startIndex: 8, type: 'delimiter.go' } - ] - }], - - [{ - line: ' f rune;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'identifier.go' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'keyword.rune.go' }, - { startIndex: 8, type: 'delimiter.go' } - ] - }], - - [{ - line: ' g uint8;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'identifier.go' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'keyword.uint8.go' }, - { startIndex: 9, type: 'delimiter.go' } - ] - }], - - [{ - line: ' h uint16;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'identifier.go' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'keyword.uint16.go' }, - { startIndex: 10, type: 'delimiter.go' } - ] - }], - - [{ - line: ' i uint32;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'identifier.go' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'keyword.uint32.go' }, - { startIndex: 10, type: 'delimiter.go' } - ] - }], - - [{ - line: ' j uint64;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'identifier.go' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'keyword.uint64.go' }, - { startIndex: 10, type: 'delimiter.go' } - ] - }], - - [{ - line: ' k int8;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'identifier.go' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'keyword.int8.go' }, - { startIndex: 8, type: 'delimiter.go' } - ] - }], - - [{ - line: ' l int16;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'identifier.go' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'keyword.int16.go' }, - { startIndex: 9, type: 'delimiter.go' } - ] - }], - - [{ - line: ' m int32;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'identifier.go' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'keyword.int32.go' }, - { startIndex: 9, type: 'delimiter.go' } - ] - }], - - [{ - line: ' n int64;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'identifier.go' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'keyword.int64.go' }, - { startIndex: 9, type: 'delimiter.go' } - ] - }], - - [{ - line: ' o float32;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'identifier.go' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'keyword.float32.go' }, - { startIndex: 11, type: 'delimiter.go' } - ] - }], - - [{ - line: ' p float64;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'identifier.go' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'keyword.float64.go' }, - { startIndex: 11, type: 'delimiter.go' } - ] - }], - - [{ - line: ' q complex64;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'identifier.go' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'keyword.complex64.go' }, - { startIndex: 13, type: 'delimiter.go' } - ] - }], - - [{ - line: ' r complex128;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'identifier.go' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'keyword.complex128.go' }, - { startIndex: 14, type: 'delimiter.go' } - ] - }], - - [{ - line: '}', - tokens: [ - { startIndex: 0, type: 'delimiter.curly.go' } - ] - }], - - [{ - line: '', - tokens: [ - - ] - }], - - [{ - line: 'func testOperators() {', - tokens: [ - { startIndex: 0, type: 'keyword.func.go' }, - { startIndex: 4, type: '' }, - { startIndex: 5, type: 'identifier.go' }, - { startIndex: 18, type: 'delimiter.parenthesis.go' }, - { startIndex: 20, type: '' }, - { startIndex: 21, type: 'delimiter.curly.go' } - ] - }], - - [{ - line: ' ', - tokens: [ - { startIndex: 0, type: '' } - ] - }], - - [{ - line: ' var a;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'keyword.var.go' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'identifier.go' }, - { startIndex: 7, type: 'delimiter.go' } - ] - }], - - [{ - line: ' var b;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'keyword.var.go' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'identifier.go' }, - { startIndex: 7, type: 'delimiter.go' } - ] - }], - - [{ - line: ' ', - tokens: [ - { startIndex: 0, type: '' } - ] - }], - - [{ - line: ' a + b;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'identifier.go' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'delimiter.go' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'identifier.go' }, - { startIndex: 7, type: 'delimiter.go' } - ] - }], - - [{ - line: ' a - b;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'identifier.go' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'delimiter.go' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'identifier.go' }, - { startIndex: 7, type: 'delimiter.go' } - ] - }], - - [{ - line: ' a * b;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'identifier.go' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'delimiter.go' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'identifier.go' }, - { startIndex: 7, type: 'delimiter.go' } - ] - }], - - [{ - line: ' a / b;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'identifier.go' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'delimiter.go' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'identifier.go' }, - { startIndex: 7, type: 'delimiter.go' } - ] - }], - - [{ - line: ' a % b;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'identifier.go' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'delimiter.go' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'identifier.go' }, - { startIndex: 7, type: 'delimiter.go' } - ] - }], - - [{ - line: ' a & b;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'identifier.go' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'delimiter.go' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'identifier.go' }, - { startIndex: 7, type: 'delimiter.go' } - ] - }], - - [{ - line: ' a | b;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'identifier.go' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'delimiter.go' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'identifier.go' }, - { startIndex: 7, type: 'delimiter.go' } - ] - }], - - [{ - line: ' a ^ b;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'identifier.go' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'delimiter.go' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'identifier.go' }, - { startIndex: 7, type: 'delimiter.go' } - ] - }], - - [{ - line: ' a << b;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'identifier.go' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'delimiter.go' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'identifier.go' }, - { startIndex: 8, type: 'delimiter.go' } - ] - }], - - [{ - line: ' a >> b;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'identifier.go' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'delimiter.go' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'identifier.go' }, - { startIndex: 8, type: 'delimiter.go' } - ] - }], - - [{ - line: ' a &^ b;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'identifier.go' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'delimiter.go' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'identifier.go' }, - { startIndex: 8, type: 'delimiter.go' } - ] - }], - - [{ - line: ' a += b;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'identifier.go' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'delimiter.go' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'identifier.go' }, - { startIndex: 8, type: 'delimiter.go' } - ] - }], - - [{ - line: ' a -= b;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'identifier.go' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'delimiter.go' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'identifier.go' }, - { startIndex: 8, type: 'delimiter.go' } - ] - }], - - [{ - line: ' a *= b;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'identifier.go' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'delimiter.go' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'identifier.go' }, - { startIndex: 8, type: 'delimiter.go' } - ] - }], - - [{ - line: ' a /= b;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'identifier.go' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'delimiter.go' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'identifier.go' }, - { startIndex: 8, type: 'delimiter.go' } - ] - }], - - [{ - line: ' a %= b;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'identifier.go' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'delimiter.go' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'identifier.go' }, - { startIndex: 8, type: 'delimiter.go' } - ] - }], - - [{ - line: ' a &= b;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'identifier.go' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'delimiter.go' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'identifier.go' }, - { startIndex: 8, type: 'delimiter.go' } - ] - }], - - [{ - line: ' a |= b;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'identifier.go' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'delimiter.go' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'identifier.go' }, - { startIndex: 8, type: 'delimiter.go' } - ] - }], - - [{ - line: ' a ^= b;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'identifier.go' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'delimiter.go' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'identifier.go' }, - { startIndex: 8, type: 'delimiter.go' } - ] - }], - - [{ - line: ' a <<= b;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'identifier.go' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'delimiter.go' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'identifier.go' }, - { startIndex: 9, type: 'delimiter.go' } - ] - }], - - [{ - line: ' a >>= b;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'identifier.go' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'delimiter.go' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'identifier.go' }, - { startIndex: 9, type: 'delimiter.go' } - ] - }], - - [{ - line: ' a &^= b;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'identifier.go' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'delimiter.go' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'identifier.go' }, - { startIndex: 9, type: 'delimiter.go' } - ] - }], - - [{ - line: ' a && b;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'identifier.go' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'delimiter.go' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'identifier.go' }, - { startIndex: 8, type: 'delimiter.go' } - ] - }], - - [{ - line: ' a || b;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'identifier.go' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'delimiter.go' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'identifier.go' }, - { startIndex: 8, type: 'delimiter.go' } - ] - }], - - [{ - line: ' a <- b;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'identifier.go' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'delimiter.go' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'identifier.go' }, - { startIndex: 8, type: 'delimiter.go' } - ] - }], - - [{ - line: ' a++;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'identifier.go' }, - { startIndex: 3, type: 'delimiter.go' } - ] - }], - - [{ - line: ' b--;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'identifier.go' }, - { startIndex: 3, type: 'delimiter.go' } - ] - }], - - [{ - line: ' a == b;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'identifier.go' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'delimiter.go' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'identifier.go' }, - { startIndex: 8, type: 'delimiter.go' } - ] - }], - - [{ - line: ' a < b;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'identifier.go' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'delimiter.angle.go' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'identifier.go' }, - { startIndex: 7, type: 'delimiter.go' } - ] - }], - - [{ - line: ' a > b;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'identifier.go' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'delimiter.angle.go' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'identifier.go' }, - { startIndex: 7, type: 'delimiter.go' } - ] - }], - - [{ - line: ' a = b; ', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'identifier.go' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'delimiter.go' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'identifier.go' }, - { startIndex: 7, type: 'delimiter.go' }, - { startIndex: 8, type: '' } - ] - }], - - [{ - line: ' !a;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'delimiter.go' }, - { startIndex: 3, type: 'identifier.go' }, - { startIndex: 4, type: 'delimiter.go' } - ] - }], - - [{ - line: ' a != b;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'identifier.go' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'delimiter.go' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'identifier.go' }, - { startIndex: 8, type: 'delimiter.go' } - ] - }], - - [{ - line: ' a <= b;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'identifier.go' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'delimiter.go' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'identifier.go' }, - { startIndex: 8, type: 'delimiter.go' } - ] - }], - - [{ - line: ' a >= b;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'identifier.go' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'delimiter.go' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'identifier.go' }, - { startIndex: 8, type: 'delimiter.go' } - ] - }], - - [{ - line: ' a := b;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'identifier.go' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'delimiter.go' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'identifier.go' }, - { startIndex: 8, type: 'delimiter.go' } - ] - }], - - [{ - line: ' a...;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'identifier.go' }, - { startIndex: 3, type: 'delimiter.go' } - ] - }], - - [{ - line: ' (a)', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'delimiter.parenthesis.go' }, - { startIndex: 3, type: 'identifier.go' }, - { startIndex: 4, type: 'delimiter.parenthesis.go' } - ] - }], - - [{ - line: ' [a]', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'delimiter.square.go' }, - { startIndex: 3, type: 'identifier.go' }, - { startIndex: 4, type: 'delimiter.square.go' } - ] - }], - - [{ - line: ' a.b;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'identifier.go' }, - { startIndex: 3, type: 'delimiter.go' }, - { startIndex: 4, type: 'identifier.go' }, - { startIndex: 5, type: 'delimiter.go' } - ] - }], - - [{ - line: ' a, b;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'identifier.go' }, - { startIndex: 3, type: 'delimiter.go' }, - { startIndex: 4, type: '' }, - { startIndex: 5, type: 'identifier.go' }, - { startIndex: 6, type: 'delimiter.go' } - ] - }], - - [{ - line: ' a : b; ', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'identifier.go' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'delimiter.go' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'identifier.go' }, - { startIndex: 7, type: 'delimiter.go' }, - { startIndex: 8, type: '' } - ] - }], - - [{ - line: '}', - tokens: [ - { startIndex: 0, type: 'delimiter.curly.go' } - ] - }], - - [{ - line: '', - tokens: [ - - ] - }], - - [{ - line: 'func keywords() {', - tokens: [ - { startIndex: 0, type: 'keyword.func.go' }, - { startIndex: 4, type: '' }, - { startIndex: 5, type: 'identifier.go' }, - { startIndex: 13, type: 'delimiter.parenthesis.go' }, - { startIndex: 15, type: '' }, - { startIndex: 16, type: 'delimiter.curly.go' } - ] - }], - - [{ - line: ' ', - tokens: [ - { startIndex: 0, type: '' } - ] - }], - - [{ - line: ' var a;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'keyword.var.go' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'identifier.go' }, - { startIndex: 7, type: 'delimiter.go' } - ] - }], - - [{ - line: ' break;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'keyword.break.go' }, - { startIndex: 7, type: 'delimiter.go' } - ] - }], - - [{ - line: ' switch(a) {', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'keyword.switch.go' }, - { startIndex: 8, type: 'delimiter.parenthesis.go' }, - { startIndex: 9, type: 'identifier.go' }, - { startIndex: 10, type: 'delimiter.parenthesis.go' }, - { startIndex: 11, type: '' }, - { startIndex: 12, type: 'delimiter.curly.go' } - ] - }], - - [{ - line: ' case 1:', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 4, type: 'keyword.case.go' }, - { startIndex: 8, type: '' }, - { startIndex: 9, type: 'number.go' }, - { startIndex: 10, type: 'delimiter.go' } - ] - }], - - [{ - line: ' fallthrough;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 6, type: 'keyword.fallthrough.go' }, - { startIndex: 17, type: 'delimiter.go' } - ] - }], - - [{ - line: ' default:', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 4, type: 'keyword.default.go' }, - { startIndex: 11, type: 'delimiter.go' } - ] - }], - - [{ - line: ' break;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 6, type: 'keyword.break.go' }, - { startIndex: 11, type: 'delimiter.go' } - ] - }], - - [{ - line: ' }', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'delimiter.curly.go' } - ] - }], - - [{ - line: ' ', - tokens: [ - { startIndex: 0, type: '' } - ] - }], - - [{ - line: ' chan;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'keyword.chan.go' }, - { startIndex: 6, type: 'delimiter.go' } - ] - }], - - [{ - line: ' const;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'keyword.const.go' }, - { startIndex: 7, type: 'delimiter.go' } - ] - }], - - [{ - line: ' continue;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'keyword.continue.go' }, - { startIndex: 10, type: 'delimiter.go' } - ] - }], - - [{ - line: ' defer;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'keyword.defer.go' }, - { startIndex: 7, type: 'delimiter.go' } - ] - }], - - [{ - line: ' if (a)', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'keyword.if.go' }, - { startIndex: 4, type: '' }, - { startIndex: 5, type: 'delimiter.parenthesis.go' }, - { startIndex: 6, type: 'identifier.go' }, - { startIndex: 7, type: 'delimiter.parenthesis.go' } - ] - }], - - [{ - line: ' return;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 4, type: 'keyword.return.go' }, - { startIndex: 10, type: 'delimiter.go' } - ] - }], - - [{ - line: ' else', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'keyword.else.go' } - ] - }], - - [{ - line: ' return;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 4, type: 'keyword.return.go' }, - { startIndex: 10, type: 'delimiter.go' } - ] - }], - - [{ - line: ' for (i = 0; i < 10; i++);', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 3, type: 'keyword.for.go' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'delimiter.parenthesis.go' }, - { startIndex: 8, type: 'identifier.go' }, - { startIndex: 9, type: '' }, - { startIndex: 10, type: 'delimiter.go' }, - { startIndex: 11, type: '' }, - { startIndex: 12, type: 'number.go' }, - { startIndex: 13, type: 'delimiter.go' }, - { startIndex: 14, type: '' }, - { startIndex: 15, type: 'identifier.go' }, - { startIndex: 16, type: '' }, - { startIndex: 17, type: 'delimiter.angle.go' }, - { startIndex: 18, type: '' }, - { startIndex: 19, type: 'number.go' }, - { startIndex: 21, type: 'delimiter.go' }, - { startIndex: 22, type: '' }, - { startIndex: 23, type: 'identifier.go' }, - { startIndex: 24, type: 'delimiter.go' }, - { startIndex: 26, type: 'delimiter.parenthesis.go' }, - { startIndex: 27, type: 'delimiter.go' } - ] - }], - - [{ - line: ' go;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 3, type: 'keyword.go.go' }, - { startIndex: 5, type: 'delimiter.go' } - ] - }], - - [{ - line: ' goto;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 3, type: 'keyword.goto.go' }, - { startIndex: 7, type: 'delimiter.go' } - ] - }], - - [{ - line: ' interface;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 3, type: 'keyword.interface.go' }, - { startIndex: 12, type: 'delimiter.go' } - ] - }], - - [{ - line: ' map;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 3, type: 'keyword.map.go' }, - { startIndex: 6, type: 'delimiter.go' } - ] - }], - - [{ - line: ' package;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 3, type: 'keyword.package.go' }, - { startIndex: 10, type: 'delimiter.go' } - ] - }], - - [{ - line: ' range;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 3, type: 'keyword.range.go' }, - { startIndex: 8, type: 'delimiter.go' } - ] - }], - - [{ - line: ' return;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 3, type: 'keyword.return.go' }, - { startIndex: 9, type: 'delimiter.go' } - ] - }], - - [{ - line: ' select;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 3, type: 'keyword.select.go' }, - { startIndex: 9, type: 'delimiter.go' } - ] - }], - - [{ - line: ' struct;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 3, type: 'keyword.struct.go' }, - { startIndex: 9, type: 'delimiter.go' } - ] - }], - - [{ - line: ' type;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 3, type: 'keyword.type.go' }, - { startIndex: 7, type: 'delimiter.go' } - ] - }], - - [{ - line: ' ', - tokens: [ - { startIndex: 0, type: '' } - ] - }], - - [{ - line: ' var x = true;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 3, type: 'keyword.var.go' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'identifier.go' }, - { startIndex: 8, type: '' }, - { startIndex: 9, type: 'delimiter.go' }, - { startIndex: 10, type: '' }, - { startIndex: 11, type: 'keyword.true.go' }, - { startIndex: 15, type: 'delimiter.go' } - ] - }], - - [{ - line: ' var y = false;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 3, type: 'keyword.var.go' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'identifier.go' }, - { startIndex: 8, type: '' }, - { startIndex: 9, type: 'delimiter.go' }, - { startIndex: 10, type: '' }, - { startIndex: 11, type: 'keyword.false.go' }, - { startIndex: 16, type: 'delimiter.go' } - ] - }], - - [{ - line: ' var z = nil;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 3, type: 'keyword.var.go' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'identifier.go' }, - { startIndex: 8, type: '' }, - { startIndex: 9, type: 'delimiter.go' }, - { startIndex: 10, type: '' }, - { startIndex: 11, type: 'keyword.nil.go' }, - { startIndex: 14, type: 'delimiter.go' } - ] - }], - - [{ - line: '}', - tokens: [ - { startIndex: 0, type: 'delimiter.curly.go' } - ] - }], - - [{ - line: '`Hello world() ""`', - tokens: [ - { startIndex: 0, type: 'string.go' } - ] - }] + [ + { + line: '/* Block comment. */', + tokens: [{ startIndex: 0, type: 'comment.go' }] + } + ], + + [ + { + line: '/* //*/ a', + tokens: [ + { startIndex: 0, type: 'comment.go' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'identifier.go' } + ] + } + ], + + [ + { + line: '// Inline comment.', + tokens: [{ startIndex: 0, type: 'comment.go' }] + } + ], + + [ + { + line: '', + tokens: [] + } + ], + + [ + { + line: 'import {', + tokens: [ + { startIndex: 0, type: 'keyword.import.go' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'delimiter.curly.go' } + ] + } + ], + + [ + { + line: ' "io"', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'string.go' } + ] + } + ], + + [ + { + line: '}', + tokens: [{ startIndex: 0, type: 'delimiter.curly.go' }] + } + ], + + [ + { + line: '', + tokens: [] + } + ], + + [ + { + line: 'type name struct {', + tokens: [ + { startIndex: 0, type: 'keyword.type.go' }, + { startIndex: 4, type: '' }, + { startIndex: 5, type: 'identifier.go' }, + { startIndex: 9, type: '' }, + { startIndex: 10, type: 'keyword.struct.go' }, + { startIndex: 16, type: '' }, + { startIndex: 17, type: 'delimiter.curly.go' } + ] + } + ], + + [ + { + line: ' firstname string', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'identifier.go' }, + { startIndex: 11, type: '' }, + { startIndex: 12, type: 'keyword.string.go' } + ] + } + ], + + [ + { + line: ' lastname string', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'identifier.go' }, + { startIndex: 10, type: '' }, + { startIndex: 11, type: 'keyword.string.go' } + ] + } + ], + + [ + { + line: '}', + tokens: [{ startIndex: 0, type: 'delimiter.curly.go' }] + } + ], + + [ + { + line: '', + tokens: [] + } + ], + + [ + { + line: 'func testTypes() {', + tokens: [ + { startIndex: 0, type: 'keyword.func.go' }, + { startIndex: 4, type: '' }, + { startIndex: 5, type: 'identifier.go' }, + { startIndex: 14, type: 'delimiter.parenthesis.go' }, + { startIndex: 16, type: '' }, + { startIndex: 17, type: 'delimiter.curly.go' } + ] + } + ], + + [ + { + line: ' a int;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'identifier.go' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'keyword.int.go' }, + { startIndex: 7, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' b uint;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'identifier.go' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'keyword.uint.go' }, + { startIndex: 8, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' c uintptr;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'identifier.go' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'keyword.uintptr.go' }, + { startIndex: 11, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' d string;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'identifier.go' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'keyword.string.go' }, + { startIndex: 10, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' e byte;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'identifier.go' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'keyword.byte.go' }, + { startIndex: 8, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' f rune;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'identifier.go' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'keyword.rune.go' }, + { startIndex: 8, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' g uint8;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'identifier.go' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'keyword.uint8.go' }, + { startIndex: 9, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' h uint16;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'identifier.go' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'keyword.uint16.go' }, + { startIndex: 10, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' i uint32;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'identifier.go' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'keyword.uint32.go' }, + { startIndex: 10, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' j uint64;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'identifier.go' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'keyword.uint64.go' }, + { startIndex: 10, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' k int8;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'identifier.go' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'keyword.int8.go' }, + { startIndex: 8, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' l int16;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'identifier.go' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'keyword.int16.go' }, + { startIndex: 9, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' m int32;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'identifier.go' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'keyword.int32.go' }, + { startIndex: 9, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' n int64;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'identifier.go' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'keyword.int64.go' }, + { startIndex: 9, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' o float32;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'identifier.go' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'keyword.float32.go' }, + { startIndex: 11, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' p float64;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'identifier.go' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'keyword.float64.go' }, + { startIndex: 11, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' q complex64;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'identifier.go' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'keyword.complex64.go' }, + { startIndex: 13, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' r complex128;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'identifier.go' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'keyword.complex128.go' }, + { startIndex: 14, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: '}', + tokens: [{ startIndex: 0, type: 'delimiter.curly.go' }] + } + ], + + [ + { + line: '', + tokens: [] + } + ], + + [ + { + line: 'func testOperators() {', + tokens: [ + { startIndex: 0, type: 'keyword.func.go' }, + { startIndex: 4, type: '' }, + { startIndex: 5, type: 'identifier.go' }, + { startIndex: 18, type: 'delimiter.parenthesis.go' }, + { startIndex: 20, type: '' }, + { startIndex: 21, type: 'delimiter.curly.go' } + ] + } + ], + + [ + { + line: ' ', + tokens: [{ startIndex: 0, type: '' }] + } + ], + + [ + { + line: ' var a;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'keyword.var.go' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'identifier.go' }, + { startIndex: 7, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' var b;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'keyword.var.go' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'identifier.go' }, + { startIndex: 7, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' ', + tokens: [{ startIndex: 0, type: '' }] + } + ], + + [ + { + line: ' a + b;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'identifier.go' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'delimiter.go' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'identifier.go' }, + { startIndex: 7, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' a - b;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'identifier.go' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'delimiter.go' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'identifier.go' }, + { startIndex: 7, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' a * b;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'identifier.go' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'delimiter.go' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'identifier.go' }, + { startIndex: 7, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' a / b;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'identifier.go' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'delimiter.go' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'identifier.go' }, + { startIndex: 7, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' a % b;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'identifier.go' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'delimiter.go' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'identifier.go' }, + { startIndex: 7, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' a & b;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'identifier.go' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'delimiter.go' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'identifier.go' }, + { startIndex: 7, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' a | b;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'identifier.go' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'delimiter.go' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'identifier.go' }, + { startIndex: 7, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' a ^ b;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'identifier.go' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'delimiter.go' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'identifier.go' }, + { startIndex: 7, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' a << b;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'identifier.go' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'delimiter.go' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'identifier.go' }, + { startIndex: 8, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' a >> b;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'identifier.go' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'delimiter.go' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'identifier.go' }, + { startIndex: 8, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' a &^ b;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'identifier.go' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'delimiter.go' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'identifier.go' }, + { startIndex: 8, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' a += b;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'identifier.go' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'delimiter.go' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'identifier.go' }, + { startIndex: 8, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' a -= b;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'identifier.go' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'delimiter.go' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'identifier.go' }, + { startIndex: 8, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' a *= b;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'identifier.go' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'delimiter.go' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'identifier.go' }, + { startIndex: 8, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' a /= b;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'identifier.go' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'delimiter.go' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'identifier.go' }, + { startIndex: 8, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' a %= b;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'identifier.go' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'delimiter.go' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'identifier.go' }, + { startIndex: 8, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' a &= b;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'identifier.go' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'delimiter.go' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'identifier.go' }, + { startIndex: 8, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' a |= b;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'identifier.go' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'delimiter.go' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'identifier.go' }, + { startIndex: 8, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' a ^= b;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'identifier.go' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'delimiter.go' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'identifier.go' }, + { startIndex: 8, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' a <<= b;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'identifier.go' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'delimiter.go' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'identifier.go' }, + { startIndex: 9, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' a >>= b;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'identifier.go' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'delimiter.go' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'identifier.go' }, + { startIndex: 9, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' a &^= b;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'identifier.go' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'delimiter.go' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'identifier.go' }, + { startIndex: 9, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' a && b;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'identifier.go' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'delimiter.go' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'identifier.go' }, + { startIndex: 8, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' a || b;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'identifier.go' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'delimiter.go' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'identifier.go' }, + { startIndex: 8, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' a <- b;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'identifier.go' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'delimiter.go' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'identifier.go' }, + { startIndex: 8, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' a++;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'identifier.go' }, + { startIndex: 3, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' b--;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'identifier.go' }, + { startIndex: 3, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' a == b;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'identifier.go' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'delimiter.go' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'identifier.go' }, + { startIndex: 8, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' a < b;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'identifier.go' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'delimiter.angle.go' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'identifier.go' }, + { startIndex: 7, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' a > b;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'identifier.go' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'delimiter.angle.go' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'identifier.go' }, + { startIndex: 7, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' a = b; ', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'identifier.go' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'delimiter.go' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'identifier.go' }, + { startIndex: 7, type: 'delimiter.go' }, + { startIndex: 8, type: '' } + ] + } + ], + + [ + { + line: ' !a;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'delimiter.go' }, + { startIndex: 3, type: 'identifier.go' }, + { startIndex: 4, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' a != b;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'identifier.go' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'delimiter.go' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'identifier.go' }, + { startIndex: 8, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' a <= b;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'identifier.go' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'delimiter.go' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'identifier.go' }, + { startIndex: 8, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' a >= b;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'identifier.go' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'delimiter.go' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'identifier.go' }, + { startIndex: 8, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' a := b;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'identifier.go' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'delimiter.go' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'identifier.go' }, + { startIndex: 8, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' a...;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'identifier.go' }, + { startIndex: 3, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' (a)', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'delimiter.parenthesis.go' }, + { startIndex: 3, type: 'identifier.go' }, + { startIndex: 4, type: 'delimiter.parenthesis.go' } + ] + } + ], + + [ + { + line: ' [a]', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'delimiter.square.go' }, + { startIndex: 3, type: 'identifier.go' }, + { startIndex: 4, type: 'delimiter.square.go' } + ] + } + ], + + [ + { + line: ' a.b;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'identifier.go' }, + { startIndex: 3, type: 'delimiter.go' }, + { startIndex: 4, type: 'identifier.go' }, + { startIndex: 5, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' a, b;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'identifier.go' }, + { startIndex: 3, type: 'delimiter.go' }, + { startIndex: 4, type: '' }, + { startIndex: 5, type: 'identifier.go' }, + { startIndex: 6, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' a : b; ', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'identifier.go' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'delimiter.go' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'identifier.go' }, + { startIndex: 7, type: 'delimiter.go' }, + { startIndex: 8, type: '' } + ] + } + ], + + [ + { + line: '}', + tokens: [{ startIndex: 0, type: 'delimiter.curly.go' }] + } + ], + + [ + { + line: '', + tokens: [] + } + ], + + [ + { + line: 'func keywords() {', + tokens: [ + { startIndex: 0, type: 'keyword.func.go' }, + { startIndex: 4, type: '' }, + { startIndex: 5, type: 'identifier.go' }, + { startIndex: 13, type: 'delimiter.parenthesis.go' }, + { startIndex: 15, type: '' }, + { startIndex: 16, type: 'delimiter.curly.go' } + ] + } + ], + + [ + { + line: ' ', + tokens: [{ startIndex: 0, type: '' }] + } + ], + + [ + { + line: ' var a;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'keyword.var.go' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'identifier.go' }, + { startIndex: 7, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' break;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'keyword.break.go' }, + { startIndex: 7, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' switch(a) {', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'keyword.switch.go' }, + { startIndex: 8, type: 'delimiter.parenthesis.go' }, + { startIndex: 9, type: 'identifier.go' }, + { startIndex: 10, type: 'delimiter.parenthesis.go' }, + { startIndex: 11, type: '' }, + { startIndex: 12, type: 'delimiter.curly.go' } + ] + } + ], + + [ + { + line: ' case 1:', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 4, type: 'keyword.case.go' }, + { startIndex: 8, type: '' }, + { startIndex: 9, type: 'number.go' }, + { startIndex: 10, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' fallthrough;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 6, type: 'keyword.fallthrough.go' }, + { startIndex: 17, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' default:', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 4, type: 'keyword.default.go' }, + { startIndex: 11, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' break;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 6, type: 'keyword.break.go' }, + { startIndex: 11, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' }', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'delimiter.curly.go' } + ] + } + ], + + [ + { + line: ' ', + tokens: [{ startIndex: 0, type: '' }] + } + ], + + [ + { + line: ' chan;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'keyword.chan.go' }, + { startIndex: 6, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' const;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'keyword.const.go' }, + { startIndex: 7, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' continue;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'keyword.continue.go' }, + { startIndex: 10, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' defer;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'keyword.defer.go' }, + { startIndex: 7, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' if (a)', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'keyword.if.go' }, + { startIndex: 4, type: '' }, + { startIndex: 5, type: 'delimiter.parenthesis.go' }, + { startIndex: 6, type: 'identifier.go' }, + { startIndex: 7, type: 'delimiter.parenthesis.go' } + ] + } + ], + + [ + { + line: ' return;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 4, type: 'keyword.return.go' }, + { startIndex: 10, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' else', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'keyword.else.go' } + ] + } + ], + + [ + { + line: ' return;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 4, type: 'keyword.return.go' }, + { startIndex: 10, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' for (i = 0; i < 10; i++);', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 3, type: 'keyword.for.go' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'delimiter.parenthesis.go' }, + { startIndex: 8, type: 'identifier.go' }, + { startIndex: 9, type: '' }, + { startIndex: 10, type: 'delimiter.go' }, + { startIndex: 11, type: '' }, + { startIndex: 12, type: 'number.go' }, + { startIndex: 13, type: 'delimiter.go' }, + { startIndex: 14, type: '' }, + { startIndex: 15, type: 'identifier.go' }, + { startIndex: 16, type: '' }, + { startIndex: 17, type: 'delimiter.angle.go' }, + { startIndex: 18, type: '' }, + { startIndex: 19, type: 'number.go' }, + { startIndex: 21, type: 'delimiter.go' }, + { startIndex: 22, type: '' }, + { startIndex: 23, type: 'identifier.go' }, + { startIndex: 24, type: 'delimiter.go' }, + { startIndex: 26, type: 'delimiter.parenthesis.go' }, + { startIndex: 27, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' go;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 3, type: 'keyword.go.go' }, + { startIndex: 5, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' goto;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 3, type: 'keyword.goto.go' }, + { startIndex: 7, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' interface;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 3, type: 'keyword.interface.go' }, + { startIndex: 12, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' map;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 3, type: 'keyword.map.go' }, + { startIndex: 6, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' package;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 3, type: 'keyword.package.go' }, + { startIndex: 10, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' range;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 3, type: 'keyword.range.go' }, + { startIndex: 8, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' return;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 3, type: 'keyword.return.go' }, + { startIndex: 9, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' select;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 3, type: 'keyword.select.go' }, + { startIndex: 9, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' struct;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 3, type: 'keyword.struct.go' }, + { startIndex: 9, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' type;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 3, type: 'keyword.type.go' }, + { startIndex: 7, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' ', + tokens: [{ startIndex: 0, type: '' }] + } + ], + + [ + { + line: ' var x = true;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 3, type: 'keyword.var.go' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'identifier.go' }, + { startIndex: 8, type: '' }, + { startIndex: 9, type: 'delimiter.go' }, + { startIndex: 10, type: '' }, + { startIndex: 11, type: 'keyword.true.go' }, + { startIndex: 15, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' var y = false;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 3, type: 'keyword.var.go' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'identifier.go' }, + { startIndex: 8, type: '' }, + { startIndex: 9, type: 'delimiter.go' }, + { startIndex: 10, type: '' }, + { startIndex: 11, type: 'keyword.false.go' }, + { startIndex: 16, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: ' var z = nil;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 3, type: 'keyword.var.go' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'identifier.go' }, + { startIndex: 8, type: '' }, + { startIndex: 9, type: 'delimiter.go' }, + { startIndex: 10, type: '' }, + { startIndex: 11, type: 'keyword.nil.go' }, + { startIndex: 14, type: 'delimiter.go' } + ] + } + ], + + [ + { + line: '}', + tokens: [{ startIndex: 0, type: 'delimiter.curly.go' }] + } + ], + + [ + { + line: '`Hello world() ""`', + tokens: [{ startIndex: 0, type: 'string.go' }] + } + ] ]); diff --git a/src/go/go.ts b/src/go/go.ts index aaac31ce..084cc099 100644 --- a/src/go/go.ts +++ b/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 = { - defaultToken: '', tokenPostfix: '.go', @@ -88,31 +87,76 @@ export const language = { 'int', 'uintptr', 'string', - 'nil', + 'nil' ], operators: [ - '+', '-', '*', '/', '%', '&', '|', '^', '<<', '>>', '&^', - '+=', '-=', '*=', '/=', '%=', '&=', '|=', '^=', '<<=', '>>=', '&^=', - '&&', '||', '<-', '++', '--', '==', '<', '>', '=', '!', '!=', '<=', '>=', ':=', '...', - '(', ')', '', ']', '{', '}', ',', ';', '.', ':' + '+', + '-', + '*', + '/', + '%', + '&', + '|', + '^', + '<<', + '>>', + '&^', + '+=', + '-=', + '*=', + '/=', + '%=', + '&=', + '|=', + '^=', + '<<=', + '>>=', + '&^=', + '&&', + '||', + '<-', + '++', + '--', + '==', + '<', + '>', + '=', + '!', + '!=', + '<=', + '>=', + ':=', + '...', + '(', + ')', + '', + ']', + '{', + '}', + ',', + ';', + '.', + ':' ], // we include these common regular expressions symbols: /[=>{ // 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 = { [/[;,.]/, '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 = { [/[ \t\r\n]+/, ''], [/\/\*\*(?!\/)/, 'comment.doc', '@doccomment'], [/\/\*/, 'comment', '@comment'], - [/\/\/.*$/, 'comment'], + [/\/\/.*$/, 'comment'] ], comment: [ @@ -187,8 +234,8 @@ export const language = { ], rawstring: [ - [/[^\`]/, "string"], - [/`/, "string", "@pop"] - ], - }, + [/[^\`]/, 'string'], + [/`/, 'string', '@pop'] + ] + } }; diff --git a/src/graphql/graphql.test.ts b/src/graphql/graphql.test.ts index 1fcc9c8a..203274db 100644 --- a/src/graphql/graphql.test.ts +++ b/src/graphql/graphql.test.ts @@ -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' }] + } ] - ]); diff --git a/src/graphql/graphql.ts b/src/graphql/graphql.ts index 438d1a11..9ba864f7 100644 --- a/src/graphql/graphql.ts +++ b/src/graphql/graphql.ts @@ -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 = { 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 = { // 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 = { { cases: { '@keywords': 'keyword', - '@default': 'argument.identifier', - }, - }, + '@default': 'argument.identifier' + } + } ], // to show class names nicely @@ -98,9 +125,9 @@ export const language = { { cases: { '@typeKeywords': 'keyword', - '@default': 'type.identifier', - }, - }, + '@default': 'type.identifier' + } + } ], // whitespace @@ -110,7 +137,7 @@ export const language = { [/[{}()\[\]]/, '@brackets'], [ /@symbols/, - { cases: { '@operators': 'operator', '@default': '' } }, + { cases: { '@operators': 'operator', '@default': '' } } ], // @ annotations. @@ -118,7 +145,7 @@ export const language = { // 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 = { // 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 = { [/[^\\"]+/, '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'] + ] + } }; diff --git a/src/handlebars/handlebars.test.ts b/src/handlebars/handlebars.test.ts index 71738d77..48a77b75 100644 --- a/src/handlebars/handlebars.test.ts +++ b/src/handlebars/handlebars.test.ts @@ -1,315 +1,357 @@ -/*--------------------------------------------------------------------------------------------- - * 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'; - -testTokenization(['handlebars', 'css'], [ - - // Just HTML - [{ - line: '

handlebars!

', - 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: '

{{ title }}

', - 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: '

{{title}}

', - 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: '

{{{ title }}}

', - 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: '
    {{#each items}}
  • {{item}}
  • {{/each}}
', - 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: '
', - 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: '{{bar}}', - 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: '
', - tokens: [ - { startIndex: 0, type: 'delimiter.html' }, - { startIndex: 2, type: 'tag.html' }, - { startIndex: 5, type: 'delimiter.html' } - ] - }], - - // HTML Expressions - [{ - line: '', - 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: '', - tokens: [ - { startIndex: 0, type: 'delimiter.html' }, - { startIndex: 2, type: 'tag.html' }, - { startIndex: 8, type: 'delimiter.html' } - ] - }], - - // HTML Nested Modes - [{ - line: '{{foo}}{{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 #2 - [{ - line: '{{elseFoo}}', - tokens: [ - { startIndex: 0, type: 'delimiter.handlebars' }, - { startIndex: 2, type: 'variable.parameter.handlebars' }, - { startIndex: 9, type: 'delimiter.handlebars' } - ] - }], - - // Token inside attribute - [{ - line: '', - 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: '' } - ] - }], - - // 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' } - ] - }], - - // Handlebars comment - [{ - line: '{{! comment }}', - tokens: [ - { startIndex: 0, type: 'comment.start.handlebars' }, - { startIndex: 3, type: 'comment.content.handlebars' }, - { startIndex: 12, type: 'comment.end.handlebars' } - ] - }], -]); +/*--------------------------------------------------------------------------------------------- + * 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'; + +testTokenization( + ['handlebars', 'css'], + [ + // Just HTML + [ + { + line: '

handlebars!

', + 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: '

{{ title }}

', + 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: '

{{title}}

', + 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: '

{{{ title }}}

', + 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: '
    {{#each items}}
  • {{item}}
  • {{/each}}
', + 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: '
', + 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: '{{bar}}', + 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: '
', + tokens: [ + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 2, type: 'tag.html' }, + { startIndex: 5, type: 'delimiter.html' } + ] + } + ], + + // HTML Expressions + [ + { + line: + '', + 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: '', + tokens: [ + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 2, type: 'tag.html' }, + { startIndex: 8, type: 'delimiter.html' } + ] + } + ], + + // HTML Nested Modes + [ + { + line: '{{foo}}{{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 #2 + [ + { + line: '{{elseFoo}}', + tokens: [ + { startIndex: 0, type: 'delimiter.handlebars' }, + { startIndex: 2, type: 'variable.parameter.handlebars' }, + { startIndex: 9, type: 'delimiter.handlebars' } + ] + } + ], + + // Token inside attribute + [ + { + line: '
', + 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: '' } + ] + } + ], + + // 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' } + ] + } + ], + + // Handlebars comment + [ + { + line: '{{! comment }}', + tokens: [ + { startIndex: 0, type: 'comment.start.handlebars' }, + { startIndex: 3, type: 'comment.content.handlebars' }, + { startIndex: 12, type: 'comment.end.handlebars' } + ] + } + ] + ] +); diff --git a/src/handlebars/handlebars.ts b/src/handlebars/handlebars.ts index 17db3fc3..b37ab6b1 100644 --- a/src/handlebars/handlebars.ts +++ b/src/handlebars/handlebars.ts @@ -1,242 +1,476 @@ -/*--------------------------------------------------------------------------------------------- - * 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 IRichLanguageConfiguration = monaco.languages.LanguageConfiguration; -import ILanguage = monaco.languages.IMonarchLanguage; - -// Allow for running under nodejs/requirejs in tests -const _monaco: typeof monaco = (typeof monaco === 'undefined' ? (self).monaco : monaco); - -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, - - comments: { - blockComment: ['{{!--', '--}}'] - }, - - brackets: [ - [''], - ['<', '>'], - ['{{', '}}'], - ['{', '}'], - ['(', ')'] - ], - - autoClosingPairs: [ - { open: '{', close: '}' }, - { open: '[', close: ']' }, - { open: '(', close: ')' }, - { open: '"', close: '"' }, - { open: '\'', close: '\'' } - ], - - surroundingPairs: [ - { open: '<', close: '>' }, - { open: '"', close: '"' }, - { open: '\'', close: '\'' } - ], - - onEnterRules: [ - { - beforeText: new RegExp(`<(?!(?:${EMPTY_ELEMENTS.join('|')}))(\\w[\\w\\d]*)([^/>]*(?!/)>)[^<]*$`, 'i'), - afterText: /^<\/(\w[\w\d]*)\s*>$/i, - action: { indentAction: _monaco.languages.IndentAction.IndentOutdent } - }, - { - beforeText: new RegExp(`<(?!(?:${EMPTY_ELEMENTS.join('|')}))(\\w[\\w\\d]*)([^/>]*(?!/)>)[^<]*$`, 'i'), - action: { indentAction: _monaco.languages.IndentAction.Indent } - } - ], -} - -export const language = { - defaultToken: '', - tokenPostfix: '', - // ignoreCase: true, - - // The main tokenizer for our languages - tokenizer: { - root: [ - [/\{\{!--/, 'comment.block.start.handlebars', '@commentBlock'], - [/\{\{!/, 'comment.start.handlebars', '@comment'], - [/\{\{/, { token: '@rematch', switchTo: '@handlebarsInSimpleState.root' }], - [/)/, ['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' }]], - [/]+/, 'metatag.content.html'], - [/>/, 'metatag.html', '@pop'], - ], - - comment: [ - [/\}\}/, 'comment.end.handlebars', '@pop'], - [/./, 'comment.content.handlebars'] - ], - - commentBlock: [ - [/--\}\}/, 'comment.block.end.handlebars', '@pop'], - [/./, 'comment.content.handlebars'] - ], - - commentHtml: [ - [/\{\{/, { token: '@rematch', switchTo: '@handlebarsInSimpleState.comment' }], - [/-->/, 'comment.html', '@pop'], - [/[^-]+/, 'comment.content.html'], - [/./, 'comment.content.html'] - ], - - otherTag: [ - [/\{\{/, { token: '@rematch', switchTo: '@handlebarsInSimpleState.otherTag' }], - [/\/?>/, 'delimiter.html', '@pop'], - [/"([^"]*)"/, 'attribute.value'], - [/'([^']*)'/, 'attribute.value'], - [/[\w\-]+/, 'attribute.name'], - [/=/, 'delimiter'], - [/[ \t\r\n]+/], // whitespace - ], - - // -- BEGIN ', - tokens: [ - { startIndex: 0, type: 'delimiter.html' }, - { startIndex: 1, type: 'tag.html' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'attribute.name.html' }, - { startIndex: 12, type: 'delimiter.html' }, - { startIndex: 13, type: 'attribute.value.html' }, - { startIndex: 30, type: 'delimiter.html' }, - { startIndex: 31, type: 'keyword.js' }, - { startIndex: 34, type: '' }, - { startIndex: 35, type: 'identifier.js' }, - { startIndex: 36, type: 'delimiter.js' }, - { startIndex: 37, type: '' }, - { startIndex: 38, type: 'number.js' }, - { startIndex: 40, type: 'delimiter.js' }, - { startIndex: 41, type: 'delimiter.html' }, - { startIndex: 43, type: 'tag.html' }, - { startIndex: 49, type: 'delimiter.html' } - ] - }], - - // Embedded Content #2 - [{ - line: '', - tokens: [ - { startIndex: 0, type: 'delimiter.html' }, - { startIndex: 2, type: 'tag.html' }, - { startIndex: 8, type: 'delimiter.html' } - ] - }], - - // Embedded Content #3 - [{ - line: '', - tokens: [ - { startIndex: 0, type: 'delimiter.html' }, - { startIndex: 2, type: 'tag.html' }, - { startIndex: 8, type: 'delimiter.html' } - ] - }], - - // Embedded Content #4 - [{ - line: '', - tokens: [ - { startIndex: 0, type: 'keyword.js' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'identifier.js' }, - { startIndex: 5, type: 'delimiter.js' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'number.js' }, - { startIndex: 9, type: 'delimiter.js' }, - { startIndex: 10, type: 'delimiter.html' }, - { startIndex: 12, type: 'tag.html' }, - { startIndex: 18, type: 'delimiter.html' } - ] - }], - - // Embedded Content #5 - [{ - line: '', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'delimiter.html' }, - { startIndex: 4, type: 'tag.html' }, - { startIndex: 10, type: 'delimiter.html' } - ] - }], - - // Embedded Content #6 - [{ - line: '', - tokens: [ - { startIndex: 0, type: 'delimiter.html' }, - { startIndex: 1, type: 'tag.html' }, - { startIndex: 7, type: 'delimiter.html' }, - { startIndex: 8, type: 'identifier.js' }, - { startIndex: 9, type: 'delimiter.html' }, - { startIndex: 11, type: 'tag.html' }, - { startIndex: 17, type: 'delimiter.html' }, - // { startIndex:18, type: 'delimiter.html' }, - { startIndex: 19, type: 'tag.html' }, - { startIndex: 25, type: 'delimiter.html' }, - { startIndex: 26, type: 'identifier.js' }, - { startIndex: 27, type: 'delimiter.html' }, - { startIndex: 29, type: 'tag.html' }, - { startIndex: 35, type: 'delimiter.html' } - ] - }], - - // Embedded Content #7 - [{ - line: '', - tokens: [ - { startIndex: 0, type: 'delimiter.html' }, - { startIndex: 1, type: 'tag.html' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'attribute.name.html' }, - { startIndex: 12, type: 'delimiter.html' }, - { startIndex: 13, type: 'attribute.value.html' }, - { startIndex: 30, type: 'delimiter.html' }, - // { startIndex:31, type: 'delimiter.html' }, - { startIndex: 33, type: 'tag.html' }, - { startIndex: 39, type: 'delimiter.html' } - ] - }], - - // Embedded Content #8 - [{ - line: '', - tokens: [ - { startIndex: 0, type: 'delimiter.html' }, - { startIndex: 1, type: 'tag.html' }, - { startIndex: 7, type: 'delimiter.html' }, - { startIndex: 8, type: 'keyword.js' }, - { startIndex: 11, type: '' }, - { startIndex: 12, type: 'identifier.js' }, - { startIndex: 13, type: 'delimiter.js' }, - { startIndex: 14, type: '' }, - { startIndex: 15, type: 'number.js' }, - { startIndex: 17, type: 'delimiter.js' }, - { startIndex: 18, type: 'delimiter.html' }, - { startIndex: 20, type: 'tag.html' }, - { startIndex: 26, type: 'delimiter.html' } - ] - }], - - // Embedded Content #9 - [{ - line: '', - tokens: [ - { startIndex: 0, type: 'delimiter.html' }, - { startIndex: 1, type: 'tag.html' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'attribute.name.html' }, - { startIndex: 12, type: 'delimiter.html' }, - { startIndex: 13, type: 'attribute.value.html' }, - { startIndex: 30, type: '' }, - { startIndex: 31, type: 'attribute.name.html' }, - { startIndex: 34, type: 'delimiter.html' }, - { startIndex: 35, type: 'attribute.value.html' }, - { startIndex: 44, type: 'delimiter.html' }, - // { startIndex:45, type: 'delimiter.html' }, - { startIndex: 47, type: 'tag.html' }, - { startIndex: 53, type: 'delimiter.html' } - ] - }], - - // Tag with Attribute - [{ - line: '', - tokens: [ - { startIndex: 0, type: 'delimiter.html' }, - { startIndex: 1, type: 'tag.html' }, - { startIndex: 4, type: '' }, - { startIndex: 5, type: 'attribute.name.html' }, - { startIndex: 8, type: 'delimiter.html' }, - { startIndex: 9, type: 'attribute.value.html' }, - { startIndex: 14, type: 'delimiter.html' } - ] - }], - - // Tag with Empty Attribute Value - [{ - line: '', - tokens: [ - { startIndex: 0, type: 'delimiter.html' }, - { startIndex: 1, type: 'tag.html' }, - { startIndex: 4, type: '' }, - { startIndex: 5, type: 'attribute.name.html' }, - { startIndex: 8, type: 'delimiter.html' }, - { startIndex: 9, type: 'attribute.value.html' }, - { startIndex: 14, type: 'delimiter.html' } - ] - }], - - // Tag with empty attributes - [{ - line: '', - tokens: [ - { startIndex: 0, type: 'delimiter.html' }, - { startIndex: 1, type: 'tag.html' }, - { startIndex: 4, type: '' }, - { startIndex: 5, type: 'attribute.name.html' }, - { startIndex: 8, type: 'delimiter.html' }, - { startIndex: 9, type: 'attribute.value.html' }, - { startIndex: 11, type: 'delimiter.html' } - ] - }], - - // Tag with Attributes - [{ - line: '', - tokens: [ - { startIndex: 0, type: 'delimiter.html' }, - { startIndex: 1, type: 'tag.html' }, - { startIndex: 4, type: '' }, - { startIndex: 5, type: 'attribute.name.html' }, - { startIndex: 8, type: 'delimiter.html' }, - { startIndex: 9, type: 'attribute.value.html' }, - { startIndex: 14, type: '' }, - { startIndex: 15, type: 'attribute.name.html' }, - { startIndex: 18, type: 'delimiter.html' }, - { startIndex: 19, type: 'attribute.value.html' }, - { startIndex: 24, type: 'delimiter.html' } - ] - }], - - // Tag with Attributes, no quotes - [{ - line: '', - tokens: [ - { startIndex: 0, type: 'delimiter.html' }, - { startIndex: 1, type: 'tag.html' }, - { startIndex: 4, type: '' }, - { startIndex: 5, type: 'attribute.name.html' }, - { startIndex: 8, type: 'delimiter.html' }, - { startIndex: 9, type: 'attribute.name.html' }, // slightly incorrect - { startIndex: 12, type: '' }, - { startIndex: 13, type: 'attribute.name.html' }, - { startIndex: 16, type: 'delimiter.html' }, - { startIndex: 17, type: 'attribute.name.html' }, // slightly incorrect - { startIndex: 24, type: 'delimiter.html' } - ] - }], - - // Tag with Attribute And Whitespace - [{ - line: '', - tokens: [ - { startIndex: 0, type: 'delimiter.html' }, - { startIndex: 1, type: 'tag.html' }, - { startIndex: 4, type: '' }, - { startIndex: 5, type: 'attribute.name.html' }, - { startIndex: 8, type: 'delimiter.html' }, - { startIndex: 9, type: '' }, - { startIndex: 11, type: 'attribute.value.html' }, - { startIndex: 16, type: 'delimiter.html' } - ] - }], - - // Tag with Attribute And Whitespace #2 - [{ - line: '', - tokens: [ - { startIndex: 0, type: 'delimiter.html' }, - { startIndex: 1, type: 'tag.html' }, - { startIndex: 4, type: '' }, - { startIndex: 5, type: 'attribute.name.html' }, - { startIndex: 8, type: '' }, - { startIndex: 9, type: 'delimiter.html' }, - { startIndex: 10, type: '' }, - { startIndex: 11, type: 'attribute.value.html' }, - { startIndex: 16, type: 'delimiter.html' } - ] - }], - - // Tag with Name-Only-Attribute #1 - [{ - line: '', - tokens: [ - { startIndex: 0, type: 'delimiter.html' }, - { startIndex: 1, type: 'tag.html' }, - { startIndex: 4, type: '' }, - { startIndex: 5, type: 'attribute.name.html' }, - { startIndex: 8, type: 'delimiter.html' } - ] - }], - - // Tag with Name-Only-Attribute #2 - [{ - line: '', - tokens: [ - { startIndex: 0, type: 'delimiter.html' }, - { startIndex: 1, type: 'tag.html' }, - { startIndex: 4, type: '' }, - { startIndex: 5, type: 'attribute.name.html' }, - { startIndex: 8, type: '' }, - { startIndex: 9, type: 'attribute.name.html' }, - { startIndex: 12, type: 'delimiter.html' } - ] - }], - - // Tag with Interesting Attribute Name - [{ - line: '', - tokens: [ - { startIndex: 0, type: 'delimiter.html' }, - { startIndex: 1, type: 'tag.html' }, - { startIndex: 4, type: '' }, - { startIndex: 5, type: 'attribute.name.html' }, - { startIndex: 8, type: '' }, - { startIndex: 11, type: 'delimiter.html' }, - { startIndex: 12, type: 'attribute.value.html' }, - { startIndex: 17, type: 'delimiter.html' } - ] - }], - - // Tag with Angular Attribute Name - [{ - line: '', - tokens: [ - { startIndex: 0, type: 'delimiter.html' }, - { startIndex: 1, type: 'tag.html' }, - { startIndex: 4, type: '' }, - { startIndex: 6, type: 'attribute.name.html' }, - { startIndex: 13, type: '' }, - { startIndex: 15, type: 'attribute.name.html' }, - { startIndex: 20, type: '' }, - { startIndex: 21, type: 'delimiter.html' }, - { startIndex: 22, type: 'attribute.value.html' }, - { startIndex: 27, type: '' }, - { startIndex: 29, type: 'attribute.name.html' }, - { startIndex: 34, type: '' }, - { startIndex: 35, type: 'delimiter.html' }, - { startIndex: 36, type: 'attribute.value.html' }, - { startIndex: 50, type: '' }, - { startIndex: 52, type: 'attribute.name.html' }, - { startIndex: 56, type: 'delimiter.html' }, - { startIndex: 57, type: 'attribute.value.html' }, - { startIndex: 72, type: 'delimiter.html' } - ] - }], - - // Tag with Invalid Attribute Value - [{ - line: '', - tokens: [ - { startIndex: 0, type: 'metatag.content.html' }, - { startIndex: 11, type: 'metatag.html' } - ] - }], - - // PR #14 - [{ - line: 'asd', - tokens: [ - { startIndex: 0, type: 'delimiter.html' }, - { startIndex: 1, type: 'tag.html' }, - { startIndex: 9, type: 'delimiter.html' }, - { startIndex: 10, type: '' }, - { startIndex: 13, type: 'delimiter.html' }, - { startIndex: 15, type: 'tag.html' }, - { startIndex: 23, type: 'delimiter.html' } - ] - }] -]); +/*--------------------------------------------------------------------------------------------- + * 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'; + +testTokenization( + ['html', 'css', 'javascript'], + [ + // Open Start Tag #1' + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: '' } + ] + } + ], + + // Open Start Tag #4 + [ + { + line: 'i ', + tokens: [ + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, + { startIndex: 4, type: 'delimiter.html' } + ] + } + ], + + // Complete Start Tag with Whitespace + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, + { startIndex: 4, type: '' }, + { startIndex: 5, type: 'delimiter.html' } + ] + } + ], + + // bug 9809 - Complete Start Tag with Namespaceprefix + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, + { startIndex: 8, type: 'delimiter.html' } + ] + } + ], + + // Complete End Tag + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 2, type: 'tag.html' }, + { startIndex: 5, type: 'delimiter.html' } + ] + } + ], + + // Complete End Tag with Whitespace + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 2, type: 'tag.html' }, + { startIndex: 5, type: '' }, + { startIndex: 7, type: 'delimiter.html' } + ] + } + ], + + // Empty Tag + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, + { startIndex: 4, type: '' }, + { startIndex: 5, type: 'delimiter.html' } + ] + } + ], + + // Embedded Content #1 + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'attribute.name.html' }, + { startIndex: 12, type: 'delimiter.html' }, + { startIndex: 13, type: 'attribute.value.html' }, + { startIndex: 30, type: 'delimiter.html' }, + { startIndex: 31, type: 'keyword.js' }, + { startIndex: 34, type: '' }, + { startIndex: 35, type: 'identifier.js' }, + { startIndex: 36, type: 'delimiter.js' }, + { startIndex: 37, type: '' }, + { startIndex: 38, type: 'number.js' }, + { startIndex: 40, type: 'delimiter.js' }, + { startIndex: 41, type: 'delimiter.html' }, + { startIndex: 43, type: 'tag.html' }, + { startIndex: 49, type: 'delimiter.html' } + ] + } + ], + + // Embedded Content #2 + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 2, type: 'tag.html' }, + { startIndex: 8, type: 'delimiter.html' } + ] + } + ], + + // Embedded Content #3 + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 2, type: 'tag.html' }, + { startIndex: 8, type: 'delimiter.html' } + ] + } + ], + + // Embedded Content #4 + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'keyword.js' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'identifier.js' }, + { startIndex: 5, type: 'delimiter.js' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'number.js' }, + { startIndex: 9, type: 'delimiter.js' }, + { startIndex: 10, type: 'delimiter.html' }, + { startIndex: 12, type: 'tag.html' }, + { startIndex: 18, type: 'delimiter.html' } + ] + } + ], + + // Embedded Content #5 + [ + { + line: '', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'delimiter.html' }, + { startIndex: 4, type: 'tag.html' }, + { startIndex: 10, type: 'delimiter.html' } + ] + } + ], + + // Embedded Content #6 + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, + { startIndex: 7, type: 'delimiter.html' }, + { startIndex: 8, type: 'identifier.js' }, + { startIndex: 9, type: 'delimiter.html' }, + { startIndex: 11, type: 'tag.html' }, + { startIndex: 17, type: 'delimiter.html' }, + // { startIndex:18, type: 'delimiter.html' }, + { startIndex: 19, type: 'tag.html' }, + { startIndex: 25, type: 'delimiter.html' }, + { startIndex: 26, type: 'identifier.js' }, + { startIndex: 27, type: 'delimiter.html' }, + { startIndex: 29, type: 'tag.html' }, + { startIndex: 35, type: 'delimiter.html' } + ] + } + ], + + // Embedded Content #7 + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'attribute.name.html' }, + { startIndex: 12, type: 'delimiter.html' }, + { startIndex: 13, type: 'attribute.value.html' }, + { startIndex: 30, type: 'delimiter.html' }, + // { startIndex:31, type: 'delimiter.html' }, + { startIndex: 33, type: 'tag.html' }, + { startIndex: 39, type: 'delimiter.html' } + ] + } + ], + + // Embedded Content #8 + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, + { startIndex: 7, type: 'delimiter.html' }, + { startIndex: 8, type: 'keyword.js' }, + { startIndex: 11, type: '' }, + { startIndex: 12, type: 'identifier.js' }, + { startIndex: 13, type: 'delimiter.js' }, + { startIndex: 14, type: '' }, + { startIndex: 15, type: 'number.js' }, + { startIndex: 17, type: 'delimiter.js' }, + { startIndex: 18, type: 'delimiter.html' }, + { startIndex: 20, type: 'tag.html' }, + { startIndex: 26, type: 'delimiter.html' } + ] + } + ], + + // Embedded Content #9 + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'attribute.name.html' }, + { startIndex: 12, type: 'delimiter.html' }, + { startIndex: 13, type: 'attribute.value.html' }, + { startIndex: 30, type: '' }, + { startIndex: 31, type: 'attribute.name.html' }, + { startIndex: 34, type: 'delimiter.html' }, + { startIndex: 35, type: 'attribute.value.html' }, + { startIndex: 44, type: 'delimiter.html' }, + // { startIndex:45, type: 'delimiter.html' }, + { startIndex: 47, type: 'tag.html' }, + { startIndex: 53, type: 'delimiter.html' } + ] + } + ], + + // Tag with Attribute + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, + { startIndex: 4, type: '' }, + { startIndex: 5, type: 'attribute.name.html' }, + { startIndex: 8, type: 'delimiter.html' }, + { startIndex: 9, type: 'attribute.value.html' }, + { startIndex: 14, type: 'delimiter.html' } + ] + } + ], + + // Tag with Empty Attribute Value + [ + { + line: "", + tokens: [ + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, + { startIndex: 4, type: '' }, + { startIndex: 5, type: 'attribute.name.html' }, + { startIndex: 8, type: 'delimiter.html' }, + { startIndex: 9, type: 'attribute.value.html' }, + { startIndex: 14, type: 'delimiter.html' } + ] + } + ], + + // Tag with empty attributes + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, + { startIndex: 4, type: '' }, + { startIndex: 5, type: 'attribute.name.html' }, + { startIndex: 8, type: 'delimiter.html' }, + { startIndex: 9, type: 'attribute.value.html' }, + { startIndex: 11, type: 'delimiter.html' } + ] + } + ], + + // Tag with Attributes + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, + { startIndex: 4, type: '' }, + { startIndex: 5, type: 'attribute.name.html' }, + { startIndex: 8, type: 'delimiter.html' }, + { startIndex: 9, type: 'attribute.value.html' }, + { startIndex: 14, type: '' }, + { startIndex: 15, type: 'attribute.name.html' }, + { startIndex: 18, type: 'delimiter.html' }, + { startIndex: 19, type: 'attribute.value.html' }, + { startIndex: 24, type: 'delimiter.html' } + ] + } + ], + + // Tag with Attributes, no quotes + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, + { startIndex: 4, type: '' }, + { startIndex: 5, type: 'attribute.name.html' }, + { startIndex: 8, type: 'delimiter.html' }, + { startIndex: 9, type: 'attribute.name.html' }, // slightly incorrect + { startIndex: 12, type: '' }, + { startIndex: 13, type: 'attribute.name.html' }, + { startIndex: 16, type: 'delimiter.html' }, + { startIndex: 17, type: 'attribute.name.html' }, // slightly incorrect + { startIndex: 24, type: 'delimiter.html' } + ] + } + ], + + // Tag with Attribute And Whitespace + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, + { startIndex: 4, type: '' }, + { startIndex: 5, type: 'attribute.name.html' }, + { startIndex: 8, type: 'delimiter.html' }, + { startIndex: 9, type: '' }, + { startIndex: 11, type: 'attribute.value.html' }, + { startIndex: 16, type: 'delimiter.html' } + ] + } + ], + + // Tag with Attribute And Whitespace #2 + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, + { startIndex: 4, type: '' }, + { startIndex: 5, type: 'attribute.name.html' }, + { startIndex: 8, type: '' }, + { startIndex: 9, type: 'delimiter.html' }, + { startIndex: 10, type: '' }, + { startIndex: 11, type: 'attribute.value.html' }, + { startIndex: 16, type: 'delimiter.html' } + ] + } + ], + + // Tag with Name-Only-Attribute #1 + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, + { startIndex: 4, type: '' }, + { startIndex: 5, type: 'attribute.name.html' }, + { startIndex: 8, type: 'delimiter.html' } + ] + } + ], + + // Tag with Name-Only-Attribute #2 + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, + { startIndex: 4, type: '' }, + { startIndex: 5, type: 'attribute.name.html' }, + { startIndex: 8, type: '' }, + { startIndex: 9, type: 'attribute.name.html' }, + { startIndex: 12, type: 'delimiter.html' } + ] + } + ], + + // Tag with Interesting Attribute Name + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, + { startIndex: 4, type: '' }, + { startIndex: 5, type: 'attribute.name.html' }, + { startIndex: 8, type: '' }, + { startIndex: 11, type: 'delimiter.html' }, + { startIndex: 12, type: 'attribute.value.html' }, + { startIndex: 17, type: 'delimiter.html' } + ] + } + ], + + // Tag with Angular Attribute Name + [ + { + line: + '', + tokens: [ + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, + { startIndex: 4, type: '' }, + { startIndex: 6, type: 'attribute.name.html' }, + { startIndex: 13, type: '' }, + { startIndex: 15, type: 'attribute.name.html' }, + { startIndex: 20, type: '' }, + { startIndex: 21, type: 'delimiter.html' }, + { startIndex: 22, type: 'attribute.value.html' }, + { startIndex: 27, type: '' }, + { startIndex: 29, type: 'attribute.name.html' }, + { startIndex: 34, type: '' }, + { startIndex: 35, type: 'delimiter.html' }, + { startIndex: 36, type: 'attribute.value.html' }, + { startIndex: 50, type: '' }, + { startIndex: 52, type: 'attribute.name.html' }, + { startIndex: 56, type: 'delimiter.html' }, + { startIndex: 57, type: 'attribute.value.html' }, + { startIndex: 72, type: 'delimiter.html' } + ] + } + ], + + // Tag with Invalid Attribute Value + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.content.html' }, + { startIndex: 11, type: 'metatag.html' } + ] + } + ], + + // PR #14 + [ + { + line: 'asd', + tokens: [ + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, + { startIndex: 9, type: 'delimiter.html' }, + { startIndex: 10, type: '' }, + { startIndex: 13, type: 'delimiter.html' }, + { startIndex: 15, type: 'tag.html' }, + { startIndex: 23, type: 'delimiter.html' } + ] + } + ] + ] +); diff --git a/src/html/html.ts b/src/html/html.ts index e8a45486..4c0999e8 100644 --- a/src/html/html.ts +++ b/src/html/html.ts @@ -1,243 +1,373 @@ -/*--------------------------------------------------------------------------------------------- - * 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 IRichLanguageConfiguration = monaco.languages.LanguageConfiguration; -import ILanguage = monaco.languages.IMonarchLanguage; - -// Allow for running under nodejs/requirejs in tests -const _monaco: typeof monaco = (typeof monaco === 'undefined' ? (self).monaco : monaco); - -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, - - comments: { - blockComment: [''] - }, - - brackets: [ - [''], - ['<', '>'], - ['{', '}'], - ['(', ')'] - ], - - autoClosingPairs: [ - { open: '{', close: '}' }, - { open: '[', close: ']' }, - { open: '(', close: ')' }, - { open: '"', close: '"' }, - { open: '\'', close: '\'' } - ], - - surroundingPairs: [ - { open: '"', close: '"' }, - { open: '\'', close: '\'' }, - { open: '{', close: '}' }, - { open: '[', close: ']' }, - { open: '(', close: ')' }, - { open: '<', close: '>' }, - ], - - onEnterRules: [ - { - beforeText: new RegExp(`<(?!(?:${EMPTY_ELEMENTS.join('|')}))([_:\\w][_:\\w-.\\d]*)([^/>]*(?!/)>)[^<]*$`, 'i'), - afterText: /^<\/([_:\w][_:\w-.\d]*)\s*>$/i, - action: { indentAction: _monaco.languages.IndentAction.IndentOutdent } - }, - { - beforeText: new RegExp(`<(?!(?:${EMPTY_ELEMENTS.join('|')}))(\\w[\\w\\d]*)([^/>]*(?!/)>)[^<]*$`, 'i'), - action: { indentAction: _monaco.languages.IndentAction.Indent } - } - ], - - folding: { - markers: { - start: new RegExp("^\\s*"), - end: new RegExp("^\\s*") - } - } -}; - -export const language = { - defaultToken: '', - tokenPostfix: '.html', - ignoreCase: true, - - // The main tokenizer for our languages - tokenizer: { - root: [ - [/)/, ['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' }]], - [/]+/, 'metatag.content'], - [/>/, 'metatag', '@pop'], - ], - - comment: [ - [/-->/, 'comment', '@pop'], - [/[^-]+/, 'comment.content'], - [/./, 'comment.content'] - ], - - otherTag: [ - [/\/?>/, 'delimiter', '@pop'], - [/"([^"]*)"/, 'attribute.value'], - [/'([^']*)'/, 'attribute.value'], - [/[\w\-]+/, 'attribute.name'], - [/=/, 'delimiter'], - [/[ \t\r\n]+/], // whitespace - ], - - // -- BEGIN -// -// -// -// +/*--------------------------------------------------------------------------------------------- + * 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 IRichLanguageConfiguration = monaco.languages.LanguageConfiguration; +import ILanguage = monaco.languages.IMonarchLanguage; + +// Allow for running under nodejs/requirejs in tests +const _monaco: typeof monaco = + typeof monaco === 'undefined' ? (self).monaco : monaco; + +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, + + comments: { + blockComment: [''] + }, + + brackets: [ + [''], + ['<', '>'], + ['{', '}'], + ['(', ')'] + ], + + autoClosingPairs: [ + { open: '{', close: '}' }, + { open: '[', close: ']' }, + { open: '(', close: ')' }, + { open: '"', close: '"' }, + { open: "'", close: "'" } + ], + + surroundingPairs: [ + { open: '"', close: '"' }, + { open: "'", close: "'" }, + { open: '{', close: '}' }, + { open: '[', close: ']' }, + { open: '(', close: ')' }, + { open: '<', close: '>' } + ], + + onEnterRules: [ + { + beforeText: new RegExp( + `<(?!(?:${EMPTY_ELEMENTS.join( + '|' + )}))([_:\\w][_:\\w-.\\d]*)([^/>]*(?!/)>)[^<]*$`, + 'i' + ), + afterText: /^<\/([_:\w][_:\w-.\d]*)\s*>$/i, + action: { + indentAction: _monaco.languages.IndentAction.IndentOutdent + } + }, + { + beforeText: new RegExp( + `<(?!(?:${EMPTY_ELEMENTS.join( + '|' + )}))(\\w[\\w\\d]*)([^/>]*(?!/)>)[^<]*$`, + 'i' + ), + action: { indentAction: _monaco.languages.IndentAction.Indent } + } + ], + + folding: { + markers: { + start: new RegExp('^\\s*'), + end: new RegExp('^\\s*') + } + } +}; + +export const language = { + defaultToken: '', + tokenPostfix: '.html', + ignoreCase: true, + + // The main tokenizer for our languages + tokenizer: { + root: [ + [/)/, + ['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' }] + ], + [/]+/, 'metatag.content'], + [/>/, 'metatag', '@pop'] + ], + + comment: [ + [/-->/, 'comment', '@pop'], + [/[^-]+/, 'comment.content'], + [/./, 'comment.content'] + ], + + otherTag: [ + [/\/?>/, 'delimiter', '@pop'], + [/"([^"]*)"/, 'attribute.value'], + [/'([^']*)'/, 'attribute.value'], + [/[\w\-]+/, 'attribute.name'], + [/=/, 'delimiter'], + [/[ \t\r\n]+/] // whitespace + ], + + // -- BEGIN +// +// +// +// diff --git a/src/ini/ini.ts b/src/ini/ini.ts index 3f44acc7..39bdbd3a 100644 --- a/src/ini/ini.ts +++ b/src/ini/ini.ts @@ -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 = { // The main tokenizer for our languages tokenizer: { root: [ - // sections [/^\[[^\]]*\]/, 'metatag'], @@ -57,27 +56,30 @@ export const language = { [/\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' + } } - }] - ], - }, + ] + ] + } }; diff --git a/src/java/java.test.ts b/src/java/java.test.ts index f9271e49..7a1eb207 100644 --- a/src/java/java.test.ts +++ b/src/java/java.test.ts @@ -9,673 +9,727 @@ import { testTokenization } from '../test/testRunner'; testTokenization('java', [ // Comments - single line - [{ - line: '//', - tokens: [ - { startIndex: 0, type: 'comment.java' } - ] - }], + [ + { + line: '//', + tokens: [{ startIndex: 0, type: 'comment.java' }] + } + ], - [{ - line: ' // a comment', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 4, type: 'comment.java' } - ] - }], + [ + { + line: ' // a comment', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 4, type: 'comment.java' } + ] + } + ], // Broken nested tokens due to invalid comment tokenization - [{ - line: '/* //*/ a', - tokens: [ - { startIndex: 0, type: 'comment.java' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'identifier.java' } - ] - }], + [ + { + line: '/* //*/ a', + tokens: [ + { startIndex: 0, type: 'comment.java' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'identifier.java' } + ] + } + ], - [{ - line: '// a comment', - tokens: [ - { startIndex: 0, type: 'comment.java' } - ] - }], + [ + { + line: '// a comment', + tokens: [{ startIndex: 0, type: 'comment.java' }] + } + ], - [{ - line: '//sticky comment', - tokens: [ - { startIndex: 0, type: 'comment.java' } - ] - }], + [ + { + line: '//sticky comment', + tokens: [{ startIndex: 0, type: 'comment.java' }] + } + ], - [{ - line: '/almost a comment', - tokens: [ - { startIndex: 0, type: 'delimiter.java' }, - { startIndex: 1, type: 'identifier.java' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'identifier.java' }, - { startIndex: 9, type: '' }, - { startIndex: 10, type: 'identifier.java' } - ] - }], + [ + { + line: '/almost a comment', + tokens: [ + { startIndex: 0, type: 'delimiter.java' }, + { startIndex: 1, type: 'identifier.java' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'identifier.java' }, + { startIndex: 9, type: '' }, + { startIndex: 10, type: 'identifier.java' } + ] + } + ], - [{ - line: '1 / 2; /* comment', - tokens: [ - { startIndex: 0, type: 'number.java' }, - { startIndex: 1, type: '' }, - { startIndex: 2, type: 'delimiter.java' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'number.java' }, - { startIndex: 5, type: 'delimiter.java' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'comment.java' } - ] - }], + [ + { + line: '1 / 2; /* comment', + tokens: [ + { startIndex: 0, type: 'number.java' }, + { startIndex: 1, type: '' }, + { startIndex: 2, type: 'delimiter.java' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'number.java' }, + { startIndex: 5, type: 'delimiter.java' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'comment.java' } + ] + } + ], - [{ - line: 'int x = 1; // my comment // is a nice one', - tokens: [ - { startIndex: 0, type: 'keyword.int.java' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'identifier.java' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'delimiter.java' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'number.java' }, - { startIndex: 9, type: 'delimiter.java' }, - { startIndex: 10, type: '' }, - { startIndex: 11, type: 'comment.java' } - ] - }], + [ + { + line: 'int x = 1; // my comment // is a nice one', + tokens: [ + { startIndex: 0, type: 'keyword.int.java' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'identifier.java' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'delimiter.java' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'number.java' }, + { startIndex: 9, type: 'delimiter.java' }, + { startIndex: 10, type: '' }, + { startIndex: 11, type: 'comment.java' } + ] + } + ], // Comments - range comment, single line - [{ - line: '/* a simple comment */', - tokens: [ - { startIndex: 0, type: 'comment.java' } - ] - }], + [ + { + line: '/* a simple comment */', + tokens: [{ startIndex: 0, type: 'comment.java' }] + } + ], - [{ - line: 'int x = /* a simple comment */ 1;', - tokens: [ - { startIndex: 0, type: 'keyword.int.java' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'identifier.java' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'delimiter.java' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'comment.java' }, - { startIndex: 30, type: '' }, - { startIndex: 31, type: 'number.java' }, - { startIndex: 32, type: 'delimiter.java' } - ] - }], + [ + { + line: 'int x = /* a simple comment */ 1;', + tokens: [ + { startIndex: 0, type: 'keyword.int.java' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'identifier.java' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'delimiter.java' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'comment.java' }, + { startIndex: 30, type: '' }, + { startIndex: 31, type: 'number.java' }, + { startIndex: 32, type: 'delimiter.java' } + ] + } + ], - [{ - line: 'int x = /* comment */ 1; */', - tokens: [ - { startIndex: 0, type: 'keyword.int.java' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'identifier.java' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'delimiter.java' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'comment.java' }, - { startIndex: 21, type: '' }, - { startIndex: 22, type: 'number.java' }, - { startIndex: 23, type: 'delimiter.java' }, - { startIndex: 24, type: '' } - ] - }], + [ + { + line: 'int x = /* comment */ 1; */', + tokens: [ + { startIndex: 0, type: 'keyword.int.java' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'identifier.java' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'delimiter.java' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'comment.java' }, + { startIndex: 21, type: '' }, + { startIndex: 22, type: 'number.java' }, + { startIndex: 23, type: 'delimiter.java' }, + { startIndex: 24, type: '' } + ] + } + ], - [{ - line: 'x = /**/;', - tokens: [ - { startIndex: 0, type: 'identifier.java' }, - { startIndex: 1, type: '' }, - { startIndex: 2, type: 'delimiter.java' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'comment.java' }, - { startIndex: 8, type: 'delimiter.java' } - ] - }], + [ + { + line: 'x = /**/;', + tokens: [ + { startIndex: 0, type: 'identifier.java' }, + { startIndex: 1, type: '' }, + { startIndex: 2, type: 'delimiter.java' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'comment.java' }, + { startIndex: 8, type: 'delimiter.java' } + ] + } + ], - [{ - line: 'x = /*/;', - tokens: [ - { startIndex: 0, type: 'identifier.java' }, - { startIndex: 1, type: '' }, - { startIndex: 2, type: 'delimiter.java' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'comment.java' } - ] - }], + [ + { + line: 'x = /*/;', + tokens: [ + { startIndex: 0, type: 'identifier.java' }, + { startIndex: 1, type: '' }, + { startIndex: 2, type: 'delimiter.java' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'comment.java' } + ] + } + ], // Comments - range comment, multiple lines - [{ - line: '/* start of multiline comment', - tokens: [ - { startIndex: 0, type: 'comment.java' } - ] - }, { - line: 'a comment between without a star', - tokens: [ - { startIndex: 0, type: 'comment.java' } - ] - }, { - line: 'end of multiline comment*/', - tokens: [ - { startIndex: 0, type: 'comment.java' } - ] - }], + [ + { + line: '/* start of multiline comment', + tokens: [{ startIndex: 0, type: 'comment.java' }] + }, + { + line: 'a comment between without a star', + tokens: [{ startIndex: 0, type: 'comment.java' }] + }, + { + line: 'end of multiline comment*/', + tokens: [{ startIndex: 0, type: 'comment.java' }] + } + ], - [{ - line: 'int x = /* start a comment', - tokens: [ - { startIndex: 0, type: 'keyword.int.java' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'identifier.java' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'delimiter.java' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'comment.java' } - ] - }, { - line: ' a ', - tokens: [ - { startIndex: 0, type: 'comment.java' } - ] - }, { - line: 'and end it */ 2;', - tokens: [ - { startIndex: 0, type: 'comment.java' }, - { startIndex: 13, type: '' }, - { startIndex: 14, type: 'number.java' }, - { startIndex: 15, type: 'delimiter.java' } - ] - }], + [ + { + line: 'int x = /* start a comment', + tokens: [ + { startIndex: 0, type: 'keyword.int.java' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'identifier.java' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'delimiter.java' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'comment.java' } + ] + }, + { + line: ' a ', + tokens: [{ startIndex: 0, type: 'comment.java' }] + }, + { + line: 'and end it */ 2;', + tokens: [ + { startIndex: 0, type: 'comment.java' }, + { startIndex: 13, type: '' }, + { startIndex: 14, type: 'number.java' }, + { startIndex: 15, type: 'delimiter.java' } + ] + } + ], // Java Doc, multiple lines - [{ - line: '/** start of Java Doc', - tokens: [ - { startIndex: 0, type: 'comment.doc.java' } - ] - }, { - line: 'a comment between without a star', - tokens: [ - { startIndex: 0, type: 'comment.doc.java' } - ] - }, { - line: 'end of multiline comment*/', - tokens: [ - { startIndex: 0, type: 'comment.doc.java' } - ] - }], + [ + { + line: '/** start of Java Doc', + tokens: [{ startIndex: 0, type: 'comment.doc.java' }] + }, + { + line: 'a comment between without a star', + tokens: [{ startIndex: 0, type: 'comment.doc.java' }] + }, + { + line: 'end of multiline comment*/', + tokens: [{ startIndex: 0, type: 'comment.doc.java' }] + } + ], // Keywords - [{ - line: 'package test; class Program { static void main(String[] args) {} } }', - tokens: [ - { startIndex: 0, type: 'keyword.package.java' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'identifier.java' }, - { startIndex: 12, type: 'delimiter.java' }, - { startIndex: 13, type: '' }, - { startIndex: 14, type: 'keyword.class.java' }, - { startIndex: 19, type: '' }, - { startIndex: 20, type: 'identifier.java' }, - { startIndex: 27, type: '' }, - { startIndex: 28, type: 'delimiter.curly.java' }, - { startIndex: 29, type: '' }, - { startIndex: 30, type: 'keyword.static.java' }, - { startIndex: 36, type: '' }, - { startIndex: 37, type: 'keyword.void.java' }, - { startIndex: 41, type: '' }, - { startIndex: 42, type: 'identifier.java' }, - { startIndex: 46, type: 'delimiter.parenthesis.java' }, - { startIndex: 47, type: 'identifier.java' }, - { startIndex: 53, type: 'delimiter.square.java' }, - { startIndex: 55, type: '' }, - { startIndex: 56, type: 'identifier.java' }, - { startIndex: 60, type: 'delimiter.parenthesis.java' }, - { startIndex: 61, type: '' }, - { startIndex: 62, type: 'delimiter.curly.java' }, - { startIndex: 64, type: '' }, - { startIndex: 65, type: 'delimiter.curly.java' }, - { startIndex: 66, type: '' }, - { startIndex: 67, type: 'delimiter.curly.java' } - ] - }], + [ + { + line: + 'package test; class Program { static void main(String[] args) {} } }', + tokens: [ + { startIndex: 0, type: 'keyword.package.java' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'identifier.java' }, + { startIndex: 12, type: 'delimiter.java' }, + { startIndex: 13, type: '' }, + { startIndex: 14, type: 'keyword.class.java' }, + { startIndex: 19, type: '' }, + { startIndex: 20, type: 'identifier.java' }, + { startIndex: 27, type: '' }, + { startIndex: 28, type: 'delimiter.curly.java' }, + { startIndex: 29, type: '' }, + { startIndex: 30, type: 'keyword.static.java' }, + { startIndex: 36, type: '' }, + { startIndex: 37, type: 'keyword.void.java' }, + { startIndex: 41, type: '' }, + { startIndex: 42, type: 'identifier.java' }, + { startIndex: 46, type: 'delimiter.parenthesis.java' }, + { startIndex: 47, type: 'identifier.java' }, + { startIndex: 53, type: 'delimiter.square.java' }, + { startIndex: 55, type: '' }, + { startIndex: 56, type: 'identifier.java' }, + { startIndex: 60, type: 'delimiter.parenthesis.java' }, + { startIndex: 61, type: '' }, + { startIndex: 62, type: 'delimiter.curly.java' }, + { startIndex: 64, type: '' }, + { startIndex: 65, type: 'delimiter.curly.java' }, + { startIndex: 66, type: '' }, + { startIndex: 67, type: 'delimiter.curly.java' } + ] + } + ], // Numbers - [{ - line: '0', - tokens: [ - { startIndex: 0, type: 'number.java' } - ] - }], + [ + { + line: '0', + tokens: [{ startIndex: 0, type: 'number.java' }] + } + ], - [{ - line: '0.10', - tokens: [ - { startIndex: 0, type: 'number.float.java' } - ] - }], + [ + { + line: '0.10', + tokens: [{ startIndex: 0, type: 'number.float.java' }] + } + ], - [{ - line: '0x', - tokens: [ - { startIndex: 0, type: 'number.java' }, - { startIndex: 1, type: 'identifier.java' } - ] - }], + [ + { + line: '0x', + tokens: [ + { startIndex: 0, type: 'number.java' }, + { startIndex: 1, type: 'identifier.java' } + ] + } + ], - [{ - line: '0x123', - tokens: [ - { startIndex: 0, type: 'number.hex.java' } - ] - }], + [ + { + line: '0x123', + tokens: [{ startIndex: 0, type: 'number.hex.java' }] + } + ], - [{ - line: '0x5_2', - tokens: [ - { startIndex: 0, type: 'number.hex.java' } - ] - }], + [ + { + line: '0x5_2', + tokens: [{ startIndex: 0, type: 'number.hex.java' }] + } + ], - [{ - line: '023L', - tokens: [ - { startIndex: 0, type: 'number.octal.java' } - ] - }], + [ + { + line: '023L', + tokens: [{ startIndex: 0, type: 'number.octal.java' }] + } + ], - [{ - line: '0123l', - tokens: [ - { startIndex: 0, type: 'number.octal.java' } - ] - }], + [ + { + line: '0123l', + tokens: [{ startIndex: 0, type: 'number.octal.java' }] + } + ], - [{ - line: '05_2', - tokens: [ - { startIndex: 0, type: 'number.octal.java' } - ] - }], + [ + { + line: '05_2', + tokens: [{ startIndex: 0, type: 'number.octal.java' }] + } + ], - [{ - line: '0b1010_0101', - tokens: [ - { startIndex: 0, type: 'number.binary.java' } - ] - }], + [ + { + line: '0b1010_0101', + tokens: [{ startIndex: 0, type: 'number.binary.java' }] + } + ], - [{ - line: '0B001', - tokens: [ - { startIndex: 0, type: 'number.binary.java' } - ] - }], + [ + { + line: '0B001', + tokens: [{ startIndex: 0, type: 'number.binary.java' }] + } + ], - [{ - line: '10e3', - tokens: [ - { startIndex: 0, type: 'number.float.java' } - ] - }], + [ + { + line: '10e3', + tokens: [{ startIndex: 0, type: 'number.float.java' }] + } + ], - [{ - line: '10f', - tokens: [ - { startIndex: 0, type: 'number.float.java' } - ] - }], + [ + { + line: '10f', + tokens: [{ startIndex: 0, type: 'number.float.java' }] + } + ], - [{ - line: '23.5', - tokens: [ - { startIndex: 0, type: 'number.float.java' } - ] - }], + [ + { + line: '23.5', + tokens: [{ startIndex: 0, type: 'number.float.java' }] + } + ], - [{ - line: '23.5e3', - tokens: [ - { startIndex: 0, type: 'number.float.java' } - ] - }], + [ + { + line: '23.5e3', + tokens: [{ startIndex: 0, type: 'number.float.java' }] + } + ], - [{ - line: '23.5e-3', - tokens: [ - { startIndex: 0, type: 'number.float.java' } - ] - }], + [ + { + line: '23.5e-3', + tokens: [{ startIndex: 0, type: 'number.float.java' }] + } + ], - [{ - line: '23.5E3', - tokens: [ - { startIndex: 0, type: 'number.float.java' } - ] - }], + [ + { + line: '23.5E3', + tokens: [{ startIndex: 0, type: 'number.float.java' }] + } + ], - [{ - line: '23.5E-3', - tokens: [ - { startIndex: 0, type: 'number.float.java' } - ] - }], + [ + { + line: '23.5E-3', + tokens: [{ startIndex: 0, type: 'number.float.java' }] + } + ], - [{ - line: '23.5F', - tokens: [ - { startIndex: 0, type: 'number.float.java' } - ] - }], + [ + { + line: '23.5F', + tokens: [{ startIndex: 0, type: 'number.float.java' }] + } + ], - [{ - line: '23.5f', - tokens: [ - { startIndex: 0, type: 'number.float.java' } - ] - }], + [ + { + line: '23.5f', + tokens: [{ startIndex: 0, type: 'number.float.java' }] + } + ], - [{ - line: '23.5D', - tokens: [ - { startIndex: 0, type: 'number.float.java' } - ] - }], + [ + { + line: '23.5D', + tokens: [{ startIndex: 0, type: 'number.float.java' }] + } + ], - [{ - line: '23.5d', - tokens: [ - { startIndex: 0, type: 'number.float.java' } - ] - }], + [ + { + line: '23.5d', + tokens: [{ startIndex: 0, type: 'number.float.java' }] + } + ], - [{ - line: '1.72E3D', - tokens: [ - { startIndex: 0, type: 'number.float.java' } - ] - }], + [ + { + line: '1.72E3D', + tokens: [{ startIndex: 0, type: 'number.float.java' }] + } + ], - [{ - line: '1.72E3d', - tokens: [ - { startIndex: 0, type: 'number.float.java' } - ] - }], + [ + { + line: '1.72E3d', + tokens: [{ startIndex: 0, type: 'number.float.java' }] + } + ], - [{ - line: '1.72E-3d', - tokens: [ - { startIndex: 0, type: 'number.float.java' } - ] - }], + [ + { + line: '1.72E-3d', + tokens: [{ startIndex: 0, type: 'number.float.java' }] + } + ], - [{ - line: '1.72e3D', - tokens: [ - { startIndex: 0, type: 'number.float.java' } - ] - }], + [ + { + line: '1.72e3D', + tokens: [{ startIndex: 0, type: 'number.float.java' }] + } + ], - [{ - line: '1.72e3d', - tokens: [ - { startIndex: 0, type: 'number.float.java' } - ] - }], + [ + { + line: '1.72e3d', + tokens: [{ startIndex: 0, type: 'number.float.java' }] + } + ], - [{ - line: '1.72e-3d', - tokens: [ - { startIndex: 0, type: 'number.float.java' } - ] - }], + [ + { + line: '1.72e-3d', + tokens: [{ startIndex: 0, type: 'number.float.java' }] + } + ], - [{ - line: '23L', - tokens: [ - { startIndex: 0, type: 'number.java' } - ] - }], + [ + { + line: '23L', + tokens: [{ startIndex: 0, type: 'number.java' }] + } + ], - [{ - line: '23l', - tokens: [ - { startIndex: 0, type: 'number.java' } - ] - }], + [ + { + line: '23l', + tokens: [{ startIndex: 0, type: 'number.java' }] + } + ], - [{ - line: '0_52', - tokens: [ - { startIndex: 0, type: 'number.java' } - ] - }], + [ + { + line: '0_52', + tokens: [{ startIndex: 0, type: 'number.java' }] + } + ], - [{ - line: '5_2', - tokens: [ - { startIndex: 0, type: 'number.java' } - ] - }], + [ + { + line: '5_2', + tokens: [{ startIndex: 0, type: 'number.java' }] + } + ], - [{ - line: '5_______2', - tokens: [ - { startIndex: 0, type: 'number.java' } - ] - }], + [ + { + line: '5_______2', + tokens: [{ startIndex: 0, type: 'number.java' }] + } + ], - [{ - line: '3_.1415F', - tokens: [ - { startIndex: 0, type: 'number.java' }, - { startIndex: 1, type: 'identifier.java' }, - { startIndex: 2, type: 'delimiter.java' }, - { startIndex: 3, type: 'number.float.java' } - ] - }], + [ + { + line: '3_.1415F', + tokens: [ + { startIndex: 0, type: 'number.java' }, + { startIndex: 1, type: 'identifier.java' }, + { startIndex: 2, type: 'delimiter.java' }, + { startIndex: 3, type: 'number.float.java' } + ] + } + ], - [{ - line: '3._1415F', - tokens: [ - { startIndex: 0, type: 'number.java' }, - { startIndex: 1, type: 'delimiter.java' }, - { startIndex: 2, type: 'identifier.java' } - ] - }], + [ + { + line: '3._1415F', + tokens: [ + { startIndex: 0, type: 'number.java' }, + { startIndex: 1, type: 'delimiter.java' }, + { startIndex: 2, type: 'identifier.java' } + ] + } + ], - [{ - line: '999_99_9999_L', - tokens: [ - { startIndex: 0, type: 'number.java' }, - { startIndex: 11, type: 'identifier.java' } - ] - }], + [ + { + line: '999_99_9999_L', + tokens: [ + { startIndex: 0, type: 'number.java' }, + { startIndex: 11, type: 'identifier.java' } + ] + } + ], - [{ - line: '52_', - tokens: [ - { startIndex: 0, type: 'number.java' }, - { startIndex: 2, type: 'identifier.java' } - ] - }], + [ + { + line: '52_', + tokens: [ + { startIndex: 0, type: 'number.java' }, + { startIndex: 2, type: 'identifier.java' } + ] + } + ], - [{ - line: '0_x52', - tokens: [ - { startIndex: 0, type: 'number.java' }, - { startIndex: 1, type: 'identifier.java' } - ] - }], + [ + { + line: '0_x52', + tokens: [ + { startIndex: 0, type: 'number.java' }, + { startIndex: 1, type: 'identifier.java' } + ] + } + ], - [{ - line: '0x_52', - tokens: [ - { startIndex: 0, type: 'number.java' }, - { startIndex: 1, type: 'identifier.java' } - ] - }], + [ + { + line: '0x_52', + tokens: [ + { startIndex: 0, type: 'number.java' }, + { startIndex: 1, type: 'identifier.java' } + ] + } + ], - [{ - line: '0x52_', - tokens: [ - { startIndex: 0, type: 'number.hex.java' }, - { startIndex: 4, type: 'identifier.java' } - ] - }], + [ + { + line: '0x52_', + tokens: [ + { startIndex: 0, type: 'number.hex.java' }, + { startIndex: 4, type: 'identifier.java' } + ] + } + ], - [{ - line: '052_', - tokens: [ - { startIndex: 0, type: 'number.octal.java' }, - { startIndex: 3, type: 'identifier.java' } - ] - }], + [ + { + line: '052_', + tokens: [ + { startIndex: 0, type: 'number.octal.java' }, + { startIndex: 3, type: 'identifier.java' } + ] + } + ], - [{ - line: '23.5L', - tokens: [ - { startIndex: 0, type: 'number.float.java' }, - { startIndex: 4, type: 'identifier.java' } - ] - }], + [ + { + line: '23.5L', + tokens: [ + { startIndex: 0, type: 'number.float.java' }, + { startIndex: 4, type: 'identifier.java' } + ] + } + ], - [{ - line: '0+0', - tokens: [ - { startIndex: 0, type: 'number.java' }, - { startIndex: 1, type: 'delimiter.java' }, - { startIndex: 2, type: 'number.java' } - ] - }], + [ + { + line: '0+0', + tokens: [ + { startIndex: 0, type: 'number.java' }, + { startIndex: 1, type: 'delimiter.java' }, + { startIndex: 2, type: 'number.java' } + ] + } + ], - [{ - line: '100+10', - tokens: [ - { startIndex: 0, type: 'number.java' }, - { startIndex: 3, type: 'delimiter.java' }, - { startIndex: 4, type: 'number.java' } - ] - }], + [ + { + line: '100+10', + tokens: [ + { startIndex: 0, type: 'number.java' }, + { startIndex: 3, type: 'delimiter.java' }, + { startIndex: 4, type: 'number.java' } + ] + } + ], - [{ - line: '0 + 0', - tokens: [ - { startIndex: 0, type: 'number.java' }, - { startIndex: 1, type: '' }, - { startIndex: 2, type: 'delimiter.java' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'number.java' } - ] - }], + [ + { + line: '0 + 0', + tokens: [ + { startIndex: 0, type: 'number.java' }, + { startIndex: 1, type: '' }, + { startIndex: 2, type: 'delimiter.java' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'number.java' } + ] + } + ], // single line Strings - [{ - line: 'String s = "I\'m a Java String";', - tokens: [ - { startIndex: 0, type: 'identifier.java' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'identifier.java' }, - { startIndex: 8, type: '' }, - { startIndex: 9, type: 'delimiter.java' }, - { startIndex: 10, type: '' }, - { startIndex: 11, type: 'string.java' }, - { startIndex: 30, type: 'delimiter.java' } - ] - }], + [ + { + line: 'String s = "I\'m a Java String";', + tokens: [ + { startIndex: 0, type: 'identifier.java' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'identifier.java' }, + { startIndex: 8, type: '' }, + { startIndex: 9, type: 'delimiter.java' }, + { startIndex: 10, type: '' }, + { startIndex: 11, type: 'string.java' }, + { startIndex: 30, type: 'delimiter.java' } + ] + } + ], - [{ - line: 'String s = "concatenated" + " String" ;', - tokens: [ - { startIndex: 0, type: 'identifier.java' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'identifier.java' }, - { startIndex: 8, type: '' }, - { startIndex: 9, type: 'delimiter.java' }, - { startIndex: 10, type: '' }, - { startIndex: 11, type: 'string.java' }, - { startIndex: 25, type: '' }, - { startIndex: 26, type: 'delimiter.java' }, - { startIndex: 27, type: '' }, - { startIndex: 28, type: 'string.java' }, - { startIndex: 37, type: '' }, - { startIndex: 38, type: 'delimiter.java' } - ] - }], + [ + { + line: 'String s = "concatenated" + " String" ;', + tokens: [ + { startIndex: 0, type: 'identifier.java' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'identifier.java' }, + { startIndex: 8, type: '' }, + { startIndex: 9, type: 'delimiter.java' }, + { startIndex: 10, type: '' }, + { startIndex: 11, type: 'string.java' }, + { startIndex: 25, type: '' }, + { startIndex: 26, type: 'delimiter.java' }, + { startIndex: 27, type: '' }, + { startIndex: 28, type: 'string.java' }, + { startIndex: 37, type: '' }, + { startIndex: 38, type: 'delimiter.java' } + ] + } + ], - [{ - line: '"quote in a string"', - tokens: [ - { startIndex: 0, type: 'string.java' } - ] - }], + [ + { + line: '"quote in a string"', + tokens: [{ startIndex: 0, type: 'string.java' }] + } + ], - [{ - line: '"escaping \\"quotes\\" is cool"', - tokens: [ - { startIndex: 0, type: 'string.java' }, - { startIndex: 10, type: 'string.escape.java' }, - { startIndex: 12, type: 'string.java' }, - { startIndex: 18, type: 'string.escape.java' }, - { startIndex: 20, type: 'string.java' } - ] - }], + [ + { + line: '"escaping \\"quotes\\" is cool"', + tokens: [ + { startIndex: 0, type: 'string.java' }, + { startIndex: 10, type: 'string.escape.java' }, + { startIndex: 12, type: 'string.java' }, + { startIndex: 18, type: 'string.escape.java' }, + { startIndex: 20, type: 'string.java' } + ] + } + ], - [{ - line: '"\\"', - tokens: [ - { startIndex: 0, type: 'string.invalid.java' } - ] - }], + [ + { + line: '"\\"', + tokens: [{ startIndex: 0, type: 'string.invalid.java' }] + } + ], // Annotations - [{ - line: '@', - tokens: [ - { startIndex: 0, type: '' } - ] - }], + [ + { + line: '@', + tokens: [{ startIndex: 0, type: '' }] + } + ], - [{ - line: '@Override', - tokens: [ - { startIndex: 0, type: 'annotation.java' } - ] - }], + [ + { + line: '@Override', + tokens: [{ startIndex: 0, type: 'annotation.java' }] + } + ], - [{ - line: '@SuppressWarnings(value = "aString")', - tokens: [ - { startIndex: 0, type: 'annotation.java' }, - { startIndex: 17, type: 'delimiter.parenthesis.java' }, - { startIndex: 18, type: 'identifier.java' }, - { startIndex: 23, type: '' }, - { startIndex: 24, type: 'delimiter.java' }, - { startIndex: 25, type: '' }, - { startIndex: 26, type: 'string.java' }, - { startIndex: 35, type: 'delimiter.parenthesis.java' } - ] - }], + [ + { + line: '@SuppressWarnings(value = "aString")', + tokens: [ + { startIndex: 0, type: 'annotation.java' }, + { startIndex: 17, type: 'delimiter.parenthesis.java' }, + { startIndex: 18, type: 'identifier.java' }, + { startIndex: 23, type: '' }, + { startIndex: 24, type: 'delimiter.java' }, + { startIndex: 25, type: '' }, + { startIndex: 26, type: 'string.java' }, + { startIndex: 35, type: 'delimiter.parenthesis.java' } + ] + } + ], - [{ - line: '@ AnnotationWithKeywordAfter private', - tokens: [ - { startIndex: 0, type: 'annotation.java' }, - { startIndex: 28, type: '' }, - { startIndex: 29, type: 'keyword.private.java' } - ] - }] + [ + { + line: '@ AnnotationWithKeywordAfter private', + tokens: [ + { startIndex: 0, type: 'annotation.java' }, + { startIndex: 28, type: '' }, + { startIndex: 29, type: 'keyword.private.java' } + ] + } + ] ]); - diff --git a/src/java/java.ts b/src/java/java.ts index 521dd7e1..4d7ce4ed 100644 --- a/src/java/java.ts +++ b/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)|(?:))") + start: new RegExp( + '^\\s*//\\s*(?:(?:#?region\\b)|(?:))' + ) } } }; @@ -48,21 +52,98 @@ export const language = { 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 = { 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 = { // 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 = { [/[;,.]/, 'delimiter'], // strings - [/"([^"\\]|\\.)*$/, 'string.invalid'], // non-teminated string + [/"([^"\\]|\\.)*$/, 'string.invalid'], // non-teminated string [/"/, 'string', '@string'], // characters @@ -126,7 +216,7 @@ export const language = { [/[ \t\r\n]+/, ''], [/\/\*\*(?!\/)/, 'comment.doc', '@javadoc'], [/\/\*/, 'comment', '@comment'], - [/\/\/.*$/, 'comment'], + [/\/\/.*$/, 'comment'] ], comment: [ @@ -150,6 +240,6 @@ export const language = { [/@escapes/, 'string.escape'], [/\\./, 'string.escape.invalid'], [/"/, 'string', '@pop'] - ], - }, + ] + } }; diff --git a/src/javascript/javascript.test.ts b/src/javascript/javascript.test.ts index 4d9db649..df731a38 100644 --- a/src/javascript/javascript.test.ts +++ b/src/javascript/javascript.test.ts @@ -9,771 +9,859 @@ import { testTokenization } from '../test/testRunner'; testTokenization('javascript', [ // Keywords - [{ - line: 'var x = function() { };', - tokens: [ - { startIndex: 0, type: 'keyword.js' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'identifier.js' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'delimiter.js' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'keyword.js' }, - { startIndex: 16, type: 'delimiter.parenthesis.js' }, - { startIndex: 18, type: '' }, - { startIndex: 19, type: 'delimiter.bracket.js' }, - { startIndex: 20, type: '' }, - { startIndex: 21, type: 'delimiter.bracket.js' }, - { startIndex: 22, type: 'delimiter.js' } - ] - }], + [ + { + line: 'var x = function() { };', + tokens: [ + { startIndex: 0, type: 'keyword.js' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'identifier.js' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'delimiter.js' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'keyword.js' }, + { startIndex: 16, type: 'delimiter.parenthesis.js' }, + { startIndex: 18, type: '' }, + { startIndex: 19, type: 'delimiter.bracket.js' }, + { startIndex: 20, type: '' }, + { startIndex: 21, type: 'delimiter.bracket.js' }, + { startIndex: 22, type: 'delimiter.js' } + ] + } + ], - [{ - line: ' var ', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 4, type: 'keyword.js' }, - { startIndex: 7, type: '' } - ] - }], + [ + { + line: ' var ', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 4, type: 'keyword.js' }, + { startIndex: 7, type: '' } + ] + } + ], // Comments - single line - [{ - line: '//', - tokens: [ - { startIndex: 0, type: 'comment.js' } - ] - }], + [ + { + line: '//', + tokens: [{ startIndex: 0, type: 'comment.js' }] + } + ], - [{ - line: ' // a comment', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 4, type: 'comment.js' } - ] - }], + [ + { + line: ' // a comment', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 4, type: 'comment.js' } + ] + } + ], - [{ - line: '// a comment', - tokens: [ - { startIndex: 0, type: 'comment.js' } - ] - }], + [ + { + line: '// a comment', + tokens: [{ startIndex: 0, type: 'comment.js' }] + } + ], - [{ - line: '// a comment /*', - tokens: [ - { startIndex: 0, type: 'comment.js' } - ] - }], + [ + { + line: '// a comment /*', + tokens: [{ startIndex: 0, type: 'comment.js' }] + } + ], - [{ - line: '// a comment /**', - tokens: [ - { startIndex: 0, type: 'comment.js' } - ] - }], + [ + { + line: '// a comment /**', + tokens: [{ startIndex: 0, type: 'comment.js' }] + } + ], - [{ - line: '//sticky comment', - tokens: [ - { startIndex: 0, type: 'comment.js' } - ] - }], + [ + { + line: '//sticky comment', + tokens: [{ startIndex: 0, type: 'comment.js' }] + } + ], - [{ - line: 'var x = 1; // my comment // is a nice one', - tokens: [ - { startIndex: 0, type: 'keyword.js' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'identifier.js' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'delimiter.js' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'number.js' }, - { startIndex: 9, type: 'delimiter.js' }, - { startIndex: 10, type: '' }, - { startIndex: 11, type: 'comment.js' } - ] - }], + [ + { + line: 'var x = 1; // my comment // is a nice one', + tokens: [ + { startIndex: 0, type: 'keyword.js' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'identifier.js' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'delimiter.js' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'number.js' }, + { startIndex: 9, type: 'delimiter.js' }, + { startIndex: 10, type: '' }, + { startIndex: 11, type: 'comment.js' } + ] + } + ], // Comments - range comment, single line - [{ - line: '/* a simple comment */', - tokens: [ - { startIndex: 0, type: 'comment.js' } - ] - }], + [ + { + line: '/* a simple comment */', + tokens: [{ startIndex: 0, type: 'comment.js' }] + } + ], - [{ - line: 'var x = /* a simple comment */ 1;', - tokens: [ - { startIndex: 0, type: 'keyword.js' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'identifier.js' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'delimiter.js' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'comment.js' }, - { startIndex: 30, type: '' }, - { startIndex: 31, type: 'number.js' }, - { startIndex: 32, type: 'delimiter.js' } - ] - }], + [ + { + line: 'var x = /* a simple comment */ 1;', + tokens: [ + { startIndex: 0, type: 'keyword.js' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'identifier.js' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'delimiter.js' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'comment.js' }, + { startIndex: 30, type: '' }, + { startIndex: 31, type: 'number.js' }, + { startIndex: 32, type: 'delimiter.js' } + ] + } + ], - [{ - line: 'x = /**/;', - tokens: [ - { startIndex: 0, type: 'identifier.js' }, - { startIndex: 1, type: '' }, - { startIndex: 2, type: 'delimiter.js' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'comment.js' }, - { startIndex: 8, type: 'delimiter.js' } - ] - }], + [ + { + line: 'x = /**/;', + tokens: [ + { startIndex: 0, type: 'identifier.js' }, + { startIndex: 1, type: '' }, + { startIndex: 2, type: 'delimiter.js' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'comment.js' }, + { startIndex: 8, type: 'delimiter.js' } + ] + } + ], - [{ - line: 'x = /*/;', - tokens: [ - { startIndex: 0, type: 'identifier.js' }, - { startIndex: 1, type: '' }, - { startIndex: 2, type: 'delimiter.js' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'comment.js' } - ] - }], + [ + { + line: 'x = /*/;', + tokens: [ + { startIndex: 0, type: 'identifier.js' }, + { startIndex: 1, type: '' }, + { startIndex: 2, type: 'delimiter.js' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'comment.js' } + ] + } + ], // Comments - range comment, multi lines - [{ - line: '/* a multiline comment', - tokens: [ - { startIndex: 0, type: 'comment.js' } - ] - }, { - line: 'can actually span', - tokens: [ - { startIndex: 0, type: 'comment.js' } - ] - }, { - line: 'multiple lines */', - tokens: [ - { startIndex: 0, type: 'comment.js' } - ] - }], + [ + { + line: '/* a multiline comment', + tokens: [{ startIndex: 0, type: 'comment.js' }] + }, + { + line: 'can actually span', + tokens: [{ startIndex: 0, type: 'comment.js' }] + }, + { + line: 'multiple lines */', + tokens: [{ startIndex: 0, type: 'comment.js' }] + } + ], - [{ - line: 'var x = /* start a comment', - tokens: [ - { startIndex: 0, type: 'keyword.js' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'identifier.js' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'delimiter.js' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'comment.js' } - ] - }, { - line: ' a ', - tokens: [ - { startIndex: 0, type: 'comment.js' } - ] - }, { - line: 'and end it */ var a = 2;', - tokens: [ - { startIndex: 0, type: 'comment.js' }, - { startIndex: 13, type: '' }, - { startIndex: 14, type: 'keyword.js' }, - { startIndex: 17, type: '' }, - { startIndex: 18, type: 'identifier.js' }, - { startIndex: 19, type: '' }, - { startIndex: 20, type: 'delimiter.js' }, - { startIndex: 21, type: '' }, - { startIndex: 22, type: 'number.js' }, - { startIndex: 23, type: 'delimiter.js' } - ] - }], + [ + { + line: 'var x = /* start a comment', + tokens: [ + { startIndex: 0, type: 'keyword.js' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'identifier.js' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'delimiter.js' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'comment.js' } + ] + }, + { + line: ' a ', + tokens: [{ startIndex: 0, type: 'comment.js' }] + }, + { + line: 'and end it */ var a = 2;', + tokens: [ + { startIndex: 0, type: 'comment.js' }, + { startIndex: 13, type: '' }, + { startIndex: 14, type: 'keyword.js' }, + { startIndex: 17, type: '' }, + { startIndex: 18, type: 'identifier.js' }, + { startIndex: 19, type: '' }, + { startIndex: 20, type: 'delimiter.js' }, + { startIndex: 21, type: '' }, + { startIndex: 22, type: 'number.js' }, + { startIndex: 23, type: 'delimiter.js' } + ] + } + ], // Strings - [{ - line: 'var a = \'a\';', - tokens: [ - { startIndex: 0, type: 'keyword.js' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'identifier.js' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'delimiter.js' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'string.js' }, - { startIndex: 11, type: 'delimiter.js' } - ] - }], + [ + { + line: "var a = 'a';", + tokens: [ + { startIndex: 0, type: 'keyword.js' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'identifier.js' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'delimiter.js' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'string.js' }, + { startIndex: 11, type: 'delimiter.js' } + ] + } + ], - [{ - line: '"use strict";', - tokens: [ - { startIndex: 0, type: 'string.js' }, - { startIndex: 12, type: 'delimiter.js' } - ] - }], + [ + { + line: '"use strict";', + tokens: [ + { startIndex: 0, type: 'string.js' }, + { startIndex: 12, type: 'delimiter.js' } + ] + } + ], - [{ - line: 'b = a + " \'cool\' "', - tokens: [ - { startIndex: 0, type: 'identifier.js' }, - { startIndex: 1, type: '' }, - { startIndex: 2, type: 'delimiter.js' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'identifier.js' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'delimiter.js' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'string.js' } - ] - }], + [ + { + line: 'b = a + " \'cool\' "', + tokens: [ + { startIndex: 0, type: 'identifier.js' }, + { startIndex: 1, type: '' }, + { startIndex: 2, type: 'delimiter.js' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'identifier.js' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'delimiter.js' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'string.js' } + ] + } + ], - [{ - line: '"escaping \\"quotes\\" is cool"', - tokens: [ - { startIndex: 0, type: 'string.js' }, - { startIndex: 10, type: 'string.escape.js' }, - { startIndex: 12, type: 'string.js' }, - { startIndex: 18, type: 'string.escape.js' }, - { startIndex: 20, type: 'string.js' }, - ] - }], + [ + { + line: '"escaping \\"quotes\\" is cool"', + tokens: [ + { startIndex: 0, type: 'string.js' }, + { startIndex: 10, type: 'string.escape.js' }, + { startIndex: 12, type: 'string.js' }, + { startIndex: 18, type: 'string.escape.js' }, + { startIndex: 20, type: 'string.js' } + ] + } + ], - [{ - line: '\'\'\'', - tokens: [ - { startIndex: 0, type: 'string.js' }, - { startIndex: 2, type: 'string.invalid.js' }, - ] - }], + [ + { + line: "'''", + tokens: [ + { startIndex: 0, type: 'string.js' }, + { startIndex: 2, type: 'string.invalid.js' } + ] + } + ], - [{ - line: '\'\\\'\'', - tokens: [ - { startIndex: 0, type: 'string.js' }, - { startIndex: 1, type: 'string.escape.js' }, - { startIndex: 3, type: 'string.js' }, - ] - }], + [ + { + line: "'\\''", + tokens: [ + { startIndex: 0, type: 'string.js' }, + { startIndex: 1, type: 'string.escape.js' }, + { startIndex: 3, type: 'string.js' } + ] + } + ], - [{ - line: '\'be careful \\not to escape\'', - tokens: [ - { startIndex: 0, type: 'string.js' }, - { startIndex: 12, type: 'string.escape.js' }, - { startIndex: 14, type: 'string.js' }, - ] - }], + [ + { + line: "'be careful \\not to escape'", + tokens: [ + { startIndex: 0, type: 'string.js' }, + { startIndex: 12, type: 'string.escape.js' }, + { startIndex: 14, type: 'string.js' } + ] + } + ], // Numbers - [{ - line: '0', - tokens: [ - { startIndex: 0, type: 'number.js' } - ] - }], + [ + { + line: '0', + tokens: [{ startIndex: 0, type: 'number.js' }] + } + ], - [{ - line: ' 0', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 1, type: 'number.js' } - ] - }], + [ + { + line: ' 0', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 1, type: 'number.js' } + ] + } + ], - [{ - line: ' 0 ', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 1, type: 'number.js' }, - { startIndex: 2, type: '' } - ] - }], + [ + { + line: ' 0 ', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 1, type: 'number.js' }, + { startIndex: 2, type: '' } + ] + } + ], - [{ - line: '0 ', - tokens: [ - { startIndex: 0, type: 'number.js' }, - { startIndex: 1, type: '' } - ] - }], + [ + { + line: '0 ', + tokens: [ + { startIndex: 0, type: 'number.js' }, + { startIndex: 1, type: '' } + ] + } + ], - [{ - line: '0+0', - tokens: [ - { startIndex: 0, type: 'number.js' }, - { startIndex: 1, type: 'delimiter.js' }, - { startIndex: 2, type: 'number.js' } - ] - }], + [ + { + line: '0+0', + tokens: [ + { startIndex: 0, type: 'number.js' }, + { startIndex: 1, type: 'delimiter.js' }, + { startIndex: 2, type: 'number.js' } + ] + } + ], - [{ - line: '100+10', - tokens: [ - { startIndex: 0, type: 'number.js' }, - { startIndex: 3, type: 'delimiter.js' }, - { startIndex: 4, type: 'number.js' } - ] - }], + [ + { + line: '100+10', + tokens: [ + { startIndex: 0, type: 'number.js' }, + { startIndex: 3, type: 'delimiter.js' }, + { startIndex: 4, type: 'number.js' } + ] + } + ], - [{ - line: '0 + 0', - tokens: [ - { startIndex: 0, type: 'number.js' }, - { startIndex: 1, type: '' }, - { startIndex: 2, type: 'delimiter.js' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'number.js' } - ] - }], + [ + { + line: '0 + 0', + tokens: [ + { startIndex: 0, type: 'number.js' }, + { startIndex: 1, type: '' }, + { startIndex: 2, type: 'delimiter.js' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'number.js' } + ] + } + ], - [{ - line: '0123', - tokens: [ - { startIndex: 0, type: 'number.octal.js' } - ] - }], + [ + { + line: '0123', + tokens: [{ startIndex: 0, type: 'number.octal.js' }] + } + ], - [{ - line: '01239', - tokens: [ - { startIndex: 0, type: 'number.octal.js' }, - { startIndex: 4, type: 'number.js' } - ] - }], + [ + { + line: '01239', + tokens: [ + { startIndex: 0, type: 'number.octal.js' }, + { startIndex: 4, type: 'number.js' } + ] + } + ], - [{ - line: '0o123', - tokens: [ - { startIndex: 0, type: 'number.octal.js' } - ] - }], + [ + { + line: '0o123', + tokens: [{ startIndex: 0, type: 'number.octal.js' }] + } + ], - [{ - line: '0O123', - tokens: [ - { startIndex: 0, type: 'number.octal.js' } - ] - }], + [ + { + line: '0O123', + tokens: [{ startIndex: 0, type: 'number.octal.js' }] + } + ], - [{ - line: '0x', - tokens: [ - { startIndex: 0, type: 'number.js' }, - { startIndex: 1, type: 'identifier.js' } - ] - }], + [ + { + line: '0x', + tokens: [ + { startIndex: 0, type: 'number.js' }, + { startIndex: 1, type: 'identifier.js' } + ] + } + ], - [{ - line: '0x123', - tokens: [ - { startIndex: 0, type: 'number.hex.js' } - ] - }], + [ + { + line: '0x123', + tokens: [{ startIndex: 0, type: 'number.hex.js' }] + } + ], - [{ - line: '0X123', - tokens: [ - { startIndex: 0, type: 'number.hex.js' } - ] - }], + [ + { + line: '0X123', + tokens: [{ startIndex: 0, type: 'number.hex.js' }] + } + ], - [{ - line: '0b101', - tokens: [ - { startIndex: 0, type: 'number.binary.js' } - ] - }], + [ + { + line: '0b101', + tokens: [{ startIndex: 0, type: 'number.binary.js' }] + } + ], - [{ - line: '0B101', - tokens: [ - { startIndex: 0, type: 'number.binary.js' } - ] - }], + [ + { + line: '0B101', + tokens: [{ startIndex: 0, type: 'number.binary.js' }] + } + ], // Bigint - [{ - line: '0n', - tokens: [ - { startIndex: 0, type: 'number.js' } - ] - }], + [ + { + line: '0n', + tokens: [{ startIndex: 0, type: 'number.js' }] + } + ], - [{ - line: ' 0n', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 1, type: 'number.js' } - ] - }], + [ + { + line: ' 0n', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 1, type: 'number.js' } + ] + } + ], - [{ - line: ' 0n ', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 1, type: 'number.js' }, - { startIndex: 3, type: '' } - ] - }], + [ + { + line: ' 0n ', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 1, type: 'number.js' }, + { startIndex: 3, type: '' } + ] + } + ], - [{ - line: '0n ', - tokens: [ - { startIndex: 0, type: 'number.js' }, - { startIndex: 2, type: '' } - ] - }], + [ + { + line: '0n ', + tokens: [ + { startIndex: 0, type: 'number.js' }, + { startIndex: 2, type: '' } + ] + } + ], - [{ - line: '0n+0n', - tokens: [ - { startIndex: 0, type: 'number.js' }, - { startIndex: 2, type: 'delimiter.js' }, - { startIndex: 3, type: 'number.js' } - ] - }], + [ + { + line: '0n+0n', + tokens: [ + { startIndex: 0, type: 'number.js' }, + { startIndex: 2, type: 'delimiter.js' }, + { startIndex: 3, type: 'number.js' } + ] + } + ], - [{ - line: '100n+10n', - tokens: [ - { startIndex: 0, type: 'number.js' }, - { startIndex: 4, type: 'delimiter.js' }, - { startIndex: 5, type: 'number.js' } - ] - }], + [ + { + line: '100n+10n', + tokens: [ + { startIndex: 0, type: 'number.js' }, + { startIndex: 4, type: 'delimiter.js' }, + { startIndex: 5, type: 'number.js' } + ] + } + ], - [{ - line: '0n + 0n', - tokens: [ - { startIndex: 0, type: 'number.js' }, - { startIndex: 2, type: '' }, - { startIndex: 3, type: 'delimiter.js' }, - { startIndex: 4, type: '' }, - { startIndex: 5, type: 'number.js' } - ] - }], + [ + { + line: '0n + 0n', + tokens: [ + { startIndex: 0, type: 'number.js' }, + { startIndex: 2, type: '' }, + { startIndex: 3, type: 'delimiter.js' }, + { startIndex: 4, type: '' }, + { startIndex: 5, type: 'number.js' } + ] + } + ], - [{ - line: '0b101n', - tokens: [ - { startIndex: 0, type: 'number.binary.js' } - ] - }], + [ + { + line: '0b101n', + tokens: [{ startIndex: 0, type: 'number.binary.js' }] + } + ], - [{ - line: '0123n', - tokens: [ - { startIndex: 0, type: 'number.octal.js' } - ] - }], + [ + { + line: '0123n', + tokens: [{ startIndex: 0, type: 'number.octal.js' }] + } + ], - [{ - line: '0o123n', - tokens: [ - { startIndex: 0, type: 'number.octal.js' } - ] - }], + [ + { + line: '0o123n', + tokens: [{ startIndex: 0, type: 'number.octal.js' }] + } + ], - [{ - line: '0x123n', - tokens: [ - { startIndex: 0, type: 'number.hex.js' } - ] - }], + [ + { + line: '0x123n', + tokens: [{ startIndex: 0, type: 'number.hex.js' }] + } + ], // Regular Expressions - [{ - line: '//', - tokens: [ - { startIndex: 0, type: 'comment.js' } - ] - }], + [ + { + line: '//', + tokens: [{ startIndex: 0, type: 'comment.js' }] + } + ], - [{ - line: '/**/', - tokens: [ - { startIndex: 0, type: 'comment.js' } - ] - }], + [ + { + line: '/**/', + tokens: [{ startIndex: 0, type: 'comment.js' }] + } + ], - [{ - line: '/***/', - tokens: [ - { startIndex: 0, type: 'comment.doc.js' } - ] - }], + [ + { + line: '/***/', + tokens: [{ startIndex: 0, type: 'comment.doc.js' }] + } + ], - [{ - line: '5 / 3;', - tokens: [ - { startIndex: 0, type: 'number.js' }, - { startIndex: 1, type: '' }, - { startIndex: 2, type: 'delimiter.js' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'number.js' }, - { startIndex: 5, type: 'delimiter.js' } - ] - }], + [ + { + line: '5 / 3;', + tokens: [ + { startIndex: 0, type: 'number.js' }, + { startIndex: 1, type: '' }, + { startIndex: 2, type: 'delimiter.js' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'number.js' }, + { startIndex: 5, type: 'delimiter.js' } + ] + } + ], // Advanced regular expressions - [{ - line: '1 / 2; /* comment', - tokens: [ - { startIndex: 0, type: 'number.js' }, - { startIndex: 1, type: '' }, - { startIndex: 2, type: 'delimiter.js' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'number.js' }, - { startIndex: 5, type: 'delimiter.js' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'comment.js' } - ] - }], + [ + { + line: '1 / 2; /* comment', + tokens: [ + { startIndex: 0, type: 'number.js' }, + { startIndex: 1, type: '' }, + { startIndex: 2, type: 'delimiter.js' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'number.js' }, + { startIndex: 5, type: 'delimiter.js' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'comment.js' } + ] + } + ], - [{ - line: '1 / 2 / x / b;', - tokens: [ - { startIndex: 0, type: 'number.js' }, - { startIndex: 1, type: '' }, - { startIndex: 2, type: 'delimiter.js' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'number.js' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'delimiter.js' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'identifier.js' }, - { startIndex: 9, type: '' }, - { startIndex: 10, type: 'delimiter.js' }, - { startIndex: 11, type: '' }, - { startIndex: 12, type: 'identifier.js' }, - { startIndex: 13, type: 'delimiter.js' } - ] - }], + [ + { + line: '1 / 2 / x / b;', + tokens: [ + { startIndex: 0, type: 'number.js' }, + { startIndex: 1, type: '' }, + { startIndex: 2, type: 'delimiter.js' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'number.js' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'delimiter.js' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'identifier.js' }, + { startIndex: 9, type: '' }, + { startIndex: 10, type: 'delimiter.js' }, + { startIndex: 11, type: '' }, + { startIndex: 12, type: 'identifier.js' }, + { startIndex: 13, type: 'delimiter.js' } + ] + } + ], - [{ - line: 'x = /foo/.test(\'\')', - tokens: [ - { startIndex: 0, type: 'identifier.js' }, - { startIndex: 1, type: '' }, - { startIndex: 2, type: 'delimiter.js' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'regexp.js' }, - { startIndex: 9, type: 'delimiter.js' }, - { startIndex: 10, type: 'identifier.js' }, - { startIndex: 14, type: 'delimiter.parenthesis.js' }, - { startIndex: 15, type: 'string.js' }, - { startIndex: 17, type: 'delimiter.parenthesis.js' } - ] - }], + [ + { + line: "x = /foo/.test('')", + tokens: [ + { startIndex: 0, type: 'identifier.js' }, + { startIndex: 1, type: '' }, + { startIndex: 2, type: 'delimiter.js' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'regexp.js' }, + { startIndex: 9, type: 'delimiter.js' }, + { startIndex: 10, type: 'identifier.js' }, + { startIndex: 14, type: 'delimiter.parenthesis.js' }, + { startIndex: 15, type: 'string.js' }, + { startIndex: 17, type: 'delimiter.parenthesis.js' } + ] + } + ], - [{ - line: '/foo/', - tokens: [ - { startIndex: 0, type: 'regexp.js' } - ] - }], + [ + { + line: '/foo/', + tokens: [{ startIndex: 0, type: 'regexp.js' }] + } + ], - [{ - line: '/foo/g', - tokens: [ - { startIndex: 0, type: 'regexp.js' }, - { startIndex: 5, type: 'keyword.other.js' } - ] - }], + [ + { + line: '/foo/g', + tokens: [ + { startIndex: 0, type: 'regexp.js' }, + { startIndex: 5, type: 'keyword.other.js' } + ] + } + ], - [{ - line: '/foo/gimsuy', - tokens: [ - { startIndex: 0, type: 'regexp.js' }, - { startIndex: 5, type: 'keyword.other.js' } - ] - }], + [ + { + line: '/foo/gimsuy', + tokens: [ + { startIndex: 0, type: 'regexp.js' }, + { startIndex: 5, type: 'keyword.other.js' } + ] + } + ], - [{ - line: '/foo/q', // invalid flag - tokens: [ - { startIndex: 0, type: 'delimiter.js' }, - { startIndex: 1, type: 'identifier.js' }, - { startIndex: 4, type: 'delimiter.js' }, - { startIndex: 5, type: 'identifier.js' } - ] - }], + [ + { + line: '/foo/q', // invalid flag + tokens: [ + { startIndex: 0, type: 'delimiter.js' }, + { startIndex: 1, type: 'identifier.js' }, + { startIndex: 4, type: 'delimiter.js' }, + { startIndex: 5, type: 'identifier.js' } + ] + } + ], - [{ - line: 'x = 1 + f(2 / 3, /foo/)', - tokens: [ - { startIndex: 0, type: 'identifier.js' }, - { startIndex: 1, type: '' }, - { startIndex: 2, type: 'delimiter.js' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'number.js' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'delimiter.js' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'identifier.js' }, - { startIndex: 9, type: 'delimiter.parenthesis.js' }, - { startIndex: 10, type: 'number.js' }, - { startIndex: 11, type: '' }, - { startIndex: 12, type: 'delimiter.js' }, - { startIndex: 13, type: '' }, - { startIndex: 14, type: 'number.js' }, - { startIndex: 15, type: 'delimiter.js' }, - { startIndex: 16, type: '' }, - { startIndex: 17, type: 'regexp.js' }, - { startIndex: 22, type: 'delimiter.parenthesis.js' } - ] - }], + [ + { + line: 'x = 1 + f(2 / 3, /foo/)', + tokens: [ + { startIndex: 0, type: 'identifier.js' }, + { startIndex: 1, type: '' }, + { startIndex: 2, type: 'delimiter.js' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'number.js' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'delimiter.js' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'identifier.js' }, + { startIndex: 9, type: 'delimiter.parenthesis.js' }, + { startIndex: 10, type: 'number.js' }, + { startIndex: 11, type: '' }, + { startIndex: 12, type: 'delimiter.js' }, + { startIndex: 13, type: '' }, + { startIndex: 14, type: 'number.js' }, + { startIndex: 15, type: 'delimiter.js' }, + { startIndex: 16, type: '' }, + { startIndex: 17, type: 'regexp.js' }, + { startIndex: 22, type: 'delimiter.parenthesis.js' } + ] + } + ], - [{ - line: 'a /ads/ b;', - tokens: [ - { startIndex: 0, type: 'identifier.js' }, - { startIndex: 1, type: '' }, - { startIndex: 2, type: 'delimiter.js' }, - { startIndex: 3, type: 'identifier.js' }, - { startIndex: 6, type: 'delimiter.js' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'identifier.js' }, - { startIndex: 9, type: 'delimiter.js' } - ] - }], + [ + { + line: 'a /ads/ b;', + tokens: [ + { startIndex: 0, type: 'identifier.js' }, + { startIndex: 1, type: '' }, + { startIndex: 2, type: 'delimiter.js' }, + { startIndex: 3, type: 'identifier.js' }, + { startIndex: 6, type: 'delimiter.js' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'identifier.js' }, + { startIndex: 9, type: 'delimiter.js' } + ] + } + ], - [{ - line: '1/(2/3)/2/3;', - tokens: [ - { startIndex: 0, type: 'number.js' }, - { startIndex: 1, type: 'delimiter.js' }, - { startIndex: 2, type: 'delimiter.parenthesis.js' }, - { startIndex: 3, type: 'number.js' }, - { startIndex: 4, type: 'delimiter.js' }, - { startIndex: 5, type: 'number.js' }, - { startIndex: 6, type: 'delimiter.parenthesis.js' }, - { startIndex: 7, type: 'delimiter.js' }, - { startIndex: 8, type: 'number.js' }, - { startIndex: 9, type: 'delimiter.js' }, - { startIndex: 10, type: 'number.js' }, - { startIndex: 11, type: 'delimiter.js' } - ] - }], + [ + { + line: '1/(2/3)/2/3;', + tokens: [ + { startIndex: 0, type: 'number.js' }, + { startIndex: 1, type: 'delimiter.js' }, + { startIndex: 2, type: 'delimiter.parenthesis.js' }, + { startIndex: 3, type: 'number.js' }, + { startIndex: 4, type: 'delimiter.js' }, + { startIndex: 5, type: 'number.js' }, + { startIndex: 6, type: 'delimiter.parenthesis.js' }, + { startIndex: 7, type: 'delimiter.js' }, + { startIndex: 8, type: 'number.js' }, + { startIndex: 9, type: 'delimiter.js' }, + { startIndex: 10, type: 'number.js' }, + { startIndex: 11, type: 'delimiter.js' } + ] + } + ], - [{ - line: '{ key: 123 }', - tokens: [ - { startIndex: 0, type: 'delimiter.bracket.js' }, - { startIndex: 1, type: '' }, - { startIndex: 2, type: 'identifier.js' }, - { startIndex: 5, type: 'delimiter.js' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'number.js' }, - { startIndex: 10, type: '' }, - { startIndex: 11, type: 'delimiter.bracket.js' } - ] - }], + [ + { + line: '{ key: 123 }', + tokens: [ + { startIndex: 0, type: 'delimiter.bracket.js' }, + { startIndex: 1, type: '' }, + { startIndex: 2, type: 'identifier.js' }, + { startIndex: 5, type: 'delimiter.js' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'number.js' }, + { startIndex: 10, type: '' }, + { startIndex: 11, type: 'delimiter.bracket.js' } + ] + } + ], - [{ - line: '[1,2,3]', - tokens: [ - { startIndex: 0, type: 'delimiter.square.js' }, - { startIndex: 1, type: 'number.js' }, - { startIndex: 2, type: 'delimiter.js' }, - { startIndex: 3, type: 'number.js' }, - { startIndex: 4, type: 'delimiter.js' }, - { startIndex: 5, type: 'number.js' }, - { startIndex: 6, type: 'delimiter.square.js' } - ] - }], + [ + { + line: '[1,2,3]', + tokens: [ + { startIndex: 0, type: 'delimiter.square.js' }, + { startIndex: 1, type: 'number.js' }, + { startIndex: 2, type: 'delimiter.js' }, + { startIndex: 3, type: 'number.js' }, + { startIndex: 4, type: 'delimiter.js' }, + { startIndex: 5, type: 'number.js' }, + { startIndex: 6, type: 'delimiter.square.js' } + ] + } + ], - [{ - line: 'foo(123);', - tokens: [ - { startIndex: 0, type: 'identifier.js' }, - { startIndex: 3, type: 'delimiter.parenthesis.js' }, - { startIndex: 4, type: 'number.js' }, - { startIndex: 7, type: 'delimiter.parenthesis.js' }, - { startIndex: 8, type: 'delimiter.js' } - ] - }], + [ + { + line: 'foo(123);', + tokens: [ + { startIndex: 0, type: 'identifier.js' }, + { startIndex: 3, type: 'delimiter.parenthesis.js' }, + { startIndex: 4, type: 'number.js' }, + { startIndex: 7, type: 'delimiter.parenthesis.js' }, + { startIndex: 8, type: 'delimiter.js' } + ] + } + ], - [{ - line: '{a:{b:[]}}', - tokens: [ - { startIndex: 0, type: 'delimiter.bracket.js' }, - { startIndex: 1, type: 'identifier.js' }, - { startIndex: 2, type: 'delimiter.js' }, - { startIndex: 3, type: 'delimiter.bracket.js' }, - { startIndex: 4, type: 'identifier.js' }, - { startIndex: 5, type: 'delimiter.js' }, - { startIndex: 6, type: 'delimiter.square.js' }, - { startIndex: 8, type: 'delimiter.bracket.js' } - ] - }], + [ + { + line: '{a:{b:[]}}', + tokens: [ + { startIndex: 0, type: 'delimiter.bracket.js' }, + { startIndex: 1, type: 'identifier.js' }, + { startIndex: 2, type: 'delimiter.js' }, + { startIndex: 3, type: 'delimiter.bracket.js' }, + { startIndex: 4, type: 'identifier.js' }, + { startIndex: 5, type: 'delimiter.js' }, + { startIndex: 6, type: 'delimiter.square.js' }, + { startIndex: 8, type: 'delimiter.bracket.js' } + ] + } + ], - [{ - line: 'x = "[{()}]"', - tokens: [ - { startIndex: 0, type: 'identifier.js' }, - { startIndex: 1, type: '' }, - { startIndex: 2, type: 'delimiter.js' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'string.js' } - ] - }], + [ + { + line: 'x = "[{()}]"', + tokens: [ + { startIndex: 0, type: 'identifier.js' }, + { startIndex: 1, type: '' }, + { startIndex: 2, type: 'delimiter.js' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'string.js' } + ] + } + ], + [ + { + line: 'test ? 1 : 2', + tokens: [ + { startIndex: 0, type: 'identifier.js' }, + { startIndex: 4, type: '' }, + { startIndex: 5, type: 'delimiter.js' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'number.js' }, + { startIndex: 8, type: '' }, + { startIndex: 9, type: 'delimiter.js' }, + { startIndex: 10, type: '' }, + { startIndex: 11, type: 'number.js' } + ] + } + ], - [{ - line: 'test ? 1 : 2', - tokens: [ - { startIndex: 0, type: 'identifier.js' }, - { startIndex: 4, type: '' }, - { startIndex: 5, type: 'delimiter.js' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'number.js' }, - { startIndex: 8, type: '' }, - { startIndex: 9, type: 'delimiter.js' }, - { startIndex: 10, type: '' }, - { startIndex: 11, type: 'number.js' }, - ] - }], - - [{ - line: 'couldBeNullish ?? 1', - tokens: [ - { startIndex: 0, type: 'identifier.js' }, - { startIndex: 14, type: '' }, - { startIndex: 15, type: 'delimiter.js' }, - { startIndex: 17, type: '' }, - { startIndex: 18, type: 'number.js' } - ] - }], - - - [{ - line: '`${5 + \'x\' + 3}a${4}`', - tokens: [ - { startIndex: 0, type: 'string.js' }, - { startIndex: 1, type: 'delimiter.bracket.js' }, - { startIndex: 3, type: 'number.js' }, - { startIndex: 4, type: '' }, - { startIndex: 5, type: 'delimiter.js' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'string.js' }, - { startIndex: 10, type: '' }, - { startIndex: 11, type: 'delimiter.js' }, - { startIndex: 12, type: '' }, - { startIndex: 13, type: 'number.js' }, - { startIndex: 14, type: 'delimiter.bracket.js' }, - { startIndex: 15, type: 'string.js' }, - { startIndex: 16, type: 'delimiter.bracket.js' }, - { startIndex: 18, type: 'number.js' }, - { startIndex: 19, type: 'delimiter.bracket.js' }, - { startIndex: 20, type: 'string.js' }, - - ] - }] + [ + { + line: 'couldBeNullish ?? 1', + tokens: [ + { startIndex: 0, type: 'identifier.js' }, + { startIndex: 14, type: '' }, + { startIndex: 15, type: 'delimiter.js' }, + { startIndex: 17, type: '' }, + { startIndex: 18, type: 'number.js' } + ] + } + ], + [ + { + line: "`${5 + 'x' + 3}a${4}`", + tokens: [ + { startIndex: 0, type: 'string.js' }, + { startIndex: 1, type: 'delimiter.bracket.js' }, + { startIndex: 3, type: 'number.js' }, + { startIndex: 4, type: '' }, + { startIndex: 5, type: 'delimiter.js' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'string.js' }, + { startIndex: 10, type: '' }, + { startIndex: 11, type: 'delimiter.js' }, + { startIndex: 12, type: '' }, + { startIndex: 13, type: 'number.js' }, + { startIndex: 14, type: 'delimiter.bracket.js' }, + { startIndex: 15, type: 'string.js' }, + { startIndex: 16, type: 'delimiter.bracket.js' }, + { startIndex: 18, type: 'number.js' }, + { startIndex: 19, type: 'delimiter.bracket.js' }, + { startIndex: 20, type: 'string.js' } + ] + } + ] ]); diff --git a/src/javascript/javascript.ts b/src/javascript/javascript.ts index e635750c..54aadc86 100644 --- a/src/javascript/javascript.ts +++ b/src/javascript/javascript.ts @@ -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' ? (self).monaco : monaco); +const _monaco: typeof monaco = + typeof monaco === 'undefined' ? (self).monaco : monaco; export const conf: IRichLanguageConfiguration = tsConf; @@ -20,13 +24,52 @@ export const language = { 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 = { hexdigits: tsLanguage.hexdigits, regexpctl: tsLanguage.regexpctl, regexpesc: tsLanguage.regexpesc, - tokenizer: tsLanguage.tokenizer, + tokenizer: tsLanguage.tokenizer }; diff --git a/src/julia/julia.contribution.ts b/src/julia/julia.contribution.ts index 77d399c6..663cc757 100644 --- a/src/julia/julia.contribution.ts +++ b/src/julia/julia.contribution.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ 'use strict'; -import {registerLanguage} from '../_.contribution'; +import { registerLanguage } from '../_.contribution'; registerLanguage({ id: 'julia', diff --git a/src/julia/julia.test.ts b/src/julia/julia.test.ts index 996ace09..926e9a20 100644 --- a/src/julia/julia.test.ts +++ b/src/julia/julia.test.ts @@ -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: "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: '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' } + ] + } + ] ]); diff --git a/src/julia/julia.ts b/src/julia/julia.ts index bfd2a515..ab0407a0 100644 --- a/src/julia/julia.ts +++ b/src/julia/julia.ts @@ -15,75 +15,323 @@ 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: "'" } ] }; export const language = { 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 = { 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 @@ -118,57 +369,68 @@ export const language = { // strings [/raw"""/, 'string.delim', '@rtstring'], [/[bv]?"""/, 'string.delim', '@dtstring'], - + [/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'], - + [/@@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 = { // 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 = { [/[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 = { [/\$\(/, 'key', '@paste'], [/\(/, '@brackets', '@paren'], [/\)/, 'metatag', '@pop'], - {include: '@root'} + { include: '@root' } ], // :(...) @@ -207,7 +472,7 @@ export const language = { [/:\(/, 'metatag', '@quote'], [/\(/, '@brackets', '@paren'], [/\)/, 'key', '@pop'], - {include: '@root'} + { include: '@root' } ], // (...) @@ -216,7 +481,7 @@ export const language = { [/:\(/, 'metatag', '@quote'], [/\(/, '@brackets', '@push'], [/\)/, '@brackets', '@pop'], - {include: '@root'} + { include: '@root' } ], // r"egex string" @@ -256,7 +521,7 @@ export const language = { [/\$/, '', '@interpolated'], [/@escapes/, 'string.escape'], [/\\./, 'string.escape.invalid'], - [/"/, 'string.delim', '@pop'], + [/"/, 'string.delim', '@pop'] ], dtstring: [ [/[^\\"\$]/, 'string'], @@ -264,7 +529,7 @@ export const language = { [/@escapes/, 'string.escape'], [/\\./, 'string.escape.invalid'], [/"(?!"")/, 'string'], - [/"""/, 'string.delim', '@pop'], + [/"""/, 'string.delim', '@pop'] ], // interpolated sequence @@ -275,23 +540,20 @@ export const language = { ], // 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'] ] } }; diff --git a/src/kotlin/kotlin.test.ts b/src/kotlin/kotlin.test.ts index e2f61e7a..e09e214c 100644 --- a/src/kotlin/kotlin.test.ts +++ b/src/kotlin/kotlin.test.ts @@ -9,98 +9,108 @@ import { testTokenization } from '../test/testRunner'; testTokenization('kotlin', [ // inline reified function - [{ - line: 'inline fun foo()', - tokens: [ - { startIndex: 0, type: 'keyword.inline.kt' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'keyword.fun.kt' }, - { startIndex: 10, type: '' }, - { startIndex: 11, type: 'delimiter.angle.kt' }, - { startIndex: 12, type: 'keyword.reified.kt' }, - { startIndex: 19, type: '' }, - { startIndex: 20, type: 'type.identifier.kt' }, - { startIndex: 21, type: '' }, - { startIndex: 22, type: 'delimiter.kt' }, - { startIndex: 23, type: '' }, - { startIndex: 24, type: 'type.identifier.kt' }, - { startIndex: 27, type: 'delimiter.angle.kt' }, - { startIndex: 28, type: '' }, - { startIndex: 29, type: 'identifier.kt' }, - { startIndex: 32, type: 'delimiter.parenthesis.kt' }, - ] - }], + [ + { + line: 'inline fun foo()', + tokens: [ + { startIndex: 0, type: 'keyword.inline.kt' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'keyword.fun.kt' }, + { startIndex: 10, type: '' }, + { startIndex: 11, type: 'delimiter.angle.kt' }, + { startIndex: 12, type: 'keyword.reified.kt' }, + { startIndex: 19, type: '' }, + { startIndex: 20, type: 'type.identifier.kt' }, + { startIndex: 21, type: '' }, + { startIndex: 22, type: 'delimiter.kt' }, + { startIndex: 23, type: '' }, + { startIndex: 24, type: 'type.identifier.kt' }, + { startIndex: 27, type: 'delimiter.angle.kt' }, + { startIndex: 28, type: '' }, + { startIndex: 29, type: 'identifier.kt' }, + { startIndex: 32, type: 'delimiter.parenthesis.kt' } + ] + } + ], // Val declaration and assignment - [{ - line: 'val x: X=5', - tokens: [ - { startIndex: 0, type: 'keyword.val.kt' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'identifier.kt' }, - { startIndex: 5, type: 'delimiter.kt' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'type.identifier.kt' }, - { startIndex: 8, type: 'delimiter.kt' }, - { startIndex: 9, type: 'number.kt' }, - ] - }], + [ + { + line: 'val x: X=5', + tokens: [ + { startIndex: 0, type: 'keyword.val.kt' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'identifier.kt' }, + { startIndex: 5, type: 'delimiter.kt' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'type.identifier.kt' }, + { startIndex: 8, type: 'delimiter.kt' }, + { startIndex: 9, type: 'number.kt' } + ] + } + ], // Comments - single line - [{ - line: '//', - tokens: [ - { startIndex: 0, type: 'comment.kt' } - ] - }], + [ + { + line: '//', + tokens: [{ startIndex: 0, type: 'comment.kt' }] + } + ], - [{ - line: ' // a comment', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 4, type: 'comment.kt' } - ] - }], + [ + { + line: ' // a comment', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 4, type: 'comment.kt' } + ] + } + ], - [{ - line: '// a comment', - tokens: [ - { startIndex: 0, type: 'comment.kt' } - ] - }], + [ + { + line: '// a comment', + tokens: [{ startIndex: 0, type: 'comment.kt' }] + } + ], - [{ - line: '//sticky comment', - tokens: [ - { startIndex: 0, type: 'comment.kt' } - ] - }], + [ + { + line: '//sticky comment', + tokens: [{ startIndex: 0, type: 'comment.kt' }] + } + ], - [{ - line: '/almost a comment', - tokens: [ - { startIndex: 0, type: 'delimiter.kt' }, - { startIndex: 1, type: 'identifier.kt' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'identifier.kt' }, - { startIndex: 9, type: '' }, - { startIndex: 10, type: 'identifier.kt' } - ] - }], + [ + { + line: '/almost a comment', + tokens: [ + { startIndex: 0, type: 'delimiter.kt' }, + { startIndex: 1, type: 'identifier.kt' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'identifier.kt' }, + { startIndex: 9, type: '' }, + { startIndex: 10, type: 'identifier.kt' } + ] + } + ], - [{ - line: '1 / 2; /* comment', - tokens: [ - { startIndex: 0, type: 'number.kt' }, - { startIndex: 1, type: '' }, - { startIndex: 2, type: 'delimiter.kt' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'number.kt' }, - { startIndex: 5, type: 'delimiter.kt' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'comment.kt' } - ] - }], + [ + { + line: '1 / 2; /* comment', + tokens: [ + { startIndex: 0, type: 'number.kt' }, + { startIndex: 1, type: '' }, + { startIndex: 2, type: 'delimiter.kt' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'number.kt' }, + { startIndex: 5, type: 'delimiter.kt' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'comment.kt' } + ] + } + ], // [{ // line: 'var x = 1 // my comment // is a nice one', @@ -120,586 +130,627 @@ testTokenization('kotlin', [ // }], // Comments - range comment, single line - [{ - line: '/* a simple comment */', - tokens: [ - { startIndex: 0, type: 'comment.kt' } - ] - }], + [ + { + line: '/* a simple comment */', + tokens: [{ startIndex: 0, type: 'comment.kt' }] + } + ], - [{ - line: 'var x = /* a simple comment */ 1', - tokens: [ - { startIndex: 0, type: 'keyword.var.kt' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'identifier.kt' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'delimiter.kt' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'comment.kt' }, - { startIndex: 30, type: '' }, - { startIndex: 31, type: 'number.kt' }, - ] - }], + [ + { + line: 'var x = /* a simple comment */ 1', + tokens: [ + { startIndex: 0, type: 'keyword.var.kt' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'identifier.kt' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'delimiter.kt' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'comment.kt' }, + { startIndex: 30, type: '' }, + { startIndex: 31, type: 'number.kt' } + ] + } + ], - [{ - line: 'var x = /* comment */ 1; */', - tokens: [ - { startIndex: 0, type: 'keyword.var.kt' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'identifier.kt' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'delimiter.kt' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'comment.kt' }, - { startIndex: 21, type: '' }, - { startIndex: 22, type: 'number.kt' }, - { startIndex: 23, type: 'delimiter.kt' }, - { startIndex: 24, type: '' } - ] - }], + [ + { + line: 'var x = /* comment */ 1; */', + tokens: [ + { startIndex: 0, type: 'keyword.var.kt' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'identifier.kt' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'delimiter.kt' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'comment.kt' }, + { startIndex: 21, type: '' }, + { startIndex: 22, type: 'number.kt' }, + { startIndex: 23, type: 'delimiter.kt' }, + { startIndex: 24, type: '' } + ] + } + ], - [{ - line: 'x = /**/', - tokens: [ - { startIndex: 0, type: 'identifier.kt' }, - { startIndex: 1, type: '' }, - { startIndex: 2, type: 'delimiter.kt' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'comment.kt' }, - ] - }], + [ + { + line: 'x = /**/', + tokens: [ + { startIndex: 0, type: 'identifier.kt' }, + { startIndex: 1, type: '' }, + { startIndex: 2, type: 'delimiter.kt' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'comment.kt' } + ] + } + ], - [{ - line: 'var x = /** start a Java Doc comment', - tokens: [ - { startIndex: 0, type: 'keyword.var.kt' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'identifier.kt' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'delimiter.kt' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'comment.doc.kt' } - ] - }, { - line: ' a ', - tokens: [ - { startIndex: 0, type: 'comment.doc.kt' } - ] - }, { - line: 'and end it */ 2', - tokens: [ - { startIndex: 0, type: 'comment.doc.kt' }, - { startIndex: 13, type: '' }, - { startIndex: 14, type: 'number.kt' }, - ] - }], + [ + { + line: 'var x = /** start a Java Doc comment', + tokens: [ + { startIndex: 0, type: 'keyword.var.kt' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'identifier.kt' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'delimiter.kt' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'comment.doc.kt' } + ] + }, + { + line: ' a ', + tokens: [{ startIndex: 0, type: 'comment.doc.kt' }] + }, + { + line: 'and end it */ 2', + tokens: [ + { startIndex: 0, type: 'comment.doc.kt' }, + { startIndex: 13, type: '' }, + { startIndex: 14, type: 'number.kt' } + ] + } + ], - [{ - line: '/** start of Java Doc', - tokens: [ - { startIndex: 0, type: 'comment.doc.kt' } - ] - }, { - line: 'a comment between without a star', - tokens: [ - { startIndex: 0, type: 'comment.doc.kt' } - ] - }, { - line: 'end of multiline comment*/', - tokens: [ - { startIndex: 0, type: 'comment.doc.kt' } - ] - }], + [ + { + line: '/** start of Java Doc', + tokens: [{ startIndex: 0, type: 'comment.doc.kt' }] + }, + { + line: 'a comment between without a star', + tokens: [{ startIndex: 0, type: 'comment.doc.kt' }] + }, + { + line: 'end of multiline comment*/', + tokens: [{ startIndex: 0, type: 'comment.doc.kt' }] + } + ], // Keywords - [{ - line: 'package test class Program { fun main(vararg args: String) {} } }', - tokens: [ - { startIndex: 0, type: 'keyword.package.kt' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'identifier.kt' }, - { startIndex: 12, type: '' }, - { startIndex: 13, type: 'keyword.class.kt' }, - { startIndex: 18, type: '' }, - { startIndex: 19, type: 'type.identifier.kt' }, - { startIndex: 26, type: '' }, - { startIndex: 27, type: 'delimiter.curly.kt' }, - { startIndex: 28, type: '' }, - { startIndex: 29, type: 'keyword.fun.kt' }, - { startIndex: 32, type: '' }, - { startIndex: 33, type: 'identifier.kt' }, - { startIndex: 37, type: 'delimiter.parenthesis.kt' }, - { startIndex: 38, type: 'keyword.vararg.kt' }, - { startIndex: 44, type: '' }, - { startIndex: 45, type: 'identifier.kt' }, - { startIndex: 49, type: 'delimiter.kt' }, - { startIndex: 50, type: '' }, - { startIndex: 51, type: 'type.identifier.kt' }, - { startIndex: 57, type: 'delimiter.parenthesis.kt' }, - { startIndex: 58, type: '' }, - { startIndex: 59, type: 'delimiter.curly.kt' }, - { startIndex: 61, type: '' }, - { startIndex: 62, type: 'delimiter.curly.kt' }, - { startIndex: 63, type: '' }, - { startIndex: 64, type: 'delimiter.curly.kt' } - ] - }], + [ + { + line: + 'package test class Program { fun main(vararg args: String) {} } }', + tokens: [ + { startIndex: 0, type: 'keyword.package.kt' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'identifier.kt' }, + { startIndex: 12, type: '' }, + { startIndex: 13, type: 'keyword.class.kt' }, + { startIndex: 18, type: '' }, + { startIndex: 19, type: 'type.identifier.kt' }, + { startIndex: 26, type: '' }, + { startIndex: 27, type: 'delimiter.curly.kt' }, + { startIndex: 28, type: '' }, + { startIndex: 29, type: 'keyword.fun.kt' }, + { startIndex: 32, type: '' }, + { startIndex: 33, type: 'identifier.kt' }, + { startIndex: 37, type: 'delimiter.parenthesis.kt' }, + { startIndex: 38, type: 'keyword.vararg.kt' }, + { startIndex: 44, type: '' }, + { startIndex: 45, type: 'identifier.kt' }, + { startIndex: 49, type: 'delimiter.kt' }, + { startIndex: 50, type: '' }, + { startIndex: 51, type: 'type.identifier.kt' }, + { startIndex: 57, type: 'delimiter.parenthesis.kt' }, + { startIndex: 58, type: '' }, + { startIndex: 59, type: 'delimiter.curly.kt' }, + { startIndex: 61, type: '' }, + { startIndex: 62, type: 'delimiter.curly.kt' }, + { startIndex: 63, type: '' }, + { startIndex: 64, type: 'delimiter.curly.kt' } + ] + } + ], // Numbers - [{ - line: '0', - tokens: [ - { startIndex: 0, type: 'number.kt' } - ] - }], + [ + { + line: '0', + tokens: [{ startIndex: 0, type: 'number.kt' }] + } + ], - [{ - line: '0.10', - tokens: [ - { startIndex: 0, type: 'number.float.kt' } - ] - }], + [ + { + line: '0.10', + tokens: [{ startIndex: 0, type: 'number.float.kt' }] + } + ], - [{ - line: '0x', - tokens: [ - { startIndex: 0, type: 'number.kt' }, - { startIndex: 1, type: 'identifier.kt' } - ] - }], + [ + { + line: '0x', + tokens: [ + { startIndex: 0, type: 'number.kt' }, + { startIndex: 1, type: 'identifier.kt' } + ] + } + ], - [{ - line: '0x123', - tokens: [ - { startIndex: 0, type: 'number.hex.kt' } - ] - }], + [ + { + line: '0x123', + tokens: [{ startIndex: 0, type: 'number.hex.kt' }] + } + ], - [{ - line: '0x5_2', - tokens: [ - { startIndex: 0, type: 'number.hex.kt' } - ] - }], + [ + { + line: '0x5_2', + tokens: [{ startIndex: 0, type: 'number.hex.kt' }] + } + ], - [{ - line: '023L', - tokens: [ - { startIndex: 0, type: 'number.octal.kt' } - ] - }], + [ + { + line: '023L', + tokens: [{ startIndex: 0, type: 'number.octal.kt' }] + } + ], - [{ - line: '0123l', - tokens: [ - { startIndex: 0, type: 'number.octal.kt' } - ] - }], + [ + { + line: '0123l', + tokens: [{ startIndex: 0, type: 'number.octal.kt' }] + } + ], - [{ - line: '05_2', - tokens: [ - { startIndex: 0, type: 'number.octal.kt' } - ] - }], + [ + { + line: '05_2', + tokens: [{ startIndex: 0, type: 'number.octal.kt' }] + } + ], - [{ - line: '0b1010_0101', - tokens: [ - { startIndex: 0, type: 'number.binary.kt' } - ] - }], + [ + { + line: '0b1010_0101', + tokens: [{ startIndex: 0, type: 'number.binary.kt' }] + } + ], - [{ - line: '0B001', - tokens: [ - { startIndex: 0, type: 'number.binary.kt' } - ] - }], + [ + { + line: '0B001', + tokens: [{ startIndex: 0, type: 'number.binary.kt' }] + } + ], - [{ - line: '10e3', - tokens: [ - { startIndex: 0, type: 'number.float.kt' } - ] - }], + [ + { + line: '10e3', + tokens: [{ startIndex: 0, type: 'number.float.kt' }] + } + ], - [{ - line: '10f', - tokens: [ - { startIndex: 0, type: 'number.float.kt' } - ] - }], + [ + { + line: '10f', + tokens: [{ startIndex: 0, type: 'number.float.kt' }] + } + ], - [{ - line: '23.5', - tokens: [ - { startIndex: 0, type: 'number.float.kt' } - ] - }], + [ + { + line: '23.5', + tokens: [{ startIndex: 0, type: 'number.float.kt' }] + } + ], - [{ - line: '23.5e3', - tokens: [ - { startIndex: 0, type: 'number.float.kt' } - ] - }], + [ + { + line: '23.5e3', + tokens: [{ startIndex: 0, type: 'number.float.kt' }] + } + ], - [{ - line: '23.5e-3', - tokens: [ - { startIndex: 0, type: 'number.float.kt' } - ] - }], + [ + { + line: '23.5e-3', + tokens: [{ startIndex: 0, type: 'number.float.kt' }] + } + ], - [{ - line: '23.5E3', - tokens: [ - { startIndex: 0, type: 'number.float.kt' } - ] - }], + [ + { + line: '23.5E3', + tokens: [{ startIndex: 0, type: 'number.float.kt' }] + } + ], - [{ - line: '23.5E-3', - tokens: [ - { startIndex: 0, type: 'number.float.kt' } - ] - }], + [ + { + line: '23.5E-3', + tokens: [{ startIndex: 0, type: 'number.float.kt' }] + } + ], - [{ - line: '23.5F', - tokens: [ - { startIndex: 0, type: 'number.float.kt' } - ] - }], + [ + { + line: '23.5F', + tokens: [{ startIndex: 0, type: 'number.float.kt' }] + } + ], - [{ - line: '23.5f', - tokens: [ - { startIndex: 0, type: 'number.float.kt' } - ] - }], + [ + { + line: '23.5f', + tokens: [{ startIndex: 0, type: 'number.float.kt' }] + } + ], - [{ - line: '23.5D', - tokens: [ - { startIndex: 0, type: 'number.float.kt' } - ] - }], + [ + { + line: '23.5D', + tokens: [{ startIndex: 0, type: 'number.float.kt' }] + } + ], - [{ - line: '23.5d', - tokens: [ - { startIndex: 0, type: 'number.float.kt' } - ] - }], + [ + { + line: '23.5d', + tokens: [{ startIndex: 0, type: 'number.float.kt' }] + } + ], - [{ - line: '1.72E3D', - tokens: [ - { startIndex: 0, type: 'number.float.kt' } - ] - }], + [ + { + line: '1.72E3D', + tokens: [{ startIndex: 0, type: 'number.float.kt' }] + } + ], - [{ - line: '1.72E3d', - tokens: [ - { startIndex: 0, type: 'number.float.kt' } - ] - }], + [ + { + line: '1.72E3d', + tokens: [{ startIndex: 0, type: 'number.float.kt' }] + } + ], - [{ - line: '1.72E-3d', - tokens: [ - { startIndex: 0, type: 'number.float.kt' } - ] - }], + [ + { + line: '1.72E-3d', + tokens: [{ startIndex: 0, type: 'number.float.kt' }] + } + ], - [{ - line: '1.72e3D', - tokens: [ - { startIndex: 0, type: 'number.float.kt' } - ] - }], + [ + { + line: '1.72e3D', + tokens: [{ startIndex: 0, type: 'number.float.kt' }] + } + ], - [{ - line: '1.72e3d', - tokens: [ - { startIndex: 0, type: 'number.float.kt' } - ] - }], + [ + { + line: '1.72e3d', + tokens: [{ startIndex: 0, type: 'number.float.kt' }] + } + ], - [{ - line: '1.72e-3d', - tokens: [ - { startIndex: 0, type: 'number.float.kt' } - ] - }], + [ + { + line: '1.72e-3d', + tokens: [{ startIndex: 0, type: 'number.float.kt' }] + } + ], - [{ - line: '23L', - tokens: [ - { startIndex: 0, type: 'number.kt' } - ] - }], + [ + { + line: '23L', + tokens: [{ startIndex: 0, type: 'number.kt' }] + } + ], - [{ - line: '23l', - tokens: [ - { startIndex: 0, type: 'number.kt' } - ] - }], + [ + { + line: '23l', + tokens: [{ startIndex: 0, type: 'number.kt' }] + } + ], - [{ - line: '0_52', - tokens: [ - { startIndex: 0, type: 'number.kt' } - ] - }], + [ + { + line: '0_52', + tokens: [{ startIndex: 0, type: 'number.kt' }] + } + ], - [{ - line: '5_2', - tokens: [ - { startIndex: 0, type: 'number.kt' } - ] - }], + [ + { + line: '5_2', + tokens: [{ startIndex: 0, type: 'number.kt' }] + } + ], - [{ - line: '5_______2', - tokens: [ - { startIndex: 0, type: 'number.kt' } - ] - }], + [ + { + line: '5_______2', + tokens: [{ startIndex: 0, type: 'number.kt' }] + } + ], - [{ - line: '3_.1415F', - tokens: [ - { startIndex: 0, type: 'number.kt' }, - { startIndex: 1, type: 'identifier.kt' }, - { startIndex: 2, type: 'delimiter.kt' }, - { startIndex: 3, type: 'number.float.kt' } - ] - }], + [ + { + line: '3_.1415F', + tokens: [ + { startIndex: 0, type: 'number.kt' }, + { startIndex: 1, type: 'identifier.kt' }, + { startIndex: 2, type: 'delimiter.kt' }, + { startIndex: 3, type: 'number.float.kt' } + ] + } + ], - [{ - line: '3._1415F', - tokens: [ - { startIndex: 0, type: 'number.kt' }, - { startIndex: 1, type: 'delimiter.kt' }, - { startIndex: 2, type: 'identifier.kt' } - ] - }], + [ + { + line: '3._1415F', + tokens: [ + { startIndex: 0, type: 'number.kt' }, + { startIndex: 1, type: 'delimiter.kt' }, + { startIndex: 2, type: 'identifier.kt' } + ] + } + ], - [{ - line: '999_99_9999_L', - tokens: [ - { startIndex: 0, type: 'number.kt' }, - { startIndex: 11, type: 'identifier.kt' } - ] - }], + [ + { + line: '999_99_9999_L', + tokens: [ + { startIndex: 0, type: 'number.kt' }, + { startIndex: 11, type: 'identifier.kt' } + ] + } + ], - [{ - line: '52_', - tokens: [ - { startIndex: 0, type: 'number.kt' }, - { startIndex: 2, type: 'identifier.kt' } - ] - }], + [ + { + line: '52_', + tokens: [ + { startIndex: 0, type: 'number.kt' }, + { startIndex: 2, type: 'identifier.kt' } + ] + } + ], - [{ - line: '0_x52', - tokens: [ - { startIndex: 0, type: 'number.kt' }, - { startIndex: 1, type: 'identifier.kt' } - ] - }], + [ + { + line: '0_x52', + tokens: [ + { startIndex: 0, type: 'number.kt' }, + { startIndex: 1, type: 'identifier.kt' } + ] + } + ], - [{ - line: '0x_52', - tokens: [ - { startIndex: 0, type: 'number.kt' }, - { startIndex: 1, type: 'identifier.kt' } - ] - }], + [ + { + line: '0x_52', + tokens: [ + { startIndex: 0, type: 'number.kt' }, + { startIndex: 1, type: 'identifier.kt' } + ] + } + ], - [{ - line: '0x52_', - tokens: [ - { startIndex: 0, type: 'number.hex.kt' }, - { startIndex: 4, type: 'identifier.kt' } - ] - }], + [ + { + line: '0x52_', + tokens: [ + { startIndex: 0, type: 'number.hex.kt' }, + { startIndex: 4, type: 'identifier.kt' } + ] + } + ], - [{ - line: '052_', - tokens: [ - { startIndex: 0, type: 'number.octal.kt' }, - { startIndex: 3, type: 'identifier.kt' } - ] - }], + [ + { + line: '052_', + tokens: [ + { startIndex: 0, type: 'number.octal.kt' }, + { startIndex: 3, type: 'identifier.kt' } + ] + } + ], - [{ - line: '0+0', - tokens: [ - { startIndex: 0, type: 'number.kt' }, - { startIndex: 1, type: 'delimiter.kt' }, - { startIndex: 2, type: 'number.kt' } - ] - }], + [ + { + line: '0+0', + tokens: [ + { startIndex: 0, type: 'number.kt' }, + { startIndex: 1, type: 'delimiter.kt' }, + { startIndex: 2, type: 'number.kt' } + ] + } + ], - [{ - line: '100+10', - tokens: [ - { startIndex: 0, type: 'number.kt' }, - { startIndex: 3, type: 'delimiter.kt' }, - { startIndex: 4, type: 'number.kt' } - ] - }], + [ + { + line: '100+10', + tokens: [ + { startIndex: 0, type: 'number.kt' }, + { startIndex: 3, type: 'delimiter.kt' }, + { startIndex: 4, type: 'number.kt' } + ] + } + ], - [{ - line: '0 + 0', - tokens: [ - { startIndex: 0, type: 'number.kt' }, - { startIndex: 1, type: '' }, - { startIndex: 2, type: 'delimiter.kt' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'number.kt' } - ] - }], + [ + { + line: '0 + 0', + tokens: [ + { startIndex: 0, type: 'number.kt' }, + { startIndex: 1, type: '' }, + { startIndex: 2, type: 'delimiter.kt' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'number.kt' } + ] + } + ], // single line Strings - [{ - line: 'var s = "I\'m a Kotlin String"', - tokens: [ - { startIndex: 0, type: 'keyword.var.kt' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'identifier.kt' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'delimiter.kt' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'string.kt' }, - ] - }], + [ + { + line: 'var s = "I\'m a Kotlin String"', + tokens: [ + { startIndex: 0, type: 'keyword.var.kt' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'identifier.kt' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'delimiter.kt' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'string.kt' } + ] + } + ], - [{ - line: 'var s = "concatenated" + " String"', - tokens: [ - { startIndex: 0, type: 'keyword.var.kt' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'identifier.kt' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'delimiter.kt' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'string.kt' }, - { startIndex: 22, type: '' }, - { startIndex: 23, type: 'delimiter.kt' }, - { startIndex: 24, type: '' }, - { startIndex: 25, type: 'string.kt' }, - ] - }], + [ + { + line: 'var s = "concatenated" + " String"', + tokens: [ + { startIndex: 0, type: 'keyword.var.kt' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'identifier.kt' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'delimiter.kt' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'string.kt' }, + { startIndex: 22, type: '' }, + { startIndex: 23, type: 'delimiter.kt' }, + { startIndex: 24, type: '' }, + { startIndex: 25, type: 'string.kt' } + ] + } + ], - [{ - line: '"quote in a string"', - tokens: [ - { startIndex: 0, type: 'string.kt' } - ] - }], + [ + { + line: '"quote in a string"', + tokens: [{ startIndex: 0, type: 'string.kt' }] + } + ], - [{ - line: '"escaping \\"quotes\\" is cool"', - tokens: [ - { startIndex: 0, type: 'string.kt' }, - { startIndex: 10, type: 'string.escape.kt' }, - { startIndex: 12, type: 'string.kt' }, - { startIndex: 18, type: 'string.escape.kt' }, - { startIndex: 20, type: 'string.kt' } - ] - }], + [ + { + line: '"escaping \\"quotes\\" is cool"', + tokens: [ + { startIndex: 0, type: 'string.kt' }, + { startIndex: 10, type: 'string.escape.kt' }, + { startIndex: 12, type: 'string.kt' }, + { startIndex: 18, type: 'string.escape.kt' }, + { startIndex: 20, type: 'string.kt' } + ] + } + ], - [{ - line: '"\\"', - tokens: [ - { startIndex: 0, type: 'string.invalid.kt' } - ] - }], + [ + { + line: '"\\"', + tokens: [{ startIndex: 0, type: 'string.invalid.kt' }] + } + ], // Annotations - [{ - line: '@', - tokens: [ - { startIndex: 0, type: '' } - ] - }], + [ + { + line: '@', + tokens: [{ startIndex: 0, type: '' }] + } + ], - [{ - line: '@Inject', - tokens: [ - { startIndex: 0, type: 'annotation.kt' } - ] - }], + [ + { + line: '@Inject', + tokens: [{ startIndex: 0, type: 'annotation.kt' }] + } + ], - [{ - line: '@SuppressWarnings("aString")', - tokens: [ - { startIndex: 0, type: 'annotation.kt' }, - { startIndex: 17, type: 'delimiter.parenthesis.kt' }, - { startIndex: 18, type: 'string.kt' }, - { startIndex: 27, type: 'delimiter.parenthesis.kt' } - ] - }], + [ + { + line: '@SuppressWarnings("aString")', + tokens: [ + { startIndex: 0, type: 'annotation.kt' }, + { startIndex: 17, type: 'delimiter.parenthesis.kt' }, + { startIndex: 18, type: 'string.kt' }, + { startIndex: 27, type: 'delimiter.parenthesis.kt' } + ] + } + ], - [{ - line: '@ AnnotationWithKeywordAfter private', - tokens: [ - { startIndex: 0, type: 'annotation.kt' }, - { startIndex: 28, type: '' }, - { startIndex: 29, type: 'keyword.private.kt' } - ] - }], + [ + { + line: '@ AnnotationWithKeywordAfter private', + tokens: [ + { startIndex: 0, type: 'annotation.kt' }, + { startIndex: 28, type: '' }, + { startIndex: 29, type: 'keyword.private.kt' } + ] + } + ], - [{ - line: 'fun /* /* */ */ main() {', - tokens: [ - { startIndex: 0, type: 'keyword.fun.kt' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'comment.kt' }, - { startIndex: 15, type: '' }, - { startIndex: 16, type: 'identifier.kt' }, - { startIndex: 20, type: 'delimiter.parenthesis.kt' }, - { startIndex: 22, type: '' }, - { startIndex: 23, type: 'delimiter.curly.kt' }, - ] - }], + [ + { + line: 'fun /* /* */ */ main() {', + tokens: [ + { startIndex: 0, type: 'keyword.fun.kt' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'comment.kt' }, + { startIndex: 15, type: '' }, + { startIndex: 16, type: 'identifier.kt' }, + { startIndex: 20, type: 'delimiter.parenthesis.kt' }, + { startIndex: 22, type: '' }, + { startIndex: 23, type: 'delimiter.curly.kt' } + ] + } + ], - [{ - line: 'val text = """', - tokens: [ - { startIndex: 0, type: 'keyword.val.kt' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'identifier.kt' }, - { startIndex: 8, type: '' }, - { startIndex: 9, type: 'delimiter.kt' }, - { startIndex: 10, type: '' }, - { startIndex: 11, type: 'string.kt' }, - ] - }, - { - line: ' for (c in "foo")', - tokens: [ - { startIndex: 0, type: 'string.kt' }, - ] - }, - { - line: ' print(c)', - tokens: [ - { startIndex: 0, type: 'string.kt' }, - ] - }, - { - line: '"""', - tokens: [ - { startIndex: 0, type: 'string.kt' }, - ] - }], + [ + { + line: 'val text = """', + tokens: [ + { startIndex: 0, type: 'keyword.val.kt' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'identifier.kt' }, + { startIndex: 8, type: '' }, + { startIndex: 9, type: 'delimiter.kt' }, + { startIndex: 10, type: '' }, + { startIndex: 11, type: 'string.kt' } + ] + }, + { + line: ' for (c in "foo")', + tokens: [{ startIndex: 0, type: 'string.kt' }] + }, + { + line: ' print(c)', + tokens: [{ startIndex: 0, type: 'string.kt' }] + }, + { + line: '"""', + tokens: [{ startIndex: 0, type: 'string.kt' }] + } + ] ]); diff --git a/src/kotlin/kotlin.ts b/src/kotlin/kotlin.ts index cc641134..ea84c5e6 100644 --- a/src/kotlin/kotlin.ts +++ b/src/kotlin/kotlin.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)|(?:))") + start: new RegExp( + '^\\s*//\\s*(?:(?:#?region\\b)|(?:))' + ) } } }; @@ -48,22 +52,125 @@ export const language = { 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 = { // 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 = { // 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 = { [/[;,.]/, 'delimiter'], // strings - [/"([^"\\]|\\.)*$/, 'string.invalid'], // non-teminated string + [/"([^"\\]|\\.)*$/, 'string.invalid'], // non-teminated string [/"""/, 'string', '@multistring'], [/"/, 'string', '@string'], @@ -132,7 +247,7 @@ export const language = { [/[ \t\r\n]+/, ''], [/\/\*\*(?!\/)/, 'comment.doc', '@javadoc'], [/\/\*/, 'comment', '@comment'], - [/\/\/.*$/, 'comment'], + [/\/\/.*$/, 'comment'] ], comment: [ @@ -144,7 +259,7 @@ export const language = { //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 = { [/\\./, 'string.escape.invalid'], [/"""/, 'string', '@pop'], [/./, 'string'] - ], - }, + ] + } }; diff --git a/src/less/less.test.ts b/src/less/less.test.ts index c3b3fd5e..f8e7215c 100644 --- a/src/less/less.test.ts +++ b/src/less/less.test.ts @@ -1,1400 +1,1568 @@ -/*--------------------------------------------------------------------------------------------- - * 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'; - -testTokenization(['less', 'javascript'], [ - - // Keywords - [{ - line: 'isnumber(10);', - tokens: [ - { startIndex: 0, type: 'keyword.less' }, - { startIndex: 8, type: 'delimiter.parenthesis.less' }, - { startIndex: 9, type: 'attribute.value.number.less' }, - { startIndex: 11, type: 'delimiter.parenthesis.less' }, - { startIndex: 12, type: 'delimiter.less' } - ] - }], - - [{ - line: 'iskeyword(@test) ;mix', - tokens: [ - { startIndex: 0, type: 'keyword.less' }, - { startIndex: 9, type: 'delimiter.parenthesis.less' }, - { startIndex: 10, type: 'variable.less' }, - { startIndex: 15, type: 'delimiter.parenthesis.less' }, - { startIndex: 16, type: '' }, - { startIndex: 17, type: 'delimiter.less' }, - { startIndex: 18, type: 'keyword.less' } - ] - }], - - [{ - line: 'whenn', - tokens: [ - { startIndex: 0, type: 'tag.less' }, - ] - }], - - [{ - line: ' round ', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 4, type: 'keyword.less' }, - { startIndex: 9, type: '' } - ] - }], - - // Units - [{ - line: 'isnumber(10px);', - tokens: [ - { startIndex: 0, type: 'keyword.less' }, - { startIndex: 8, type: 'delimiter.parenthesis.less' }, - { startIndex: 9, type: 'attribute.value.number.less' }, - { startIndex: 11, type: 'attribute.value.unit.less' }, - { startIndex: 13, type: 'delimiter.parenthesis.less' }, - { startIndex: 14, type: 'delimiter.less' } - ] - }], - - [{ - line: 'pxx ', - tokens: [ - { startIndex: 0, type: 'tag.less' }, - { startIndex: 3, type: '' } - ] - }], - - // single line Strings - [{ - line: '@test: "I\'m a LESS String\";', - tokens: [ - { startIndex: 0, type: 'variable.less' }, - { startIndex: 5, type: 'delimiter.less' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'string.delimiter.less' }, - { startIndex: 8, type: 'string.less' }, - { startIndex: 25, type: 'string.delimiter.less' }, - { startIndex: 26, type: 'delimiter.less' } - ] - }], - - [{ - line: '@test: "concatenated" + "String";', - tokens: [ - { startIndex: 0, type: 'variable.less' }, - { startIndex: 5, type: 'delimiter.less' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'string.delimiter.less' }, - { startIndex: 8, type: 'string.less' }, - { startIndex: 20, type: 'string.delimiter.less' }, - { startIndex: 21, type: '' }, - { startIndex: 22, type: 'operator.less' }, - { startIndex: 23, type: '' }, - { startIndex: 24, type: 'string.delimiter.less' }, - { startIndex: 25, type: 'string.less' }, - { startIndex: 31, type: 'string.delimiter.less' }, - { startIndex: 32, type: 'delimiter.less' } - ] - }], - - [{ - line: '@test: "quote in\'adasdsa\\"asd\' a string"', - tokens: [ - { startIndex: 0, type: 'variable.less' }, - { startIndex: 5, type: 'delimiter.less' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'string.delimiter.less' }, - { startIndex: 8, type: 'string.less' }, - { startIndex: 39, type: 'string.delimiter.less' }, - ] - }], - - [{ - line: '@test: \'doublequote in\"ada\\\'sds\\\'a\"asd a string\'', - tokens: [ - { startIndex: 0, type: 'variable.less' }, - { startIndex: 5, type: 'delimiter.less' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'string.delimiter.less' }, - { startIndex: 8, type: 'string.less' }, - { startIndex: 47, type: 'string.delimiter.less' } - ] - }], - - // Comments - range comment, multiple lines - [{ - line: '/* start of multiline comment', - tokens: [ - { startIndex: 0, type: 'comment.less' } - ] - }, { - line: 'a comment between without a star', - tokens: [ - { startIndex: 0, type: 'comment.less' } - ] - }, { - line: 'end of multiline comment*/', - tokens: [ - { startIndex: 0, type: 'comment.less' } - ] - }, { - line: 'when /* start a comment', - tokens: [ - { startIndex: 0, type: 'keyword.less' }, - { startIndex: 4, type: '' }, - { startIndex: 5, type: 'comment.less' }, - ] - }, { - line: ' a ', - tokens: [ - { startIndex: 0, type: 'comment.less' } - ] - }, { - line: 'and end it */ 2;', - tokens: [ - { startIndex: 0, type: 'comment.less' }, - { startIndex: 13, type: '' }, - { startIndex: 14, type: 'attribute.value.number.less' }, - { startIndex: 15, type: 'delimiter.less' } - ] - }], - - // Numbers - [{ - line: '0', - tokens: [ - { startIndex: 0, type: 'attribute.value.number.less' } - ] - }], - - [{ - line: ' 0', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 1, type: 'attribute.value.number.less' } - ] - }], - - [{ - line: ' 0 ', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 1, type: 'attribute.value.number.less' }, - { startIndex: 2, type: '' } - ] - }], - - [{ - line: '0 ', - tokens: [ - { startIndex: 0, type: 'attribute.value.number.less' }, - { startIndex: 1, type: '' } - ] - }], - - [{ - line: '@test: 0+0', - tokens: [ - { startIndex: 0, type: 'variable.less' }, - { startIndex: 5, type: 'delimiter.less' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'attribute.value.number.less' }, - { startIndex: 8, type: 'operator.less' }, - { startIndex: 9, type: 'attribute.value.number.less' } - ] - }], - - [{ - line: '@test: 100+10.00', - tokens: [ - { startIndex: 0, type: 'variable.less' }, - { startIndex: 5, type: 'delimiter.less' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'attribute.value.number.less' }, - { startIndex: 10, type: 'operator.less' }, - { startIndex: 11, type: 'attribute.value.number.less' } - ] - }], - - [{ - line: '@test: 0 + 0', - tokens: [ - { startIndex: 0, type: 'variable.less' }, - { startIndex: 5, type: 'delimiter.less' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'attribute.value.number.less' }, - { startIndex: 8, type: '' }, - { startIndex: 9, type: 'operator.less' }, - { startIndex: 10, type: '' }, - { startIndex: 11, type: 'attribute.value.number.less' } - ] - }], - - [{ - line: '0123', - tokens: [{ startIndex: 0, type: 'attribute.value.number.less' }] - }], - - [{ - line: '#012343', - tokens: [{ startIndex: 0, type: 'attribute.value.hex.less' }] - }], - - // Bracket Matching - [{ - line: '[1,2,3]', - tokens: [ - { startIndex: 0, type: 'delimiter.bracket.less' }, - { startIndex: 1, type: 'attribute.value.number.less' }, - { startIndex: 2, type: 'delimiter.less' }, - { startIndex: 3, type: 'attribute.value.number.less' }, - { startIndex: 4, type: 'delimiter.less' }, - { startIndex: 5, type: 'attribute.value.number.less' }, - { startIndex: 6, type: 'delimiter.bracket.less' } - ] - }], - - [{ - line: 'foo(123);', - tokens: [ - { startIndex: 0, type: 'tag.less' }, - { startIndex: 3, type: 'delimiter.parenthesis.less' }, - { startIndex: 4, type: 'attribute.value.number.less' }, - { startIndex: 7, type: 'delimiter.parenthesis.less' }, - { startIndex: 8, type: 'delimiter.less' } - ] - }], - - // No Bracket Matching inside strings - [{ - line: '@test: \'[{()}]\'', - tokens: [ - { startIndex: 0, type: 'variable.less' }, - { startIndex: 5, type: 'delimiter.less' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'string.delimiter.less' }, - { startIndex: 8, type: 'string.less' }, - { startIndex: 14, type: 'string.delimiter.less' } - ] - }], - - // Singleline Comments - [{ - line: '//', - tokens: [{ startIndex: 0, type: 'comment.less' }] - }], - - [{ - line: ' // a comment', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 4, type: 'comment.less' } - ] - }], - - [{ - line: '// a comment', - tokens: [{ startIndex: 0, type: 'comment.less' }] - }], - - [{ - line: '//sticky comment', - tokens: [{ startIndex: 0, type: 'comment.less' }] - }], - - [{ - line: '@something : 2; // my comment // this is a nice one', - tokens: [ - { startIndex: 0, type: 'variable.less' }, - { startIndex: 10, type: '' }, - { startIndex: 11, type: 'delimiter.less' }, - { startIndex: 12, type: '' }, - { startIndex: 13, type: 'attribute.value.number.less' }, - { startIndex: 14, type: 'delimiter.less' }, - { startIndex: 15, type: '' }, - { startIndex: 16, type: 'comment.less' } - ] - }], - - [{ - line: '.something(@some, @other) when (iscolor(@other)) { aname// my commen', - tokens: [ - { startIndex: 0, type: 'tag.class.less' }, - { startIndex: 10, type: 'delimiter.parenthesis.less' }, - { startIndex: 11, type: 'variable.less' }, - { startIndex: 16, type: 'delimiter.less' }, - { startIndex: 17, type: '' }, - { startIndex: 18, type: 'variable.less' }, - { startIndex: 24, type: 'delimiter.parenthesis.less' }, - { startIndex: 25, type: '' }, - { startIndex: 26, type: 'keyword.less' }, - { startIndex: 30, type: '' }, - { startIndex: 31, type: 'delimiter.parenthesis.less' }, - { startIndex: 32, type: 'keyword.less' }, - { startIndex: 39, type: 'delimiter.parenthesis.less' }, - { startIndex: 40, type: 'variable.less' }, - { startIndex: 46, type: 'delimiter.parenthesis.less' }, - { startIndex: 48, type: '' }, - { startIndex: 49, type: 'delimiter.curly.less' }, - { startIndex: 50, type: '' }, - { startIndex: 51, type: 'tag.less' }, - { startIndex: 56, type: 'comment.less' } - ] - }], - - [{ - line: '.something(@some//mycomment', - tokens: [ - { startIndex: 0, type: 'tag.class.less' }, - { startIndex: 10, type: 'delimiter.parenthesis.less' }, - { startIndex: 11, type: 'variable.less' }, - { startIndex: 16, type: 'comment.less' } - ] - }], - - [{ - line: '@something : #2;', - tokens: [ - { startIndex: 0, type: 'variable.less' }, - { startIndex: 10, type: '' }, - { startIndex: 11, type: 'delimiter.less' }, - { startIndex: 12, type: '' }, - { startIndex: 13, type: 'attribute.value.hex.less' }, - { startIndex: 15, type: 'delimiter.less' } - ] - }], - - // Singleline Range-Comments - [{ - line: '/*slcomment*/', - tokens: [{ startIndex: 0, type: 'comment.less' }] - }], - - [{ - line: '/* slcomment */', - tokens: [{ startIndex: 0, type: 'comment.less' }] - }], - - [{ - line: '/*sl/com* ment*/', - tokens: [{ startIndex: 0, type: 'comment.less' }] - }], - - [{ - line: '/**/', - tokens: [{ startIndex: 0, type: 'comment.less' }] - }], - - [{ - line: '@something: /*comm/* * /ent*/2;', - tokens: [ - { startIndex: 0, type: 'variable.less' }, - { startIndex: 10, type: 'delimiter.less' }, - { startIndex: 11, type: '' }, - { startIndex: 12, type: 'comment.less' }, - { startIndex: 29, type: 'attribute.value.number.less' }, - { startIndex: 30, type: 'delimiter.less' } - ] - }], - - [{ - line: '@something: /*comment*/ 2;', - tokens: [ - { startIndex: 0, type: 'variable.less' }, - { startIndex: 10, type: 'delimiter.less' }, - { startIndex: 11, type: '' }, - { startIndex: 12, type: 'comment.less' }, - { startIndex: 23, type: '' }, - { startIndex: 24, type: 'attribute.value.number.less' }, - { startIndex: 25, type: 'delimiter.less' } - ] - }], - - // Comments - range comment, multi lines - [{ - line: '/* a multiline comment', - tokens: [ - { startIndex: 0, type: 'comment.less' } - ] - }, { - line: 'can actually span', - tokens: [ - { startIndex: 0, type: 'comment.less' } - ] - }, { - line: 'multiple lines */', - tokens: [ - { startIndex: 0, type: 'comment.less' } - ] - }], - - [{ - line: '@some /* start a comment here', - tokens: [ - { startIndex: 0, type: 'variable.less' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'comment.less' } - ] - }, { - line: ' span over this line and ', - tokens: [ - { startIndex: 0, type: 'comment.less' } - ] - }, { - line: 'end it there */ : 2;', - tokens: [ - { startIndex: 0, type: 'comment.less' }, - { startIndex: 15, type: '' }, - { startIndex: 16, type: 'delimiter.less' }, - { startIndex: 17, type: '' }, - { startIndex: 18, type: 'attribute.value.number.less' }, - { startIndex: 19, type: 'delimiter.less' } - ] - }], - - // Escape Strings - [{ - line: '.class { filter: ~"ms:alwaysHasItsOwnSyntax.For.Stuff()";', - tokens: [ - { startIndex: 0, type: 'tag.class.less' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'delimiter.curly.less' }, - { startIndex: 8, type: '' }, - { startIndex: 9, type: 'attribute.name.less' }, - { startIndex: 15, type: 'delimiter.less' }, - { startIndex: 16, type: '' }, - { startIndex: 17, type: 'string.delimiter.less' }, - { startIndex: 19, type: 'string.less' }, - { startIndex: 55, type: 'string.delimiter.less' }, - { startIndex: 56, type: 'delimiter.less' } - ] - }], - - // Guards - [{ - line: '.class {.mixin (@a) when (@a > 10), (@a < -10) { }', - tokens: [ - { startIndex: 0, type: 'tag.class.less' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'delimiter.curly.less' }, - { startIndex: 8, type: 'tag.class.less' }, - { startIndex: 14, type: '' }, - { startIndex: 15, type: 'delimiter.parenthesis.less' }, - { startIndex: 16, type: 'variable.less' }, - { startIndex: 18, type: 'delimiter.parenthesis.less' }, - { startIndex: 19, type: '' }, - { startIndex: 20, type: 'keyword.less' }, - { startIndex: 24, type: '' }, - { startIndex: 25, type: 'delimiter.parenthesis.less' }, - { startIndex: 26, type: 'variable.less' }, - { startIndex: 28, type: '' }, - { startIndex: 29, type: 'operator.less' }, - { startIndex: 30, type: '' }, - { startIndex: 31, type: 'attribute.value.number.less' }, - { startIndex: 33, type: 'delimiter.parenthesis.less' }, - { startIndex: 34, type: 'delimiter.less' }, - { startIndex: 35, type: '' }, - { startIndex: 36, type: 'delimiter.parenthesis.less' }, - { startIndex: 37, type: 'variable.less' }, - { startIndex: 39, type: '' }, - { startIndex: 40, type: 'operator.less' }, - { startIndex: 41, type: '' }, - { startIndex: 42, type: 'operator.less' }, - { startIndex: 43, type: 'attribute.value.number.less' }, - { startIndex: 45, type: 'delimiter.parenthesis.less' }, - { startIndex: 46, type: '' }, - { startIndex: 47, type: 'delimiter.curly.less' }, - { startIndex: 48, type: '' }, - { startIndex: 49, type: 'delimiter.curly.less' } - ] - }], - - [{ - line: '.truth (@a) when (@a = true) { }', - tokens: [ - { startIndex: 0, type: 'tag.class.less' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'delimiter.parenthesis.less' }, - { startIndex: 8, type: 'variable.less' }, - { startIndex: 10, type: 'delimiter.parenthesis.less' }, - { startIndex: 11, type: '' }, - { startIndex: 12, type: 'keyword.less' }, - { startIndex: 16, type: '' }, - { startIndex: 17, type: 'delimiter.parenthesis.less' }, - { startIndex: 18, type: 'variable.less' }, - { startIndex: 20, type: '' }, - { startIndex: 21, type: 'operator.less' }, - { startIndex: 22, type: '' }, - { startIndex: 23, type: 'keyword.less' }, - { startIndex: 27, type: 'delimiter.parenthesis.less' }, - { startIndex: 28, type: '' }, - { startIndex: 29, type: 'delimiter.curly.less' }, - { startIndex: 30, type: '' }, - { startIndex: 31, type: 'delimiter.curly.less' } - ] - }], - - [{ - line: '.max (@a, @b) when (@a > @b) { width: @a; }', - tokens: [ - { startIndex: 0, type: 'tag.class.less' }, - { startIndex: 4, type: '' }, - { startIndex: 5, type: 'delimiter.parenthesis.less' }, - { startIndex: 6, type: 'variable.less' }, - { startIndex: 8, type: 'delimiter.less' }, - { startIndex: 9, type: '' }, - { startIndex: 10, type: 'variable.less' }, - { startIndex: 12, type: 'delimiter.parenthesis.less' }, - { startIndex: 13, type: '' }, - { startIndex: 14, type: 'keyword.less' }, - { startIndex: 18, type: '' }, - { startIndex: 19, type: 'delimiter.parenthesis.less' }, - { startIndex: 20, type: 'variable.less' }, - { startIndex: 22, type: '' }, - { startIndex: 23, type: 'operator.less' }, - { startIndex: 24, type: '' }, - { startIndex: 25, type: 'variable.less' }, - { startIndex: 27, type: 'delimiter.parenthesis.less' }, - { startIndex: 28, type: '' }, - { startIndex: 29, type: 'delimiter.curly.less' }, - { startIndex: 30, type: '' }, - { startIndex: 31, type: 'attribute.name.less' }, - { startIndex: 36, type: 'delimiter.less' }, - { startIndex: 37, type: '' }, - { startIndex: 38, type: 'variable.less' }, - { startIndex: 40, type: 'delimiter.less' }, - { startIndex: 41, type: '' }, - { startIndex: 42, type: 'delimiter.curly.less' } - ] - }], - - [{ - line: '.mixin (@a, @b: 0) when (isnumber(@b)) { }', - tokens: [ - { startIndex: 0, type: 'tag.class.less' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'delimiter.parenthesis.less' }, - { startIndex: 8, type: 'variable.less' }, - { startIndex: 10, type: 'delimiter.less' }, - { startIndex: 11, type: '' }, - { startIndex: 12, type: 'variable.less' }, - { startIndex: 14, type: 'delimiter.less' }, - { startIndex: 15, type: '' }, - { startIndex: 16, type: 'attribute.value.number.less' }, - { startIndex: 17, type: 'delimiter.parenthesis.less' }, - { startIndex: 18, type: '' }, - { startIndex: 19, type: 'keyword.less' }, - { startIndex: 23, type: '' }, - { startIndex: 24, type: 'delimiter.parenthesis.less' }, - { startIndex: 25, type: 'keyword.less' }, - { startIndex: 33, type: 'delimiter.parenthesis.less' }, - { startIndex: 34, type: 'variable.less' }, - { startIndex: 36, type: 'delimiter.parenthesis.less' }, - { startIndex: 38, type: '' }, - { startIndex: 39, type: 'delimiter.curly.less' }, - { startIndex: 40, type: '' }, - { startIndex: 41, type: 'delimiter.curly.less' } - ] - }], - - [{ - line: '.mixin (@a, @b: black) when (iscolor(@b)) { }', - tokens: [ - { startIndex: 0, type: 'tag.class.less' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'delimiter.parenthesis.less' }, - { startIndex: 8, type: 'variable.less' }, - { startIndex: 10, type: 'delimiter.less' }, - { startIndex: 11, type: '' }, - { startIndex: 12, type: 'variable.less' }, - { startIndex: 14, type: 'delimiter.less' }, - { startIndex: 15, type: '' }, - { startIndex: 16, type: 'attribute.value.less' }, - { startIndex: 21, type: 'delimiter.parenthesis.less' }, - { startIndex: 22, type: '' }, - { startIndex: 23, type: 'keyword.less' }, - { startIndex: 27, type: '' }, - { startIndex: 28, type: 'delimiter.parenthesis.less' }, - { startIndex: 29, type: 'keyword.less' }, - { startIndex: 36, type: 'delimiter.parenthesis.less' }, - { startIndex: 37, type: 'variable.less' }, - { startIndex: 39, type: 'delimiter.parenthesis.less' }, - { startIndex: 41, type: '' }, - { startIndex: 42, type: 'delimiter.curly.less' }, - { startIndex: 43, type: '' }, - { startIndex: 44, type: 'delimiter.curly.less' } - ] - }], - - // Nested JavaScript - [{ - line: '@test: `function display()` //works well', - tokens: [ - { startIndex: 0, type: 'variable.less' }, - { startIndex: 5, type: 'delimiter.less' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'delimiter.backtick.less' }, - { startIndex: 8, type: 'keyword.js' }, - { startIndex: 16, type: '' }, - { startIndex: 17, type: 'identifier.js' }, - { startIndex: 24, type: 'delimiter.parenthesis.js' }, - { startIndex: 26, type: 'delimiter.backtick.less' }, - { startIndex: 27, type: '' }, - { startIndex: 28, type: 'comment.less' } - ] - }], - - // Attribute in a .class(...) - [{ - line: '.box-shadow(inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(82,168,236,.6));', - tokens: [ - { startIndex: 0, type: 'tag.class.less' }, - { startIndex: 11, type: 'delimiter.parenthesis.less' }, - { startIndex: 12, type: 'attribute.value.less' }, - { startIndex: 17, type: '' }, - { startIndex: 18, type: 'attribute.value.number.less' }, - { startIndex: 19, type: '' }, - { startIndex: 20, type: 'attribute.value.number.less' }, - { startIndex: 21, type: 'attribute.value.unit.less' }, - { startIndex: 23, type: '' }, - { startIndex: 24, type: 'attribute.value.number.less' }, - { startIndex: 25, type: 'attribute.value.unit.less' }, - { startIndex: 27, type: '' }, - { startIndex: 28, type: 'attribute.value.less' }, - { startIndex: 32, type: 'delimiter.parenthesis.less' }, - { startIndex: 33, type: 'attribute.value.number.less' }, - { startIndex: 34, type: 'delimiter.less' }, - { startIndex: 35, type: 'attribute.value.number.less' }, - { startIndex: 36, type: 'delimiter.less' }, - { startIndex: 37, type: 'attribute.value.number.less' }, - { startIndex: 38, type: 'delimiter.less' }, - { startIndex: 39, type: 'attribute.value.number.less' }, - { startIndex: 43, type: 'delimiter.parenthesis.less' }, - { startIndex: 44, type: 'delimiter.less' }, - { startIndex: 45, type: '' }, - { startIndex: 46, type: 'attribute.value.number.less' }, - { startIndex: 47, type: '' }, - { startIndex: 48, type: 'attribute.value.number.less' }, - { startIndex: 49, type: '' }, - { startIndex: 50, type: 'attribute.value.number.less' }, - { startIndex: 51, type: 'attribute.value.unit.less' }, - { startIndex: 53, type: '' }, - { startIndex: 54, type: 'attribute.value.less' }, - { startIndex: 58, type: 'delimiter.parenthesis.less' }, - { startIndex: 59, type: 'attribute.value.number.less' }, - { startIndex: 61, type: 'delimiter.less' }, - { startIndex: 62, type: 'attribute.value.number.less' }, - { startIndex: 65, type: 'delimiter.less' }, - { startIndex: 66, type: 'attribute.value.number.less' }, - { startIndex: 69, type: 'delimiter.less' }, - { startIndex: 70, type: 'attribute.value.number.less' }, - { startIndex: 72, type: 'delimiter.parenthesis.less' }, - { startIndex: 74, type: 'delimiter.less' } - ] - }], - - // Difficult little bugs... => String mismatches - [{ - line: 'input[type="radio"]', - tokens: [ - { startIndex: 0, type: 'tag.less' }, - { startIndex: 5, type: 'delimiter.bracket.less' }, - { startIndex: 6, type: 'tag.less' }, - { startIndex: 10, type: 'operator.less' }, - { startIndex: 11, type: 'string.delimiter.less' }, - { startIndex: 12, type: 'string.less' }, - { startIndex: 17, type: 'string.delimiter.less' }, - { startIndex: 18, type: 'delimiter.bracket.less' } - ] - }], - - [{ - line: '~\'.offset@{index}\')', - tokens: [ - { startIndex: 0, type: 'string.delimiter.less' }, - { startIndex: 2, type: 'string.less' }, - { startIndex: 17, type: 'string.delimiter.less' }, - { startIndex: 18, type: 'delimiter.parenthesis.less' } - ] - }], - - [{ - line: 'some("\\42");', - tokens: [ - { startIndex: 0, type: 'tag.less' }, - { startIndex: 4, type: 'delimiter.parenthesis.less' }, - { startIndex: 5, type: 'string.delimiter.less' }, - { startIndex: 6, type: 'string.less' }, - { startIndex: 9, type: 'string.delimiter.less' }, - { startIndex: 10, type: 'delimiter.parenthesis.less' }, - { startIndex: 11, type: 'delimiter.less' } - ] - }], - - [{ - line: ' ~ "icon-"', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 1, type: 'operator.less' }, - { startIndex: 2, type: '' }, - { startIndex: 3, type: 'string.delimiter.less' }, - { startIndex: 4, type: 'string.less' }, - { startIndex: 9, type: 'string.delimiter.less' } - ] - }], - - // Difficult little bugs... => Operator mismatches - [{ - line: 'class^="icon-"', - tokens: [ - { startIndex: 0, type: 'tag.less' }, - { startIndex: 5, type: 'operator.less' }, - { startIndex: 7, type: 'string.delimiter.less' }, - { startIndex: 8, type: 'string.less' }, - { startIndex: 13, type: 'string.delimiter.less' } - ] - }], - - [{ - line: 'class*="icon-"', - tokens: [ - { startIndex: 0, type: 'tag.less' }, - { startIndex: 5, type: 'operator.less' }, - { startIndex: 7, type: 'string.delimiter.less' }, - { startIndex: 8, type: 'string.less' }, - { startIndex: 13, type: 'string.delimiter.less' } - ] - }], - - [{ - line: 'class~="icon-"', - tokens: [ - { startIndex: 0, type: 'tag.less' }, - { startIndex: 5, type: 'operator.less' }, - { startIndex: 7, type: 'string.delimiter.less' }, - { startIndex: 8, type: 'string.less' }, - { startIndex: 13, type: 'string.delimiter.less' } - ] - }], - - [{ - line: 'class ~ = "icon-"', - tokens: [ - { startIndex: 0, type: 'tag.less' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'operator.less' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'operator.less' }, - { startIndex: 9, type: '' }, - { startIndex: 10, type: 'string.delimiter.less' }, - { startIndex: 11, type: 'string.less' }, - { startIndex: 16, type: 'string.delimiter.less' } - ] - }], - - [{ - line: 'class|="icon-"', - tokens: [ - { startIndex: 0, type: 'tag.less' }, - { startIndex: 5, type: 'operator.less' }, - { startIndex: 7, type: 'string.delimiter.less' }, - { startIndex: 8, type: 'string.less' }, - { startIndex: 13, type: 'string.delimiter.less' } - ] - }], - - [{ - line: '.hide-text { font: 0/0 a; }', - tokens: [ - { startIndex: 0, type: 'tag.class.less' }, - { startIndex: 10, type: '' }, - { startIndex: 11, type: 'delimiter.curly.less' }, - { startIndex: 12, type: '' }, - { startIndex: 13, type: 'attribute.name.less' }, - { startIndex: 17, type: 'delimiter.less' }, - { startIndex: 18, type: '' }, - { startIndex: 19, type: 'attribute.value.number.less' }, - { startIndex: 20, type: 'operator.less' }, - { startIndex: 21, type: 'attribute.value.number.less' }, - { startIndex: 22, type: '' }, - { startIndex: 23, type: 'attribute.value.less' }, - { startIndex: 24, type: 'delimiter.less' }, - { startIndex: 25, type: '' }, - { startIndex: 26, type: 'delimiter.curly.less' } - ] - }], - - // Difficult little bugs... => Numbers in classes - [{ - line: '.translate3d(@x, @y, @z) { -webkit-transform: translate3d(@x, @y, @z); }', - tokens: [ - { startIndex: 0, type: 'tag.class.less' }, - { startIndex: 12, type: 'delimiter.parenthesis.less' }, - { startIndex: 13, type: 'variable.less' }, - { startIndex: 15, type: 'delimiter.less' }, - { startIndex: 16, type: '' }, - { startIndex: 17, type: 'variable.less' }, - { startIndex: 19, type: 'delimiter.less' }, - { startIndex: 20, type: '' }, - { startIndex: 21, type: 'variable.less' }, - { startIndex: 23, type: 'delimiter.parenthesis.less' }, - { startIndex: 24, type: '' }, - { startIndex: 25, type: 'delimiter.curly.less' }, - { startIndex: 26, type: '' }, - { startIndex: 27, type: 'attribute.name.less' }, - { startIndex: 44, type: 'delimiter.less' }, - { startIndex: 45, type: '' }, - { startIndex: 46, type: 'attribute.value.less' }, - { startIndex: 57, type: 'delimiter.parenthesis.less' }, - { startIndex: 58, type: 'variable.less' }, - { startIndex: 60, type: 'delimiter.less' }, - { startIndex: 61, type: '' }, - { startIndex: 62, type: 'variable.less' }, - { startIndex: 64, type: 'delimiter.less' }, - { startIndex: 65, type: '' }, - { startIndex: 66, type: 'variable.less' }, - { startIndex: 68, type: 'delimiter.parenthesis.less' }, - { startIndex: 69, type: 'delimiter.less' }, - { startIndex: 70, type: '' }, - { startIndex: 71, type: 'delimiter.curly.less' } - ] - }], - - // Difficult little bugs... => Generic mismatches, worst case... - [{ - line: '.dropdown-menu > li > a:hover > [class=" icon-"]', - tokens: [ - { startIndex: 0, type: 'tag.class.less' }, - { startIndex: 14, type: '' }, - { startIndex: 15, type: 'operator.less' }, - { startIndex: 16, type: '' }, - { startIndex: 17, type: 'tag.less' }, - { startIndex: 19, type: '' }, - { startIndex: 20, type: 'operator.less' }, - { startIndex: 21, type: '' }, - { startIndex: 22, type: 'tag.less' }, - { startIndex: 29, type: '' }, - { startIndex: 30, type: 'operator.less' }, - { startIndex: 31, type: '' }, - { startIndex: 32, type: 'delimiter.bracket.less' }, - { startIndex: 33, type: 'tag.less' }, - { startIndex: 38, type: 'operator.less' }, - { startIndex: 39, type: 'string.delimiter.less' }, - { startIndex: 40, type: 'string.less' }, - { startIndex: 46, type: 'string.delimiter.less' }, - { startIndex: 47, type: 'delimiter.bracket.less' } - ] - }], - - [{ - line: '.bw-gradient(@color: #F5F5F5, @start: 0, @stop: 255) { background: -webkit-gradient(color-stop(0, rgb(@start,@start,@start)), color-stop(1, rgb(@stop,@stop,@stop))); }', - tokens: [ - { startIndex: 0, type: 'tag.class.less' }, - { startIndex: 12, type: 'delimiter.parenthesis.less' }, - { startIndex: 13, type: 'variable.less' }, - { startIndex: 19, type: 'delimiter.less' }, - { startIndex: 20, type: '' }, - { startIndex: 21, type: 'attribute.value.hex.less' }, - { startIndex: 28, type: 'delimiter.less' }, - { startIndex: 29, type: '' }, - { startIndex: 30, type: 'variable.less' }, - { startIndex: 36, type: 'delimiter.less' }, - { startIndex: 37, type: '' }, - { startIndex: 38, type: 'attribute.value.number.less' }, - { startIndex: 39, type: 'delimiter.less' }, - { startIndex: 40, type: '' }, - { startIndex: 41, type: 'variable.less' }, - { startIndex: 46, type: 'delimiter.less' }, - { startIndex: 47, type: '' }, - { startIndex: 48, type: 'attribute.value.number.less' }, - { startIndex: 51, type: 'delimiter.parenthesis.less' }, - { startIndex: 52, type: '' }, - { startIndex: 53, type: 'delimiter.curly.less' }, - { startIndex: 54, type: '' }, - { startIndex: 55, type: 'attribute.name.less' }, - { startIndex: 65, type: 'delimiter.less' }, - { startIndex: 66, type: '' }, - { startIndex: 67, type: 'attribute.value.less' }, - { startIndex: 83, type: 'delimiter.parenthesis.less' }, - { startIndex: 84, type: 'attribute.value.less' }, - { startIndex: 94, type: 'delimiter.parenthesis.less' }, - { startIndex: 95, type: 'attribute.value.number.less' }, - { startIndex: 96, type: 'delimiter.less' }, - { startIndex: 97, type: '' }, - { startIndex: 98, type: 'attribute.value.less' }, - { startIndex: 101, type: 'delimiter.parenthesis.less' }, - { startIndex: 102, type: 'variable.less' }, - { startIndex: 108, type: 'delimiter.less' }, - { startIndex: 109, type: 'variable.less' }, - { startIndex: 115, type: 'delimiter.less' }, - { startIndex: 116, type: 'variable.less' }, - { startIndex: 122, type: 'delimiter.parenthesis.less' }, - { startIndex: 124, type: 'delimiter.less' }, - { startIndex: 125, type: '' }, - { startIndex: 126, type: 'attribute.value.less' }, - { startIndex: 136, type: 'delimiter.parenthesis.less' }, - { startIndex: 137, type: 'attribute.value.number.less' }, - { startIndex: 138, type: 'delimiter.less' }, - { startIndex: 139, type: '' }, - { startIndex: 140, type: 'attribute.value.less' }, - { startIndex: 143, type: 'delimiter.parenthesis.less' }, - { startIndex: 144, type: 'variable.less' }, - { startIndex: 149, type: 'delimiter.less' }, - { startIndex: 150, type: 'variable.less' }, - { startIndex: 155, type: 'delimiter.less' }, - { startIndex: 156, type: 'variable.less' }, - { startIndex: 161, type: 'delimiter.parenthesis.less' }, - { startIndex: 164, type: 'delimiter.less' }, - { startIndex: 165, type: '' }, - { startIndex: 166, type: 'delimiter.curly.less' } - ] - }], - - // Here CSS Tests from CSS File - // Skip whitespace - [{ - line: ' body ', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 6, type: 'tag.less' }, - { startIndex: 10, type: '' } - ] - }], - - // CSS rule - // body { - // margin: 0; - // padding: 3em 6em; - // font-family: tahoma, arial, sans-serif; - // text-decoration: none !important; - // color: #000 - // } - [{ - line: 'body {', - tokens: [ - { startIndex: 0, type: 'tag.less' }, - { startIndex: 4, type: '' }, - { startIndex: 5, type: 'delimiter.curly.less' } - ] - }, { - line: ' margin: 0;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'attribute.name.less' }, - { startIndex: 8, type: 'delimiter.less' }, - { startIndex: 9, type: '' }, - { startIndex: 10, type: 'attribute.value.number.less' }, - { startIndex: 11, type: 'delimiter.less' } - ] - }, { - line: ' padding: 3em 6em;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'attribute.name.less' }, - { startIndex: 9, type: 'delimiter.less' }, - { startIndex: 10, type: '' }, - { startIndex: 11, type: 'attribute.value.number.less' }, - { startIndex: 12, type: 'attribute.value.unit.less' }, - { startIndex: 14, type: '' }, - { startIndex: 15, type: 'attribute.value.number.less' }, - { startIndex: 16, type: 'attribute.value.unit.less' }, - { startIndex: 18, type: 'delimiter.less' } - ] - }, { - line: ' font-family: tahoma, arial, sans-serif;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'attribute.name.less' }, - { startIndex: 13, type: 'delimiter.less' }, - { startIndex: 14, type: '' }, - { startIndex: 15, type: 'attribute.value.less' }, - { startIndex: 21, type: 'delimiter.less' }, - { startIndex: 22, type: '' }, - { startIndex: 23, type: 'attribute.value.less' }, - { startIndex: 28, type: 'delimiter.less' }, - { startIndex: 29, type: '' }, - { startIndex: 30, type: 'attribute.value.less' }, - { startIndex: 40, type: 'delimiter.less' } - ] - }, { - line: ' text-decoration: none !important;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'attribute.name.less' }, - { startIndex: 17, type: 'delimiter.less' }, - { startIndex: 18, type: '' }, - { startIndex: 19, type: 'attribute.value.less' }, - { startIndex: 23, type: '' }, - { startIndex: 24, type: 'keyword.less' }, - { startIndex: 34, type: 'delimiter.less' } - ] - }, { - line: ' color: #000;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'attribute.name.less' }, - { startIndex: 7, type: 'delimiter.less' }, - { startIndex: 8, type: '' }, - { startIndex: 9, type: 'attribute.value.hex.less' }, - { startIndex: 13, type: 'delimiter.less' } - ] - }, { - line: ' }', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'delimiter.curly.less' } - ] - }], - - // CSS units and numbers - [{ - line: '* { padding: 3em -9pt -0.5px; }', - tokens: [ - { startIndex: 0, type: 'operator.less' }, - { startIndex: 1, type: '' }, - { startIndex: 2, type: 'delimiter.curly.less' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'attribute.name.less' }, - { startIndex: 11, type: 'delimiter.less' }, - { startIndex: 12, type: '' }, - { startIndex: 13, type: 'attribute.value.number.less' }, - { startIndex: 14, type: 'attribute.value.unit.less' }, - { startIndex: 16, type: '' }, - { startIndex: 17, type: 'operator.less' }, - { startIndex: 18, type: 'attribute.value.number.less' }, - { startIndex: 19, type: 'attribute.value.unit.less' }, - { startIndex: 21, type: '' }, - { startIndex: 22, type: 'operator.less' }, - { startIndex: 23, type: 'attribute.value.number.less' }, - { startIndex: 26, type: 'attribute.value.unit.less' }, - { startIndex: 28, type: 'delimiter.less' }, - { startIndex: 29, type: '' }, - { startIndex: 30, type: 'delimiter.curly.less' } - ] - }], - - // CSS single line comment - // h1 /*comment*/ p { - [{ - line: 'h1 /*comment*/ p {', - tokens: [ - { startIndex: 0, type: 'tag.less' }, - { startIndex: 2, type: '' }, - { startIndex: 3, type: 'comment.less' }, - { startIndex: 14, type: '' }, - { startIndex: 15, type: 'tag.less' }, - { startIndex: 16, type: '' }, - { startIndex: 17, type: 'delimiter.curly.less' } - ] - }], - - // CSS multi line comment - // h1 /*com - // ment*/ p { - [{ - line: 'h1 /*com', - tokens: [ - { startIndex: 0, type: 'tag.less' }, - { startIndex: 2, type: '' }, - { startIndex: 3, type: 'comment.less' } - ] - }, { - line: 'ment*/ p', - tokens: [ - { startIndex: 0, type: 'comment.less' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'tag.less' } - ] - }], - - // CSS ID rule - // #myID { - // font-size: 80%; - // content: 'contents'; - // } - [{ - line: '#myID {', - tokens: [ - { startIndex: 0, type: 'tag.id.less' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'delimiter.curly.less' } - ] - }], - - // CSS Class rules - // .myID { - // h1 > p { - [{ - line: '.myID {', - tokens: [ - { startIndex: 0, type: 'tag.class.less' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'delimiter.curly.less' } - ] - }], - - // CSS @import etc - // @import url('something.less'); { - [{ - line: '@import url(\"something.less\");', - tokens: [ - { startIndex: 0, type: 'keyword.less' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'tag.less' }, - { startIndex: 12, type: 'string.delimiter.less' }, - { startIndex: 13, type: 'string.less' }, - { startIndex: 27, type: 'string.delimiter.less' }, - { startIndex: 28, type: 'delimiter.parenthesis.less' }, - { startIndex: 29, type: 'delimiter.less' } - ] - }], - - // CSS multi-line string with an escaped newline - // body { - // content: 'con\ - // tent'; - [{ - line: 'body {', - tokens: [ - { startIndex: 0, type: 'tag.less' }, - { startIndex: 4, type: '' }, - { startIndex: 5, type: 'delimiter.curly.less' }, - ] - }, { - line: ' content: \"con\\', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'attribute.name.less' }, - { startIndex: 9, type: 'delimiter.less' }, - { startIndex: 10, type: '' }, - { startIndex: 11, type: 'string.delimiter.less' }, - { startIndex: 12, type: 'string.less' } - ] - }, { - line: 'tent\";', - tokens: [ - { startIndex: 0, type: 'string.less' }, - { startIndex: 4, type: 'string.delimiter.less' }, - { startIndex: 5, type: 'delimiter.less' } - ] - }], - - // CSS empty string value - // body { - // content: ''; - [{ - line: 'body {', - tokens: [ - { startIndex: 0, type: 'tag.less' }, - { startIndex: 4, type: '' }, - { startIndex: 5, type: 'delimiter.curly.less' }, - ] - }, { - line: ' content: \"\";', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'attribute.name.less' }, - { startIndex: 9, type: 'delimiter.less' }, - { startIndex: 10, type: '' }, - { startIndex: 11, type: 'string.delimiter.less' }, - { startIndex: 13, type: 'delimiter.less' } - ] - }], - - - // CSS font face - // @font-face { - // font-family: 'Opificio'; - // } - [{ - line: '@font-face {', - tokens: [ - { startIndex: 0, type: 'variable.less' }, - { startIndex: 10, type: '' }, - { startIndex: 11, type: 'delimiter.curly.less' } - ] - }, { - line: ' font-family: "Opificio";', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'attribute.name.less' }, - { startIndex: 13, type: 'delimiter.less' }, - { startIndex: 14, type: '' }, - { startIndex: 15, type: 'string.delimiter.less' }, - { startIndex: 16, type: 'string.less' }, - { startIndex: 24, type: 'string.delimiter.less' }, - { startIndex: 25, type: 'delimiter.less' } - ] - }], - - // CSS string with escaped quotes - // 's\"tr' - [{ - line: '"s\\"tr\\"sadsad', - tokens: [ - { startIndex: 0, type: 'string.delimiter.less' }, - { startIndex: 1, type: 'string.less' } - ] - }], - - // EG: Bracket Matching - [{ - line: 'p{}', - tokens: [ - { startIndex: 0, type: 'tag.less' }, - { startIndex: 1, type: 'delimiter.curly.less' }, - ] - }], - - [{ - line: 'p:nth() {}', - tokens: [ - { startIndex: 0, type: 'tag.less' }, - { startIndex: 5, type: 'delimiter.parenthesis.less' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'delimiter.curly.less' }, - ] - }], - - // EG: import statement - bug #10308 - // @import url('something.css');@import url('something.css'); - [{ - line: '@import url(\"something.css\");@import url(\"something.css\");', - tokens: [ - { startIndex: 0, type: 'keyword.less' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'tag.less' }, - { startIndex: 12, type: 'string.delimiter.less' }, - { startIndex: 13, type: 'string.less' }, - { startIndex: 26, type: 'string.delimiter.less' }, - { startIndex: 27, type: 'delimiter.parenthesis.less' }, - { startIndex: 28, type: 'delimiter.less' }, - { startIndex: 29, type: 'keyword.less' }, - { startIndex: 36, type: '' }, - { startIndex: 37, type: 'tag.less' }, - { startIndex: 41, type: 'string.delimiter.less' }, - { startIndex: 42, type: 'string.less' }, - { startIndex: 55, type: 'string.delimiter.less' }, - { startIndex: 56, type: 'delimiter.parenthesis.less' }, - { startIndex: 57, type: 'delimiter.less' } - ] - }], - - // EG: Triple quotes - bug #9870 - [{ - line: '""""', - tokens: [ - { startIndex: 0, type: 'string.delimiter.less' }, - ] - }], - - // EG: CSS @import related coloring bug 9553 - // @import url('something.css'); - // .rule1{} - // .rule2{} - [{ - line: '@import url("something.css");', - tokens: [ - { startIndex: 0, type: 'keyword.less' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'tag.less' }, - { startIndex: 12, type: 'string.delimiter.less' }, - { startIndex: 13, type: 'string.less' }, - { startIndex: 26, type: 'string.delimiter.less' }, - { startIndex: 27, type: 'delimiter.parenthesis.less' }, - { startIndex: 28, type: 'delimiter.less' } - ] - }, { - line: '.rule1{}', - tokens: [ - { startIndex: 0, type: 'tag.class.less' }, - { startIndex: 6, type: 'delimiter.curly.less' }, - ] - }, { - line: '.rule2{}', - tokens: [ - { startIndex: 0, type: 'tag.class.less' }, - { startIndex: 6, type: 'delimiter.curly.less' }, - ] - }], - - // EG: CSS key frame animation syntax - [{ - line: '@-webkit-keyframes infinite-spinning {', - tokens: [ - { startIndex: 0, type: 'variable.less' }, - { startIndex: 18, type: '' }, - { startIndex: 19, type: 'tag.less' }, - { startIndex: 36, type: '' }, - { startIndex: 37, type: 'delimiter.curly.less' } - ] - }, { - line: ' from {', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'tag.less' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'delimiter.curly.less' } - ] - }, { - line: ' -webkit-transform: rotate(0deg);', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'attribute.name.less' }, - { startIndex: 19, type: 'delimiter.less' }, - { startIndex: 20, type: '' }, - { startIndex: 21, type: 'attribute.value.less' }, - { startIndex: 27, type: 'delimiter.parenthesis.less' }, - { startIndex: 28, type: 'attribute.value.number.less' }, - { startIndex: 29, type: 'attribute.value.unit.less' }, - { startIndex: 32, type: 'delimiter.parenthesis.less' }, - { startIndex: 33, type: 'delimiter.less' } - ] - }, { - line: ' }', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'delimiter.curly.less' } - ] - }, { - line: ' to {', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'tag.less' }, - { startIndex: 4, type: '' }, - { startIndex: 5, type: 'delimiter.curly.less' } - ] - }, { - line: ' -webkit-transform: rotate(360deg);', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'attribute.name.less' }, - { startIndex: 19, type: 'delimiter.less' }, - { startIndex: 20, type: '' }, - { startIndex: 21, type: 'attribute.value.less' }, - { startIndex: 27, type: 'delimiter.parenthesis.less' }, - { startIndex: 28, type: 'attribute.value.number.less' }, - { startIndex: 31, type: 'attribute.value.unit.less' }, - { startIndex: 34, type: 'delimiter.parenthesis.less' }, - { startIndex: 35, type: 'delimiter.less' } - ] - }, { - line: ' }', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'delimiter.curly.less' } - ] - }, { - line: '}', - tokens: [ - { startIndex: 0, type: 'delimiter.curly.less' } - ] - }] -]); +/*--------------------------------------------------------------------------------------------- + * 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'; + +testTokenization( + ['less', 'javascript'], + [ + // Keywords + [ + { + line: 'isnumber(10);', + tokens: [ + { startIndex: 0, type: 'keyword.less' }, + { startIndex: 8, type: 'delimiter.parenthesis.less' }, + { startIndex: 9, type: 'attribute.value.number.less' }, + { startIndex: 11, type: 'delimiter.parenthesis.less' }, + { startIndex: 12, type: 'delimiter.less' } + ] + } + ], + + [ + { + line: 'iskeyword(@test) ;mix', + tokens: [ + { startIndex: 0, type: 'keyword.less' }, + { startIndex: 9, type: 'delimiter.parenthesis.less' }, + { startIndex: 10, type: 'variable.less' }, + { startIndex: 15, type: 'delimiter.parenthesis.less' }, + { startIndex: 16, type: '' }, + { startIndex: 17, type: 'delimiter.less' }, + { startIndex: 18, type: 'keyword.less' } + ] + } + ], + + [ + { + line: 'whenn', + tokens: [{ startIndex: 0, type: 'tag.less' }] + } + ], + + [ + { + line: ' round ', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 4, type: 'keyword.less' }, + { startIndex: 9, type: '' } + ] + } + ], + + // Units + [ + { + line: 'isnumber(10px);', + tokens: [ + { startIndex: 0, type: 'keyword.less' }, + { startIndex: 8, type: 'delimiter.parenthesis.less' }, + { startIndex: 9, type: 'attribute.value.number.less' }, + { startIndex: 11, type: 'attribute.value.unit.less' }, + { startIndex: 13, type: 'delimiter.parenthesis.less' }, + { startIndex: 14, type: 'delimiter.less' } + ] + } + ], + + [ + { + line: 'pxx ', + tokens: [ + { startIndex: 0, type: 'tag.less' }, + { startIndex: 3, type: '' } + ] + } + ], + + // single line Strings + [ + { + line: '@test: "I\'m a LESS String";', + tokens: [ + { startIndex: 0, type: 'variable.less' }, + { startIndex: 5, type: 'delimiter.less' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'string.delimiter.less' }, + { startIndex: 8, type: 'string.less' }, + { startIndex: 25, type: 'string.delimiter.less' }, + { startIndex: 26, type: 'delimiter.less' } + ] + } + ], + + [ + { + line: '@test: "concatenated" + "String";', + tokens: [ + { startIndex: 0, type: 'variable.less' }, + { startIndex: 5, type: 'delimiter.less' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'string.delimiter.less' }, + { startIndex: 8, type: 'string.less' }, + { startIndex: 20, type: 'string.delimiter.less' }, + { startIndex: 21, type: '' }, + { startIndex: 22, type: 'operator.less' }, + { startIndex: 23, type: '' }, + { startIndex: 24, type: 'string.delimiter.less' }, + { startIndex: 25, type: 'string.less' }, + { startIndex: 31, type: 'string.delimiter.less' }, + { startIndex: 32, type: 'delimiter.less' } + ] + } + ], + + [ + { + line: '@test: "quote in\'adasdsa\\"asd\' a string"', + tokens: [ + { startIndex: 0, type: 'variable.less' }, + { startIndex: 5, type: 'delimiter.less' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'string.delimiter.less' }, + { startIndex: 8, type: 'string.less' }, + { startIndex: 39, type: 'string.delimiter.less' } + ] + } + ], + + [ + { + line: "@test: 'doublequote in\"ada\\'sds\\'a\"asd a string'", + tokens: [ + { startIndex: 0, type: 'variable.less' }, + { startIndex: 5, type: 'delimiter.less' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'string.delimiter.less' }, + { startIndex: 8, type: 'string.less' }, + { startIndex: 47, type: 'string.delimiter.less' } + ] + } + ], + + // Comments - range comment, multiple lines + [ + { + line: '/* start of multiline comment', + tokens: [{ startIndex: 0, type: 'comment.less' }] + }, + { + line: 'a comment between without a star', + tokens: [{ startIndex: 0, type: 'comment.less' }] + }, + { + line: 'end of multiline comment*/', + tokens: [{ startIndex: 0, type: 'comment.less' }] + }, + { + line: 'when /* start a comment', + tokens: [ + { startIndex: 0, type: 'keyword.less' }, + { startIndex: 4, type: '' }, + { startIndex: 5, type: 'comment.less' } + ] + }, + { + line: ' a ', + tokens: [{ startIndex: 0, type: 'comment.less' }] + }, + { + line: 'and end it */ 2;', + tokens: [ + { startIndex: 0, type: 'comment.less' }, + { startIndex: 13, type: '' }, + { startIndex: 14, type: 'attribute.value.number.less' }, + { startIndex: 15, type: 'delimiter.less' } + ] + } + ], + + // Numbers + [ + { + line: '0', + tokens: [{ startIndex: 0, type: 'attribute.value.number.less' }] + } + ], + + [ + { + line: ' 0', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 1, type: 'attribute.value.number.less' } + ] + } + ], + + [ + { + line: ' 0 ', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 1, type: 'attribute.value.number.less' }, + { startIndex: 2, type: '' } + ] + } + ], + + [ + { + line: '0 ', + tokens: [ + { startIndex: 0, type: 'attribute.value.number.less' }, + { startIndex: 1, type: '' } + ] + } + ], + + [ + { + line: '@test: 0+0', + tokens: [ + { startIndex: 0, type: 'variable.less' }, + { startIndex: 5, type: 'delimiter.less' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'attribute.value.number.less' }, + { startIndex: 8, type: 'operator.less' }, + { startIndex: 9, type: 'attribute.value.number.less' } + ] + } + ], + + [ + { + line: '@test: 100+10.00', + tokens: [ + { startIndex: 0, type: 'variable.less' }, + { startIndex: 5, type: 'delimiter.less' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'attribute.value.number.less' }, + { startIndex: 10, type: 'operator.less' }, + { startIndex: 11, type: 'attribute.value.number.less' } + ] + } + ], + + [ + { + line: '@test: 0 + 0', + tokens: [ + { startIndex: 0, type: 'variable.less' }, + { startIndex: 5, type: 'delimiter.less' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'attribute.value.number.less' }, + { startIndex: 8, type: '' }, + { startIndex: 9, type: 'operator.less' }, + { startIndex: 10, type: '' }, + { startIndex: 11, type: 'attribute.value.number.less' } + ] + } + ], + + [ + { + line: '0123', + tokens: [{ startIndex: 0, type: 'attribute.value.number.less' }] + } + ], + + [ + { + line: '#012343', + tokens: [{ startIndex: 0, type: 'attribute.value.hex.less' }] + } + ], + + // Bracket Matching + [ + { + line: '[1,2,3]', + tokens: [ + { startIndex: 0, type: 'delimiter.bracket.less' }, + { startIndex: 1, type: 'attribute.value.number.less' }, + { startIndex: 2, type: 'delimiter.less' }, + { startIndex: 3, type: 'attribute.value.number.less' }, + { startIndex: 4, type: 'delimiter.less' }, + { startIndex: 5, type: 'attribute.value.number.less' }, + { startIndex: 6, type: 'delimiter.bracket.less' } + ] + } + ], + + [ + { + line: 'foo(123);', + tokens: [ + { startIndex: 0, type: 'tag.less' }, + { startIndex: 3, type: 'delimiter.parenthesis.less' }, + { startIndex: 4, type: 'attribute.value.number.less' }, + { startIndex: 7, type: 'delimiter.parenthesis.less' }, + { startIndex: 8, type: 'delimiter.less' } + ] + } + ], + + // No Bracket Matching inside strings + [ + { + line: "@test: '[{()}]'", + tokens: [ + { startIndex: 0, type: 'variable.less' }, + { startIndex: 5, type: 'delimiter.less' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'string.delimiter.less' }, + { startIndex: 8, type: 'string.less' }, + { startIndex: 14, type: 'string.delimiter.less' } + ] + } + ], + + // Singleline Comments + [ + { + line: '//', + tokens: [{ startIndex: 0, type: 'comment.less' }] + } + ], + + [ + { + line: ' // a comment', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 4, type: 'comment.less' } + ] + } + ], + + [ + { + line: '// a comment', + tokens: [{ startIndex: 0, type: 'comment.less' }] + } + ], + + [ + { + line: '//sticky comment', + tokens: [{ startIndex: 0, type: 'comment.less' }] + } + ], + + [ + { + line: '@something : 2; // my comment // this is a nice one', + tokens: [ + { startIndex: 0, type: 'variable.less' }, + { startIndex: 10, type: '' }, + { startIndex: 11, type: 'delimiter.less' }, + { startIndex: 12, type: '' }, + { startIndex: 13, type: 'attribute.value.number.less' }, + { startIndex: 14, type: 'delimiter.less' }, + { startIndex: 15, type: '' }, + { startIndex: 16, type: 'comment.less' } + ] + } + ], + + [ + { + line: + '.something(@some, @other) when (iscolor(@other)) { aname// my commen', + tokens: [ + { startIndex: 0, type: 'tag.class.less' }, + { startIndex: 10, type: 'delimiter.parenthesis.less' }, + { startIndex: 11, type: 'variable.less' }, + { startIndex: 16, type: 'delimiter.less' }, + { startIndex: 17, type: '' }, + { startIndex: 18, type: 'variable.less' }, + { startIndex: 24, type: 'delimiter.parenthesis.less' }, + { startIndex: 25, type: '' }, + { startIndex: 26, type: 'keyword.less' }, + { startIndex: 30, type: '' }, + { startIndex: 31, type: 'delimiter.parenthesis.less' }, + { startIndex: 32, type: 'keyword.less' }, + { startIndex: 39, type: 'delimiter.parenthesis.less' }, + { startIndex: 40, type: 'variable.less' }, + { startIndex: 46, type: 'delimiter.parenthesis.less' }, + { startIndex: 48, type: '' }, + { startIndex: 49, type: 'delimiter.curly.less' }, + { startIndex: 50, type: '' }, + { startIndex: 51, type: 'tag.less' }, + { startIndex: 56, type: 'comment.less' } + ] + } + ], + + [ + { + line: '.something(@some//mycomment', + tokens: [ + { startIndex: 0, type: 'tag.class.less' }, + { startIndex: 10, type: 'delimiter.parenthesis.less' }, + { startIndex: 11, type: 'variable.less' }, + { startIndex: 16, type: 'comment.less' } + ] + } + ], + + [ + { + line: '@something : #2;', + tokens: [ + { startIndex: 0, type: 'variable.less' }, + { startIndex: 10, type: '' }, + { startIndex: 11, type: 'delimiter.less' }, + { startIndex: 12, type: '' }, + { startIndex: 13, type: 'attribute.value.hex.less' }, + { startIndex: 15, type: 'delimiter.less' } + ] + } + ], + + // Singleline Range-Comments + [ + { + line: '/*slcomment*/', + tokens: [{ startIndex: 0, type: 'comment.less' }] + } + ], + + [ + { + line: '/* slcomment */', + tokens: [{ startIndex: 0, type: 'comment.less' }] + } + ], + + [ + { + line: '/*sl/com* ment*/', + tokens: [{ startIndex: 0, type: 'comment.less' }] + } + ], + + [ + { + line: '/**/', + tokens: [{ startIndex: 0, type: 'comment.less' }] + } + ], + + [ + { + line: '@something: /*comm/* * /ent*/2;', + tokens: [ + { startIndex: 0, type: 'variable.less' }, + { startIndex: 10, type: 'delimiter.less' }, + { startIndex: 11, type: '' }, + { startIndex: 12, type: 'comment.less' }, + { startIndex: 29, type: 'attribute.value.number.less' }, + { startIndex: 30, type: 'delimiter.less' } + ] + } + ], + + [ + { + line: '@something: /*comment*/ 2;', + tokens: [ + { startIndex: 0, type: 'variable.less' }, + { startIndex: 10, type: 'delimiter.less' }, + { startIndex: 11, type: '' }, + { startIndex: 12, type: 'comment.less' }, + { startIndex: 23, type: '' }, + { startIndex: 24, type: 'attribute.value.number.less' }, + { startIndex: 25, type: 'delimiter.less' } + ] + } + ], + + // Comments - range comment, multi lines + [ + { + line: '/* a multiline comment', + tokens: [{ startIndex: 0, type: 'comment.less' }] + }, + { + line: 'can actually span', + tokens: [{ startIndex: 0, type: 'comment.less' }] + }, + { + line: 'multiple lines */', + tokens: [{ startIndex: 0, type: 'comment.less' }] + } + ], + + [ + { + line: '@some /* start a comment here', + tokens: [ + { startIndex: 0, type: 'variable.less' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'comment.less' } + ] + }, + { + line: ' span over this line and ', + tokens: [{ startIndex: 0, type: 'comment.less' }] + }, + { + line: 'end it there */ : 2;', + tokens: [ + { startIndex: 0, type: 'comment.less' }, + { startIndex: 15, type: '' }, + { startIndex: 16, type: 'delimiter.less' }, + { startIndex: 17, type: '' }, + { startIndex: 18, type: 'attribute.value.number.less' }, + { startIndex: 19, type: 'delimiter.less' } + ] + } + ], + + // Escape Strings + [ + { + line: + '.class { filter: ~"ms:alwaysHasItsOwnSyntax.For.Stuff()";', + tokens: [ + { startIndex: 0, type: 'tag.class.less' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'delimiter.curly.less' }, + { startIndex: 8, type: '' }, + { startIndex: 9, type: 'attribute.name.less' }, + { startIndex: 15, type: 'delimiter.less' }, + { startIndex: 16, type: '' }, + { startIndex: 17, type: 'string.delimiter.less' }, + { startIndex: 19, type: 'string.less' }, + { startIndex: 55, type: 'string.delimiter.less' }, + { startIndex: 56, type: 'delimiter.less' } + ] + } + ], + + // Guards + [ + { + line: '.class {.mixin (@a) when (@a > 10), (@a < -10) { }', + tokens: [ + { startIndex: 0, type: 'tag.class.less' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'delimiter.curly.less' }, + { startIndex: 8, type: 'tag.class.less' }, + { startIndex: 14, type: '' }, + { startIndex: 15, type: 'delimiter.parenthesis.less' }, + { startIndex: 16, type: 'variable.less' }, + { startIndex: 18, type: 'delimiter.parenthesis.less' }, + { startIndex: 19, type: '' }, + { startIndex: 20, type: 'keyword.less' }, + { startIndex: 24, type: '' }, + { startIndex: 25, type: 'delimiter.parenthesis.less' }, + { startIndex: 26, type: 'variable.less' }, + { startIndex: 28, type: '' }, + { startIndex: 29, type: 'operator.less' }, + { startIndex: 30, type: '' }, + { startIndex: 31, type: 'attribute.value.number.less' }, + { startIndex: 33, type: 'delimiter.parenthesis.less' }, + { startIndex: 34, type: 'delimiter.less' }, + { startIndex: 35, type: '' }, + { startIndex: 36, type: 'delimiter.parenthesis.less' }, + { startIndex: 37, type: 'variable.less' }, + { startIndex: 39, type: '' }, + { startIndex: 40, type: 'operator.less' }, + { startIndex: 41, type: '' }, + { startIndex: 42, type: 'operator.less' }, + { startIndex: 43, type: 'attribute.value.number.less' }, + { startIndex: 45, type: 'delimiter.parenthesis.less' }, + { startIndex: 46, type: '' }, + { startIndex: 47, type: 'delimiter.curly.less' }, + { startIndex: 48, type: '' }, + { startIndex: 49, type: 'delimiter.curly.less' } + ] + } + ], + + [ + { + line: '.truth (@a) when (@a = true) { }', + tokens: [ + { startIndex: 0, type: 'tag.class.less' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'delimiter.parenthesis.less' }, + { startIndex: 8, type: 'variable.less' }, + { startIndex: 10, type: 'delimiter.parenthesis.less' }, + { startIndex: 11, type: '' }, + { startIndex: 12, type: 'keyword.less' }, + { startIndex: 16, type: '' }, + { startIndex: 17, type: 'delimiter.parenthesis.less' }, + { startIndex: 18, type: 'variable.less' }, + { startIndex: 20, type: '' }, + { startIndex: 21, type: 'operator.less' }, + { startIndex: 22, type: '' }, + { startIndex: 23, type: 'keyword.less' }, + { startIndex: 27, type: 'delimiter.parenthesis.less' }, + { startIndex: 28, type: '' }, + { startIndex: 29, type: 'delimiter.curly.less' }, + { startIndex: 30, type: '' }, + { startIndex: 31, type: 'delimiter.curly.less' } + ] + } + ], + + [ + { + line: '.max (@a, @b) when (@a > @b) { width: @a; }', + tokens: [ + { startIndex: 0, type: 'tag.class.less' }, + { startIndex: 4, type: '' }, + { startIndex: 5, type: 'delimiter.parenthesis.less' }, + { startIndex: 6, type: 'variable.less' }, + { startIndex: 8, type: 'delimiter.less' }, + { startIndex: 9, type: '' }, + { startIndex: 10, type: 'variable.less' }, + { startIndex: 12, type: 'delimiter.parenthesis.less' }, + { startIndex: 13, type: '' }, + { startIndex: 14, type: 'keyword.less' }, + { startIndex: 18, type: '' }, + { startIndex: 19, type: 'delimiter.parenthesis.less' }, + { startIndex: 20, type: 'variable.less' }, + { startIndex: 22, type: '' }, + { startIndex: 23, type: 'operator.less' }, + { startIndex: 24, type: '' }, + { startIndex: 25, type: 'variable.less' }, + { startIndex: 27, type: 'delimiter.parenthesis.less' }, + { startIndex: 28, type: '' }, + { startIndex: 29, type: 'delimiter.curly.less' }, + { startIndex: 30, type: '' }, + { startIndex: 31, type: 'attribute.name.less' }, + { startIndex: 36, type: 'delimiter.less' }, + { startIndex: 37, type: '' }, + { startIndex: 38, type: 'variable.less' }, + { startIndex: 40, type: 'delimiter.less' }, + { startIndex: 41, type: '' }, + { startIndex: 42, type: 'delimiter.curly.less' } + ] + } + ], + + [ + { + line: '.mixin (@a, @b: 0) when (isnumber(@b)) { }', + tokens: [ + { startIndex: 0, type: 'tag.class.less' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'delimiter.parenthesis.less' }, + { startIndex: 8, type: 'variable.less' }, + { startIndex: 10, type: 'delimiter.less' }, + { startIndex: 11, type: '' }, + { startIndex: 12, type: 'variable.less' }, + { startIndex: 14, type: 'delimiter.less' }, + { startIndex: 15, type: '' }, + { startIndex: 16, type: 'attribute.value.number.less' }, + { startIndex: 17, type: 'delimiter.parenthesis.less' }, + { startIndex: 18, type: '' }, + { startIndex: 19, type: 'keyword.less' }, + { startIndex: 23, type: '' }, + { startIndex: 24, type: 'delimiter.parenthesis.less' }, + { startIndex: 25, type: 'keyword.less' }, + { startIndex: 33, type: 'delimiter.parenthesis.less' }, + { startIndex: 34, type: 'variable.less' }, + { startIndex: 36, type: 'delimiter.parenthesis.less' }, + { startIndex: 38, type: '' }, + { startIndex: 39, type: 'delimiter.curly.less' }, + { startIndex: 40, type: '' }, + { startIndex: 41, type: 'delimiter.curly.less' } + ] + } + ], + + [ + { + line: '.mixin (@a, @b: black) when (iscolor(@b)) { }', + tokens: [ + { startIndex: 0, type: 'tag.class.less' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'delimiter.parenthesis.less' }, + { startIndex: 8, type: 'variable.less' }, + { startIndex: 10, type: 'delimiter.less' }, + { startIndex: 11, type: '' }, + { startIndex: 12, type: 'variable.less' }, + { startIndex: 14, type: 'delimiter.less' }, + { startIndex: 15, type: '' }, + { startIndex: 16, type: 'attribute.value.less' }, + { startIndex: 21, type: 'delimiter.parenthesis.less' }, + { startIndex: 22, type: '' }, + { startIndex: 23, type: 'keyword.less' }, + { startIndex: 27, type: '' }, + { startIndex: 28, type: 'delimiter.parenthesis.less' }, + { startIndex: 29, type: 'keyword.less' }, + { startIndex: 36, type: 'delimiter.parenthesis.less' }, + { startIndex: 37, type: 'variable.less' }, + { startIndex: 39, type: 'delimiter.parenthesis.less' }, + { startIndex: 41, type: '' }, + { startIndex: 42, type: 'delimiter.curly.less' }, + { startIndex: 43, type: '' }, + { startIndex: 44, type: 'delimiter.curly.less' } + ] + } + ], + + // Nested JavaScript + [ + { + line: '@test: `function display()` //works well', + tokens: [ + { startIndex: 0, type: 'variable.less' }, + { startIndex: 5, type: 'delimiter.less' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'delimiter.backtick.less' }, + { startIndex: 8, type: 'keyword.js' }, + { startIndex: 16, type: '' }, + { startIndex: 17, type: 'identifier.js' }, + { startIndex: 24, type: 'delimiter.parenthesis.js' }, + { startIndex: 26, type: 'delimiter.backtick.less' }, + { startIndex: 27, type: '' }, + { startIndex: 28, type: 'comment.less' } + ] + } + ], + + // Attribute in a .class(...) + [ + { + line: + '.box-shadow(inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(82,168,236,.6));', + tokens: [ + { startIndex: 0, type: 'tag.class.less' }, + { startIndex: 11, type: 'delimiter.parenthesis.less' }, + { startIndex: 12, type: 'attribute.value.less' }, + { startIndex: 17, type: '' }, + { startIndex: 18, type: 'attribute.value.number.less' }, + { startIndex: 19, type: '' }, + { startIndex: 20, type: 'attribute.value.number.less' }, + { startIndex: 21, type: 'attribute.value.unit.less' }, + { startIndex: 23, type: '' }, + { startIndex: 24, type: 'attribute.value.number.less' }, + { startIndex: 25, type: 'attribute.value.unit.less' }, + { startIndex: 27, type: '' }, + { startIndex: 28, type: 'attribute.value.less' }, + { startIndex: 32, type: 'delimiter.parenthesis.less' }, + { startIndex: 33, type: 'attribute.value.number.less' }, + { startIndex: 34, type: 'delimiter.less' }, + { startIndex: 35, type: 'attribute.value.number.less' }, + { startIndex: 36, type: 'delimiter.less' }, + { startIndex: 37, type: 'attribute.value.number.less' }, + { startIndex: 38, type: 'delimiter.less' }, + { startIndex: 39, type: 'attribute.value.number.less' }, + { startIndex: 43, type: 'delimiter.parenthesis.less' }, + { startIndex: 44, type: 'delimiter.less' }, + { startIndex: 45, type: '' }, + { startIndex: 46, type: 'attribute.value.number.less' }, + { startIndex: 47, type: '' }, + { startIndex: 48, type: 'attribute.value.number.less' }, + { startIndex: 49, type: '' }, + { startIndex: 50, type: 'attribute.value.number.less' }, + { startIndex: 51, type: 'attribute.value.unit.less' }, + { startIndex: 53, type: '' }, + { startIndex: 54, type: 'attribute.value.less' }, + { startIndex: 58, type: 'delimiter.parenthesis.less' }, + { startIndex: 59, type: 'attribute.value.number.less' }, + { startIndex: 61, type: 'delimiter.less' }, + { startIndex: 62, type: 'attribute.value.number.less' }, + { startIndex: 65, type: 'delimiter.less' }, + { startIndex: 66, type: 'attribute.value.number.less' }, + { startIndex: 69, type: 'delimiter.less' }, + { startIndex: 70, type: 'attribute.value.number.less' }, + { startIndex: 72, type: 'delimiter.parenthesis.less' }, + { startIndex: 74, type: 'delimiter.less' } + ] + } + ], + + // Difficult little bugs... => String mismatches + [ + { + line: 'input[type="radio"]', + tokens: [ + { startIndex: 0, type: 'tag.less' }, + { startIndex: 5, type: 'delimiter.bracket.less' }, + { startIndex: 6, type: 'tag.less' }, + { startIndex: 10, type: 'operator.less' }, + { startIndex: 11, type: 'string.delimiter.less' }, + { startIndex: 12, type: 'string.less' }, + { startIndex: 17, type: 'string.delimiter.less' }, + { startIndex: 18, type: 'delimiter.bracket.less' } + ] + } + ], + + [ + { + line: "~'.offset@{index}')", + tokens: [ + { startIndex: 0, type: 'string.delimiter.less' }, + { startIndex: 2, type: 'string.less' }, + { startIndex: 17, type: 'string.delimiter.less' }, + { startIndex: 18, type: 'delimiter.parenthesis.less' } + ] + } + ], + + [ + { + line: 'some("\\42");', + tokens: [ + { startIndex: 0, type: 'tag.less' }, + { startIndex: 4, type: 'delimiter.parenthesis.less' }, + { startIndex: 5, type: 'string.delimiter.less' }, + { startIndex: 6, type: 'string.less' }, + { startIndex: 9, type: 'string.delimiter.less' }, + { startIndex: 10, type: 'delimiter.parenthesis.less' }, + { startIndex: 11, type: 'delimiter.less' } + ] + } + ], + + [ + { + line: ' ~ "icon-"', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 1, type: 'operator.less' }, + { startIndex: 2, type: '' }, + { startIndex: 3, type: 'string.delimiter.less' }, + { startIndex: 4, type: 'string.less' }, + { startIndex: 9, type: 'string.delimiter.less' } + ] + } + ], + + // Difficult little bugs... => Operator mismatches + [ + { + line: 'class^="icon-"', + tokens: [ + { startIndex: 0, type: 'tag.less' }, + { startIndex: 5, type: 'operator.less' }, + { startIndex: 7, type: 'string.delimiter.less' }, + { startIndex: 8, type: 'string.less' }, + { startIndex: 13, type: 'string.delimiter.less' } + ] + } + ], + + [ + { + line: 'class*="icon-"', + tokens: [ + { startIndex: 0, type: 'tag.less' }, + { startIndex: 5, type: 'operator.less' }, + { startIndex: 7, type: 'string.delimiter.less' }, + { startIndex: 8, type: 'string.less' }, + { startIndex: 13, type: 'string.delimiter.less' } + ] + } + ], + + [ + { + line: 'class~="icon-"', + tokens: [ + { startIndex: 0, type: 'tag.less' }, + { startIndex: 5, type: 'operator.less' }, + { startIndex: 7, type: 'string.delimiter.less' }, + { startIndex: 8, type: 'string.less' }, + { startIndex: 13, type: 'string.delimiter.less' } + ] + } + ], + + [ + { + line: 'class ~ = "icon-"', + tokens: [ + { startIndex: 0, type: 'tag.less' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'operator.less' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'operator.less' }, + { startIndex: 9, type: '' }, + { startIndex: 10, type: 'string.delimiter.less' }, + { startIndex: 11, type: 'string.less' }, + { startIndex: 16, type: 'string.delimiter.less' } + ] + } + ], + + [ + { + line: 'class|="icon-"', + tokens: [ + { startIndex: 0, type: 'tag.less' }, + { startIndex: 5, type: 'operator.less' }, + { startIndex: 7, type: 'string.delimiter.less' }, + { startIndex: 8, type: 'string.less' }, + { startIndex: 13, type: 'string.delimiter.less' } + ] + } + ], + + [ + { + line: '.hide-text { font: 0/0 a; }', + tokens: [ + { startIndex: 0, type: 'tag.class.less' }, + { startIndex: 10, type: '' }, + { startIndex: 11, type: 'delimiter.curly.less' }, + { startIndex: 12, type: '' }, + { startIndex: 13, type: 'attribute.name.less' }, + { startIndex: 17, type: 'delimiter.less' }, + { startIndex: 18, type: '' }, + { startIndex: 19, type: 'attribute.value.number.less' }, + { startIndex: 20, type: 'operator.less' }, + { startIndex: 21, type: 'attribute.value.number.less' }, + { startIndex: 22, type: '' }, + { startIndex: 23, type: 'attribute.value.less' }, + { startIndex: 24, type: 'delimiter.less' }, + { startIndex: 25, type: '' }, + { startIndex: 26, type: 'delimiter.curly.less' } + ] + } + ], + + // Difficult little bugs... => Numbers in classes + [ + { + line: + '.translate3d(@x, @y, @z) { -webkit-transform: translate3d(@x, @y, @z); }', + tokens: [ + { startIndex: 0, type: 'tag.class.less' }, + { startIndex: 12, type: 'delimiter.parenthesis.less' }, + { startIndex: 13, type: 'variable.less' }, + { startIndex: 15, type: 'delimiter.less' }, + { startIndex: 16, type: '' }, + { startIndex: 17, type: 'variable.less' }, + { startIndex: 19, type: 'delimiter.less' }, + { startIndex: 20, type: '' }, + { startIndex: 21, type: 'variable.less' }, + { startIndex: 23, type: 'delimiter.parenthesis.less' }, + { startIndex: 24, type: '' }, + { startIndex: 25, type: 'delimiter.curly.less' }, + { startIndex: 26, type: '' }, + { startIndex: 27, type: 'attribute.name.less' }, + { startIndex: 44, type: 'delimiter.less' }, + { startIndex: 45, type: '' }, + { startIndex: 46, type: 'attribute.value.less' }, + { startIndex: 57, type: 'delimiter.parenthesis.less' }, + { startIndex: 58, type: 'variable.less' }, + { startIndex: 60, type: 'delimiter.less' }, + { startIndex: 61, type: '' }, + { startIndex: 62, type: 'variable.less' }, + { startIndex: 64, type: 'delimiter.less' }, + { startIndex: 65, type: '' }, + { startIndex: 66, type: 'variable.less' }, + { startIndex: 68, type: 'delimiter.parenthesis.less' }, + { startIndex: 69, type: 'delimiter.less' }, + { startIndex: 70, type: '' }, + { startIndex: 71, type: 'delimiter.curly.less' } + ] + } + ], + + // Difficult little bugs... => Generic mismatches, worst case... + [ + { + line: '.dropdown-menu > li > a:hover > [class=" icon-"]', + tokens: [ + { startIndex: 0, type: 'tag.class.less' }, + { startIndex: 14, type: '' }, + { startIndex: 15, type: 'operator.less' }, + { startIndex: 16, type: '' }, + { startIndex: 17, type: 'tag.less' }, + { startIndex: 19, type: '' }, + { startIndex: 20, type: 'operator.less' }, + { startIndex: 21, type: '' }, + { startIndex: 22, type: 'tag.less' }, + { startIndex: 29, type: '' }, + { startIndex: 30, type: 'operator.less' }, + { startIndex: 31, type: '' }, + { startIndex: 32, type: 'delimiter.bracket.less' }, + { startIndex: 33, type: 'tag.less' }, + { startIndex: 38, type: 'operator.less' }, + { startIndex: 39, type: 'string.delimiter.less' }, + { startIndex: 40, type: 'string.less' }, + { startIndex: 46, type: 'string.delimiter.less' }, + { startIndex: 47, type: 'delimiter.bracket.less' } + ] + } + ], + + [ + { + line: + '.bw-gradient(@color: #F5F5F5, @start: 0, @stop: 255) { background: -webkit-gradient(color-stop(0, rgb(@start,@start,@start)), color-stop(1, rgb(@stop,@stop,@stop))); }', + tokens: [ + { startIndex: 0, type: 'tag.class.less' }, + { startIndex: 12, type: 'delimiter.parenthesis.less' }, + { startIndex: 13, type: 'variable.less' }, + { startIndex: 19, type: 'delimiter.less' }, + { startIndex: 20, type: '' }, + { startIndex: 21, type: 'attribute.value.hex.less' }, + { startIndex: 28, type: 'delimiter.less' }, + { startIndex: 29, type: '' }, + { startIndex: 30, type: 'variable.less' }, + { startIndex: 36, type: 'delimiter.less' }, + { startIndex: 37, type: '' }, + { startIndex: 38, type: 'attribute.value.number.less' }, + { startIndex: 39, type: 'delimiter.less' }, + { startIndex: 40, type: '' }, + { startIndex: 41, type: 'variable.less' }, + { startIndex: 46, type: 'delimiter.less' }, + { startIndex: 47, type: '' }, + { startIndex: 48, type: 'attribute.value.number.less' }, + { startIndex: 51, type: 'delimiter.parenthesis.less' }, + { startIndex: 52, type: '' }, + { startIndex: 53, type: 'delimiter.curly.less' }, + { startIndex: 54, type: '' }, + { startIndex: 55, type: 'attribute.name.less' }, + { startIndex: 65, type: 'delimiter.less' }, + { startIndex: 66, type: '' }, + { startIndex: 67, type: 'attribute.value.less' }, + { startIndex: 83, type: 'delimiter.parenthesis.less' }, + { startIndex: 84, type: 'attribute.value.less' }, + { startIndex: 94, type: 'delimiter.parenthesis.less' }, + { startIndex: 95, type: 'attribute.value.number.less' }, + { startIndex: 96, type: 'delimiter.less' }, + { startIndex: 97, type: '' }, + { startIndex: 98, type: 'attribute.value.less' }, + { startIndex: 101, type: 'delimiter.parenthesis.less' }, + { startIndex: 102, type: 'variable.less' }, + { startIndex: 108, type: 'delimiter.less' }, + { startIndex: 109, type: 'variable.less' }, + { startIndex: 115, type: 'delimiter.less' }, + { startIndex: 116, type: 'variable.less' }, + { startIndex: 122, type: 'delimiter.parenthesis.less' }, + { startIndex: 124, type: 'delimiter.less' }, + { startIndex: 125, type: '' }, + { startIndex: 126, type: 'attribute.value.less' }, + { startIndex: 136, type: 'delimiter.parenthesis.less' }, + { startIndex: 137, type: 'attribute.value.number.less' }, + { startIndex: 138, type: 'delimiter.less' }, + { startIndex: 139, type: '' }, + { startIndex: 140, type: 'attribute.value.less' }, + { startIndex: 143, type: 'delimiter.parenthesis.less' }, + { startIndex: 144, type: 'variable.less' }, + { startIndex: 149, type: 'delimiter.less' }, + { startIndex: 150, type: 'variable.less' }, + { startIndex: 155, type: 'delimiter.less' }, + { startIndex: 156, type: 'variable.less' }, + { startIndex: 161, type: 'delimiter.parenthesis.less' }, + { startIndex: 164, type: 'delimiter.less' }, + { startIndex: 165, type: '' }, + { startIndex: 166, type: 'delimiter.curly.less' } + ] + } + ], + + // Here CSS Tests from CSS File + // Skip whitespace + [ + { + line: ' body ', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 6, type: 'tag.less' }, + { startIndex: 10, type: '' } + ] + } + ], + + // CSS rule + // body { + // margin: 0; + // padding: 3em 6em; + // font-family: tahoma, arial, sans-serif; + // text-decoration: none !important; + // color: #000 + // } + [ + { + line: 'body {', + tokens: [ + { startIndex: 0, type: 'tag.less' }, + { startIndex: 4, type: '' }, + { startIndex: 5, type: 'delimiter.curly.less' } + ] + }, + { + line: ' margin: 0;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'attribute.name.less' }, + { startIndex: 8, type: 'delimiter.less' }, + { startIndex: 9, type: '' }, + { startIndex: 10, type: 'attribute.value.number.less' }, + { startIndex: 11, type: 'delimiter.less' } + ] + }, + { + line: ' padding: 3em 6em;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'attribute.name.less' }, + { startIndex: 9, type: 'delimiter.less' }, + { startIndex: 10, type: '' }, + { startIndex: 11, type: 'attribute.value.number.less' }, + { startIndex: 12, type: 'attribute.value.unit.less' }, + { startIndex: 14, type: '' }, + { startIndex: 15, type: 'attribute.value.number.less' }, + { startIndex: 16, type: 'attribute.value.unit.less' }, + { startIndex: 18, type: 'delimiter.less' } + ] + }, + { + line: ' font-family: tahoma, arial, sans-serif;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'attribute.name.less' }, + { startIndex: 13, type: 'delimiter.less' }, + { startIndex: 14, type: '' }, + { startIndex: 15, type: 'attribute.value.less' }, + { startIndex: 21, type: 'delimiter.less' }, + { startIndex: 22, type: '' }, + { startIndex: 23, type: 'attribute.value.less' }, + { startIndex: 28, type: 'delimiter.less' }, + { startIndex: 29, type: '' }, + { startIndex: 30, type: 'attribute.value.less' }, + { startIndex: 40, type: 'delimiter.less' } + ] + }, + { + line: ' text-decoration: none !important;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'attribute.name.less' }, + { startIndex: 17, type: 'delimiter.less' }, + { startIndex: 18, type: '' }, + { startIndex: 19, type: 'attribute.value.less' }, + { startIndex: 23, type: '' }, + { startIndex: 24, type: 'keyword.less' }, + { startIndex: 34, type: 'delimiter.less' } + ] + }, + { + line: ' color: #000;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'attribute.name.less' }, + { startIndex: 7, type: 'delimiter.less' }, + { startIndex: 8, type: '' }, + { startIndex: 9, type: 'attribute.value.hex.less' }, + { startIndex: 13, type: 'delimiter.less' } + ] + }, + { + line: ' }', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'delimiter.curly.less' } + ] + } + ], + + // CSS units and numbers + [ + { + line: '* { padding: 3em -9pt -0.5px; }', + tokens: [ + { startIndex: 0, type: 'operator.less' }, + { startIndex: 1, type: '' }, + { startIndex: 2, type: 'delimiter.curly.less' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'attribute.name.less' }, + { startIndex: 11, type: 'delimiter.less' }, + { startIndex: 12, type: '' }, + { startIndex: 13, type: 'attribute.value.number.less' }, + { startIndex: 14, type: 'attribute.value.unit.less' }, + { startIndex: 16, type: '' }, + { startIndex: 17, type: 'operator.less' }, + { startIndex: 18, type: 'attribute.value.number.less' }, + { startIndex: 19, type: 'attribute.value.unit.less' }, + { startIndex: 21, type: '' }, + { startIndex: 22, type: 'operator.less' }, + { startIndex: 23, type: 'attribute.value.number.less' }, + { startIndex: 26, type: 'attribute.value.unit.less' }, + { startIndex: 28, type: 'delimiter.less' }, + { startIndex: 29, type: '' }, + { startIndex: 30, type: 'delimiter.curly.less' } + ] + } + ], + + // CSS single line comment + // h1 /*comment*/ p { + [ + { + line: 'h1 /*comment*/ p {', + tokens: [ + { startIndex: 0, type: 'tag.less' }, + { startIndex: 2, type: '' }, + { startIndex: 3, type: 'comment.less' }, + { startIndex: 14, type: '' }, + { startIndex: 15, type: 'tag.less' }, + { startIndex: 16, type: '' }, + { startIndex: 17, type: 'delimiter.curly.less' } + ] + } + ], + + // CSS multi line comment + // h1 /*com + // ment*/ p { + [ + { + line: 'h1 /*com', + tokens: [ + { startIndex: 0, type: 'tag.less' }, + { startIndex: 2, type: '' }, + { startIndex: 3, type: 'comment.less' } + ] + }, + { + line: 'ment*/ p', + tokens: [ + { startIndex: 0, type: 'comment.less' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'tag.less' } + ] + } + ], + + // CSS ID rule + // #myID { + // font-size: 80%; + // content: 'contents'; + // } + [ + { + line: '#myID {', + tokens: [ + { startIndex: 0, type: 'tag.id.less' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'delimiter.curly.less' } + ] + } + ], + + // CSS Class rules + // .myID { + // h1 > p { + [ + { + line: '.myID {', + tokens: [ + { startIndex: 0, type: 'tag.class.less' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'delimiter.curly.less' } + ] + } + ], + + // CSS @import etc + // @import url('something.less'); { + [ + { + line: '@import url("something.less");', + tokens: [ + { startIndex: 0, type: 'keyword.less' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'tag.less' }, + { startIndex: 12, type: 'string.delimiter.less' }, + { startIndex: 13, type: 'string.less' }, + { startIndex: 27, type: 'string.delimiter.less' }, + { startIndex: 28, type: 'delimiter.parenthesis.less' }, + { startIndex: 29, type: 'delimiter.less' } + ] + } + ], + + // CSS multi-line string with an escaped newline + // body { + // content: 'con\ + // tent'; + [ + { + line: 'body {', + tokens: [ + { startIndex: 0, type: 'tag.less' }, + { startIndex: 4, type: '' }, + { startIndex: 5, type: 'delimiter.curly.less' } + ] + }, + { + line: ' content: "con\\', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'attribute.name.less' }, + { startIndex: 9, type: 'delimiter.less' }, + { startIndex: 10, type: '' }, + { startIndex: 11, type: 'string.delimiter.less' }, + { startIndex: 12, type: 'string.less' } + ] + }, + { + line: 'tent";', + tokens: [ + { startIndex: 0, type: 'string.less' }, + { startIndex: 4, type: 'string.delimiter.less' }, + { startIndex: 5, type: 'delimiter.less' } + ] + } + ], + + // CSS empty string value + // body { + // content: ''; + [ + { + line: 'body {', + tokens: [ + { startIndex: 0, type: 'tag.less' }, + { startIndex: 4, type: '' }, + { startIndex: 5, type: 'delimiter.curly.less' } + ] + }, + { + line: ' content: "";', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'attribute.name.less' }, + { startIndex: 9, type: 'delimiter.less' }, + { startIndex: 10, type: '' }, + { startIndex: 11, type: 'string.delimiter.less' }, + { startIndex: 13, type: 'delimiter.less' } + ] + } + ], + + // CSS font face + // @font-face { + // font-family: 'Opificio'; + // } + [ + { + line: '@font-face {', + tokens: [ + { startIndex: 0, type: 'variable.less' }, + { startIndex: 10, type: '' }, + { startIndex: 11, type: 'delimiter.curly.less' } + ] + }, + { + line: ' font-family: "Opificio";', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'attribute.name.less' }, + { startIndex: 13, type: 'delimiter.less' }, + { startIndex: 14, type: '' }, + { startIndex: 15, type: 'string.delimiter.less' }, + { startIndex: 16, type: 'string.less' }, + { startIndex: 24, type: 'string.delimiter.less' }, + { startIndex: 25, type: 'delimiter.less' } + ] + } + ], + + // CSS string with escaped quotes + // 's\"tr' + [ + { + line: '"s\\"tr\\"sadsad', + tokens: [ + { startIndex: 0, type: 'string.delimiter.less' }, + { startIndex: 1, type: 'string.less' } + ] + } + ], + + // EG: Bracket Matching + [ + { + line: 'p{}', + tokens: [ + { startIndex: 0, type: 'tag.less' }, + { startIndex: 1, type: 'delimiter.curly.less' } + ] + } + ], + + [ + { + line: 'p:nth() {}', + tokens: [ + { startIndex: 0, type: 'tag.less' }, + { startIndex: 5, type: 'delimiter.parenthesis.less' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'delimiter.curly.less' } + ] + } + ], + + // EG: import statement - bug #10308 + // @import url('something.css');@import url('something.css'); + [ + { + line: + '@import url("something.css");@import url("something.css");', + tokens: [ + { startIndex: 0, type: 'keyword.less' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'tag.less' }, + { startIndex: 12, type: 'string.delimiter.less' }, + { startIndex: 13, type: 'string.less' }, + { startIndex: 26, type: 'string.delimiter.less' }, + { startIndex: 27, type: 'delimiter.parenthesis.less' }, + { startIndex: 28, type: 'delimiter.less' }, + { startIndex: 29, type: 'keyword.less' }, + { startIndex: 36, type: '' }, + { startIndex: 37, type: 'tag.less' }, + { startIndex: 41, type: 'string.delimiter.less' }, + { startIndex: 42, type: 'string.less' }, + { startIndex: 55, type: 'string.delimiter.less' }, + { startIndex: 56, type: 'delimiter.parenthesis.less' }, + { startIndex: 57, type: 'delimiter.less' } + ] + } + ], + + // EG: Triple quotes - bug #9870 + [ + { + line: '""""', + tokens: [{ startIndex: 0, type: 'string.delimiter.less' }] + } + ], + + // EG: CSS @import related coloring bug 9553 + // @import url('something.css'); + // .rule1{} + // .rule2{} + [ + { + line: '@import url("something.css");', + tokens: [ + { startIndex: 0, type: 'keyword.less' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'tag.less' }, + { startIndex: 12, type: 'string.delimiter.less' }, + { startIndex: 13, type: 'string.less' }, + { startIndex: 26, type: 'string.delimiter.less' }, + { startIndex: 27, type: 'delimiter.parenthesis.less' }, + { startIndex: 28, type: 'delimiter.less' } + ] + }, + { + line: '.rule1{}', + tokens: [ + { startIndex: 0, type: 'tag.class.less' }, + { startIndex: 6, type: 'delimiter.curly.less' } + ] + }, + { + line: '.rule2{}', + tokens: [ + { startIndex: 0, type: 'tag.class.less' }, + { startIndex: 6, type: 'delimiter.curly.less' } + ] + } + ], + + // EG: CSS key frame animation syntax + [ + { + line: '@-webkit-keyframes infinite-spinning {', + tokens: [ + { startIndex: 0, type: 'variable.less' }, + { startIndex: 18, type: '' }, + { startIndex: 19, type: 'tag.less' }, + { startIndex: 36, type: '' }, + { startIndex: 37, type: 'delimiter.curly.less' } + ] + }, + { + line: ' from {', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'tag.less' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'delimiter.curly.less' } + ] + }, + { + line: ' -webkit-transform: rotate(0deg);', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'attribute.name.less' }, + { startIndex: 19, type: 'delimiter.less' }, + { startIndex: 20, type: '' }, + { startIndex: 21, type: 'attribute.value.less' }, + { startIndex: 27, type: 'delimiter.parenthesis.less' }, + { startIndex: 28, type: 'attribute.value.number.less' }, + { startIndex: 29, type: 'attribute.value.unit.less' }, + { startIndex: 32, type: 'delimiter.parenthesis.less' }, + { startIndex: 33, type: 'delimiter.less' } + ] + }, + { + line: ' }', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'delimiter.curly.less' } + ] + }, + { + line: ' to {', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'tag.less' }, + { startIndex: 4, type: '' }, + { startIndex: 5, type: 'delimiter.curly.less' } + ] + }, + { + line: ' -webkit-transform: rotate(360deg);', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'attribute.name.less' }, + { startIndex: 19, type: 'delimiter.less' }, + { startIndex: 20, type: '' }, + { startIndex: 21, type: 'attribute.value.less' }, + { startIndex: 27, type: 'delimiter.parenthesis.less' }, + { startIndex: 28, type: 'attribute.value.number.less' }, + { startIndex: 31, type: 'attribute.value.unit.less' }, + { startIndex: 34, type: 'delimiter.parenthesis.less' }, + { startIndex: 35, type: 'delimiter.less' } + ] + }, + { + line: ' }', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'delimiter.curly.less' } + ] + }, + { + line: '}', + tokens: [{ startIndex: 0, type: 'delimiter.curly.less' }] + } + ] + ] +); diff --git a/src/less/less.ts b/src/less/less.ts index d3c3a79f..34bb25c6 100644 --- a/src/less/less.ts +++ b/src/less/less.ts @@ -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 = { 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 = { { 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 = { 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: [ @@ -135,26 +156,39 @@ export const language = { 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: [ - ['~?"', { token: 'string.delimiter', next: '@stringsEndDoubleQuote' }], - ['~?\'', { token: 'string.delimiter', next: '@stringsEndQuote' }] + [ + '~?"', + { token: 'string.delimiter', next: '@stringsEndDoubleQuote' } + ], + [ + "~?'", + { token: 'string.delimiter', next: '@stringsEndQuote' } + ] ], stringsEndDoubleQuote: [ @@ -164,8 +198,8 @@ export const language = { ], stringsEndQuote: [ - ['\\\\\'', 'string'], - ['\'', { token: 'string.delimiter', next: '@popall' }], + ["\\\\'", 'string'], + ["'", { token: 'string.delimiter', next: '@popall' }], ['.', 'string'] ], diff --git a/src/lexon/lexon.test.ts b/src/lexon/lexon.test.ts index 5e9405cd..672eaa8c 100644 --- a/src/lexon/lexon.test.ts +++ b/src/lexon/lexon.test.ts @@ -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' } // . + ] + } + ] ]); diff --git a/src/lexon/lexon.ts b/src/lexon/lexon.ts index bc020bfd..a931ef69 100644 --- a/src/lexon/lexon.ts +++ b/src/lexon/lexon.ts @@ -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 = { 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: /[=>{ [/^(\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 = { [/\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 = { 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']] + } }; diff --git a/src/lua/lua.test.ts b/src/lua/lua.test.ts index c040aac6..75c21eec 100644 --- a/src/lua/lua.test.ts +++ b/src/lua/lua.test.ts @@ -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' }] + } + ] ]); diff --git a/src/lua/lua.ts b/src/lua/lua.ts index 5b4a7ff0..8638c886 100644 --- a/src/lua/lua.ts +++ b/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 = { 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 = { ], operators: [ - '+', '-', '*', '/', '%', '^', '#', '==', '~=', '<=', '>=', '<', '>', '=', - ';', ':', ',', '.', '..', '...' + '+', + '-', + '*', + '/', + '%', + '^', + '#', + '==', + '~=', + '<=', + '>=', + '<', + '>', + '=', + ';', + ':', + ',', + '.', + '..', + '...' ], // we include these common regular expressions @@ -65,27 +100,39 @@ export const language = { 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 = { [/[;,.]/, '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 = { [/[^\\"']+/, 'string'], [/@escapes/, 'string.escape'], [/\\./, 'string.escape.invalid'], - [/["']/, { - cases: { - '$#==$S2': { token: 'string', next: '@pop' }, - '@default': 'string' + [ + /["']/, + { + cases: { + '$#==$S2': { token: 'string', next: '@pop' }, + '@default': 'string' + } } - }] - ], - - }, + ] + ] + } }; diff --git a/src/markdown/markdown.contribution.ts b/src/markdown/markdown.contribution.ts index 16563180..3b487d64 100644 --- a/src/markdown/markdown.contribution.ts +++ b/src/markdown/markdown.contribution.ts @@ -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') }); diff --git a/src/markdown/markdown.test.ts b/src/markdown/markdown.test.ts index 5e802682..9e308862 100644 --- a/src/markdown/markdown.test.ts +++ b/src/markdown/markdown.test.ts @@ -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 ![link](http://link.com)', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 5, type: 'string.link.md' }, - { startIndex: 7, type: '' }, - { startIndex: 11, type: 'string.link.md' } - ] - }] + [ + { + line: 'some ![link](http://link.com)', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 5, type: 'string.link.md' }, + { startIndex: 7, type: '' }, + { startIndex: 11, type: 'string.link.md' } + ] + } + ] ]); diff --git a/src/markdown/markdown.ts b/src/markdown/markdown.ts index 9fa4dbca..d6c6f441 100644 --- a/src/markdown/markdown.ts +++ b/src/markdown/markdown.ts @@ -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*"), - end: new RegExp("^\\s*") + start: new RegExp('^\\s*'), + end: new RegExp('^\\s*') } } }; @@ -50,18 +50,31 @@ export const language = { // 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 = { [/^(\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 = { // 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 = { 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' }], [/*/?> */var y = 4;', - tokens: [ - { startIndex: 0, type: 'delimiter.html' }, - { startIndex: 1, type: 'tag.html' }, - { startIndex: 5, type: 'delimiter.html' }, - // { startIndex:6, type: 'delimiter.html' }, - { startIndex: 7, type: 'tag.html' }, - { startIndex: 12, type: 'delimiter.html' }, - { startIndex: 13, type: 'metatag.php' }, - { startIndex: 16, type: 'string.php' }, - { startIndex: 21, type: 'metatag.php' }, - { startIndex: 23, type: '' }, - { startIndex: 24, type: 'delimiter.bracket.css' }, - { startIndex: 25, type: '' }, - { startIndex: 26, type: 'attribute.name.css' }, - { startIndex: 32, type: 'attribute.value.css' }, - { startIndex: 36, type: 'delimiter.css' }, - { startIndex: 37, type: '' }, - { startIndex: 38, type: 'delimiter.bracket.css' }, - { startIndex: 39, type: 'delimiter.html' }, - { startIndex: 41, type: 'tag.html' }, - { startIndex: 46, type: 'delimiter.html' }, - { startIndex: 47, type: 'comment.html' }, - { startIndex: 51, type: 'metatag.php' }, - { startIndex: 54, type: 'string.php' }, - { startIndex: 68, type: 'metatag.php' }, - { startIndex: 70, type: 'comment.html' }, - { startIndex: 73, type: 'delimiter.html' }, - { startIndex: 74, type: 'tag.html' }, - { startIndex: 80, type: 'delimiter.html' }, - { startIndex: 81, type: 'keyword.js' }, - { startIndex: 84, type: '' }, - { startIndex: 85, type: 'identifier.js' }, - { startIndex: 86, type: '' }, - { startIndex: 87, type: 'delimiter.js' }, - { startIndex: 88, type: '' }, - { startIndex: 89, type: 'number.js' }, - { startIndex: 90, type: 'delimiter.js' }, - { startIndex: 91, type: 'comment.js' }, - { startIndex: 94, type: 'metatag.php' }, - { startIndex: 97, type: 'string.php' }, - { startIndex: 109, type: 'comment.php' }, - { startIndex: 122, type: 'metatag.php' }, - { startIndex: 124, type: '' }, - { startIndex: 127, type: 'keyword.js' }, - { startIndex: 130, type: '' }, - { startIndex: 131, type: 'identifier.js' }, - { startIndex: 132, type: '' }, - { startIndex: 133, type: 'delimiter.js' }, - { startIndex: 134, type: '' }, - { startIndex: 135, type: 'number.js' }, - { startIndex: 136, type: 'delimiter.js' }, - { startIndex: 137, type: 'delimiter.html' }, - { startIndex: 139, type: 'tag.html' }, - { startIndex: 145, type: 'delimiter.html' }, - // { startIndex:146, type: 'delimiter.html' }, - { startIndex: 148, type: 'tag.html' }, - { startIndex: 152, type: 'delimiter.html' }, - { startIndex: 153, type: 'metatag.php' }, - { startIndex: 155, type: '' }, - { startIndex: 156, type: 'variable.php' }, - { startIndex: 158, type: '' }, - { startIndex: 159, type: 'delimiter.php' }, - { startIndex: 160, type: '' }, - { startIndex: 161, type: 'number.php' }, - { startIndex: 162, type: 'delimiter.php' }, - { startIndex: 163, type: 'metatag.php' } - ] - }], - - // PHP-tag detection - [{ - line: '//""', - tokens: [ - { startIndex: 0, type: 'delimiter.html' }, - { startIndex: 1, type: 'tag.html' }, - { startIndex: 7, type: 'delimiter.html' }, - { startIndex: 8, type: 'string.invalid.js' }, - { startIndex: 9, type: 'metatag.php' }, - { startIndex: 14, type: 'number.php' }, - { startIndex: 15, type: 'delimiter.php' }, - { startIndex: 16, type: 'number.php' }, - { startIndex: 17, type: 'metatag.php' }, - { startIndex: 19, type: 'string.invalid.js' } - ] - }], - - [{ - line: '', - tokens: [ - { startIndex: 0, type: 'metatag.php' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'identifier.php' }, - { startIndex: 14, type: 'delimiter.parenthesis.php' }, - { startIndex: 16, type: 'delimiter.php' }, - { startIndex: 17, type: '' }, - { startIndex: 18, type: 'metatag.php' } - ] - }], - - [{ - line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'comment.php' }, + { startIndex: 19, type: '' }, + { startIndex: 20, type: 'metatag.php' } + ] + } + ], + + // Variables + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'variable.php' }, + { startIndex: 10, type: '' }, + { startIndex: 11, type: 'delimiter.php' }, + { startIndex: 12, type: '' }, + { startIndex: 13, type: 'number.php' }, + { startIndex: 14, type: 'delimiter.php' }, + { startIndex: 15, type: '' }, + { startIndex: 16, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'variable.php' }, + { startIndex: 8, type: '' }, + { startIndex: 9, type: 'delimiter.php' }, + { startIndex: 10, type: '' }, + { startIndex: 11, type: 'string.php' }, + { startIndex: 18, type: 'delimiter.php' }, + { startIndex: 19, type: '' }, + { startIndex: 20, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'variable.php' }, + { startIndex: 12, type: '' }, + { startIndex: 13, type: 'delimiter.php' }, + { startIndex: 14, type: '' }, + { startIndex: 15, type: 'delimiter.php' }, + { startIndex: 16, type: 'number.php' }, + { startIndex: 18, type: 'delimiter.php' }, + { startIndex: 19, type: '' }, + { startIndex: 20, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'variable.php' }, + { startIndex: 12, type: '' }, + { startIndex: 13, type: 'delimiter.php' }, + { startIndex: 14, type: '' }, + { startIndex: 15, type: 'number.php' }, + { startIndex: 16, type: '' }, + { startIndex: 17, type: 'delimiter.php' }, + { startIndex: 18, type: '' }, + { startIndex: 19, type: 'delimiter.parenthesis.php' }, + { startIndex: 20, type: 'number.php' }, + { startIndex: 22, type: '' }, + { startIndex: 23, type: 'delimiter.php' }, + { startIndex: 24, type: '' }, + { startIndex: 25, type: 'number.php' }, + { startIndex: 26, type: 'delimiter.parenthesis.php' }, + { startIndex: 27, type: 'delimiter.php' }, + { startIndex: 28, type: '' }, + { startIndex: 29, type: 'metatag.php' } + ] + } + ], + + // Keywords + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 14, type: '' }, + { startIndex: 15, type: 'identifier.php' }, + { startIndex: 21, type: 'delimiter.parenthesis.php' }, + { startIndex: 23, type: '' }, + { startIndex: 24, type: 'delimiter.bracket.php' }, + { startIndex: 25, type: '' }, + { startIndex: 26, type: 'delimiter.bracket.php' }, + { startIndex: 27, type: '' }, + { startIndex: 28, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 14, type: '' }, + { startIndex: 15, type: 'metatag.php' } + ] + } + ], + + [ + { + line: ' 52) { $start = 0; } ?>', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 8, type: '' }, + { startIndex: 9, type: 'delimiter.parenthesis.php' }, + { startIndex: 10, type: 'variable.php' }, + { startIndex: 16, type: '' }, + { startIndex: 17, type: 'delimiter.php' }, + { startIndex: 18, type: '' }, + { startIndex: 19, type: 'number.php' }, + { startIndex: 21, type: 'delimiter.parenthesis.php' }, + { startIndex: 22, type: '' }, + { startIndex: 23, type: 'delimiter.bracket.php' }, + { startIndex: 24, type: '' }, + { startIndex: 25, type: 'variable.php' }, + { startIndex: 31, type: '' }, + { startIndex: 32, type: 'delimiter.php' }, + { startIndex: 33, type: '' }, + { startIndex: 34, type: 'number.php' }, + { startIndex: 35, type: 'delimiter.php' }, + { startIndex: 36, type: '' }, + { startIndex: 37, type: 'delimiter.bracket.php' }, + { startIndex: 38, type: '' }, + { startIndex: 39, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 8, type: '' }, + { startIndex: 9, type: 'delimiter.parenthesis.php' }, + { startIndex: 10, type: 'keyword.php' }, + { startIndex: 14, type: 'delimiter.parenthesis.php' }, + { startIndex: 15, type: '' }, + { startIndex: 16, type: 'delimiter.bracket.php' }, + { startIndex: 17, type: '' }, + { startIndex: 18, type: 'variable.php' }, + { startIndex: 24, type: '' }, + { startIndex: 25, type: 'delimiter.php' }, + { startIndex: 26, type: '' }, + { startIndex: 27, type: 'number.php' }, + { startIndex: 28, type: 'delimiter.php' }, + { startIndex: 29, type: '' }, + { startIndex: 30, type: 'delimiter.bracket.php' }, + { startIndex: 31, type: '' }, + { startIndex: 32, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 14, type: '' }, + { startIndex: 15, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 9, type: '' }, + { startIndex: 10, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 11, type: '' }, + { startIndex: 12, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 8, type: '' }, + { startIndex: 9, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 11, type: '' }, + { startIndex: 12, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 10, type: '' }, + { startIndex: 11, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 11, type: '' }, + { startIndex: 12, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 15, type: '' }, + { startIndex: 16, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 11, type: '' }, + { startIndex: 12, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 11, type: '' }, + { startIndex: 12, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 11, type: '' }, + { startIndex: 12, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 14, type: '' }, + { startIndex: 15, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 13, type: '' }, + { startIndex: 14, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 13, type: '' }, + { startIndex: 14, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 8, type: '' }, + { startIndex: 9, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 10, type: '' }, + { startIndex: 11, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 12, type: '' }, + { startIndex: 13, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 16, type: '' }, + { startIndex: 17, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 12, type: '' }, + { startIndex: 13, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 16, type: '' }, + { startIndex: 17, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 11, type: '' }, + { startIndex: 12, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 15, type: '' }, + { startIndex: 16, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 14, type: '' }, + { startIndex: 15, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 13, type: '' }, + { startIndex: 14, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 11, type: '' }, + { startIndex: 12, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 11, type: '' }, + { startIndex: 12, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 9, type: '' }, + { startIndex: 10, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 13, type: '' }, + { startIndex: 14, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 14, type: '' }, + { startIndex: 15, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 12, type: '' }, + { startIndex: 13, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 10, type: '' }, + { startIndex: 11, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 8, type: '' }, + { startIndex: 9, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 16, type: '' }, + { startIndex: 17, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 15, type: '' }, + { startIndex: 16, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 16, type: '' }, + { startIndex: 17, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 15, type: '' }, + { startIndex: 16, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 9, type: '' }, + { startIndex: 10, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 10, type: '' }, + { startIndex: 11, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 12, type: '' }, + { startIndex: 13, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 18, type: '' }, + { startIndex: 19, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 8, type: '' }, + { startIndex: 9, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 13, type: '' }, + { startIndex: 14, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 15, type: '' }, + { startIndex: 16, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 12, type: '' }, + { startIndex: 13, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 14, type: '' }, + { startIndex: 15, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 12, type: '' }, + { startIndex: 13, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 12, type: '' }, + { startIndex: 13, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 11, type: '' }, + { startIndex: 12, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 9, type: '' }, + { startIndex: 10, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 10, type: '' }, + { startIndex: 11, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 9, type: '' }, + { startIndex: 10, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 9, type: '' }, + { startIndex: 10, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 11, type: '' }, + { startIndex: 12, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 9, type: '' }, + { startIndex: 10, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 9, type: '' }, + { startIndex: 10, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 10, type: '' }, + { startIndex: 11, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 11, type: '' }, + { startIndex: 12, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 10, type: '' }, + { startIndex: 11, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 10, type: '' }, + { startIndex: 11, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 13, type: '' }, + { startIndex: 14, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 18, type: '' }, + { startIndex: 19, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 11, type: '' }, + { startIndex: 12, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 10, type: '' }, + { startIndex: 11, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 13, type: '' }, + { startIndex: 14, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 18, type: '' }, + { startIndex: 19, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 12, type: '' }, + { startIndex: 13, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 11, type: '' }, + { startIndex: 12, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 11, type: '' }, + { startIndex: 12, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 17, type: '' }, + { startIndex: 18, type: 'metatag.php' } + ] + } + ], + + // Compile Time Constants + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'constant.php' }, + { startIndex: 14, type: '' }, + { startIndex: 15, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'variable.php' }, + { startIndex: 15, type: '' }, + { startIndex: 16, type: 'delimiter.php' }, + { startIndex: 17, type: '' }, + { startIndex: 18, type: 'constant.php' }, + { startIndex: 26, type: 'delimiter.php' }, + { startIndex: 27, type: '' }, + { startIndex: 28, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'constant.php' }, + { startIndex: 15, type: '' }, + { startIndex: 16, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'constant.php' }, + { startIndex: 13, type: '' }, + { startIndex: 14, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'constant.php' }, + { startIndex: 14, type: '' }, + { startIndex: 15, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'constant.php' }, + { startIndex: 19, type: '' }, + { startIndex: 20, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'constant.php' }, + { startIndex: 16, type: '' }, + { startIndex: 17, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'constant.php' }, + { startIndex: 18, type: '' }, + { startIndex: 19, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'constant.php' }, + { startIndex: 15, type: '' }, + { startIndex: 16, type: 'metatag.php' } + ] + } + ], + + // Predefined Variables + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'variable.predefined.php' }, + { startIndex: 11, type: '' }, + { startIndex: 12, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.php' }, + { startIndex: 10, type: '' }, + { startIndex: 11, type: 'variable.predefined.php' }, + { startIndex: 16, type: 'delimiter.php' }, + { startIndex: 17, type: '' }, + { startIndex: 18, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'variable.predefined.php' }, + { startIndex: 14, type: '' }, + { startIndex: 15, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'variable.predefined.php' }, + { startIndex: 14, type: '' }, + { startIndex: 15, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'variable.predefined.php' }, + { startIndex: 11, type: '' }, + { startIndex: 12, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'variable.predefined.php' }, + { startIndex: 12, type: '' }, + { startIndex: 13, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'variable.predefined.php' }, + { startIndex: 13, type: '' }, + { startIndex: 14, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'variable.predefined.php' }, + { startIndex: 15, type: '' }, + { startIndex: 16, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'variable.predefined.php' }, + { startIndex: 15, type: '' }, + { startIndex: 16, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'variable.predefined.php' }, + { startIndex: 11, type: '' }, + { startIndex: 12, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'variable.predefined.php' }, + { startIndex: 14, type: '' }, + { startIndex: 15, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'variable.predefined.php' }, + { startIndex: 19, type: '' }, + { startIndex: 20, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'variable.predefined.php' }, + { startIndex: 25, type: '' }, + { startIndex: 26, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'variable.predefined.php' }, + { startIndex: 27, type: '' }, + { startIndex: 28, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'variable.predefined.php' }, + { startIndex: 11, type: '' }, + { startIndex: 12, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'variable.predefined.php' }, + { startIndex: 11, type: '' }, + { startIndex: 12, type: 'metatag.php' } + ] + } + ], + + // Comments - single line + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'comment.php' }, + { startIndex: 28, type: '' }, + { startIndex: 29, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'variable.php' }, + { startIndex: 8, type: '' }, + { startIndex: 9, type: 'delimiter.php' }, + { startIndex: 10, type: '' }, + { startIndex: 11, type: 'comment.php' }, + { startIndex: 33, type: '' }, + { startIndex: 34, type: 'number.php' }, + { startIndex: 35, type: 'delimiter.php' }, + { startIndex: 36, type: '' }, + { startIndex: 37, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'variable.php' }, + { startIndex: 8, type: '' }, + { startIndex: 9, type: 'delimiter.php' }, + { startIndex: 10, type: '' }, + { startIndex: 11, type: 'comment.php' }, + { startIndex: 24, type: '' }, + { startIndex: 25, type: 'number.php' }, + { startIndex: 26, type: 'delimiter.php' }, + { startIndex: 27, type: '' }, + { startIndex: 28, type: 'delimiter.php' }, + { startIndex: 30, type: '' }, + { startIndex: 31, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'variable.php' }, + { startIndex: 8, type: '' }, + { startIndex: 9, type: 'delimiter.php' }, + { startIndex: 10, type: '' }, + { startIndex: 11, type: 'comment.php' }, + { startIndex: 15, type: 'delimiter.php' }, + { startIndex: 16, type: '' }, + { startIndex: 17, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '", + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'variable.php' }, + { startIndex: 8, type: '' }, + { startIndex: 9, type: 'delimiter.php' }, + { startIndex: 10, type: '' }, + { startIndex: 11, type: 'string.php' }, + { startIndex: 14, type: 'delimiter.php' }, + { startIndex: 15, type: '' }, + { startIndex: 16, type: 'metatag.php' } + ] + } + ], + + [ + { + line: "", + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'string.php' }, + { startIndex: 18, type: 'delimiter.php' }, + { startIndex: 19, type: '' }, + { startIndex: 20, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'variable.php' }, + { startIndex: 8, type: '' }, + { startIndex: 9, type: 'delimiter.php' }, + { startIndex: 10, type: '' }, + { startIndex: 11, type: 'variable.php' }, + { startIndex: 13, type: '' }, + { startIndex: 14, type: 'delimiter.php' }, + { startIndex: 15, type: '' }, + { startIndex: 16, type: 'string.php' }, + { startIndex: 27, type: '' }, + { startIndex: 28, type: 'metatag.php' } + ] + } + ], + + [ + { + line: "', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'number.php' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'number.php' }, + { startIndex: 7, type: 'delimiter.php' }, + { startIndex: 8, type: 'number.php' }, + { startIndex: 9, type: '' }, + { startIndex: 10, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'number.php' }, + { startIndex: 9, type: 'delimiter.php' }, + { startIndex: 10, type: 'number.php' }, + { startIndex: 12, type: '' }, + { startIndex: 13, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'number.php' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'delimiter.php' }, + { startIndex: 9, type: '' }, + { startIndex: 10, type: 'number.php' }, + { startIndex: 11, type: '' }, + { startIndex: 12, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'number.octal.php' }, + { startIndex: 10, type: '' }, + { startIndex: 11, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'number.octal.php' }, + { startIndex: 10, type: 'number.php' }, + { startIndex: 11, type: '' }, + { startIndex: 12, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'number.php' }, + { startIndex: 7, type: 'identifier.php' }, + { startIndex: 8, type: '' }, + { startIndex: 9, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'number.hex.php' }, + { startIndex: 11, type: '' }, + { startIndex: 12, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'number.binary.php' }, + { startIndex: 9, type: '' }, + { startIndex: 10, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'delimiter.bracket.php' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'delimiter.bracket.php' }, + { startIndex: 9, type: '' }, + { startIndex: 10, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'delimiter.array.php' }, + { startIndex: 7, type: 'number.php' }, + { startIndex: 8, type: 'delimiter.php' }, + { startIndex: 9, type: 'number.php' }, + { startIndex: 10, type: 'delimiter.php' }, + { startIndex: 11, type: 'number.php' }, + { startIndex: 12, type: 'delimiter.array.php' }, + { startIndex: 13, type: '' }, + { startIndex: 14, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'variable.php' }, + { startIndex: 8, type: '' }, + { startIndex: 9, type: 'delimiter.php' }, + { startIndex: 10, type: '' }, + { startIndex: 11, type: 'string.php' }, + { startIndex: 19, type: '' }, + { startIndex: 20, type: 'metatag.php' } + ] + } + ], + + // Comments - comment with sharp + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'comment.php' }, + { startIndex: 15, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'comment.php' }, + { startIndex: 17, type: 'metatag.php' } + ] + } + ], + + // 3-languages parser + + // php + [ + { + line: "", + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 3, type: 'string.php' }, + { startIndex: 7, type: 'metatag.php' } + ] + } + ], + + // php/html/php + [ + { + line: '
', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: 'number.php' }, + { startIndex: 6, type: 'delimiter.php' }, + { startIndex: 7, type: 'number.php' }, + { startIndex: 8, type: 'metatag.php' }, + { startIndex: 10, type: 'delimiter.html' }, + { startIndex: 11, type: 'tag.html' }, + { startIndex: 13, type: 'delimiter.html' }, + { startIndex: 15, type: 'metatag.php' }, + { startIndex: 18, type: 'number.php' }, + { startIndex: 19, type: 'metatag.php' } + ] + } + ], + + // php/html/php + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: 'number.php' }, + { startIndex: 6, type: 'delimiter.php' }, + { startIndex: 7, type: 'number.php' }, + { startIndex: 8, type: 'metatag.php' }, + { startIndex: 10, type: 'delimiter.html' }, + { startIndex: 11, type: 'tag.html' }, + { startIndex: 14, type: 'delimiter.html' }, + { startIndex: 15, type: 'metatag.php' }, + { startIndex: 18, type: 'number.php' }, + { startIndex: 19, type: 'metatag.php' } + ] + } + ], + + // html/php/html + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, + { startIndex: 4, type: 'delimiter.html' }, + { startIndex: 5, type: 'metatag.php' }, + { startIndex: 10, type: 'number.php' }, + { startIndex: 11, type: 'delimiter.php' }, + { startIndex: 12, type: 'number.php' }, + { startIndex: 13, type: 'metatag.php' }, + { startIndex: 15, type: 'delimiter.html' }, + { startIndex: 16, type: 'tag.html' }, + { startIndex: 19, type: 'delimiter.html' } + ] + } + ], + + // html/js/php/html + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, + { startIndex: 4, type: 'delimiter.html' }, + // { startIndex:5, type: 'delimiter.html' }, + { startIndex: 6, type: 'tag.html' }, + { startIndex: 12, type: 'delimiter.html' }, + { startIndex: 13, type: 'keyword.js' }, + { startIndex: 16, type: '' }, + { startIndex: 17, type: 'identifier.js' }, + { startIndex: 18, type: 'delimiter.js' }, + { startIndex: 19, type: '' }, + { startIndex: 20, type: 'number.js' }, + { startIndex: 22, type: 'delimiter.js' }, + { startIndex: 23, type: 'delimiter.html' }, + { startIndex: 25, type: 'tag.html' }, + { startIndex: 31, type: 'delimiter.html' }, + { startIndex: 32, type: 'metatag.php' }, + { startIndex: 37, type: 'number.php' }, + { startIndex: 38, type: 'delimiter.php' }, + { startIndex: 39, type: 'number.php' }, + { startIndex: 40, type: 'metatag.php' }, + { startIndex: 42, type: 'delimiter.html' }, + { startIndex: 43, type: 'tag.html' }, + { startIndex: 46, type: 'delimiter.html' } + ] + } + ], + + // html/js/php/js/ + [ + { + line: + '', + tokens: [ + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, + { startIndex: 4, type: 'delimiter.html' }, + // { startIndex:5, type: 'delimiter.html' }, + { startIndex: 6, type: 'tag.html' }, + { startIndex: 12, type: 'delimiter.html' }, + { startIndex: 13, type: 'keyword.js' }, + { startIndex: 16, type: '' }, + { startIndex: 17, type: 'identifier.js' }, + { startIndex: 18, type: 'delimiter.js' }, + { startIndex: 19, type: '' }, + { startIndex: 20, type: 'number.js' }, + { startIndex: 22, type: 'delimiter.js' }, + { startIndex: 23, type: 'delimiter.html' }, + { startIndex: 25, type: 'tag.html' }, + { startIndex: 31, type: 'delimiter.html' }, + { startIndex: 32, type: 'metatag.php' }, + { startIndex: 37, type: 'number.php' }, + { startIndex: 38, type: 'delimiter.php' }, + { startIndex: 39, type: 'number.php' }, + { startIndex: 40, type: 'metatag.php' }, + { startIndex: 42, type: 'delimiter.html' }, + { startIndex: 43, type: 'tag.html' }, + { startIndex: 49, type: 'delimiter.html' }, + { startIndex: 50, type: 'keyword.js' }, + { startIndex: 53, type: '' }, + { startIndex: 54, type: 'identifier.js' }, + { startIndex: 55, type: 'delimiter.js' }, + { startIndex: 56, type: '' }, + { startIndex: 57, type: 'number.js' }, + { startIndex: 59, type: 'delimiter.js' }, + { startIndex: 60, type: 'delimiter.html' }, + { startIndex: 62, type: 'tag.html' }, + { startIndex: 68, type: 'delimiter.html' } + ] + } + ], + + // Multiline test + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, + { startIndex: 5, type: 'delimiter.html' } + ] + }, + { + line: '', + tokens: [ + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, + { startIndex: 6, type: 'delimiter.html' }, + { startIndex: 7, type: 'metatag.php' }, + { startIndex: 10, type: 'string.php' }, + { startIndex: 15, type: 'metatag.php' }, + { startIndex: 17, type: 'delimiter.bracket.css' }, + { startIndex: 18, type: '' }, + { startIndex: 19, type: 'attribute.name.css' }, + { startIndex: 25, type: 'attribute.value.css' }, + { startIndex: 29, type: 'delimiter.css' }, + { startIndex: 30, type: '' }, + { startIndex: 31, type: 'delimiter.bracket.css' }, + { startIndex: 32, type: 'delimiter.html' }, + { startIndex: 34, type: 'tag.html' }, + { startIndex: 39, type: 'delimiter.html' } + ] + } + ], + + // HTML (CSS (PHP)), HTML ( PHP, JS (PHP), PHP) + [ + { + line: + '*/?> */var y = 4;', + tokens: [ + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, + { startIndex: 5, type: 'delimiter.html' }, + // { startIndex:6, type: 'delimiter.html' }, + { startIndex: 7, type: 'tag.html' }, + { startIndex: 12, type: 'delimiter.html' }, + { startIndex: 13, type: 'metatag.php' }, + { startIndex: 16, type: 'string.php' }, + { startIndex: 21, type: 'metatag.php' }, + { startIndex: 23, type: '' }, + { startIndex: 24, type: 'delimiter.bracket.css' }, + { startIndex: 25, type: '' }, + { startIndex: 26, type: 'attribute.name.css' }, + { startIndex: 32, type: 'attribute.value.css' }, + { startIndex: 36, type: 'delimiter.css' }, + { startIndex: 37, type: '' }, + { startIndex: 38, type: 'delimiter.bracket.css' }, + { startIndex: 39, type: 'delimiter.html' }, + { startIndex: 41, type: 'tag.html' }, + { startIndex: 46, type: 'delimiter.html' }, + { startIndex: 47, type: 'comment.html' }, + { startIndex: 51, type: 'metatag.php' }, + { startIndex: 54, type: 'string.php' }, + { startIndex: 68, type: 'metatag.php' }, + { startIndex: 70, type: 'comment.html' }, + { startIndex: 73, type: 'delimiter.html' }, + { startIndex: 74, type: 'tag.html' }, + { startIndex: 80, type: 'delimiter.html' }, + { startIndex: 81, type: 'keyword.js' }, + { startIndex: 84, type: '' }, + { startIndex: 85, type: 'identifier.js' }, + { startIndex: 86, type: '' }, + { startIndex: 87, type: 'delimiter.js' }, + { startIndex: 88, type: '' }, + { startIndex: 89, type: 'number.js' }, + { startIndex: 90, type: 'delimiter.js' }, + { startIndex: 91, type: 'comment.js' }, + { startIndex: 94, type: 'metatag.php' }, + { startIndex: 97, type: 'string.php' }, + { startIndex: 109, type: 'comment.php' }, + { startIndex: 122, type: 'metatag.php' }, + { startIndex: 124, type: '' }, + { startIndex: 127, type: 'keyword.js' }, + { startIndex: 130, type: '' }, + { startIndex: 131, type: 'identifier.js' }, + { startIndex: 132, type: '' }, + { startIndex: 133, type: 'delimiter.js' }, + { startIndex: 134, type: '' }, + { startIndex: 135, type: 'number.js' }, + { startIndex: 136, type: 'delimiter.js' }, + { startIndex: 137, type: 'delimiter.html' }, + { startIndex: 139, type: 'tag.html' }, + { startIndex: 145, type: 'delimiter.html' }, + // { startIndex:146, type: 'delimiter.html' }, + { startIndex: 148, type: 'tag.html' }, + { startIndex: 152, type: 'delimiter.html' }, + { startIndex: 153, type: 'metatag.php' }, + { startIndex: 155, type: '' }, + { startIndex: 156, type: 'variable.php' }, + { startIndex: 158, type: '' }, + { startIndex: 159, type: 'delimiter.php' }, + { startIndex: 160, type: '' }, + { startIndex: 161, type: 'number.php' }, + { startIndex: 162, type: 'delimiter.php' }, + { startIndex: 163, type: 'metatag.php' } + ] + } + ], + + // PHP-tag detection + [ + { + line: '//""', + tokens: [ + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, + { startIndex: 7, type: 'delimiter.html' }, + { startIndex: 8, type: 'string.invalid.js' }, + { startIndex: 9, type: 'metatag.php' }, + { startIndex: 14, type: 'number.php' }, + { startIndex: 15, type: 'delimiter.php' }, + { startIndex: 16, type: 'number.php' }, + { startIndex: 17, type: 'metatag.php' }, + { startIndex: 19, type: 'string.invalid.js' } + ] + } + ], + + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'metatag.php' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'identifier.php' }, + { startIndex: 14, type: 'delimiter.parenthesis.php' }, + { startIndex: 16, type: 'delimiter.php' }, + { startIndex: 17, type: '' }, + { startIndex: 18, type: 'metatag.php' } + ] + } + ], + + [ + { + line: '\/\?\s]+)/g, - - comments: { - lineComment: '//', - blockComment: ['/*', '*/'] - }, - - brackets: [ - ['{', '}'], - ['[', ']'], - ['(', ')'] - ], - - autoClosingPairs: [ - { open: '{', close: '}', notIn: ['string'] }, - { open: '[', close: ']', notIn: ['string'] }, - { open: '(', close: ')', notIn: ['string'] }, - { open: '"', close: '"', notIn: ['string'] }, - { open: '\'', close: '\'', notIn: ['string', 'comment'] } - ], - - folding: { - markers: { - start: new RegExp("^\\s*(#|\/\/)region\\b"), - end: new RegExp("^\\s*(#|\/\/)endregion\\b") - } - } -}; - -export const language = { - defaultToken: '', - tokenPostfix: '', - // ignoreCase: true, - - // The main tokenizer for our languages - tokenizer: { - root: [ - [/<\?((php)|=)?/, { token: '@rematch', switchTo: '@phpInSimpleState.root' }], - [/)/, ['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' }]], - [/]+/, 'metatag.content.html'], - [/>/, 'metatag.html', '@pop'], - ], - - comment: [ - [/<\?((php)|=)?/, { token: '@rematch', switchTo: '@phpInSimpleState.comment' }], - [/-->/, 'comment.html', '@pop'], - [/[^-]+/, 'comment.content.html'], - [/./, 'comment.content.html'] - ], - - otherTag: [ - [/<\?((php)|=)?/, { token: '@rematch', switchTo: '@phpInSimpleState.otherTag' }], - [/\/?>/, 'delimiter.html', '@pop'], - [/"([^"]*)"/, 'attribute.value'], - [/'([^']*)'/, 'attribute.value'], - [/[\w\-]+/, 'attribute.name'], - [/=/, 'delimiter'], - [/[ \t\r\n]+/], // whitespace - ], - - // -- BEGIN - -//
-// Hello -// -// -// -// guest -// -// ! -//
- -// "); - -// // display shuffled cards (EXAMPLE ONLY) -// for ($index = 0; $index < 52; $index++) { -// if ($starting_point == 52) { $starting_point = 0; } -// print("Uncut Point: $deck[$index] "); -// print("Starting Point: $deck[$starting_point]
"); -// $starting_point++; -// } -// ?> - -// -// +/*--------------------------------------------------------------------------------------------- + * 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 IRichLanguageConfiguration = monaco.languages.LanguageConfiguration; +import ILanguage = monaco.languages.IMonarchLanguage; + +export const conf: IRichLanguageConfiguration = { + wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\@\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g, + + comments: { + lineComment: '//', + blockComment: ['/*', '*/'] + }, + + brackets: [ + ['{', '}'], + ['[', ']'], + ['(', ')'] + ], + + autoClosingPairs: [ + { open: '{', close: '}', notIn: ['string'] }, + { open: '[', close: ']', notIn: ['string'] }, + { open: '(', close: ')', notIn: ['string'] }, + { open: '"', close: '"', notIn: ['string'] }, + { open: "'", close: "'", notIn: ['string', 'comment'] } + ], + + folding: { + markers: { + start: new RegExp('^\\s*(#|//)region\\b'), + end: new RegExp('^\\s*(#|//)endregion\\b') + } + } +}; + +export const language = { + defaultToken: '', + tokenPostfix: '', + // ignoreCase: true, + + // The main tokenizer for our languages + tokenizer: { + root: [ + [ + /<\?((php)|=)?/, + { token: '@rematch', switchTo: '@phpInSimpleState.root' } + ], + [/)/, ['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' }] + ], + [/]+/, 'metatag.content.html'], + [/>/, 'metatag.html', '@pop'] + ], + + comment: [ + [ + /<\?((php)|=)?/, + { token: '@rematch', switchTo: '@phpInSimpleState.comment' } + ], + [/-->/, 'comment.html', '@pop'], + [/[^-]+/, 'comment.content.html'], + [/./, 'comment.content.html'] + ], + + otherTag: [ + [ + /<\?((php)|=)?/, + { token: '@rematch', switchTo: '@phpInSimpleState.otherTag' } + ], + [/\/?>/, 'delimiter.html', '@pop'], + [/"([^"]*)"/, 'attribute.value'], + [/'([^']*)'/, 'attribute.value'], + [/[\w\-]+/, 'attribute.name'], + [/=/, 'delimiter'], + [/[ \t\r\n]+/] // whitespace + ], + + // -- BEGIN + +//
+// Hello +// +// +// +// guest +// +// ! +//
+ +// "); + +// // display shuffled cards (EXAMPLE ONLY) +// for ($index = 0; $index < 52; $index++) { +// if ($starting_point == 52) { $starting_point = 0; } +// print("Uncut Point: $deck[$index] "); +// print("Starting Point: $deck[$starting_point]
"); +// $starting_point++; +// } +// ?> + +// +// diff --git a/src/postiats/postiats.test.ts b/src/postiats/postiats.test.ts index e4624729..83a862c9 100644 --- a/src/postiats/postiats.test.ts +++ b/src/postiats/postiats.test.ts @@ -9,297 +9,325 @@ import { testTokenization } from '../test/testRunner'; testTokenization('postiats', [ // Keywords - [{ - line: 'implement main(argc, argv) =', - tokens: [ - { startIndex: 0, type: 'keyword.pats' }, - { startIndex: 9, type: '' }, - { startIndex: 10, type: 'identifier.pats' }, - { startIndex: 14, type: 'delimiter.parenthesis.pats' }, - { startIndex: 15, type: 'identifier.pats' }, - { startIndex: 19, type: 'delimiter.comma.pats' }, - { startIndex: 20, type: '' }, - { startIndex: 21, type: 'identifier.pats' }, - { startIndex: 25, type: 'delimiter.parenthesis.pats' }, - { startIndex: 26, type: '' }, - { startIndex: 27, type: 'keyword.pats' } - ] - }], + [ + { + line: 'implement main(argc, argv) =', + tokens: [ + { startIndex: 0, type: 'keyword.pats' }, + { startIndex: 9, type: '' }, + { startIndex: 10, type: 'identifier.pats' }, + { startIndex: 14, type: 'delimiter.parenthesis.pats' }, + { startIndex: 15, type: 'identifier.pats' }, + { startIndex: 19, type: 'delimiter.comma.pats' }, + { startIndex: 20, type: '' }, + { startIndex: 21, type: 'identifier.pats' }, + { startIndex: 25, type: 'delimiter.parenthesis.pats' }, + { startIndex: 26, type: '' }, + { startIndex: 27, type: 'keyword.pats' } + ] + } + ], // Comments - single line - [{ - line: '//', - tokens: [ - { startIndex: 0, type: 'comment.pats' } - ] - }], + [ + { + line: '//', + tokens: [{ startIndex: 0, type: 'comment.pats' }] + } + ], - [{ - line: ' // a comment', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 4, type: 'comment.pats' } - ] - }], + [ + { + line: ' // a comment', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 4, type: 'comment.pats' } + ] + } + ], - [{ - line: '// a comment', - tokens: [ - { startIndex: 0, type: 'comment.pats' } - ] - }], + [ + { + line: '// a comment', + tokens: [{ startIndex: 0, type: 'comment.pats' }] + } + ], - [{ - line: '//sticky comment', - tokens: [ - { startIndex: 0, type: 'comment.pats' } - ] - }], + [ + { + line: '//sticky comment', + tokens: [{ startIndex: 0, type: 'comment.pats' }] + } + ], - [{ - line: '/almost a comment', - tokens: [ - { startIndex: 0, type: 'operator.pats' }, - { startIndex: 1, type: 'identifier.pats' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'identifier.pats' }, - { startIndex: 9, type: '' }, - { startIndex: 10, type: 'identifier.pats' } - ] - }], + [ + { + line: '/almost a comment', + tokens: [ + { startIndex: 0, type: 'operator.pats' }, + { startIndex: 1, type: 'identifier.pats' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'identifier.pats' }, + { startIndex: 9, type: '' }, + { startIndex: 10, type: 'identifier.pats' } + ] + } + ], - [{ - line: '/* //*/ a', - tokens: [ - { startIndex: 0, type: 'comment.pats' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'identifier.pats' } - ] - }], + [ + { + line: '/* //*/ a', + tokens: [ + { startIndex: 0, type: 'comment.pats' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'identifier.pats' } + ] + } + ], - [{ - line: '1 / 2; /* comment', - tokens: [ - { startIndex: 0, type: 'number.decimal.pats' }, - { startIndex: 1, type: '' }, - { startIndex: 2, type: 'operator.pats' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'number.decimal.pats' }, - { startIndex: 5, type: 'delimiter.semicolon.pats' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'comment.pats' } - ] - }], + [ + { + line: '1 / 2; /* comment', + tokens: [ + { startIndex: 0, type: 'number.decimal.pats' }, + { startIndex: 1, type: '' }, + { startIndex: 2, type: 'operator.pats' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'number.decimal.pats' }, + { startIndex: 5, type: 'delimiter.semicolon.pats' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'comment.pats' } + ] + } + ], - [{ - line: 'val x:int = 1; // my comment // is a nice one', - tokens: [ - { startIndex: 0, type: 'keyword.pats' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'identifier.pats' }, - { startIndex: 5, type: 'keyword.pats' }, - { startIndex: 6, type: 'type.pats' }, - { startIndex: 9, type: '' }, - { startIndex: 10, type: 'keyword.pats' }, - { startIndex: 11, type: '' }, - { startIndex: 12, type: 'number.decimal.pats' }, - { startIndex: 13, type: 'delimiter.semicolon.pats' }, - { startIndex: 14, type: '' }, - { startIndex: 15, type: 'comment.pats' } - ] - }], + [ + { + line: 'val x:int = 1; // my comment // is a nice one', + tokens: [ + { startIndex: 0, type: 'keyword.pats' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'identifier.pats' }, + { startIndex: 5, type: 'keyword.pats' }, + { startIndex: 6, type: 'type.pats' }, + { startIndex: 9, type: '' }, + { startIndex: 10, type: 'keyword.pats' }, + { startIndex: 11, type: '' }, + { startIndex: 12, type: 'number.decimal.pats' }, + { startIndex: 13, type: 'delimiter.semicolon.pats' }, + { startIndex: 14, type: '' }, + { startIndex: 15, type: 'comment.pats' } + ] + } + ], // Comments - range comment, single line - [{ - line: '/* a simple comment */', - tokens: [ - { startIndex: 0, type: 'comment.pats' } - ] - }], + [ + { + line: '/* a simple comment */', + tokens: [{ startIndex: 0, type: 'comment.pats' }] + } + ], - [{ - line: 'var x : int = /* a simple comment */ 1;', - tokens: [ - { startIndex: 0, type: 'keyword.pats' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'identifier.pats' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'keyword.pats' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'type.pats' }, - { startIndex: 11, type: '' }, - { startIndex: 12, type: 'keyword.pats' }, - { startIndex: 13, type: '' }, - { startIndex: 14, type: 'comment.pats' }, - { startIndex: 36, type: '' }, - { startIndex: 37, type: 'number.decimal.pats' }, - { startIndex: 38, type: 'delimiter.semicolon.pats' } - ] - }], + [ + { + line: 'var x : int = /* a simple comment */ 1;', + tokens: [ + { startIndex: 0, type: 'keyword.pats' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'identifier.pats' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.pats' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'type.pats' }, + { startIndex: 11, type: '' }, + { startIndex: 12, type: 'keyword.pats' }, + { startIndex: 13, type: '' }, + { startIndex: 14, type: 'comment.pats' }, + { startIndex: 36, type: '' }, + { startIndex: 37, type: 'number.decimal.pats' }, + { startIndex: 38, type: 'delimiter.semicolon.pats' } + ] + } + ], - [{ - line: 'val x = /* comment */ 1; */', - tokens: [ - { startIndex: 0, type: 'keyword.pats' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'identifier.pats' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'keyword.pats' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'comment.pats' }, - { startIndex: 21, type: '' }, - { startIndex: 22, type: 'number.decimal.pats' }, - { startIndex: 23, type: 'delimiter.semicolon.pats' }, - { startIndex: 24, type: '' }, - { startIndex: 25, type: 'operator.pats' } - ] - }], + [ + { + line: 'val x = /* comment */ 1; */', + tokens: [ + { startIndex: 0, type: 'keyword.pats' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'identifier.pats' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.pats' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'comment.pats' }, + { startIndex: 21, type: '' }, + { startIndex: 22, type: 'number.decimal.pats' }, + { startIndex: 23, type: 'delimiter.semicolon.pats' }, + { startIndex: 24, type: '' }, + { startIndex: 25, type: 'operator.pats' } + ] + } + ], - [{ - line: 'x = /**/;', - tokens: [ - { startIndex: 0, type: 'identifier.pats' }, - { startIndex: 1, type: '' }, - { startIndex: 2, type: 'keyword.pats' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'comment.pats' }, - { startIndex: 8, type: 'delimiter.semicolon.pats' } - ] - }], + [ + { + line: 'x = /**/;', + tokens: [ + { startIndex: 0, type: 'identifier.pats' }, + { startIndex: 1, type: '' }, + { startIndex: 2, type: 'keyword.pats' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'comment.pats' }, + { startIndex: 8, type: 'delimiter.semicolon.pats' } + ] + } + ], - [{ - line: 'x = /*/;', - tokens: [ - { startIndex: 0, type: 'identifier.pats' }, - { startIndex: 1, type: '' }, - { startIndex: 2, type: 'keyword.pats' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'comment.pats' } - ] - }], + [ + { + line: 'x = /*/;', + tokens: [ + { startIndex: 0, type: 'identifier.pats' }, + { startIndex: 1, type: '' }, + { startIndex: 2, type: 'keyword.pats' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'comment.pats' } + ] + } + ], // block comments, single line - [{ - line: '(* a simple comment *)', - tokens: [ - { startIndex: 0, type: 'comment.pats' } - ] - }], + [ + { + line: '(* a simple comment *)', + tokens: [{ startIndex: 0, type: 'comment.pats' }] + } + ], - [{ - line: '(* a simple (* nested *) comment *)', - tokens: [ - { startIndex: 0, type: 'comment.pats' } - ] - }], + [ + { + line: '(* a simple (* nested *) comment *)', + tokens: [{ startIndex: 0, type: 'comment.pats' }] + } + ], - [{ - line: '(* ****** ****** *)', - tokens: [ - { startIndex: 0, type: 'comment.pats' } - ] - }], + [ + { + line: '(* ****** ****** *)', + tokens: [{ startIndex: 0, type: 'comment.pats' }] + } + ], - [{ - line: 'var x : int = (* a simple comment *) 1;', - tokens: [ - { startIndex: 0, type: 'keyword.pats' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'identifier.pats' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'keyword.pats' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'type.pats' }, - { startIndex: 11, type: '' }, - { startIndex: 12, type: 'keyword.pats' }, - { startIndex: 13, type: '' }, - { startIndex: 14, type: 'comment.pats' }, - { startIndex: 36, type: '' }, - { startIndex: 37, type: 'number.decimal.pats' }, - { startIndex: 38, type: 'delimiter.semicolon.pats' } - ] - }], + [ + { + line: 'var x : int = (* a simple comment *) 1;', + tokens: [ + { startIndex: 0, type: 'keyword.pats' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'identifier.pats' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.pats' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'type.pats' }, + { startIndex: 11, type: '' }, + { startIndex: 12, type: 'keyword.pats' }, + { startIndex: 13, type: '' }, + { startIndex: 14, type: 'comment.pats' }, + { startIndex: 36, type: '' }, + { startIndex: 37, type: 'number.decimal.pats' }, + { startIndex: 38, type: 'delimiter.semicolon.pats' } + ] + } + ], - [{ - line: 'val x = (* comment *) 1; *)', - tokens: [ - { startIndex: 0, type: 'keyword.pats' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'identifier.pats' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'keyword.pats' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'comment.pats' }, - { startIndex: 21, type: '' }, - { startIndex: 22, type: 'number.decimal.pats' }, - { startIndex: 23, type: 'delimiter.semicolon.pats' }, - { startIndex: 24, type: '' }, - { startIndex: 25, type: 'operator.pats' }, - { startIndex: 26, type: 'delimiter.parenthesis.pats' }, - ] - }], + [ + { + line: 'val x = (* comment *) 1; *)', + tokens: [ + { startIndex: 0, type: 'keyword.pats' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'identifier.pats' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.pats' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'comment.pats' }, + { startIndex: 21, type: '' }, + { startIndex: 22, type: 'number.decimal.pats' }, + { startIndex: 23, type: 'delimiter.semicolon.pats' }, + { startIndex: 24, type: '' }, + { startIndex: 25, type: 'operator.pats' }, + { startIndex: 26, type: 'delimiter.parenthesis.pats' } + ] + } + ], - [{ - line: 'x = (**);', - tokens: [ - { startIndex: 0, type: 'identifier.pats' }, - { startIndex: 1, type: '' }, - { startIndex: 2, type: 'keyword.pats' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'comment.pats' }, - { startIndex: 8, type: 'delimiter.semicolon.pats' } - ] - }], + [ + { + line: 'x = (**);', + tokens: [ + { startIndex: 0, type: 'identifier.pats' }, + { startIndex: 1, type: '' }, + { startIndex: 2, type: 'keyword.pats' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'comment.pats' }, + { startIndex: 8, type: 'delimiter.semicolon.pats' } + ] + } + ], - [{ - line: '(*)', - tokens: [ - { startIndex: 0, type: 'invalid.pats' }, // not a comment! - ] - }], + [ + { + line: '(*)', + tokens: [ + { startIndex: 0, type: 'invalid.pats' } // not a comment! + ] + } + ], // Numbers - [{ - line: '0', - tokens: [ - { startIndex: 0, type: 'number.decimal.pats' } - ] - }], + [ + { + line: '0', + tokens: [{ startIndex: 0, type: 'number.decimal.pats' }] + } + ], - [{ - line: '12l', - tokens: [ - { startIndex: 0, type: 'number.decimal.pats' } - ] - }], + [ + { + line: '12l', + tokens: [{ startIndex: 0, type: 'number.decimal.pats' }] + } + ], - [{ - line: '34U', - tokens: [ - { startIndex: 0, type: 'number.decimal.pats' } - ] - }], + [ + { + line: '34U', + tokens: [{ startIndex: 0, type: 'number.decimal.pats' }] + } + ], - [{ - line: '55LL', - tokens: [ - { startIndex: 0, type: 'number.decimal.pats' } - ] - }], + [ + { + line: '55LL', + tokens: [{ startIndex: 0, type: 'number.decimal.pats' }] + } + ], - [{ - line: '34ul', - tokens: [ - { startIndex: 0, type: 'number.decimal.pats' } - ] - }], + [ + { + line: '34ul', + tokens: [{ startIndex: 0, type: 'number.decimal.pats' }] + } + ], - [{ - line: '55llU', - tokens: [ - { startIndex: 0, type: 'number.decimal.pats' } - ] - }], + [ + { + line: '55llU', + tokens: [{ startIndex: 0, type: 'number.decimal.pats' }] + } + ], /* [{ @@ -314,694 +342,712 @@ testTokenization('postiats', [ { startIndex: 0, type: 'number.pats' } ]}], */ - [{ - line: '0x100aafllU', - tokens: [ - { startIndex: 0, type: 'number.hex.pats' } - ] - }], + [ + { + line: '0x100aafllU', + tokens: [{ startIndex: 0, type: 'number.hex.pats' }] + } + ], - [{ - line: '0342325', - tokens: [ - { startIndex: 0, type: 'number.octal.pats' } - ] - }], + [ + { + line: '0342325', + tokens: [{ startIndex: 0, type: 'number.octal.pats' }] + } + ], - [{ - line: '0x123', - tokens: [ - { startIndex: 0, type: 'number.hex.pats' } - ] - }], + [ + { + line: '0x123', + tokens: [{ startIndex: 0, type: 'number.hex.pats' }] + } + ], - [{ - line: '23.5', - tokens: [ - { startIndex: 0, type: 'number.float.pats' } - ] - }], + [ + { + line: '23.5', + tokens: [{ startIndex: 0, type: 'number.float.pats' }] + } + ], - [{ - line: '23.5e3', - tokens: [ - { startIndex: 0, type: 'number.float.pats' } - ] - }], + [ + { + line: '23.5e3', + tokens: [{ startIndex: 0, type: 'number.float.pats' }] + } + ], - [{ - line: '23.5E3', - tokens: [ - { startIndex: 0, type: 'number.float.pats' } - ] - }], + [ + { + line: '23.5E3', + tokens: [{ startIndex: 0, type: 'number.float.pats' }] + } + ], - [{ - line: '23.5F', - tokens: [ - { startIndex: 0, type: 'number.float.pats' } - ] - }], + [ + { + line: '23.5F', + tokens: [{ startIndex: 0, type: 'number.float.pats' }] + } + ], - [{ - line: '23.5f', - tokens: [ - { startIndex: 0, type: 'number.float.pats' } - ] - }], + [ + { + line: '23.5f', + tokens: [{ startIndex: 0, type: 'number.float.pats' }] + } + ], - [{ - line: '1.72E3F', - tokens: [ - { startIndex: 0, type: 'number.float.pats' } - ] - }], + [ + { + line: '1.72E3F', + tokens: [{ startIndex: 0, type: 'number.float.pats' }] + } + ], - [{ - line: '1.72E3f', - tokens: [ - { startIndex: 0, type: 'number.float.pats' } - ] - }], + [ + { + line: '1.72E3f', + tokens: [{ startIndex: 0, type: 'number.float.pats' }] + } + ], - [{ - line: '1.72e3F', - tokens: [ - { startIndex: 0, type: 'number.float.pats' } - ] - }], + [ + { + line: '1.72e3F', + tokens: [{ startIndex: 0, type: 'number.float.pats' }] + } + ], - [{ - line: '1.72e3f', - tokens: [ - { startIndex: 0, type: 'number.float.pats' } - ] - }], + [ + { + line: '1.72e3f', + tokens: [{ startIndex: 0, type: 'number.float.pats' }] + } + ], - [{ - line: '23.5L', - tokens: [ - { startIndex: 0, type: 'number.float.pats' } - ] - }], + [ + { + line: '23.5L', + tokens: [{ startIndex: 0, type: 'number.float.pats' }] + } + ], - [{ - line: '23.5l', - tokens: [ - { startIndex: 0, type: 'number.float.pats' } - ] - }], + [ + { + line: '23.5l', + tokens: [{ startIndex: 0, type: 'number.float.pats' }] + } + ], - [{ - line: '1.72E3L', - tokens: [ - { startIndex: 0, type: 'number.float.pats' } - ] - }], + [ + { + line: '1.72E3L', + tokens: [{ startIndex: 0, type: 'number.float.pats' }] + } + ], - [{ - line: '1.72E3l', - tokens: [ - { startIndex: 0, type: 'number.float.pats' } - ] - }], + [ + { + line: '1.72E3l', + tokens: [{ startIndex: 0, type: 'number.float.pats' }] + } + ], - [{ - line: '1.72e3L', - tokens: [ - { startIndex: 0, type: 'number.float.pats' } - ] - }], + [ + { + line: '1.72e3L', + tokens: [{ startIndex: 0, type: 'number.float.pats' }] + } + ], - [{ - line: '1.72e3l', - tokens: [ - { startIndex: 0, type: 'number.float.pats' } - ] - }], + [ + { + line: '1.72e3l', + tokens: [{ startIndex: 0, type: 'number.float.pats' }] + } + ], - [{ - line: '0+0', - tokens: [ - { startIndex: 0, type: 'number.decimal.pats' }, - { startIndex: 1, type: 'operator.pats' }, - { startIndex: 2, type: 'number.decimal.pats' } - ] - }], + [ + { + line: '0+0', + tokens: [ + { startIndex: 0, type: 'number.decimal.pats' }, + { startIndex: 1, type: 'operator.pats' }, + { startIndex: 2, type: 'number.decimal.pats' } + ] + } + ], - [{ - line: '100+10', - tokens: [ - { startIndex: 0, type: 'number.decimal.pats' }, - { startIndex: 3, type: 'operator.pats' }, - { startIndex: 4, type: 'number.decimal.pats' } - ] - }], + [ + { + line: '100+10', + tokens: [ + { startIndex: 0, type: 'number.decimal.pats' }, + { startIndex: 3, type: 'operator.pats' }, + { startIndex: 4, type: 'number.decimal.pats' } + ] + } + ], - [{ - line: '0 + 0', - tokens: [ - { startIndex: 0, type: 'number.decimal.pats' }, - { startIndex: 1, type: '' }, - { startIndex: 2, type: 'operator.pats' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'number.decimal.pats' } - ] - }], + [ + { + line: '0 + 0', + tokens: [ + { startIndex: 0, type: 'number.decimal.pats' }, + { startIndex: 1, type: '' }, + { startIndex: 2, type: 'operator.pats' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'number.decimal.pats' } + ] + } + ], // hi-lighting of variables in staload/dynload - [{ - line: '"{$LIBATSCC2JS}/staloadall.hats"', - tokens: [ - { startIndex: 0, type: 'string.quote.pats' }, - { startIndex: 1, type: 'string.escape.pats' }, - { startIndex: 3, type: 'identifier.pats' }, - { startIndex: 14, type: 'string.escape.pats' }, - { startIndex: 15, type: 'string.pats' }, - { startIndex: 31, type: 'string.quote.pats' } - ] - }], + [ + { + line: '"{$LIBATSCC2JS}/staloadall.hats"', + tokens: [ + { startIndex: 0, type: 'string.quote.pats' }, + { startIndex: 1, type: 'string.escape.pats' }, + { startIndex: 3, type: 'identifier.pats' }, + { startIndex: 14, type: 'string.escape.pats' }, + { startIndex: 15, type: 'string.pats' }, + { startIndex: 31, type: 'string.quote.pats' } + ] + } + ], // Monarch Generated - [{ - line: '#include "/path/to/my/file.h"', - tokens: [ - { startIndex: 0, type: 'keyword.srp.pats' }, - { startIndex: 8, type: '' }, - { startIndex: 9, type: 'string.quote.pats' }, - { startIndex: 10, type: 'string.pats' }, - { startIndex: 28, type: 'string.quote.pats' } - ] - }, { - line: '', - tokens: [ - - ] - }, { - line: '#ifdef VAR #then', - tokens: [ - { startIndex: 0, type: 'keyword.srp.pats' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'identifier.pats' }, - { startIndex: 10, type: '' }, - { startIndex: 11, type: 'keyword.srp.pats' } - ] - }, { - line: '#define SUM(A,B) (A) + (B)', - tokens: [ - { startIndex: 0, type: 'keyword.srp.pats' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'identifier.pats' }, - { startIndex: 11, type: 'delimiter.parenthesis.pats' }, - { startIndex: 12, type: 'identifier.pats' }, - { startIndex: 13, type: 'delimiter.comma.pats' }, - { startIndex: 14, type: 'identifier.pats' }, - { startIndex: 15, type: 'delimiter.parenthesis.pats' }, - { startIndex: 16, type: '' }, - { startIndex: 17, type: 'delimiter.parenthesis.pats' }, - { startIndex: 18, type: 'identifier.pats' }, - { startIndex: 19, type: 'delimiter.parenthesis.pats' }, - { startIndex: 20, type: '' }, - { startIndex: 21, type: 'operator.pats' }, - { startIndex: 22, type: '' }, - { startIndex: 23, type: 'delimiter.parenthesis.pats' }, - { startIndex: 24, type: 'identifier.pats' }, - { startIndex: 25, type: 'delimiter.parenthesis.pats' } - ] - }, { - line: 'staload Asdf_CDE = "./myfile.sats"', - tokens: [ - { startIndex: 0, type: 'keyword.pats' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'identifier.pats' }, - { startIndex: 16, type: '' }, - { startIndex: 17, type: 'keyword.pats' }, - { startIndex: 18, type: '' }, - { startIndex: 19, type: 'string.quote.pats' }, - { startIndex: 20, type: 'string.pats' }, - { startIndex: 33, type: 'string.quote.pats' }, - ] - }, { - line: '', - tokens: [ - - ] - }, { - line: 'implement main(argc, argv)', - tokens: [ - { startIndex: 0, type: 'keyword.pats' }, - { startIndex: 9, type: '' }, - { startIndex: 10, type: 'identifier.pats' }, - { startIndex: 14, type: 'delimiter.parenthesis.pats' }, - { startIndex: 15, type: 'identifier.pats' }, - { startIndex: 19, type: 'delimiter.comma.pats' }, - { startIndex: 20, type: '' }, - { startIndex: 21, type: 'identifier.pats' }, - { startIndex: 25, type: 'delimiter.parenthesis.pats' } - ] - }, { - line: ' = begin', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 1, type: 'keyword.pats' }, - { startIndex: 2, type: '' }, - { startIndex: 3, type: 'keyword.pats' } - ] - }, { - line: '0', - tokens: [ - { startIndex: 0, type: 'number.decimal.pats' }, - ] - }, { - line: 'end', - tokens: [ - { startIndex: 0, type: 'keyword.pats' } - ] - }, { - line: '', - tokens: [ - - ] - }, { - line: '', - tokens: [ - - ] - }, { - line: 'dataprop FACT (int, int) =', - tokens: [ - { startIndex: 0, type: 'keyword.pats' }, - { startIndex: 8, type: '' }, - { startIndex: 9, type: 'identifier.pats' }, - { startIndex: 13, type: '' }, - { startIndex: 14, type: 'delimiter.parenthesis.pats' }, - { startIndex: 15, type: 'type.pats' }, - { startIndex: 18, type: 'delimiter.comma.pats' }, - { startIndex: 19, type: '' }, - { startIndex: 20, type: 'type.pats' }, - { startIndex: 23, type: 'delimiter.parenthesis.pats' }, - { startIndex: 24, type: '' }, - { startIndex: 25, type: 'keyword.pats' } - ] - }, { - line: ' | FACTbas (0, 1) of ()', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 1, type: 'keyword.pats' }, - { startIndex: 2, type: '' }, - { startIndex: 3, type: 'identifier.pats' }, - { startIndex: 10, type: '' }, - { startIndex: 11, type: 'delimiter.parenthesis.pats' }, - { startIndex: 12, type: 'number.decimal.pats' }, - { startIndex: 13, type: 'delimiter.comma.pats' }, - { startIndex: 14, type: '' }, - { startIndex: 15, type: 'number.decimal.pats' }, - { startIndex: 16, type: 'delimiter.parenthesis.pats' }, - { startIndex: 17, type: '' }, - { startIndex: 18, type: 'keyword.pats' }, - { startIndex: 20, type: '' }, - { startIndex: 21, type: 'delimiter.parenthesis.pats' } - ] - }, { - line: ' | {n:pos}{r:int} FACTind (n, n*r) of FACT (n-1, r)', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 1, type: 'keyword.pats' }, - { startIndex: 2, type: '' }, - { startIndex: 3, type: 'delimiter.curly.pats' }, - { startIndex: 4, type: 'identifier.pats' }, - { startIndex: 5, type: 'keyword.pats' }, - { startIndex: 6, type: 'identifier.pats' }, - { startIndex: 9, type: 'delimiter.parenthesis.pats' }, - { startIndex: 10, type: 'delimiter.curly.pats' }, - { startIndex: 11, type: 'identifier.pats' }, - { startIndex: 12, type: 'keyword.pats' }, - { startIndex: 13, type: 'type.pats' }, - { startIndex: 16, type: 'delimiter.parenthesis.pats' }, - { startIndex: 17, type: '' }, - { startIndex: 18, type: 'identifier.pats' }, - { startIndex: 25, type: '' }, - { startIndex: 26, type: 'delimiter.parenthesis.pats' }, - { startIndex: 27, type: 'identifier.pats' }, - { startIndex: 28, type: 'delimiter.comma.pats' }, - { startIndex: 29, type: '' }, - { startIndex: 30, type: 'identifier.pats' }, - { startIndex: 31, type: 'operator.pats' }, - { startIndex: 32, type: 'identifier.pats' }, - { startIndex: 33, type: 'delimiter.parenthesis.pats' }, - { startIndex: 34, type: '' }, - { startIndex: 35, type: 'keyword.pats' }, - { startIndex: 37, type: '' }, - { startIndex: 38, type: 'identifier.pats' }, - { startIndex: 42, type: '' }, - { startIndex: 43, type: 'delimiter.parenthesis.pats' }, - { startIndex: 44, type: 'identifier.pats' }, - { startIndex: 45, type: 'operator.pats' }, - { startIndex: 46, type: 'number.decimal.pats' }, - { startIndex: 47, type: 'delimiter.comma.pats' }, - { startIndex: 48, type: '' }, - { startIndex: 49, type: 'identifier.pats' }, - { startIndex: 50, type: 'delimiter.parenthesis.pats' }, - ] - }, { - line: '', - tokens: [ - - ] - }, { - line: 'fun fact {n:nat} .. (x: int n) : [r:int] (FACT(n, r) | int(r)) = (', - tokens: [ - { startIndex: 0, type: 'keyword.pats' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'identifier.pats' }, - { startIndex: 8, type: '' }, - { startIndex: 9, type: 'delimiter.curly.pats' }, - { startIndex: 10, type: 'identifier.pats' }, - { startIndex: 11, type: 'keyword.pats' }, - { startIndex: 12, type: 'identifier.pats' }, - { startIndex: 15, type: 'delimiter.parenthesis.pats' }, - { startIndex: 16, type: '' }, - { startIndex: 17, type: 'identifier.sym.pats' }, - { startIndex: 19, type: 'identifier.pats' }, - { startIndex: 20, type: 'keyword.pats' }, - { startIndex: 22, type: '' }, - { startIndex: 23, type: 'delimiter.parenthesis.pats' }, - { startIndex: 24, type: 'identifier.pats' }, - { startIndex: 25, type: 'keyword.pats' }, - { startIndex: 26, type: '' }, - { startIndex: 27, type: 'type.pats' }, - { startIndex: 30, type: '' }, - { startIndex: 31, type: 'identifier.pats' }, - { startIndex: 32, type: 'delimiter.parenthesis.pats' }, - { startIndex: 33, type: '' }, - { startIndex: 34, type: 'keyword.pats' }, - { startIndex: 35, type: '' }, - { startIndex: 36, type: 'delimiter.square.pats' }, - { startIndex: 37, type: 'identifier.pats' }, - { startIndex: 38, type: 'keyword.pats' }, - { startIndex: 39, type: 'type.pats' }, - { startIndex: 42, type: 'delimiter.square.pats' }, - { startIndex: 43, type: '' }, - { startIndex: 44, type: 'delimiter.parenthesis.pats' }, - { startIndex: 45, type: 'identifier.pats' }, - { startIndex: 49, type: 'delimiter.parenthesis.pats' }, - { startIndex: 50, type: 'identifier.pats' }, - { startIndex: 51, type: 'delimiter.comma.pats' }, - { startIndex: 52, type: '' }, - { startIndex: 53, type: 'identifier.pats' }, - { startIndex: 54, type: 'delimiter.parenthesis.pats' }, - { startIndex: 55, type: '' }, - { startIndex: 56, type: 'keyword.pats' }, - { startIndex: 57, type: '' }, - { startIndex: 58, type: 'type.pats' }, - { startIndex: 61, type: 'delimiter.parenthesis.pats' }, - { startIndex: 62, type: 'identifier.pats' }, - { startIndex: 63, type: 'delimiter.parenthesis.pats' }, - { startIndex: 65, type: '' }, - { startIndex: 66, type: 'keyword.pats' }, - { startIndex: 67, type: '' }, - { startIndex: 68, type: 'delimiter.parenthesis.pats' }, - ] - }, { - line: 'if x > 0 then let', - tokens: [ - { startIndex: 0, type: 'keyword.pats' }, - { startIndex: 2, type: '' }, - { startIndex: 3, type: 'identifier.pats' }, - { startIndex: 4, type: '' }, - { startIndex: 5, type: 'keyword.pats' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'number.decimal.pats' }, - { startIndex: 8, type: '' }, - { startIndex: 9, type: 'keyword.pats' }, - { startIndex: 13, type: '' }, - { startIndex: 14, type: 'keyword.pats' }, - ] - }, { - line: ' val [r1:int] (pf1 | r1) = fact (x-1)', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'keyword.pats' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'delimiter.square.pats' }, - { startIndex: 7, type: 'identifier.pats' }, - { startIndex: 9, type: 'keyword.pats' }, - { startIndex: 10, type: 'type.pats' }, - { startIndex: 13, type: 'delimiter.square.pats' }, - { startIndex: 14, type: '' }, - { startIndex: 15, type: 'delimiter.parenthesis.pats' }, - { startIndex: 16, type: 'identifier.pats' }, - { startIndex: 19, type: '' }, - { startIndex: 20, type: 'keyword.pats' }, - { startIndex: 21, type: '' }, - { startIndex: 22, type: 'identifier.pats' }, - { startIndex: 24, type: 'delimiter.parenthesis.pats' }, - { startIndex: 25, type: '' }, - { startIndex: 26, type: 'keyword.pats' }, - { startIndex: 27, type: '' }, - { startIndex: 28, type: 'identifier.pats' }, - { startIndex: 32, type: '' }, - { startIndex: 33, type: 'delimiter.parenthesis.pats' }, - { startIndex: 34, type: 'identifier.pats' }, - { startIndex: 35, type: 'operator.pats' }, - { startIndex: 36, type: 'number.decimal.pats' }, - { startIndex: 37, type: 'delimiter.parenthesis.pats' }, - ] - }, { - line: ' prval pf = FACTind {n}{r1} (pf1)', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'keyword.pats' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'identifier.pats' }, - { startIndex: 10, type: '' }, - { startIndex: 11, type: 'keyword.pats' }, - { startIndex: 12, type: '' }, - { startIndex: 13, type: 'identifier.pats' }, - { startIndex: 20, type: '' }, - { startIndex: 21, type: 'delimiter.curly.pats' }, - { startIndex: 22, type: 'identifier.pats' }, - { startIndex: 23, type: 'delimiter.parenthesis.pats' }, - { startIndex: 24, type: 'delimiter.curly.pats' }, - { startIndex: 25, type: 'identifier.pats' }, - { startIndex: 27, type: 'delimiter.parenthesis.pats' }, - { startIndex: 28, type: '' }, - { startIndex: 29, type: 'delimiter.parenthesis.pats' }, - { startIndex: 30, type: 'identifier.pats' }, - { startIndex: 33, type: 'delimiter.parenthesis.pats' } - ] - }, { - line: ' val r = x * r1', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'keyword.pats' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'identifier.pats' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'keyword.pats' }, - { startIndex: 9, type: '' }, - { startIndex: 10, type: 'identifier.pats' }, - { startIndex: 11, type: '' }, - { startIndex: 12, type: 'operator.pats' }, - { startIndex: 13, type: '' }, - { startIndex: 14, type: 'identifier.pats' } - ] - }, { - line: 'in', - tokens: [ - { startIndex: 0, type: 'keyword.pats' } - ] - }, { - line: ' (pf | r)', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'delimiter.parenthesis.pats' }, - { startIndex: 3, type: 'identifier.pats' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'keyword.pats' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'identifier.pats' }, - { startIndex: 9, type: 'delimiter.parenthesis.pats' } - ] - }, { - line: 'end // end of [then]', - tokens: [ - { startIndex: 0, type: 'keyword.pats' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'comment.pats' } - ] - }, { - line: 'else (FACTbas () | 1)', - tokens: [ - { startIndex: 0, type: 'keyword.pats' }, - { startIndex: 4, type: '' }, - { startIndex: 5, type: 'delimiter.parenthesis.pats' }, - { startIndex: 6, type: 'identifier.pats' }, - { startIndex: 13, type: '' }, - { startIndex: 14, type: 'delimiter.parenthesis.pats' }, - { startIndex: 16, type: '' }, - { startIndex: 17, type: 'keyword.pats' }, - { startIndex: 18, type: '' }, - { startIndex: 19, type: 'number.decimal.pats' }, - { startIndex: 20, type: 'delimiter.parenthesis.pats' } - ] - }, { - line: ') (* end of [fact] *)', - tokens: [ - { startIndex: 0, type: 'delimiter.parenthesis.pats' }, - { startIndex: 1, type: '' }, - { startIndex: 2, type: 'comment.pats' } - ] - }, { - line: '', - tokens: [ - - ] - }, { - line: 'local', - tokens: [ - { startIndex: 0, type: 'keyword.pats' } - ] - }, { - line: 'var __count: int = 0 // it is statically allocated', - tokens: [ - { startIndex: 0, type: 'keyword.pats' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'identifier.pats' }, - { startIndex: 11, type: 'keyword.pats' }, - { startIndex: 12, type: '' }, - { startIndex: 13, type: 'type.pats' }, - { startIndex: 16, type: '' }, - { startIndex: 17, type: 'keyword.pats' }, - { startIndex: 18, type: '' }, - { startIndex: 19, type: 'number.decimal.pats' }, - { startIndex: 20, type: '' }, - { startIndex: 21, type: 'comment.pats' } - ] - }, { - line: '', - tokens: [ - ] - }, { - line: 'val theCount =', - tokens: [ - { startIndex: 0, type: 'keyword.pats' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'identifier.pats' }, - { startIndex: 12, type: '' }, - { startIndex: 13, type: 'keyword.pats' } - ] - }, { - line: ' ref_make_viewptr{int}(view@(__count) | addr@(__count))', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'identifier.pats' }, - { startIndex: 18, type: 'delimiter.curly.pats' }, - { startIndex: 19, type: 'type.pats' }, - { startIndex: 22, type: 'delimiter.parenthesis.pats' }, - { startIndex: 24, type: 'keyword.pats' }, - { startIndex: 29, type: 'delimiter.parenthesis.pats' }, - { startIndex: 30, type: 'identifier.pats' }, - { startIndex: 37, type: 'delimiter.parenthesis.pats' }, - { startIndex: 38, type: '' }, - { startIndex: 39, type: 'keyword.pats' }, - { startIndex: 40, type: '' }, - { startIndex: 41, type: 'keyword.pats' }, - { startIndex: 46, type: 'delimiter.parenthesis.pats' }, - { startIndex: 47, type: 'identifier.pats' }, - { startIndex: 54, type: 'delimiter.parenthesis.pats' }, - ] - }, { - line: '// end of [val]', - tokens: [ - { startIndex: 0, type: 'comment.pats' } - ] - }, { - line: '', - tokens: [ - - ] - }, { - line: 'in (* in of [local] *)', - tokens: [ - { startIndex: 0, type: 'keyword.pats' }, - { startIndex: 2, type: '' }, - { startIndex: 3, type: 'comment.pats' } - ] - }, { - line: '', - tokens: [ - - ] - }, { - line: 'fun theCount_get (): int = !theCount', - tokens: [ - { startIndex: 0, type: 'keyword.pats' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'identifier.pats' }, - { startIndex: 16, type: '' }, - { startIndex: 17, type: 'delimiter.parenthesis.pats' }, - { startIndex: 19, type: 'keyword.pats' }, - { startIndex: 20, type: '' }, - { startIndex: 21, type: 'type.pats' }, - { startIndex: 24, type: '' }, - { startIndex: 25, type: 'keyword.pats' }, - { startIndex: 26, type: '' }, - { startIndex: 27, type: 'keyword.pats' }, - { startIndex: 28, type: 'identifier.pats' } - ] - }, { - line: '', - tokens: [ - - ] - }, { - line: 'fun theCount_inc (): void = !theCount := !theCount + 1', - tokens: [ - { startIndex: 0, type: 'keyword.pats' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'identifier.pats' }, - { startIndex: 16, type: '' }, - { startIndex: 17, type: 'delimiter.parenthesis.pats' }, - { startIndex: 19, type: 'keyword.pats' }, - { startIndex: 20, type: '' }, - { startIndex: 21, type: 'type.pats' }, - { startIndex: 25, type: '' }, - { startIndex: 26, type: 'keyword.pats' }, - { startIndex: 27, type: '' }, - { startIndex: 28, type: 'keyword.pats' }, - { startIndex: 29, type: 'identifier.pats' }, - { startIndex: 37, type: '' }, - { startIndex: 38, type: 'operator.pats' }, - { startIndex: 40, type: '' }, - { startIndex: 41, type: 'keyword.pats' }, - { startIndex: 42, type: 'identifier.pats' }, - { startIndex: 50, type: '' }, - { startIndex: 51, type: 'operator.pats' }, - { startIndex: 52, type: '' }, - { startIndex: 53, type: 'number.decimal.pats' } - ] - }, { - line: '', - tokens: [ - - ] - }, { - line: 'end // end of [local]', - tokens: [ - { startIndex: 0, type: 'keyword.pats' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'comment.pats' } - ] - }, { - line: '', - tokens: [ - - ] - }, { - line: '#endif', - tokens: [ - { startIndex: 0, type: 'keyword.srp.pats' } - ] - }] + [ + { + line: '#include "/path/to/my/file.h"', + tokens: [ + { startIndex: 0, type: 'keyword.srp.pats' }, + { startIndex: 8, type: '' }, + { startIndex: 9, type: 'string.quote.pats' }, + { startIndex: 10, type: 'string.pats' }, + { startIndex: 28, type: 'string.quote.pats' } + ] + }, + { + line: '', + tokens: [] + }, + { + line: '#ifdef VAR #then', + tokens: [ + { startIndex: 0, type: 'keyword.srp.pats' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'identifier.pats' }, + { startIndex: 10, type: '' }, + { startIndex: 11, type: 'keyword.srp.pats' } + ] + }, + { + line: '#define SUM(A,B) (A) + (B)', + tokens: [ + { startIndex: 0, type: 'keyword.srp.pats' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'identifier.pats' }, + { startIndex: 11, type: 'delimiter.parenthesis.pats' }, + { startIndex: 12, type: 'identifier.pats' }, + { startIndex: 13, type: 'delimiter.comma.pats' }, + { startIndex: 14, type: 'identifier.pats' }, + { startIndex: 15, type: 'delimiter.parenthesis.pats' }, + { startIndex: 16, type: '' }, + { startIndex: 17, type: 'delimiter.parenthesis.pats' }, + { startIndex: 18, type: 'identifier.pats' }, + { startIndex: 19, type: 'delimiter.parenthesis.pats' }, + { startIndex: 20, type: '' }, + { startIndex: 21, type: 'operator.pats' }, + { startIndex: 22, type: '' }, + { startIndex: 23, type: 'delimiter.parenthesis.pats' }, + { startIndex: 24, type: 'identifier.pats' }, + { startIndex: 25, type: 'delimiter.parenthesis.pats' } + ] + }, + { + line: 'staload Asdf_CDE = "./myfile.sats"', + tokens: [ + { startIndex: 0, type: 'keyword.pats' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'identifier.pats' }, + { startIndex: 16, type: '' }, + { startIndex: 17, type: 'keyword.pats' }, + { startIndex: 18, type: '' }, + { startIndex: 19, type: 'string.quote.pats' }, + { startIndex: 20, type: 'string.pats' }, + { startIndex: 33, type: 'string.quote.pats' } + ] + }, + { + line: '', + tokens: [] + }, + { + line: 'implement main(argc, argv)', + tokens: [ + { startIndex: 0, type: 'keyword.pats' }, + { startIndex: 9, type: '' }, + { startIndex: 10, type: 'identifier.pats' }, + { startIndex: 14, type: 'delimiter.parenthesis.pats' }, + { startIndex: 15, type: 'identifier.pats' }, + { startIndex: 19, type: 'delimiter.comma.pats' }, + { startIndex: 20, type: '' }, + { startIndex: 21, type: 'identifier.pats' }, + { startIndex: 25, type: 'delimiter.parenthesis.pats' } + ] + }, + { + line: ' = begin', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 1, type: 'keyword.pats' }, + { startIndex: 2, type: '' }, + { startIndex: 3, type: 'keyword.pats' } + ] + }, + { + line: '0', + tokens: [{ startIndex: 0, type: 'number.decimal.pats' }] + }, + { + line: 'end', + tokens: [{ startIndex: 0, type: 'keyword.pats' }] + }, + { + line: '', + tokens: [] + }, + { + line: '', + tokens: [] + }, + { + line: 'dataprop FACT (int, int) =', + tokens: [ + { startIndex: 0, type: 'keyword.pats' }, + { startIndex: 8, type: '' }, + { startIndex: 9, type: 'identifier.pats' }, + { startIndex: 13, type: '' }, + { startIndex: 14, type: 'delimiter.parenthesis.pats' }, + { startIndex: 15, type: 'type.pats' }, + { startIndex: 18, type: 'delimiter.comma.pats' }, + { startIndex: 19, type: '' }, + { startIndex: 20, type: 'type.pats' }, + { startIndex: 23, type: 'delimiter.parenthesis.pats' }, + { startIndex: 24, type: '' }, + { startIndex: 25, type: 'keyword.pats' } + ] + }, + { + line: ' | FACTbas (0, 1) of ()', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 1, type: 'keyword.pats' }, + { startIndex: 2, type: '' }, + { startIndex: 3, type: 'identifier.pats' }, + { startIndex: 10, type: '' }, + { startIndex: 11, type: 'delimiter.parenthesis.pats' }, + { startIndex: 12, type: 'number.decimal.pats' }, + { startIndex: 13, type: 'delimiter.comma.pats' }, + { startIndex: 14, type: '' }, + { startIndex: 15, type: 'number.decimal.pats' }, + { startIndex: 16, type: 'delimiter.parenthesis.pats' }, + { startIndex: 17, type: '' }, + { startIndex: 18, type: 'keyword.pats' }, + { startIndex: 20, type: '' }, + { startIndex: 21, type: 'delimiter.parenthesis.pats' } + ] + }, + { + line: ' | {n:pos}{r:int} FACTind (n, n*r) of FACT (n-1, r)', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 1, type: 'keyword.pats' }, + { startIndex: 2, type: '' }, + { startIndex: 3, type: 'delimiter.curly.pats' }, + { startIndex: 4, type: 'identifier.pats' }, + { startIndex: 5, type: 'keyword.pats' }, + { startIndex: 6, type: 'identifier.pats' }, + { startIndex: 9, type: 'delimiter.parenthesis.pats' }, + { startIndex: 10, type: 'delimiter.curly.pats' }, + { startIndex: 11, type: 'identifier.pats' }, + { startIndex: 12, type: 'keyword.pats' }, + { startIndex: 13, type: 'type.pats' }, + { startIndex: 16, type: 'delimiter.parenthesis.pats' }, + { startIndex: 17, type: '' }, + { startIndex: 18, type: 'identifier.pats' }, + { startIndex: 25, type: '' }, + { startIndex: 26, type: 'delimiter.parenthesis.pats' }, + { startIndex: 27, type: 'identifier.pats' }, + { startIndex: 28, type: 'delimiter.comma.pats' }, + { startIndex: 29, type: '' }, + { startIndex: 30, type: 'identifier.pats' }, + { startIndex: 31, type: 'operator.pats' }, + { startIndex: 32, type: 'identifier.pats' }, + { startIndex: 33, type: 'delimiter.parenthesis.pats' }, + { startIndex: 34, type: '' }, + { startIndex: 35, type: 'keyword.pats' }, + { startIndex: 37, type: '' }, + { startIndex: 38, type: 'identifier.pats' }, + { startIndex: 42, type: '' }, + { startIndex: 43, type: 'delimiter.parenthesis.pats' }, + { startIndex: 44, type: 'identifier.pats' }, + { startIndex: 45, type: 'operator.pats' }, + { startIndex: 46, type: 'number.decimal.pats' }, + { startIndex: 47, type: 'delimiter.comma.pats' }, + { startIndex: 48, type: '' }, + { startIndex: 49, type: 'identifier.pats' }, + { startIndex: 50, type: 'delimiter.parenthesis.pats' } + ] + }, + { + line: '', + tokens: [] + }, + { + line: + 'fun fact {n:nat} .. (x: int n) : [r:int] (FACT(n, r) | int(r)) = (', + tokens: [ + { startIndex: 0, type: 'keyword.pats' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'identifier.pats' }, + { startIndex: 8, type: '' }, + { startIndex: 9, type: 'delimiter.curly.pats' }, + { startIndex: 10, type: 'identifier.pats' }, + { startIndex: 11, type: 'keyword.pats' }, + { startIndex: 12, type: 'identifier.pats' }, + { startIndex: 15, type: 'delimiter.parenthesis.pats' }, + { startIndex: 16, type: '' }, + { startIndex: 17, type: 'identifier.sym.pats' }, + { startIndex: 19, type: 'identifier.pats' }, + { startIndex: 20, type: 'keyword.pats' }, + { startIndex: 22, type: '' }, + { startIndex: 23, type: 'delimiter.parenthesis.pats' }, + { startIndex: 24, type: 'identifier.pats' }, + { startIndex: 25, type: 'keyword.pats' }, + { startIndex: 26, type: '' }, + { startIndex: 27, type: 'type.pats' }, + { startIndex: 30, type: '' }, + { startIndex: 31, type: 'identifier.pats' }, + { startIndex: 32, type: 'delimiter.parenthesis.pats' }, + { startIndex: 33, type: '' }, + { startIndex: 34, type: 'keyword.pats' }, + { startIndex: 35, type: '' }, + { startIndex: 36, type: 'delimiter.square.pats' }, + { startIndex: 37, type: 'identifier.pats' }, + { startIndex: 38, type: 'keyword.pats' }, + { startIndex: 39, type: 'type.pats' }, + { startIndex: 42, type: 'delimiter.square.pats' }, + { startIndex: 43, type: '' }, + { startIndex: 44, type: 'delimiter.parenthesis.pats' }, + { startIndex: 45, type: 'identifier.pats' }, + { startIndex: 49, type: 'delimiter.parenthesis.pats' }, + { startIndex: 50, type: 'identifier.pats' }, + { startIndex: 51, type: 'delimiter.comma.pats' }, + { startIndex: 52, type: '' }, + { startIndex: 53, type: 'identifier.pats' }, + { startIndex: 54, type: 'delimiter.parenthesis.pats' }, + { startIndex: 55, type: '' }, + { startIndex: 56, type: 'keyword.pats' }, + { startIndex: 57, type: '' }, + { startIndex: 58, type: 'type.pats' }, + { startIndex: 61, type: 'delimiter.parenthesis.pats' }, + { startIndex: 62, type: 'identifier.pats' }, + { startIndex: 63, type: 'delimiter.parenthesis.pats' }, + { startIndex: 65, type: '' }, + { startIndex: 66, type: 'keyword.pats' }, + { startIndex: 67, type: '' }, + { startIndex: 68, type: 'delimiter.parenthesis.pats' } + ] + }, + { + line: 'if x > 0 then let', + tokens: [ + { startIndex: 0, type: 'keyword.pats' }, + { startIndex: 2, type: '' }, + { startIndex: 3, type: 'identifier.pats' }, + { startIndex: 4, type: '' }, + { startIndex: 5, type: 'keyword.pats' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'number.decimal.pats' }, + { startIndex: 8, type: '' }, + { startIndex: 9, type: 'keyword.pats' }, + { startIndex: 13, type: '' }, + { startIndex: 14, type: 'keyword.pats' } + ] + }, + { + line: ' val [r1:int] (pf1 | r1) = fact (x-1)', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'keyword.pats' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'delimiter.square.pats' }, + { startIndex: 7, type: 'identifier.pats' }, + { startIndex: 9, type: 'keyword.pats' }, + { startIndex: 10, type: 'type.pats' }, + { startIndex: 13, type: 'delimiter.square.pats' }, + { startIndex: 14, type: '' }, + { startIndex: 15, type: 'delimiter.parenthesis.pats' }, + { startIndex: 16, type: 'identifier.pats' }, + { startIndex: 19, type: '' }, + { startIndex: 20, type: 'keyword.pats' }, + { startIndex: 21, type: '' }, + { startIndex: 22, type: 'identifier.pats' }, + { startIndex: 24, type: 'delimiter.parenthesis.pats' }, + { startIndex: 25, type: '' }, + { startIndex: 26, type: 'keyword.pats' }, + { startIndex: 27, type: '' }, + { startIndex: 28, type: 'identifier.pats' }, + { startIndex: 32, type: '' }, + { startIndex: 33, type: 'delimiter.parenthesis.pats' }, + { startIndex: 34, type: 'identifier.pats' }, + { startIndex: 35, type: 'operator.pats' }, + { startIndex: 36, type: 'number.decimal.pats' }, + { startIndex: 37, type: 'delimiter.parenthesis.pats' } + ] + }, + { + line: ' prval pf = FACTind {n}{r1} (pf1)', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'keyword.pats' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'identifier.pats' }, + { startIndex: 10, type: '' }, + { startIndex: 11, type: 'keyword.pats' }, + { startIndex: 12, type: '' }, + { startIndex: 13, type: 'identifier.pats' }, + { startIndex: 20, type: '' }, + { startIndex: 21, type: 'delimiter.curly.pats' }, + { startIndex: 22, type: 'identifier.pats' }, + { startIndex: 23, type: 'delimiter.parenthesis.pats' }, + { startIndex: 24, type: 'delimiter.curly.pats' }, + { startIndex: 25, type: 'identifier.pats' }, + { startIndex: 27, type: 'delimiter.parenthesis.pats' }, + { startIndex: 28, type: '' }, + { startIndex: 29, type: 'delimiter.parenthesis.pats' }, + { startIndex: 30, type: 'identifier.pats' }, + { startIndex: 33, type: 'delimiter.parenthesis.pats' } + ] + }, + { + line: ' val r = x * r1', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'keyword.pats' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'identifier.pats' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'keyword.pats' }, + { startIndex: 9, type: '' }, + { startIndex: 10, type: 'identifier.pats' }, + { startIndex: 11, type: '' }, + { startIndex: 12, type: 'operator.pats' }, + { startIndex: 13, type: '' }, + { startIndex: 14, type: 'identifier.pats' } + ] + }, + { + line: 'in', + tokens: [{ startIndex: 0, type: 'keyword.pats' }] + }, + { + line: ' (pf | r)', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'delimiter.parenthesis.pats' }, + { startIndex: 3, type: 'identifier.pats' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'keyword.pats' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'identifier.pats' }, + { startIndex: 9, type: 'delimiter.parenthesis.pats' } + ] + }, + { + line: 'end // end of [then]', + tokens: [ + { startIndex: 0, type: 'keyword.pats' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'comment.pats' } + ] + }, + { + line: 'else (FACTbas () | 1)', + tokens: [ + { startIndex: 0, type: 'keyword.pats' }, + { startIndex: 4, type: '' }, + { startIndex: 5, type: 'delimiter.parenthesis.pats' }, + { startIndex: 6, type: 'identifier.pats' }, + { startIndex: 13, type: '' }, + { startIndex: 14, type: 'delimiter.parenthesis.pats' }, + { startIndex: 16, type: '' }, + { startIndex: 17, type: 'keyword.pats' }, + { startIndex: 18, type: '' }, + { startIndex: 19, type: 'number.decimal.pats' }, + { startIndex: 20, type: 'delimiter.parenthesis.pats' } + ] + }, + { + line: ') (* end of [fact] *)', + tokens: [ + { startIndex: 0, type: 'delimiter.parenthesis.pats' }, + { startIndex: 1, type: '' }, + { startIndex: 2, type: 'comment.pats' } + ] + }, + { + line: '', + tokens: [] + }, + { + line: 'local', + tokens: [{ startIndex: 0, type: 'keyword.pats' }] + }, + { + line: 'var __count: int = 0 // it is statically allocated', + tokens: [ + { startIndex: 0, type: 'keyword.pats' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'identifier.pats' }, + { startIndex: 11, type: 'keyword.pats' }, + { startIndex: 12, type: '' }, + { startIndex: 13, type: 'type.pats' }, + { startIndex: 16, type: '' }, + { startIndex: 17, type: 'keyword.pats' }, + { startIndex: 18, type: '' }, + { startIndex: 19, type: 'number.decimal.pats' }, + { startIndex: 20, type: '' }, + { startIndex: 21, type: 'comment.pats' } + ] + }, + { + line: '', + tokens: [] + }, + { + line: 'val theCount =', + tokens: [ + { startIndex: 0, type: 'keyword.pats' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'identifier.pats' }, + { startIndex: 12, type: '' }, + { startIndex: 13, type: 'keyword.pats' } + ] + }, + { + line: ' ref_make_viewptr{int}(view@(__count) | addr@(__count))', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'identifier.pats' }, + { startIndex: 18, type: 'delimiter.curly.pats' }, + { startIndex: 19, type: 'type.pats' }, + { startIndex: 22, type: 'delimiter.parenthesis.pats' }, + { startIndex: 24, type: 'keyword.pats' }, + { startIndex: 29, type: 'delimiter.parenthesis.pats' }, + { startIndex: 30, type: 'identifier.pats' }, + { startIndex: 37, type: 'delimiter.parenthesis.pats' }, + { startIndex: 38, type: '' }, + { startIndex: 39, type: 'keyword.pats' }, + { startIndex: 40, type: '' }, + { startIndex: 41, type: 'keyword.pats' }, + { startIndex: 46, type: 'delimiter.parenthesis.pats' }, + { startIndex: 47, type: 'identifier.pats' }, + { startIndex: 54, type: 'delimiter.parenthesis.pats' } + ] + }, + { + line: '// end of [val]', + tokens: [{ startIndex: 0, type: 'comment.pats' }] + }, + { + line: '', + tokens: [] + }, + { + line: 'in (* in of [local] *)', + tokens: [ + { startIndex: 0, type: 'keyword.pats' }, + { startIndex: 2, type: '' }, + { startIndex: 3, type: 'comment.pats' } + ] + }, + { + line: '', + tokens: [] + }, + { + line: 'fun theCount_get (): int = !theCount', + tokens: [ + { startIndex: 0, type: 'keyword.pats' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'identifier.pats' }, + { startIndex: 16, type: '' }, + { startIndex: 17, type: 'delimiter.parenthesis.pats' }, + { startIndex: 19, type: 'keyword.pats' }, + { startIndex: 20, type: '' }, + { startIndex: 21, type: 'type.pats' }, + { startIndex: 24, type: '' }, + { startIndex: 25, type: 'keyword.pats' }, + { startIndex: 26, type: '' }, + { startIndex: 27, type: 'keyword.pats' }, + { startIndex: 28, type: 'identifier.pats' } + ] + }, + { + line: '', + tokens: [] + }, + { + line: 'fun theCount_inc (): void = !theCount := !theCount + 1', + tokens: [ + { startIndex: 0, type: 'keyword.pats' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'identifier.pats' }, + { startIndex: 16, type: '' }, + { startIndex: 17, type: 'delimiter.parenthesis.pats' }, + { startIndex: 19, type: 'keyword.pats' }, + { startIndex: 20, type: '' }, + { startIndex: 21, type: 'type.pats' }, + { startIndex: 25, type: '' }, + { startIndex: 26, type: 'keyword.pats' }, + { startIndex: 27, type: '' }, + { startIndex: 28, type: 'keyword.pats' }, + { startIndex: 29, type: 'identifier.pats' }, + { startIndex: 37, type: '' }, + { startIndex: 38, type: 'operator.pats' }, + { startIndex: 40, type: '' }, + { startIndex: 41, type: 'keyword.pats' }, + { startIndex: 42, type: 'identifier.pats' }, + { startIndex: 50, type: '' }, + { startIndex: 51, type: 'operator.pats' }, + { startIndex: 52, type: '' }, + { startIndex: 53, type: 'number.decimal.pats' } + ] + }, + { + line: '', + tokens: [] + }, + { + line: 'end // end of [local]', + tokens: [ + { startIndex: 0, type: 'keyword.pats' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'comment.pats' } + ] + }, + { + line: '', + tokens: [] + }, + { + line: '#endif', + tokens: [{ startIndex: 0, type: 'keyword.srp.pats' }] + } + ] ]); diff --git a/src/postiats/postiats.ts b/src/postiats/postiats.ts index e4ff08ef..299e8086 100644 --- a/src/postiats/postiats.ts +++ b/src/postiats/postiats.ts @@ -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 = { 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 = { "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 = { // 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 = { { 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 = { // 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: /:{ */ { 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 = { 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 = { 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 = { // 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*[{ } }, // 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: /-<|={ // - 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 = { } }, { 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' } } - ], - }, + ] + } }; - diff --git a/src/powerquery/powerquery.test.ts b/src/powerquery/powerquery.test.ts index 90d44af5..65428c1d 100644 --- a/src/powerquery/powerquery.test.ts +++ b/src/powerquery/powerquery.test.ts @@ -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' } + ] + } + ] ]); diff --git a/src/powerquery/powerquery.ts b/src/powerquery/powerquery.ts index 5c0da9d5..2f0a97da 100644 --- a/src/powerquery/powerquery.ts +++ b/src/powerquery/powerquery.ts @@ -11,14 +11,18 @@ import ILanguage = monaco.languages.IMonarchLanguage; export const conf: IRichLanguageConfiguration = { comments: { lineComment: '//', - blockComment: ['/*', '*/'], + blockComment: ['/*', '*/'] }, - brackets: [['[', ']'], ['(', ')'], ['{', '}']], + brackets: [ + ['[', ']'], + ['(', ')'], + ['{', '}'] + ], autoClosingPairs: [ { open: '"', close: '"', notIn: ['string', 'comment', 'identifier'] }, { open: '[', close: ']', notIn: ['string', 'comment', 'identifier'] }, { open: '(', close: ')', notIn: ['string', 'comment', 'identifier'] }, - { open: '{', close: '}', notIn: ['string', 'comment', 'identifier'] }, + { open: '{', close: '}', notIn: ['string', 'comment', 'identifier'] } ] }; @@ -33,902 +37,895 @@ export const language = { { open: '(', close: ')', token: 'delimiter.parenthesis' } ], - operatorKeywords: [ - "and", - "not", - "or" - ], + operatorKeywords: ['and', 'not', 'or'], keywords: [ - "as", - "each", - "else", - "error", - "false", - "if", - "in", - "is", - "let", - "meta", - "otherwise", - "section", - "shared", - "then", - "true", - "try", - "type" + 'as', + 'each', + 'else', + 'error', + 'false', + 'if', + 'in', + 'is', + 'let', + 'meta', + 'otherwise', + 'section', + 'shared', + 'then', + 'true', + 'try', + 'type' ], constructors: [ - "#binary", - "#date", - "#datetime", - "#datetimezone", - "#duration", - "#table", - "#time" + '#binary', + '#date', + '#datetime', + '#datetimezone', + '#duration', + '#table', + '#time' ], - constants: [ - "#infinity", - "#nan", - "#sections", - "#shared" - ], + constants: ['#infinity', '#nan', '#sections', '#shared'], typeKeywords: [ - "action", - "any", - "anynonnull", - "none", - "null", - "logical", - "number", - "time", - "date", - "datetime", - "datetimezone", - "duration", - "text", - "binary", - "list", - "record", - "table", - "function" + 'action', + 'any', + 'anynonnull', + 'none', + 'null', + 'logical', + 'number', + 'time', + 'date', + 'datetime', + 'datetimezone', + 'duration', + 'text', + 'binary', + 'list', + 'record', + 'table', + 'function' ], builtinFunctions: [ - "Access.Database", - "Action.Return", - "Action.Sequence", - "Action.Try", - "ActiveDirectory.Domains", - "AdoDotNet.DataSource", - "AdoDotNet.Query", - "AdobeAnalytics.Cubes", - "AnalysisServices.Database", - "AnalysisServices.Databases", - "AzureStorage.BlobContents", - "AzureStorage.Blobs", - "AzureStorage.Tables", - "Binary.Buffer", - "Binary.Combine", - "Binary.Compress", - "Binary.Decompress", - "Binary.End", - "Binary.From", - "Binary.FromList", - "Binary.FromText", - "Binary.InferContentType", - "Binary.Length", - "Binary.ToList", - "Binary.ToText", - "BinaryFormat.7BitEncodedSignedInteger", - "BinaryFormat.7BitEncodedUnsignedInteger", - "BinaryFormat.Binary", - "BinaryFormat.Byte", - "BinaryFormat.ByteOrder", - "BinaryFormat.Choice", - "BinaryFormat.Decimal", - "BinaryFormat.Double", - "BinaryFormat.Group", - "BinaryFormat.Length", - "BinaryFormat.List", - "BinaryFormat.Null", - "BinaryFormat.Record", - "BinaryFormat.SignedInteger16", - "BinaryFormat.SignedInteger32", - "BinaryFormat.SignedInteger64", - "BinaryFormat.Single", - "BinaryFormat.Text", - "BinaryFormat.Transform", - "BinaryFormat.UnsignedInteger16", - "BinaryFormat.UnsignedInteger32", - "BinaryFormat.UnsignedInteger64", - "Byte.From", - "Character.FromNumber", - "Character.ToNumber", - "Combiner.CombineTextByDelimiter", - "Combiner.CombineTextByEachDelimiter", - "Combiner.CombineTextByLengths", - "Combiner.CombineTextByPositions", - "Combiner.CombineTextByRanges", - "Comparer.Equals", - "Comparer.FromCulture", - "Comparer.Ordinal", - "Comparer.OrdinalIgnoreCase", - "Csv.Document", - "Cube.AddAndExpandDimensionColumn", - "Cube.AddMeasureColumn", - "Cube.ApplyParameter", - "Cube.AttributeMemberId", - "Cube.AttributeMemberProperty", - "Cube.CollapseAndRemoveColumns", - "Cube.Dimensions", - "Cube.DisplayFolders", - "Cube.Measures", - "Cube.Parameters", - "Cube.Properties", - "Cube.PropertyKey", - "Cube.ReplaceDimensions", - "Cube.Transform", - "Currency.From", - "DB2.Database", - "Date.AddDays", - "Date.AddMonths", - "Date.AddQuarters", - "Date.AddWeeks", - "Date.AddYears", - "Date.Day", - "Date.DayOfWeek", - "Date.DayOfWeekName", - "Date.DayOfYear", - "Date.DaysInMonth", - "Date.EndOfDay", - "Date.EndOfMonth", - "Date.EndOfQuarter", - "Date.EndOfWeek", - "Date.EndOfYear", - "Date.From", - "Date.FromText", - "Date.IsInCurrentDay", - "Date.IsInCurrentMonth", - "Date.IsInCurrentQuarter", - "Date.IsInCurrentWeek", - "Date.IsInCurrentYear", - "Date.IsInNextDay", - "Date.IsInNextMonth", - "Date.IsInNextNDays", - "Date.IsInNextNMonths", - "Date.IsInNextNQuarters", - "Date.IsInNextNWeeks", - "Date.IsInNextNYears", - "Date.IsInNextQuarter", - "Date.IsInNextWeek", - "Date.IsInNextYear", - "Date.IsInPreviousDay", - "Date.IsInPreviousMonth", - "Date.IsInPreviousNDays", - "Date.IsInPreviousNMonths", - "Date.IsInPreviousNQuarters", - "Date.IsInPreviousNWeeks", - "Date.IsInPreviousNYears", - "Date.IsInPreviousQuarter", - "Date.IsInPreviousWeek", - "Date.IsInPreviousYear", - "Date.IsInYearToDate", - "Date.IsLeapYear", - "Date.Month", - "Date.MonthName", - "Date.QuarterOfYear", - "Date.StartOfDay", - "Date.StartOfMonth", - "Date.StartOfQuarter", - "Date.StartOfWeek", - "Date.StartOfYear", - "Date.ToRecord", - "Date.ToText", - "Date.WeekOfMonth", - "Date.WeekOfYear", - "Date.Year", - "DateTime.AddZone", - "DateTime.Date", - "DateTime.FixedLocalNow", - "DateTime.From", - "DateTime.FromFileTime", - "DateTime.FromText", - "DateTime.IsInCurrentHour", - "DateTime.IsInCurrentMinute", - "DateTime.IsInCurrentSecond", - "DateTime.IsInNextHour", - "DateTime.IsInNextMinute", - "DateTime.IsInNextNHours", - "DateTime.IsInNextNMinutes", - "DateTime.IsInNextNSeconds", - "DateTime.IsInNextSecond", - "DateTime.IsInPreviousHour", - "DateTime.IsInPreviousMinute", - "DateTime.IsInPreviousNHours", - "DateTime.IsInPreviousNMinutes", - "DateTime.IsInPreviousNSeconds", - "DateTime.IsInPreviousSecond", - "DateTime.LocalNow", - "DateTime.Time", - "DateTime.ToRecord", - "DateTime.ToText", - "DateTimeZone.FixedLocalNow", - "DateTimeZone.FixedUtcNow", - "DateTimeZone.From", - "DateTimeZone.FromFileTime", - "DateTimeZone.FromText", - "DateTimeZone.LocalNow", - "DateTimeZone.RemoveZone", - "DateTimeZone.SwitchZone", - "DateTimeZone.ToLocal", - "DateTimeZone.ToRecord", - "DateTimeZone.ToText", - "DateTimeZone.ToUtc", - "DateTimeZone.UtcNow", - "DateTimeZone.ZoneHours", - "DateTimeZone.ZoneMinutes", - "Decimal.From", - "Diagnostics.ActivityId", - "Diagnostics.Trace", - "DirectQueryCapabilities.From", - "Double.From", - "Duration.Days", - "Duration.From", - "Duration.FromText", - "Duration.Hours", - "Duration.Minutes", - "Duration.Seconds", - "Duration.ToRecord", - "Duration.ToText", - "Duration.TotalDays", - "Duration.TotalHours", - "Duration.TotalMinutes", - "Duration.TotalSeconds", - "Embedded.Value", - "Error.Record", - "Excel.CurrentWorkbook", - "Excel.Workbook", - "Exchange.Contents", - "Expression.Constant", - "Expression.Evaluate", - "Expression.Identifier", - "Facebook.Graph", - "File.Contents", - "Folder.Contents", - "Folder.Files", - "Function.From", - "Function.Invoke", - "Function.InvokeAfter", - "Function.IsDataSource", - "GoogleAnalytics.Accounts", - "Guid.From", - "HdInsight.Containers", - "HdInsight.Contents", - "HdInsight.Files", - "Hdfs.Contents", - "Hdfs.Files", - "Informix.Database", - "Int16.From", - "Int32.From", - "Int64.From", - "Int8.From", - "ItemExpression.From", - "Json.Document", - "Json.FromValue", - "Lines.FromBinary", - "Lines.FromText", - "Lines.ToBinary", - "Lines.ToText", - "List.Accumulate", - "List.AllTrue", - "List.Alternate", - "List.AnyTrue", - "List.Average", - "List.Buffer", - "List.Combine", - "List.Contains", - "List.ContainsAll", - "List.ContainsAny", - "List.Count", - "List.Covariance", - "List.DateTimeZones", - "List.DateTimes", - "List.Dates", - "List.Difference", - "List.Distinct", - "List.Durations", - "List.FindText", - "List.First", - "List.FirstN", - "List.Generate", - "List.InsertRange", - "List.Intersect", - "List.IsDistinct", - "List.IsEmpty", - "List.Last", - "List.LastN", - "List.MatchesAll", - "List.MatchesAny", - "List.Max", - "List.MaxN", - "List.Median", - "List.Min", - "List.MinN", - "List.Mode", - "List.Modes", - "List.NonNullCount", - "List.Numbers", - "List.PositionOf", - "List.PositionOfAny", - "List.Positions", - "List.Product", - "List.Random", - "List.Range", - "List.RemoveFirstN", - "List.RemoveItems", - "List.RemoveLastN", - "List.RemoveMatchingItems", - "List.RemoveNulls", - "List.RemoveRange", - "List.Repeat", - "List.ReplaceMatchingItems", - "List.ReplaceRange", - "List.ReplaceValue", - "List.Reverse", - "List.Select", - "List.Single", - "List.SingleOrDefault", - "List.Skip", - "List.Sort", - "List.StandardDeviation", - "List.Sum", - "List.Times", - "List.Transform", - "List.TransformMany", - "List.Union", - "List.Zip", - "Logical.From", - "Logical.FromText", - "Logical.ToText", - "MQ.Queue", - "MySQL.Database", - "Number.Abs", - "Number.Acos", - "Number.Asin", - "Number.Atan", - "Number.Atan2", - "Number.BitwiseAnd", - "Number.BitwiseNot", - "Number.BitwiseOr", - "Number.BitwiseShiftLeft", - "Number.BitwiseShiftRight", - "Number.BitwiseXor", - "Number.Combinations", - "Number.Cos", - "Number.Cosh", - "Number.Exp", - "Number.Factorial", - "Number.From", - "Number.FromText", - "Number.IntegerDivide", - "Number.IsEven", - "Number.IsNaN", - "Number.IsOdd", - "Number.Ln", - "Number.Log", - "Number.Log10", - "Number.Mod", - "Number.Permutations", - "Number.Power", - "Number.Random", - "Number.RandomBetween", - "Number.Round", - "Number.RoundAwayFromZero", - "Number.RoundDown", - "Number.RoundTowardZero", - "Number.RoundUp", - "Number.Sign", - "Number.Sin", - "Number.Sinh", - "Number.Sqrt", - "Number.Tan", - "Number.Tanh", - "Number.ToText", - "OData.Feed", - "Odbc.DataSource", - "Odbc.Query", - "OleDb.DataSource", - "OleDb.Query", - "Oracle.Database", - "Percentage.From", - "PostgreSQL.Database", - "RData.FromBinary", - "Record.AddField", - "Record.Combine", - "Record.Field", - "Record.FieldCount", - "Record.FieldNames", - "Record.FieldOrDefault", - "Record.FieldValues", - "Record.FromList", - "Record.FromTable", - "Record.HasFields", - "Record.RemoveFields", - "Record.RenameFields", - "Record.ReorderFields", - "Record.SelectFields", - "Record.ToList", - "Record.ToTable", - "Record.TransformFields", - "Replacer.ReplaceText", - "Replacer.ReplaceValue", - "RowExpression.Column", - "RowExpression.From", - "Salesforce.Data", - "Salesforce.Reports", - "SapBusinessWarehouse.Cubes", - "SapHana.Database", - "SharePoint.Contents", - "SharePoint.Files", - "SharePoint.Tables", - "Single.From", - "Soda.Feed", - "Splitter.SplitByNothing", - "Splitter.SplitTextByAnyDelimiter", - "Splitter.SplitTextByDelimiter", - "Splitter.SplitTextByEachDelimiter", - "Splitter.SplitTextByLengths", - "Splitter.SplitTextByPositions", - "Splitter.SplitTextByRanges", - "Splitter.SplitTextByRepeatedLengths", - "Splitter.SplitTextByWhitespace", - "Sql.Database", - "Sql.Databases", - "SqlExpression.SchemaFrom", - "SqlExpression.ToExpression", - "Sybase.Database", - "Table.AddColumn", - "Table.AddIndexColumn", - "Table.AddJoinColumn", - "Table.AddKey", - "Table.AggregateTableColumn", - "Table.AlternateRows", - "Table.Buffer", - "Table.Column", - "Table.ColumnCount", - "Table.ColumnNames", - "Table.ColumnsOfType", - "Table.Combine", - "Table.CombineColumns", - "Table.Contains", - "Table.ContainsAll", - "Table.ContainsAny", - "Table.DemoteHeaders", - "Table.Distinct", - "Table.DuplicateColumn", - "Table.ExpandListColumn", - "Table.ExpandRecordColumn", - "Table.ExpandTableColumn", - "Table.FillDown", - "Table.FillUp", - "Table.FilterWithDataTable", - "Table.FindText", - "Table.First", - "Table.FirstN", - "Table.FirstValue", - "Table.FromColumns", - "Table.FromList", - "Table.FromPartitions", - "Table.FromRecords", - "Table.FromRows", - "Table.FromValue", - "Table.Group", - "Table.HasColumns", - "Table.InsertRows", - "Table.IsDistinct", - "Table.IsEmpty", - "Table.Join", - "Table.Keys", - "Table.Last", - "Table.LastN", - "Table.MatchesAllRows", - "Table.MatchesAnyRows", - "Table.Max", - "Table.MaxN", - "Table.Min", - "Table.MinN", - "Table.NestedJoin", - "Table.Partition", - "Table.PartitionValues", - "Table.Pivot", - "Table.PositionOf", - "Table.PositionOfAny", - "Table.PrefixColumns", - "Table.Profile", - "Table.PromoteHeaders", - "Table.Range", - "Table.RemoveColumns", - "Table.RemoveFirstN", - "Table.RemoveLastN", - "Table.RemoveMatchingRows", - "Table.RemoveRows", - "Table.RemoveRowsWithErrors", - "Table.RenameColumns", - "Table.ReorderColumns", - "Table.Repeat", - "Table.ReplaceErrorValues", - "Table.ReplaceKeys", - "Table.ReplaceMatchingRows", - "Table.ReplaceRelationshipIdentity", - "Table.ReplaceRows", - "Table.ReplaceValue", - "Table.ReverseRows", - "Table.RowCount", - "Table.Schema", - "Table.SelectColumns", - "Table.SelectRows", - "Table.SelectRowsWithErrors", - "Table.SingleRow", - "Table.Skip", - "Table.Sort", - "Table.SplitColumn", - "Table.ToColumns", - "Table.ToList", - "Table.ToRecords", - "Table.ToRows", - "Table.TransformColumnNames", - "Table.TransformColumnTypes", - "Table.TransformColumns", - "Table.TransformRows", - "Table.Transpose", - "Table.Unpivot", - "Table.UnpivotOtherColumns", - "Table.View", - "Table.ViewFunction", - "TableAction.DeleteRows", - "TableAction.InsertRows", - "TableAction.UpdateRows", - "Tables.GetRelationships", - "Teradata.Database", - "Text.AfterDelimiter", - "Text.At", - "Text.BeforeDelimiter", - "Text.BetweenDelimiters", - "Text.Clean", - "Text.Combine", - "Text.Contains", - "Text.End", - "Text.EndsWith", - "Text.Format", - "Text.From", - "Text.FromBinary", - "Text.Insert", - "Text.Length", - "Text.Lower", - "Text.Middle", - "Text.NewGuid", - "Text.PadEnd", - "Text.PadStart", - "Text.PositionOf", - "Text.PositionOfAny", - "Text.Proper", - "Text.Range", - "Text.Remove", - "Text.RemoveRange", - "Text.Repeat", - "Text.Replace", - "Text.ReplaceRange", - "Text.Select", - "Text.Split", - "Text.SplitAny", - "Text.Start", - "Text.StartsWith", - "Text.ToBinary", - "Text.ToList", - "Text.Trim", - "Text.TrimEnd", - "Text.TrimStart", - "Text.Upper", - "Time.EndOfHour", - "Time.From", - "Time.FromText", - "Time.Hour", - "Time.Minute", - "Time.Second", - "Time.StartOfHour", - "Time.ToRecord", - "Time.ToText", - "Type.AddTableKey", - "Type.ClosedRecord", - "Type.Facets", - "Type.ForFunction", - "Type.ForRecord", - "Type.FunctionParameters", - "Type.FunctionRequiredParameters", - "Type.FunctionReturn", - "Type.Is", - "Type.IsNullable", - "Type.IsOpenRecord", - "Type.ListItem", - "Type.NonNullable", - "Type.OpenRecord", - "Type.RecordFields", - "Type.ReplaceFacets", - "Type.ReplaceTableKeys", - "Type.TableColumn", - "Type.TableKeys", - "Type.TableRow", - "Type.TableSchema", - "Type.Union", - "Uri.BuildQueryString", - "Uri.Combine", - "Uri.EscapeDataString", - "Uri.Parts", - "Value.Add", - "Value.As", - "Value.Compare", - "Value.Divide", - "Value.Equals", - "Value.Firewall", - "Value.FromText", - "Value.Is", - "Value.Metadata", - "Value.Multiply", - "Value.NativeQuery", - "Value.NullableEquals", - "Value.RemoveMetadata", - "Value.ReplaceMetadata", - "Value.ReplaceType", - "Value.Subtract", - "Value.Type", - "ValueAction.NativeStatement", - "ValueAction.Replace", - "Variable.Value", - "Web.Contents", - "Web.Page", - "WebAction.Request", - "Xml.Document", - "Xml.Tables" + 'Access.Database', + 'Action.Return', + 'Action.Sequence', + 'Action.Try', + 'ActiveDirectory.Domains', + 'AdoDotNet.DataSource', + 'AdoDotNet.Query', + 'AdobeAnalytics.Cubes', + 'AnalysisServices.Database', + 'AnalysisServices.Databases', + 'AzureStorage.BlobContents', + 'AzureStorage.Blobs', + 'AzureStorage.Tables', + 'Binary.Buffer', + 'Binary.Combine', + 'Binary.Compress', + 'Binary.Decompress', + 'Binary.End', + 'Binary.From', + 'Binary.FromList', + 'Binary.FromText', + 'Binary.InferContentType', + 'Binary.Length', + 'Binary.ToList', + 'Binary.ToText', + 'BinaryFormat.7BitEncodedSignedInteger', + 'BinaryFormat.7BitEncodedUnsignedInteger', + 'BinaryFormat.Binary', + 'BinaryFormat.Byte', + 'BinaryFormat.ByteOrder', + 'BinaryFormat.Choice', + 'BinaryFormat.Decimal', + 'BinaryFormat.Double', + 'BinaryFormat.Group', + 'BinaryFormat.Length', + 'BinaryFormat.List', + 'BinaryFormat.Null', + 'BinaryFormat.Record', + 'BinaryFormat.SignedInteger16', + 'BinaryFormat.SignedInteger32', + 'BinaryFormat.SignedInteger64', + 'BinaryFormat.Single', + 'BinaryFormat.Text', + 'BinaryFormat.Transform', + 'BinaryFormat.UnsignedInteger16', + 'BinaryFormat.UnsignedInteger32', + 'BinaryFormat.UnsignedInteger64', + 'Byte.From', + 'Character.FromNumber', + 'Character.ToNumber', + 'Combiner.CombineTextByDelimiter', + 'Combiner.CombineTextByEachDelimiter', + 'Combiner.CombineTextByLengths', + 'Combiner.CombineTextByPositions', + 'Combiner.CombineTextByRanges', + 'Comparer.Equals', + 'Comparer.FromCulture', + 'Comparer.Ordinal', + 'Comparer.OrdinalIgnoreCase', + 'Csv.Document', + 'Cube.AddAndExpandDimensionColumn', + 'Cube.AddMeasureColumn', + 'Cube.ApplyParameter', + 'Cube.AttributeMemberId', + 'Cube.AttributeMemberProperty', + 'Cube.CollapseAndRemoveColumns', + 'Cube.Dimensions', + 'Cube.DisplayFolders', + 'Cube.Measures', + 'Cube.Parameters', + 'Cube.Properties', + 'Cube.PropertyKey', + 'Cube.ReplaceDimensions', + 'Cube.Transform', + 'Currency.From', + 'DB2.Database', + 'Date.AddDays', + 'Date.AddMonths', + 'Date.AddQuarters', + 'Date.AddWeeks', + 'Date.AddYears', + 'Date.Day', + 'Date.DayOfWeek', + 'Date.DayOfWeekName', + 'Date.DayOfYear', + 'Date.DaysInMonth', + 'Date.EndOfDay', + 'Date.EndOfMonth', + 'Date.EndOfQuarter', + 'Date.EndOfWeek', + 'Date.EndOfYear', + 'Date.From', + 'Date.FromText', + 'Date.IsInCurrentDay', + 'Date.IsInCurrentMonth', + 'Date.IsInCurrentQuarter', + 'Date.IsInCurrentWeek', + 'Date.IsInCurrentYear', + 'Date.IsInNextDay', + 'Date.IsInNextMonth', + 'Date.IsInNextNDays', + 'Date.IsInNextNMonths', + 'Date.IsInNextNQuarters', + 'Date.IsInNextNWeeks', + 'Date.IsInNextNYears', + 'Date.IsInNextQuarter', + 'Date.IsInNextWeek', + 'Date.IsInNextYear', + 'Date.IsInPreviousDay', + 'Date.IsInPreviousMonth', + 'Date.IsInPreviousNDays', + 'Date.IsInPreviousNMonths', + 'Date.IsInPreviousNQuarters', + 'Date.IsInPreviousNWeeks', + 'Date.IsInPreviousNYears', + 'Date.IsInPreviousQuarter', + 'Date.IsInPreviousWeek', + 'Date.IsInPreviousYear', + 'Date.IsInYearToDate', + 'Date.IsLeapYear', + 'Date.Month', + 'Date.MonthName', + 'Date.QuarterOfYear', + 'Date.StartOfDay', + 'Date.StartOfMonth', + 'Date.StartOfQuarter', + 'Date.StartOfWeek', + 'Date.StartOfYear', + 'Date.ToRecord', + 'Date.ToText', + 'Date.WeekOfMonth', + 'Date.WeekOfYear', + 'Date.Year', + 'DateTime.AddZone', + 'DateTime.Date', + 'DateTime.FixedLocalNow', + 'DateTime.From', + 'DateTime.FromFileTime', + 'DateTime.FromText', + 'DateTime.IsInCurrentHour', + 'DateTime.IsInCurrentMinute', + 'DateTime.IsInCurrentSecond', + 'DateTime.IsInNextHour', + 'DateTime.IsInNextMinute', + 'DateTime.IsInNextNHours', + 'DateTime.IsInNextNMinutes', + 'DateTime.IsInNextNSeconds', + 'DateTime.IsInNextSecond', + 'DateTime.IsInPreviousHour', + 'DateTime.IsInPreviousMinute', + 'DateTime.IsInPreviousNHours', + 'DateTime.IsInPreviousNMinutes', + 'DateTime.IsInPreviousNSeconds', + 'DateTime.IsInPreviousSecond', + 'DateTime.LocalNow', + 'DateTime.Time', + 'DateTime.ToRecord', + 'DateTime.ToText', + 'DateTimeZone.FixedLocalNow', + 'DateTimeZone.FixedUtcNow', + 'DateTimeZone.From', + 'DateTimeZone.FromFileTime', + 'DateTimeZone.FromText', + 'DateTimeZone.LocalNow', + 'DateTimeZone.RemoveZone', + 'DateTimeZone.SwitchZone', + 'DateTimeZone.ToLocal', + 'DateTimeZone.ToRecord', + 'DateTimeZone.ToText', + 'DateTimeZone.ToUtc', + 'DateTimeZone.UtcNow', + 'DateTimeZone.ZoneHours', + 'DateTimeZone.ZoneMinutes', + 'Decimal.From', + 'Diagnostics.ActivityId', + 'Diagnostics.Trace', + 'DirectQueryCapabilities.From', + 'Double.From', + 'Duration.Days', + 'Duration.From', + 'Duration.FromText', + 'Duration.Hours', + 'Duration.Minutes', + 'Duration.Seconds', + 'Duration.ToRecord', + 'Duration.ToText', + 'Duration.TotalDays', + 'Duration.TotalHours', + 'Duration.TotalMinutes', + 'Duration.TotalSeconds', + 'Embedded.Value', + 'Error.Record', + 'Excel.CurrentWorkbook', + 'Excel.Workbook', + 'Exchange.Contents', + 'Expression.Constant', + 'Expression.Evaluate', + 'Expression.Identifier', + 'Facebook.Graph', + 'File.Contents', + 'Folder.Contents', + 'Folder.Files', + 'Function.From', + 'Function.Invoke', + 'Function.InvokeAfter', + 'Function.IsDataSource', + 'GoogleAnalytics.Accounts', + 'Guid.From', + 'HdInsight.Containers', + 'HdInsight.Contents', + 'HdInsight.Files', + 'Hdfs.Contents', + 'Hdfs.Files', + 'Informix.Database', + 'Int16.From', + 'Int32.From', + 'Int64.From', + 'Int8.From', + 'ItemExpression.From', + 'Json.Document', + 'Json.FromValue', + 'Lines.FromBinary', + 'Lines.FromText', + 'Lines.ToBinary', + 'Lines.ToText', + 'List.Accumulate', + 'List.AllTrue', + 'List.Alternate', + 'List.AnyTrue', + 'List.Average', + 'List.Buffer', + 'List.Combine', + 'List.Contains', + 'List.ContainsAll', + 'List.ContainsAny', + 'List.Count', + 'List.Covariance', + 'List.DateTimeZones', + 'List.DateTimes', + 'List.Dates', + 'List.Difference', + 'List.Distinct', + 'List.Durations', + 'List.FindText', + 'List.First', + 'List.FirstN', + 'List.Generate', + 'List.InsertRange', + 'List.Intersect', + 'List.IsDistinct', + 'List.IsEmpty', + 'List.Last', + 'List.LastN', + 'List.MatchesAll', + 'List.MatchesAny', + 'List.Max', + 'List.MaxN', + 'List.Median', + 'List.Min', + 'List.MinN', + 'List.Mode', + 'List.Modes', + 'List.NonNullCount', + 'List.Numbers', + 'List.PositionOf', + 'List.PositionOfAny', + 'List.Positions', + 'List.Product', + 'List.Random', + 'List.Range', + 'List.RemoveFirstN', + 'List.RemoveItems', + 'List.RemoveLastN', + 'List.RemoveMatchingItems', + 'List.RemoveNulls', + 'List.RemoveRange', + 'List.Repeat', + 'List.ReplaceMatchingItems', + 'List.ReplaceRange', + 'List.ReplaceValue', + 'List.Reverse', + 'List.Select', + 'List.Single', + 'List.SingleOrDefault', + 'List.Skip', + 'List.Sort', + 'List.StandardDeviation', + 'List.Sum', + 'List.Times', + 'List.Transform', + 'List.TransformMany', + 'List.Union', + 'List.Zip', + 'Logical.From', + 'Logical.FromText', + 'Logical.ToText', + 'MQ.Queue', + 'MySQL.Database', + 'Number.Abs', + 'Number.Acos', + 'Number.Asin', + 'Number.Atan', + 'Number.Atan2', + 'Number.BitwiseAnd', + 'Number.BitwiseNot', + 'Number.BitwiseOr', + 'Number.BitwiseShiftLeft', + 'Number.BitwiseShiftRight', + 'Number.BitwiseXor', + 'Number.Combinations', + 'Number.Cos', + 'Number.Cosh', + 'Number.Exp', + 'Number.Factorial', + 'Number.From', + 'Number.FromText', + 'Number.IntegerDivide', + 'Number.IsEven', + 'Number.IsNaN', + 'Number.IsOdd', + 'Number.Ln', + 'Number.Log', + 'Number.Log10', + 'Number.Mod', + 'Number.Permutations', + 'Number.Power', + 'Number.Random', + 'Number.RandomBetween', + 'Number.Round', + 'Number.RoundAwayFromZero', + 'Number.RoundDown', + 'Number.RoundTowardZero', + 'Number.RoundUp', + 'Number.Sign', + 'Number.Sin', + 'Number.Sinh', + 'Number.Sqrt', + 'Number.Tan', + 'Number.Tanh', + 'Number.ToText', + 'OData.Feed', + 'Odbc.DataSource', + 'Odbc.Query', + 'OleDb.DataSource', + 'OleDb.Query', + 'Oracle.Database', + 'Percentage.From', + 'PostgreSQL.Database', + 'RData.FromBinary', + 'Record.AddField', + 'Record.Combine', + 'Record.Field', + 'Record.FieldCount', + 'Record.FieldNames', + 'Record.FieldOrDefault', + 'Record.FieldValues', + 'Record.FromList', + 'Record.FromTable', + 'Record.HasFields', + 'Record.RemoveFields', + 'Record.RenameFields', + 'Record.ReorderFields', + 'Record.SelectFields', + 'Record.ToList', + 'Record.ToTable', + 'Record.TransformFields', + 'Replacer.ReplaceText', + 'Replacer.ReplaceValue', + 'RowExpression.Column', + 'RowExpression.From', + 'Salesforce.Data', + 'Salesforce.Reports', + 'SapBusinessWarehouse.Cubes', + 'SapHana.Database', + 'SharePoint.Contents', + 'SharePoint.Files', + 'SharePoint.Tables', + 'Single.From', + 'Soda.Feed', + 'Splitter.SplitByNothing', + 'Splitter.SplitTextByAnyDelimiter', + 'Splitter.SplitTextByDelimiter', + 'Splitter.SplitTextByEachDelimiter', + 'Splitter.SplitTextByLengths', + 'Splitter.SplitTextByPositions', + 'Splitter.SplitTextByRanges', + 'Splitter.SplitTextByRepeatedLengths', + 'Splitter.SplitTextByWhitespace', + 'Sql.Database', + 'Sql.Databases', + 'SqlExpression.SchemaFrom', + 'SqlExpression.ToExpression', + 'Sybase.Database', + 'Table.AddColumn', + 'Table.AddIndexColumn', + 'Table.AddJoinColumn', + 'Table.AddKey', + 'Table.AggregateTableColumn', + 'Table.AlternateRows', + 'Table.Buffer', + 'Table.Column', + 'Table.ColumnCount', + 'Table.ColumnNames', + 'Table.ColumnsOfType', + 'Table.Combine', + 'Table.CombineColumns', + 'Table.Contains', + 'Table.ContainsAll', + 'Table.ContainsAny', + 'Table.DemoteHeaders', + 'Table.Distinct', + 'Table.DuplicateColumn', + 'Table.ExpandListColumn', + 'Table.ExpandRecordColumn', + 'Table.ExpandTableColumn', + 'Table.FillDown', + 'Table.FillUp', + 'Table.FilterWithDataTable', + 'Table.FindText', + 'Table.First', + 'Table.FirstN', + 'Table.FirstValue', + 'Table.FromColumns', + 'Table.FromList', + 'Table.FromPartitions', + 'Table.FromRecords', + 'Table.FromRows', + 'Table.FromValue', + 'Table.Group', + 'Table.HasColumns', + 'Table.InsertRows', + 'Table.IsDistinct', + 'Table.IsEmpty', + 'Table.Join', + 'Table.Keys', + 'Table.Last', + 'Table.LastN', + 'Table.MatchesAllRows', + 'Table.MatchesAnyRows', + 'Table.Max', + 'Table.MaxN', + 'Table.Min', + 'Table.MinN', + 'Table.NestedJoin', + 'Table.Partition', + 'Table.PartitionValues', + 'Table.Pivot', + 'Table.PositionOf', + 'Table.PositionOfAny', + 'Table.PrefixColumns', + 'Table.Profile', + 'Table.PromoteHeaders', + 'Table.Range', + 'Table.RemoveColumns', + 'Table.RemoveFirstN', + 'Table.RemoveLastN', + 'Table.RemoveMatchingRows', + 'Table.RemoveRows', + 'Table.RemoveRowsWithErrors', + 'Table.RenameColumns', + 'Table.ReorderColumns', + 'Table.Repeat', + 'Table.ReplaceErrorValues', + 'Table.ReplaceKeys', + 'Table.ReplaceMatchingRows', + 'Table.ReplaceRelationshipIdentity', + 'Table.ReplaceRows', + 'Table.ReplaceValue', + 'Table.ReverseRows', + 'Table.RowCount', + 'Table.Schema', + 'Table.SelectColumns', + 'Table.SelectRows', + 'Table.SelectRowsWithErrors', + 'Table.SingleRow', + 'Table.Skip', + 'Table.Sort', + 'Table.SplitColumn', + 'Table.ToColumns', + 'Table.ToList', + 'Table.ToRecords', + 'Table.ToRows', + 'Table.TransformColumnNames', + 'Table.TransformColumnTypes', + 'Table.TransformColumns', + 'Table.TransformRows', + 'Table.Transpose', + 'Table.Unpivot', + 'Table.UnpivotOtherColumns', + 'Table.View', + 'Table.ViewFunction', + 'TableAction.DeleteRows', + 'TableAction.InsertRows', + 'TableAction.UpdateRows', + 'Tables.GetRelationships', + 'Teradata.Database', + 'Text.AfterDelimiter', + 'Text.At', + 'Text.BeforeDelimiter', + 'Text.BetweenDelimiters', + 'Text.Clean', + 'Text.Combine', + 'Text.Contains', + 'Text.End', + 'Text.EndsWith', + 'Text.Format', + 'Text.From', + 'Text.FromBinary', + 'Text.Insert', + 'Text.Length', + 'Text.Lower', + 'Text.Middle', + 'Text.NewGuid', + 'Text.PadEnd', + 'Text.PadStart', + 'Text.PositionOf', + 'Text.PositionOfAny', + 'Text.Proper', + 'Text.Range', + 'Text.Remove', + 'Text.RemoveRange', + 'Text.Repeat', + 'Text.Replace', + 'Text.ReplaceRange', + 'Text.Select', + 'Text.Split', + 'Text.SplitAny', + 'Text.Start', + 'Text.StartsWith', + 'Text.ToBinary', + 'Text.ToList', + 'Text.Trim', + 'Text.TrimEnd', + 'Text.TrimStart', + 'Text.Upper', + 'Time.EndOfHour', + 'Time.From', + 'Time.FromText', + 'Time.Hour', + 'Time.Minute', + 'Time.Second', + 'Time.StartOfHour', + 'Time.ToRecord', + 'Time.ToText', + 'Type.AddTableKey', + 'Type.ClosedRecord', + 'Type.Facets', + 'Type.ForFunction', + 'Type.ForRecord', + 'Type.FunctionParameters', + 'Type.FunctionRequiredParameters', + 'Type.FunctionReturn', + 'Type.Is', + 'Type.IsNullable', + 'Type.IsOpenRecord', + 'Type.ListItem', + 'Type.NonNullable', + 'Type.OpenRecord', + 'Type.RecordFields', + 'Type.ReplaceFacets', + 'Type.ReplaceTableKeys', + 'Type.TableColumn', + 'Type.TableKeys', + 'Type.TableRow', + 'Type.TableSchema', + 'Type.Union', + 'Uri.BuildQueryString', + 'Uri.Combine', + 'Uri.EscapeDataString', + 'Uri.Parts', + 'Value.Add', + 'Value.As', + 'Value.Compare', + 'Value.Divide', + 'Value.Equals', + 'Value.Firewall', + 'Value.FromText', + 'Value.Is', + 'Value.Metadata', + 'Value.Multiply', + 'Value.NativeQuery', + 'Value.NullableEquals', + 'Value.RemoveMetadata', + 'Value.ReplaceMetadata', + 'Value.ReplaceType', + 'Value.Subtract', + 'Value.Type', + 'ValueAction.NativeStatement', + 'ValueAction.Replace', + 'Variable.Value', + 'Web.Contents', + 'Web.Page', + 'WebAction.Request', + 'Xml.Document', + 'Xml.Tables' ], builtinConstants: [ - "BinaryEncoding.Base64", - "BinaryEncoding.Hex", - "BinaryOccurrence.Optional", - "BinaryOccurrence.Repeating", - "BinaryOccurrence.Required", - "ByteOrder.BigEndian", - "ByteOrder.LittleEndian", - "Compression.Deflate", - "Compression.GZip", - "CsvStyle.QuoteAfterDelimiter", - "CsvStyle.QuoteAlways", - "Culture.Current", - "Day.Friday", - "Day.Monday", - "Day.Saturday", - "Day.Sunday", - "Day.Thursday", - "Day.Tuesday", - "Day.Wednesday", - "ExtraValues.Error", - "ExtraValues.Ignore", - "ExtraValues.List", - "GroupKind.Global", - "GroupKind.Local", - "JoinAlgorithm.Dynamic", - "JoinAlgorithm.LeftHash", - "JoinAlgorithm.LeftIndex", - "JoinAlgorithm.PairwiseHash", - "JoinAlgorithm.RightHash", - "JoinAlgorithm.RightIndex", - "JoinAlgorithm.SortMerge", - "JoinKind.FullOuter", - "JoinKind.Inner", - "JoinKind.LeftAnti", - "JoinKind.LeftOuter", - "JoinKind.RightAnti", - "JoinKind.RightOuter", - "JoinSide.Left", - "JoinSide.Right", - "MissingField.Error", - "MissingField.Ignore", - "MissingField.UseNull", - "Number.E", - "Number.Epsilon", - "Number.NaN", - "Number.NegativeInfinity", - "Number.PI", - "Number.PositiveInfinity", - "Occurrence.All", - "Occurrence.First", - "Occurrence.Last", - "Occurrence.Optional", - "Occurrence.Repeating", - "Occurrence.Required", - "Order.Ascending", - "Order.Descending", - "Precision.Decimal", - "Precision.Double", - "QuoteStyle.Csv", - "QuoteStyle.None", - "RelativePosition.FromEnd", - "RelativePosition.FromStart", - "RoundingMode.AwayFromZero", - "RoundingMode.Down", - "RoundingMode.ToEven", - "RoundingMode.TowardZero", - "RoundingMode.Up", - "SapHanaDistribution.All", - "SapHanaDistribution.Connection", - "SapHanaDistribution.Off", - "SapHanaDistribution.Statement", - "SapHanaRangeOperator.Equals", - "SapHanaRangeOperator.GreaterThan", - "SapHanaRangeOperator.GreaterThanOrEquals", - "SapHanaRangeOperator.LessThan", - "SapHanaRangeOperator.LessThanOrEquals", - "SapHanaRangeOperator.NotEquals", - "TextEncoding.Ascii", - "TextEncoding.BigEndianUnicode", - "TextEncoding.Unicode", - "TextEncoding.Utf16", - "TextEncoding.Utf8", - "TextEncoding.Windows", - "TraceLevel.Critical", - "TraceLevel.Error", - "TraceLevel.Information", - "TraceLevel.Verbose", - "TraceLevel.Warning", - "WebMethod.Delete", - "WebMethod.Get", - "WebMethod.Head", - "WebMethod.Patch", - "WebMethod.Post", - "WebMethod.Put" + 'BinaryEncoding.Base64', + 'BinaryEncoding.Hex', + 'BinaryOccurrence.Optional', + 'BinaryOccurrence.Repeating', + 'BinaryOccurrence.Required', + 'ByteOrder.BigEndian', + 'ByteOrder.LittleEndian', + 'Compression.Deflate', + 'Compression.GZip', + 'CsvStyle.QuoteAfterDelimiter', + 'CsvStyle.QuoteAlways', + 'Culture.Current', + 'Day.Friday', + 'Day.Monday', + 'Day.Saturday', + 'Day.Sunday', + 'Day.Thursday', + 'Day.Tuesday', + 'Day.Wednesday', + 'ExtraValues.Error', + 'ExtraValues.Ignore', + 'ExtraValues.List', + 'GroupKind.Global', + 'GroupKind.Local', + 'JoinAlgorithm.Dynamic', + 'JoinAlgorithm.LeftHash', + 'JoinAlgorithm.LeftIndex', + 'JoinAlgorithm.PairwiseHash', + 'JoinAlgorithm.RightHash', + 'JoinAlgorithm.RightIndex', + 'JoinAlgorithm.SortMerge', + 'JoinKind.FullOuter', + 'JoinKind.Inner', + 'JoinKind.LeftAnti', + 'JoinKind.LeftOuter', + 'JoinKind.RightAnti', + 'JoinKind.RightOuter', + 'JoinSide.Left', + 'JoinSide.Right', + 'MissingField.Error', + 'MissingField.Ignore', + 'MissingField.UseNull', + 'Number.E', + 'Number.Epsilon', + 'Number.NaN', + 'Number.NegativeInfinity', + 'Number.PI', + 'Number.PositiveInfinity', + 'Occurrence.All', + 'Occurrence.First', + 'Occurrence.Last', + 'Occurrence.Optional', + 'Occurrence.Repeating', + 'Occurrence.Required', + 'Order.Ascending', + 'Order.Descending', + 'Precision.Decimal', + 'Precision.Double', + 'QuoteStyle.Csv', + 'QuoteStyle.None', + 'RelativePosition.FromEnd', + 'RelativePosition.FromStart', + 'RoundingMode.AwayFromZero', + 'RoundingMode.Down', + 'RoundingMode.ToEven', + 'RoundingMode.TowardZero', + 'RoundingMode.Up', + 'SapHanaDistribution.All', + 'SapHanaDistribution.Connection', + 'SapHanaDistribution.Off', + 'SapHanaDistribution.Statement', + 'SapHanaRangeOperator.Equals', + 'SapHanaRangeOperator.GreaterThan', + 'SapHanaRangeOperator.GreaterThanOrEquals', + 'SapHanaRangeOperator.LessThan', + 'SapHanaRangeOperator.LessThanOrEquals', + 'SapHanaRangeOperator.NotEquals', + 'TextEncoding.Ascii', + 'TextEncoding.BigEndianUnicode', + 'TextEncoding.Unicode', + 'TextEncoding.Utf16', + 'TextEncoding.Utf8', + 'TextEncoding.Windows', + 'TraceLevel.Critical', + 'TraceLevel.Error', + 'TraceLevel.Information', + 'TraceLevel.Verbose', + 'TraceLevel.Warning', + 'WebMethod.Delete', + 'WebMethod.Get', + 'WebMethod.Head', + 'WebMethod.Patch', + 'WebMethod.Post', + 'WebMethod.Put' ], builtinTypes: [ - "Action.Type", - "Any.Type", - "Binary.Type", - "BinaryEncoding.Type", - "BinaryOccurrence.Type", - "Byte.Type", - "ByteOrder.Type", - "Character.Type", - "Compression.Type", - "CsvStyle.Type", - "Currency.Type", - "Date.Type", - "DateTime.Type", - "DateTimeZone.Type", - "Day.Type", - "Decimal.Type", - "Double.Type", - "Duration.Type", - "ExtraValues.Type", - "Function.Type", - "GroupKind.Type", - "Guid.Type", - "Int16.Type", - "Int32.Type", - "Int64.Type", - "Int8.Type", - "JoinAlgorithm.Type", - "JoinKind.Type", - "JoinSide.Type", - "List.Type", - "Logical.Type", - "MissingField.Type", - "None.Type", - "Null.Type", - "Number.Type", - "Occurrence.Type", - "Order.Type", - "Password.Type", - "Percentage.Type", - "Precision.Type", - "QuoteStyle.Type", - "Record.Type", - "RelativePosition.Type", - "RoundingMode.Type", - "SapHanaDistribution.Type", - "SapHanaRangeOperator.Type", - "Single.Type", - "Table.Type", - "Text.Type", - "TextEncoding.Type", - "Time.Type", - "TraceLevel.Type", - "Type.Type", - "Uri.Type", - "WebMethod.Type" + 'Action.Type', + 'Any.Type', + 'Binary.Type', + 'BinaryEncoding.Type', + 'BinaryOccurrence.Type', + 'Byte.Type', + 'ByteOrder.Type', + 'Character.Type', + 'Compression.Type', + 'CsvStyle.Type', + 'Currency.Type', + 'Date.Type', + 'DateTime.Type', + 'DateTimeZone.Type', + 'Day.Type', + 'Decimal.Type', + 'Double.Type', + 'Duration.Type', + 'ExtraValues.Type', + 'Function.Type', + 'GroupKind.Type', + 'Guid.Type', + 'Int16.Type', + 'Int32.Type', + 'Int64.Type', + 'Int8.Type', + 'JoinAlgorithm.Type', + 'JoinKind.Type', + 'JoinSide.Type', + 'List.Type', + 'Logical.Type', + 'MissingField.Type', + 'None.Type', + 'Null.Type', + 'Number.Type', + 'Occurrence.Type', + 'Order.Type', + 'Password.Type', + 'Percentage.Type', + 'Precision.Type', + 'QuoteStyle.Type', + 'Record.Type', + 'RelativePosition.Type', + 'RoundingMode.Type', + 'SapHanaDistribution.Type', + 'SapHanaRangeOperator.Type', + 'Single.Type', + 'Table.Type', + 'Text.Type', + 'TextEncoding.Type', + 'Time.Type', + 'TraceLevel.Type', + 'Type.Type', + 'Uri.Type', + 'WebMethod.Type' ], tokenizer: { root: [ // quoted identifier - [/#"[\w \.]+"/, "identifier.quote"], + [/#"[\w \.]+"/, 'identifier.quote'], // numbers - [/\d*\.\d+([eE][\-+]?\d+)?/, "number.float"], - [/0[xX][0-9a-fA-F]+/, "number.hex"], - [/\d+([eE][\-+]?\d+)?/, "number"], + [/\d*\.\d+([eE][\-+]?\d+)?/, 'number.float'], + [/0[xX][0-9a-fA-F]+/, 'number.hex'], + [/\d+([eE][\-+]?\d+)?/, 'number'], // keywords - [/(#?[a-z]+)\b/, + [ + /(#?[a-z]+)\b/, { cases: { - "@typeKeywords": "type", - "@keywords": "keyword", - "@constants": "constant", - "@constructors": "constructor", - "@operatorKeywords": "operators", - "@default": "identifier" + '@typeKeywords': 'type', + '@keywords': 'keyword', + '@constants': 'constant', + '@constructors': 'constructor', + '@operatorKeywords': 'operators', + '@default': 'identifier' } } ], // built-in types - [/\b([A-Z][a-zA-Z0-9]+\.Type)\b/, + [ + /\b([A-Z][a-zA-Z0-9]+\.Type)\b/, { cases: { - "@builtinTypes": "type", - "@default": "identifier" + '@builtinTypes': 'type', + '@default': 'identifier' } } ], // other built-ins - [/\b([A-Z][a-zA-Z0-9]+\.[A-Z][a-zA-Z0-9]+)\b/, + [ + /\b([A-Z][a-zA-Z0-9]+\.[A-Z][a-zA-Z0-9]+)\b/, { cases: { - "@builtinFunctions": "keyword.function", - "@builtinConstants": "constant", - "@default": "identifier" + '@builtinFunctions': 'keyword.function', + '@builtinConstants': 'constant', + '@default': 'identifier' } } ], // other identifiers - [/\b([a-zA-Z_][\w\.]*)\b/, "identifier"], + [/\b([a-zA-Z_][\w\.]*)\b/, 'identifier'], - { include: "@whitespace" }, - { include: "@comments" }, - { include: "@strings" }, + { include: '@whitespace' }, + { include: '@comments' }, + { include: '@strings' }, - [/[{}()\[\]]/, "@brackets"], - [/([=\+<>\-\*&@\?\/!])|([<>]=)|(<>)|(=>)|(\.\.\.)|(\.\.)/, "operators"], - [/[,;]/, "delimiter"], + [/[{}()\[\]]/, '@brackets'], + [ + /([=\+<>\-\*&@\?\/!])|([<>]=)|(<>)|(=>)|(\.\.\.)|(\.\.)/, + 'operators' + ], + [/[,;]/, 'delimiter'] ], - whitespace: [ - [/\s+/, "white"] - ], + whitespace: [[/\s+/, 'white']], comments: [ - ["\\/\\*", "comment", "@comment"], - ["\\/\\/+.*", "comment"] + ['\\/\\*', 'comment', '@comment'], + ['\\/\\/+.*', 'comment'] ], comment: [ - ["\\*\\/", "comment", "@pop"], - [".", "comment"] + ['\\*\\/', 'comment', '@pop'], + ['.', 'comment'] ], - strings: [ - ["\"", "string", "@string"] - ], + strings: [['"', 'string', '@string']], string: [ - ["\"\"", "string.escape"], - ["\"", "string", "@pop"], - [".", "string"] + ['""', 'string.escape'], + ['"', 'string', '@pop'], + ['.', 'string'] ] } }; diff --git a/src/powershell/powershell.test.ts b/src/powershell/powershell.test.ts index 295733c7..7278409f 100644 --- a/src/powershell/powershell.test.ts +++ b/src/powershell/powershell.test.ts @@ -9,828 +9,884 @@ import { testTokenization } from '../test/testRunner'; testTokenization('powershell', [ // Comments - single line - [{ - line: '#', - tokens: [ - { startIndex: 0, type: 'comment.ps1' } - ] - }], + [ + { + line: '#', + tokens: [{ startIndex: 0, type: 'comment.ps1' }] + } + ], - [{ - line: ' # a comment', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 4, type: 'comment.ps1' } - ] - }], + [ + { + line: ' # a comment', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 4, type: 'comment.ps1' } + ] + } + ], - [{ - line: '# a comment', - tokens: [ - { startIndex: 0, type: 'comment.ps1' } - ] - }], + [ + { + line: '# a comment', + tokens: [{ startIndex: 0, type: 'comment.ps1' }] + } + ], - [{ - line: '#sticky comment', - tokens: [ - { startIndex: 0, type: 'comment.ps1' } - ] - }], + [ + { + line: '#sticky comment', + tokens: [{ startIndex: 0, type: 'comment.ps1' }] + } + ], - [{ - line: '##still a comment', - tokens: [ - { startIndex: 0, type: 'comment.ps1' } - ] - }], + [ + { + line: '##still a comment', + tokens: [{ startIndex: 0, type: 'comment.ps1' }] + } + ], - [{ - line: '1 / 2 /# comment', - tokens: [ - { startIndex: 0, type: 'number.ps1' }, - { startIndex: 1, type: '' }, - { startIndex: 2, type: 'delimiter.ps1' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'number.ps1' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'delimiter.ps1' }, - { startIndex: 7, type: 'comment.ps1' } - ] - }], + [ + { + line: '1 / 2 /# comment', + tokens: [ + { startIndex: 0, type: 'number.ps1' }, + { startIndex: 1, type: '' }, + { startIndex: 2, type: 'delimiter.ps1' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'number.ps1' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'delimiter.ps1' }, + { startIndex: 7, type: 'comment.ps1' } + ] + } + ], - [{ - line: '$x = 1 # my comment # is a nice one', - tokens: [ - { startIndex: 0, type: 'variable.ps1' }, - { startIndex: 2, type: '' }, - { startIndex: 3, type: 'delimiter.ps1' }, - { startIndex: 4, type: '' }, - { startIndex: 5, type: 'number.ps1' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'comment.ps1' } - ] - }], + [ + { + line: '$x = 1 # my comment # is a nice one', + tokens: [ + { startIndex: 0, type: 'variable.ps1' }, + { startIndex: 2, type: '' }, + { startIndex: 3, type: 'delimiter.ps1' }, + { startIndex: 4, type: '' }, + { startIndex: 5, type: 'number.ps1' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'comment.ps1' } + ] + } + ], // Comments - range comment, single line - [{ - line: '<# a simple comment #>', - tokens: [ - { startIndex: 0, type: 'comment.ps1' } - ] - }], + [ + { + line: '<# a simple comment #>', + tokens: [{ startIndex: 0, type: 'comment.ps1' }] + } + ], - [{ - line: '$x = <# a simple comment #> 1', - tokens: [ - { startIndex: 0, type: 'variable.ps1' }, - { startIndex: 2, type: '' }, - { startIndex: 3, type: 'delimiter.ps1' }, - { startIndex: 4, type: '' }, - { startIndex: 5, type: 'comment.ps1' }, - { startIndex: 27, type: '' }, - { startIndex: 28, type: 'number.ps1' } - ] - }], + [ + { + line: '$x = <# a simple comment #> 1', + tokens: [ + { startIndex: 0, type: 'variable.ps1' }, + { startIndex: 2, type: '' }, + { startIndex: 3, type: 'delimiter.ps1' }, + { startIndex: 4, type: '' }, + { startIndex: 5, type: 'comment.ps1' }, + { startIndex: 27, type: '' }, + { startIndex: 28, type: 'number.ps1' } + ] + } + ], - [{ - line: '$yy = <# comment #> 14', - tokens: [ - { startIndex: 0, type: 'variable.ps1' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'delimiter.ps1' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'comment.ps1' }, - { startIndex: 19, type: '' }, - { startIndex: 20, type: 'number.ps1' } - ] - }], + [ + { + line: '$yy = <# comment #> 14', + tokens: [ + { startIndex: 0, type: 'variable.ps1' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'delimiter.ps1' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'comment.ps1' }, + { startIndex: 19, type: '' }, + { startIndex: 20, type: 'number.ps1' } + ] + } + ], - [{ - line: '$x = <##>7', - tokens: [ - { startIndex: 0, type: 'variable.ps1' }, - { startIndex: 2, type: '' }, - { startIndex: 3, type: 'delimiter.ps1' }, - { startIndex: 4, type: '' }, - { startIndex: 5, type: 'comment.ps1' }, - { startIndex: 9, type: 'number.ps1' } - ] - }], + [ + { + line: '$x = <##>7', + tokens: [ + { startIndex: 0, type: 'variable.ps1' }, + { startIndex: 2, type: '' }, + { startIndex: 3, type: 'delimiter.ps1' }, + { startIndex: 4, type: '' }, + { startIndex: 5, type: 'comment.ps1' }, + { startIndex: 9, type: 'number.ps1' } + ] + } + ], - [{ - line: '$x = <#<85', - tokens: [ - { startIndex: 0, type: 'variable.ps1' }, - { startIndex: 2, type: '' }, - { startIndex: 3, type: 'delimiter.ps1' }, - { startIndex: 4, type: '' }, - { startIndex: 5, type: 'comment.ps1' } - ] - }], + [ + { + line: '$x = <#<85', + tokens: [ + { startIndex: 0, type: 'variable.ps1' }, + { startIndex: 2, type: '' }, + { startIndex: 3, type: 'delimiter.ps1' }, + { startIndex: 4, type: '' }, + { startIndex: 5, type: 'comment.ps1' } + ] + } + ], // Comments - range comment, multiple lines - [{ - line: '<# start of multiline comment', - tokens: [ - { startIndex: 0, type: 'comment.ps1' } - ] - }, { - line: 'a comment between', - tokens: [ - { startIndex: 0, type: 'comment.ps1' } - ] - }, { - line: 'end of multiline comment#>', - tokens: [ - { startIndex: 0, type: 'comment.ps1' } - ] - }], + [ + { + line: '<# start of multiline comment', + tokens: [{ startIndex: 0, type: 'comment.ps1' }] + }, + { + line: 'a comment between', + tokens: [{ startIndex: 0, type: 'comment.ps1' }] + }, + { + line: 'end of multiline comment#>', + tokens: [{ startIndex: 0, type: 'comment.ps1' }] + } + ], - [{ - line: '$x = <# start a comment', - tokens: [ - { startIndex: 0, type: 'variable.ps1' }, - { startIndex: 2, type: '' }, - { startIndex: 3, type: 'delimiter.ps1' }, - { startIndex: 4, type: '' }, - { startIndex: 5, type: 'comment.ps1' } - ] - }, { - line: ' a ', - tokens: [ - { startIndex: 0, type: 'comment.ps1' } - ] - }, { - line: 'and end it #> 2', - tokens: [ - { startIndex: 0, type: 'comment.ps1' }, - { startIndex: 13, type: '' }, - { startIndex: 14, type: 'number.ps1' } - ] - }], + [ + { + line: '$x = <# start a comment', + tokens: [ + { startIndex: 0, type: 'variable.ps1' }, + { startIndex: 2, type: '' }, + { startIndex: 3, type: 'delimiter.ps1' }, + { startIndex: 4, type: '' }, + { startIndex: 5, type: 'comment.ps1' } + ] + }, + { + line: ' a ', + tokens: [{ startIndex: 0, type: 'comment.ps1' }] + }, + { + line: 'and end it #> 2', + tokens: [ + { startIndex: 0, type: 'comment.ps1' }, + { startIndex: 13, type: '' }, + { startIndex: 14, type: 'number.ps1' } + ] + } + ], // Keywords - [{ - line: 'foreach($i in $b) {if (7) continue}', - tokens: [ - { startIndex: 0, type: 'keyword.foreach.ps1' }, - { startIndex: 7, type: 'delimiter.parenthesis.ps1' }, - { startIndex: 8, type: 'variable.ps1' }, - { startIndex: 10, type: '' }, - { startIndex: 11, type: 'keyword.in.ps1' }, - { startIndex: 13, type: '' }, - { startIndex: 14, type: 'variable.ps1' }, - { startIndex: 16, type: 'delimiter.parenthesis.ps1' }, - { startIndex: 17, type: '' }, - { startIndex: 18, type: 'delimiter.curly.ps1' }, - { startIndex: 19, type: 'keyword.if.ps1' }, - { startIndex: 21, type: '' }, - { startIndex: 22, type: 'delimiter.parenthesis.ps1' }, - { startIndex: 23, type: 'number.ps1' }, - { startIndex: 24, type: 'delimiter.parenthesis.ps1' }, - { startIndex: 25, type: '' }, - { startIndex: 26, type: 'keyword.continue.ps1' }, - { startIndex: 34, type: 'delimiter.curly.ps1' } - ] - }], + [ + { + line: 'foreach($i in $b) {if (7) continue}', + tokens: [ + { startIndex: 0, type: 'keyword.foreach.ps1' }, + { startIndex: 7, type: 'delimiter.parenthesis.ps1' }, + { startIndex: 8, type: 'variable.ps1' }, + { startIndex: 10, type: '' }, + { startIndex: 11, type: 'keyword.in.ps1' }, + { startIndex: 13, type: '' }, + { startIndex: 14, type: 'variable.ps1' }, + { startIndex: 16, type: 'delimiter.parenthesis.ps1' }, + { startIndex: 17, type: '' }, + { startIndex: 18, type: 'delimiter.curly.ps1' }, + { startIndex: 19, type: 'keyword.if.ps1' }, + { startIndex: 21, type: '' }, + { startIndex: 22, type: 'delimiter.parenthesis.ps1' }, + { startIndex: 23, type: 'number.ps1' }, + { startIndex: 24, type: 'delimiter.parenthesis.ps1' }, + { startIndex: 25, type: '' }, + { startIndex: 26, type: 'keyword.continue.ps1' }, + { startIndex: 34, type: 'delimiter.curly.ps1' } + ] + } + ], // Redirect operand - [{ - line: '$i > output1.txt', - tokens: [ - { startIndex: 0, type: 'variable.ps1' }, - { startIndex: 2, type: '' }, - { startIndex: 3, type: 'delimiter.ps1' }, - { startIndex: 4, type: '' }, - { startIndex: 12, type: 'delimiter.ps1' }, - { startIndex: 13, type: '' } - ] - }], + [ + { + line: '$i > output1.txt', + tokens: [ + { startIndex: 0, type: 'variable.ps1' }, + { startIndex: 2, type: '' }, + { startIndex: 3, type: 'delimiter.ps1' }, + { startIndex: 4, type: '' }, + { startIndex: 12, type: 'delimiter.ps1' }, + { startIndex: 13, type: '' } + ] + } + ], // Numbers - [{ - line: '0', - tokens: [ - { startIndex: 0, type: 'number.ps1' } - ] - }], + [ + { + line: '0', + tokens: [{ startIndex: 0, type: 'number.ps1' }] + } + ], - [{ - line: '0.10', - tokens: [ - { startIndex: 0, type: 'number.float.ps1' } - ] - }], + [ + { + line: '0.10', + tokens: [{ startIndex: 0, type: 'number.float.ps1' }] + } + ], - [{ - line: '0X123', - tokens: [ - { startIndex: 0, type: 'number.hex.ps1' } - ] - }], + [ + { + line: '0X123', + tokens: [{ startIndex: 0, type: 'number.hex.ps1' }] + } + ], - [{ - line: '0x123', - tokens: [ - { startIndex: 0, type: 'number.hex.ps1' } - ] - }], + [ + { + line: '0x123', + tokens: [{ startIndex: 0, type: 'number.hex.ps1' }] + } + ], - [{ - line: '23.5e3', - tokens: [ - { startIndex: 0, type: 'number.float.ps1' } - ] - }], + [ + { + line: '23.5e3', + tokens: [{ startIndex: 0, type: 'number.float.ps1' }] + } + ], - [{ - line: '23.5e-3', - tokens: [ - { startIndex: 0, type: 'number.float.ps1' } - ] - }], + [ + { + line: '23.5e-3', + tokens: [{ startIndex: 0, type: 'number.float.ps1' }] + } + ], - [{ - line: '23.5E3', - tokens: [ - { startIndex: 0, type: 'number.float.ps1' } - ] - }], + [ + { + line: '23.5E3', + tokens: [{ startIndex: 0, type: 'number.float.ps1' }] + } + ], - [{ - line: '23.5E-3', - tokens: [ - { startIndex: 0, type: 'number.float.ps1' } - ] - }], + [ + { + line: '23.5E-3', + tokens: [{ startIndex: 0, type: 'number.float.ps1' }] + } + ], - [{ - line: '23.5', - tokens: [ - { startIndex: 0, type: 'number.float.ps1' } - ] - }], + [ + { + line: '23.5', + tokens: [{ startIndex: 0, type: 'number.float.ps1' }] + } + ], - [{ - line: '0+0', - tokens: [ - { startIndex: 0, type: 'number.ps1' }, - { startIndex: 1, type: 'delimiter.ps1' }, - { startIndex: 2, type: 'number.ps1' } - ] - }], + [ + { + line: '0+0', + tokens: [ + { startIndex: 0, type: 'number.ps1' }, + { startIndex: 1, type: 'delimiter.ps1' }, + { startIndex: 2, type: 'number.ps1' } + ] + } + ], - [{ - line: '100+10', - tokens: [ - { startIndex: 0, type: 'number.ps1' }, - { startIndex: 3, type: 'delimiter.ps1' }, - { startIndex: 4, type: 'number.ps1' } - ] - }], + [ + { + line: '100+10', + tokens: [ + { startIndex: 0, type: 'number.ps1' }, + { startIndex: 3, type: 'delimiter.ps1' }, + { startIndex: 4, type: 'number.ps1' } + ] + } + ], - [{ - line: '10 + 0', - tokens: [ - { startIndex: 0, type: 'number.ps1' }, - { startIndex: 2, type: '' }, - { startIndex: 3, type: 'delimiter.ps1' }, - { startIndex: 4, type: '' }, - { startIndex: 5, type: 'number.ps1' } - ] - }], + [ + { + line: '10 + 0', + tokens: [ + { startIndex: 0, type: 'number.ps1' }, + { startIndex: 2, type: '' }, + { startIndex: 3, type: 'delimiter.ps1' }, + { startIndex: 4, type: '' }, + { startIndex: 5, type: 'number.ps1' } + ] + } + ], // Strings - [{ - line: '$s = "I am a String"', - tokens: [ - { startIndex: 0, type: 'variable.ps1' }, - { startIndex: 2, type: '' }, - { startIndex: 3, type: 'delimiter.ps1' }, - { startIndex: 4, type: '' }, - { startIndex: 5, type: 'string.ps1' } - ] - }], + [ + { + line: '$s = "I am a String"', + tokens: [ + { startIndex: 0, type: 'variable.ps1' }, + { startIndex: 2, type: '' }, + { startIndex: 3, type: 'delimiter.ps1' }, + { startIndex: 4, type: '' }, + { startIndex: 5, type: 'string.ps1' } + ] + } + ], - [{ - line: '\'I am also a ( String\'', - tokens: [ - { startIndex: 0, type: 'string.ps1' } - ] - }], + [ + { + line: "'I am also a ( String'", + tokens: [{ startIndex: 0, type: 'string.ps1' }] + } + ], - [{ - line: '$s = "concatenated" + " String"', - tokens: [ - { startIndex: 0, type: 'variable.ps1' }, - { startIndex: 2, type: '' }, - { startIndex: 3, type: 'delimiter.ps1' }, - { startIndex: 4, type: '' }, - { startIndex: 5, type: 'string.ps1' }, - { startIndex: 19, type: '' }, - { startIndex: 20, type: 'delimiter.ps1' }, - { startIndex: 21, type: '' }, - { startIndex: 22, type: 'string.ps1' } - ] - }], + [ + { + line: '$s = "concatenated" + " String"', + tokens: [ + { startIndex: 0, type: 'variable.ps1' }, + { startIndex: 2, type: '' }, + { startIndex: 3, type: 'delimiter.ps1' }, + { startIndex: 4, type: '' }, + { startIndex: 5, type: 'string.ps1' }, + { startIndex: 19, type: '' }, + { startIndex: 20, type: 'delimiter.ps1' }, + { startIndex: 21, type: '' }, + { startIndex: 22, type: 'string.ps1' } + ] + } + ], - [{ - line: '"escaping `"quotes`" is cool"', - tokens: [ - { startIndex: 0, type: 'string.ps1' }, - { startIndex: 10, type: 'string.escape.ps1' }, - { startIndex: 12, type: 'string.ps1' }, - { startIndex: 18, type: 'string.escape.ps1' }, - { startIndex: 20, type: 'string.ps1' } - ] - }], + [ + { + line: '"escaping `"quotes`" is cool"', + tokens: [ + { startIndex: 0, type: 'string.ps1' }, + { startIndex: 10, type: 'string.escape.ps1' }, + { startIndex: 12, type: 'string.ps1' }, + { startIndex: 18, type: 'string.escape.ps1' }, + { startIndex: 20, type: 'string.ps1' } + ] + } + ], - [{ - line: '\'`\'end of the string', - tokens: [ - { startIndex: 0, type: 'string.ps1' }, - { startIndex: 1, type: 'string.escape.ps1' }, - { startIndex: 3, type: 'string.ps1' } - ] - }], + [ + { + line: "'`'end of the string", + tokens: [ + { startIndex: 0, type: 'string.ps1' }, + { startIndex: 1, type: 'string.escape.ps1' }, + { startIndex: 3, type: 'string.ps1' } + ] + } + ], - [{ - line: '@"I am an expandable String"@', - tokens: [ - { startIndex: 0, type: 'string.ps1' } - ] - }], + [ + { + line: '@"I am an expandable String"@', + tokens: [{ startIndex: 0, type: 'string.ps1' }] + } + ], - [{ - line: '@\'I am also an expandable String\'@', - tokens: [ - { startIndex: 0, type: 'string.ps1' } - ] - }], + [ + { + line: "@'I am also an expandable String'@", + tokens: [{ startIndex: 0, type: 'string.ps1' }] + } + ], - [{ - line: '$s = @\'I am also an expandable String\'@', - tokens: [ - { startIndex: 0, type: 'variable.ps1' }, - { startIndex: 2, type: '' }, - { startIndex: 3, type: 'delimiter.ps1' }, - { startIndex: 4, type: '' }, - { startIndex: 5, type: 'string.ps1' } - ] - }], + [ + { + line: "$s = @'I am also an expandable String'@", + tokens: [ + { startIndex: 0, type: 'variable.ps1' }, + { startIndex: 2, type: '' }, + { startIndex: 3, type: 'delimiter.ps1' }, + { startIndex: 4, type: '' }, + { startIndex: 5, type: 'string.ps1' } + ] + } + ], - [{ - line: '$s = @\'I am also an expandable String\'@+7', - tokens: [ - { startIndex: 0, type: 'variable.ps1' }, - { startIndex: 2, type: '' }, - { startIndex: 3, type: 'delimiter.ps1' }, - { startIndex: 4, type: '' }, - { startIndex: 5, type: 'string.ps1' } - ] - }], + [ + { + line: "$s = @'I am also an expandable String'@+7", + tokens: [ + { startIndex: 0, type: 'variable.ps1' }, + { startIndex: 2, type: '' }, + { startIndex: 3, type: 'delimiter.ps1' }, + { startIndex: 4, type: '' }, + { startIndex: 5, type: 'string.ps1' } + ] + } + ], - [{ - line: '@\'I am a multiline string,', - tokens: [ - { startIndex: 0, type: 'string.ps1' } - ] - }, { - line: 'and this is the middle line,', - tokens: [ - { startIndex: 0, type: 'string.ps1' } - ] - }, { - line: 'and this is NOT the end of the string\'@foreach $i', - tokens: [ - { startIndex: 0, type: 'string.ps1' } - ] - }, { - line: '\'@', - tokens: [ - { startIndex: 0, type: 'string.ps1' } - ] - }, { - line: '${script:foo}', - tokens: [ - { startIndex: 0, type: 'variable.ps1' } - ] - }, { - line: 'foreach $i', - tokens: [ - { startIndex: 0, type: 'keyword.foreach.ps1' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'variable.ps1' } - ] - }], + [ + { + line: "@'I am a multiline string,", + tokens: [{ startIndex: 0, type: 'string.ps1' }] + }, + { + line: 'and this is the middle line,', + tokens: [{ startIndex: 0, type: 'string.ps1' }] + }, + { + line: "and this is NOT the end of the string'@foreach $i", + tokens: [{ startIndex: 0, type: 'string.ps1' }] + }, + { + line: "'@", + tokens: [{ startIndex: 0, type: 'string.ps1' }] + }, + { + line: '${script:foo}', + tokens: [{ startIndex: 0, type: 'variable.ps1' }] + }, + { + line: 'foreach $i', + tokens: [ + { startIndex: 0, type: 'keyword.foreach.ps1' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'variable.ps1' } + ] + } + ], // Generated from sample - [{ - line: '$SelectedObjectNames=@();', - tokens: [ - { startIndex: 0, type: 'variable.ps1' }, - { startIndex: 20, type: 'delimiter.ps1' }, - { startIndex: 21, type: '' }, - { startIndex: 22, type: 'delimiter.parenthesis.ps1' }, - { startIndex: 24, type: 'delimiter.ps1' } - ] - }, { - line: '$XenCenterNodeSelected = 0;', - tokens: [ - { startIndex: 0, type: 'variable.ps1' }, - { startIndex: 22, type: '' }, - { startIndex: 23, type: 'delimiter.ps1' }, - { startIndex: 24, type: '' }, - { startIndex: 25, type: 'number.ps1' }, - { startIndex: 26, type: 'delimiter.ps1' } - ] - }, { - line: '#the object info array contains hashmaps, each of which represent a parameter set and describe a target in the XenCenter resource list', - tokens: [ - { startIndex: 0, type: 'comment.ps1' } - ] - }, { - line: 'foreach($parameterSet in $ObjInfoArray)', - tokens: [ - { startIndex: 0, type: 'keyword.foreach.ps1' }, - { startIndex: 7, type: 'delimiter.parenthesis.ps1' }, - { startIndex: 8, type: 'variable.ps1' }, - { startIndex: 21, type: '' }, - { startIndex: 22, type: 'keyword.in.ps1' }, - { startIndex: 24, type: '' }, - { startIndex: 25, type: 'variable.ps1' }, - { startIndex: 38, type: 'delimiter.parenthesis.ps1' } - ] - }, { - line: '{', - tokens: [ - { startIndex: 0, type: 'delimiter.curly.ps1' } - ] - }, { - line: ' if ($parameterSet["class"] -eq "blank")', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 1, type: 'keyword.if.ps1' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'delimiter.parenthesis.ps1' }, - { startIndex: 5, type: 'variable.ps1' }, - { startIndex: 18, type: 'delimiter.square.ps1' }, - { startIndex: 19, type: 'string.ps1' }, - { startIndex: 26, type: 'delimiter.square.ps1' }, - { startIndex: 27, type: '' }, - { startIndex: 28, type: 'delimiter.ps1' }, - { startIndex: 29, type: '' }, - { startIndex: 32, type: 'string.ps1' }, - { startIndex: 39, type: 'delimiter.parenthesis.ps1' } - ] - }, { - line: ' {', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 1, type: 'delimiter.curly.ps1' } - ] - }, { - line: ' #When the XenCenter node is selected a parameter set is created for each of your connected servers with the class and objUuid keys marked as blank', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'comment.ps1' } - ] - }, { - line: ' if ($XenCenterNodeSelected)', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'keyword.if.ps1' }, - { startIndex: 4, type: '' }, - { startIndex: 5, type: 'delimiter.parenthesis.ps1' }, - { startIndex: 6, type: 'variable.ps1' }, - { startIndex: 28, type: 'delimiter.parenthesis.ps1' } - ] - }, { - line: ' {', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'delimiter.curly.ps1' } - ] - }, { - line: ' continue', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 3, type: 'keyword.continue.ps1' } - ] - }, { - line: ' }', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'delimiter.curly.ps1' } - ] - }, { - line: ' $XenCenterNodeSelected = 1;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'variable.ps1' }, - { startIndex: 24, type: '' }, - { startIndex: 25, type: 'delimiter.ps1' }, - { startIndex: 26, type: '' }, - { startIndex: 27, type: 'number.ps1' }, - { startIndex: 28, type: 'delimiter.ps1' } - ] - }, { - line: ' $SelectedObjectNames += "XenCenter"', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'variable.ps1' }, - { startIndex: 22, type: '' }, - { startIndex: 23, type: 'delimiter.ps1' }, - { startIndex: 25, type: '' }, - { startIndex: 26, type: 'string.ps1' } - ] - }, { - line: ' }', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 1, type: 'delimiter.curly.ps1' } - ] - }, { - line: ' elseif ($parameterSet["sessionRef"] -eq "null")', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 1, type: 'keyword.elseif.ps1' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'delimiter.parenthesis.ps1' }, - { startIndex: 9, type: 'variable.ps1' }, - { startIndex: 22, type: 'delimiter.square.ps1' }, - { startIndex: 23, type: 'string.ps1' }, - { startIndex: 35, type: 'delimiter.square.ps1' }, - { startIndex: 36, type: '' }, - { startIndex: 37, type: 'delimiter.ps1' }, - { startIndex: 38, type: '' }, - { startIndex: 41, type: 'string.ps1' }, - { startIndex: 47, type: 'delimiter.parenthesis.ps1' } - ] - }, { - line: ' {', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 1, type: 'delimiter.curly.ps1' } - ] - }, { - line: ' #When a disconnected server is selected there is no session information, we get null for everything except class', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'comment.ps1' } - ] - }, { - line: ' }', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 1, type: 'delimiter.curly.ps1' } - ] - }, { - line: ' $SelectedObjectNames += "a disconnected server"', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'variable.ps1' }, - { startIndex: 22, type: '' }, - { startIndex: 23, type: 'delimiter.ps1' }, - { startIndex: 25, type: '' }, - { startIndex: 26, type: 'string.ps1' } - ] - }, { - line: ' else', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 1, type: 'keyword.else.ps1' } - ] - }, { - line: ' {', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 1, type: 'delimiter.curly.ps1' } - ] - }, { - line: ' Connect-XenServer -url $parameterSet["url"] -opaqueref $parameterSet["sessionRef"]', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 20, type: 'delimiter.ps1' }, - { startIndex: 21, type: '' }, - { startIndex: 25, type: 'variable.ps1' }, - { startIndex: 38, type: 'delimiter.square.ps1' }, - { startIndex: 39, type: 'string.ps1' }, - { startIndex: 44, type: 'delimiter.square.ps1' }, - { startIndex: 45, type: '' }, - { startIndex: 46, type: 'delimiter.ps1' }, - { startIndex: 47, type: '' }, - { startIndex: 57, type: 'variable.ps1' }, - { startIndex: 70, type: 'delimiter.square.ps1' }, - { startIndex: 71, type: 'string.ps1' }, - { startIndex: 83, type: 'delimiter.square.ps1' } - ] - }, { - line: ' #Use $class to determine which server objects to get', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'comment.ps1' } - ] - }, { - line: ' #-properties allows us to filter the results to just include the selected object', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'comment.ps1' } - ] - }, { - line: ' $exp = "Get-XenServer:{0} -properties @{{uuid=\'{1}\'}}" -f $parameterSet["class"], $parameterSet["objUuid"]', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'variable.ps1' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'delimiter.ps1' }, - { startIndex: 8, type: '' }, - { startIndex: 9, type: 'string.ps1' }, - { startIndex: 56, type: '' }, - { startIndex: 57, type: 'delimiter.ps1' }, - { startIndex: 58, type: '' }, - { startIndex: 60, type: 'variable.ps1' }, - { startIndex: 73, type: 'delimiter.square.ps1' }, - { startIndex: 74, type: 'string.ps1' }, - { startIndex: 81, type: 'delimiter.square.ps1' }, - { startIndex: 82, type: 'delimiter.ps1' }, - { startIndex: 83, type: '' }, - { startIndex: 84, type: 'variable.ps1' }, - { startIndex: 97, type: 'delimiter.square.ps1' }, - { startIndex: 98, type: 'string.ps1' }, - { startIndex: 107, type: 'delimiter.square.ps1' } - ] - }, { - line: ' $obj = Invoke-Expression $exp', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'variable.ps1' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'delimiter.ps1' }, - { startIndex: 8, type: '' }, - { startIndex: 27, type: 'variable.ps1' } - ] - }, { - line: ' $SelectedObjectNames += $obj.name_label;', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'variable.ps1' }, - { startIndex: 22, type: '' }, - { startIndex: 23, type: 'delimiter.ps1' }, - { startIndex: 25, type: '' }, - { startIndex: 26, type: 'variable.ps1' }, - { startIndex: 30, type: 'delimiter.ps1' }, - { startIndex: 31, type: '' }, - { startIndex: 41, type: 'delimiter.ps1' } - ] - }, { - line: ' } ', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 1, type: 'delimiter.curly.ps1' }, - { startIndex: 2, type: '' } - ] - }, { - line: '}', - tokens: [ - { startIndex: 0, type: 'delimiter.curly.ps1' } - ] - }, { - line: '', - tokens: [ - - ] - }, { - line: '$test = "in string var$test"', - tokens: [ - { startIndex: 0, type: 'variable.ps1' }, - { startIndex: 5, type: '' }, - { startIndex: 6, type: 'delimiter.ps1' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'string.ps1' }, - { startIndex: 22, type: 'variable.ps1' }, - { startIndex: 27, type: 'string.ps1' } - ] - }, { - line: '$another = \'not a $var\'', - tokens: [ - { startIndex: 0, type: 'variable.ps1' }, - { startIndex: 8, type: '' }, - { startIndex: 9, type: 'delimiter.ps1' }, - { startIndex: 10, type: '' }, - { startIndex: 11, type: 'string.ps1' } - ] - }, { - line: '$third = "a $var and not `$var string"', - tokens: [ - { startIndex: 0, type: 'variable.ps1' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'delimiter.ps1' }, - { startIndex: 8, type: '' }, - { startIndex: 9, type: 'string.ps1' }, - { startIndex: 12, type: 'variable.ps1' }, - { startIndex: 16, type: 'string.ps1' }, - { startIndex: 25, type: 'string.escape.ps1' }, - { startIndex: 27, type: 'string.ps1' } - ] - }, { - line: '', - tokens: [ - - ] - }, { - line: ':aLabel', - tokens: [ - { startIndex: 0, type: 'metatag.ps1' } - ] - }, { - line: '', - tokens: [ - - ] - }, { - line: '<#', - tokens: [ - { startIndex: 0, type: 'comment.ps1' } - ] - }, { - line: '.SYNOPSIS', - tokens: [ - { startIndex: 0, type: 'comment.keyword.synopsis.ps1' } - ] - }, { - line: ' some text', - tokens: [ - { startIndex: 0, type: 'comment.ps1' } - ] - }, { - line: ' ', - tokens: [ - { startIndex: 0, type: 'comment.ps1' } - ] - }, { - line: '.LINK', - tokens: [ - { startIndex: 0, type: 'comment.keyword.link.ps1' } - ] - }, { - line: ' some more text', - tokens: [ - { startIndex: 0, type: 'comment.ps1' } - ] - }, { - line: '#>', - tokens: [ - { startIndex: 0, type: 'comment.ps1' } - ] - }, { - line: '', - tokens: [ - - ] - }, { - line: '', - tokens: [ - - ] - }, { - line: '$hereString = @"', - tokens: [ - { startIndex: 0, type: 'variable.ps1' }, - { startIndex: 11, type: '' }, - { startIndex: 12, type: 'delimiter.ps1' }, - { startIndex: 13, type: '' }, - { startIndex: 14, type: 'string.ps1' } - ] - }, { - line: ' a string', - tokens: [ - { startIndex: 0, type: 'string.ps1' } - ] - }, { - line: ' still "@ a string $withVar', - tokens: [ - { startIndex: 0, type: 'string.ps1' }, - { startIndex: 20, type: 'variable.ps1' } - ] - }, { - line: ' still a string `$noVar', - tokens: [ - { startIndex: 0, type: 'string.ps1' }, - { startIndex: 17, type: 'string.escape.ps1' }, - { startIndex: 19, type: 'string.ps1' } - ] - }, { - line: '', - tokens: [ - - ] - }, { - line: '"@ still a string', - tokens: [ - { startIndex: 0, type: 'string.ps1' }, - { startIndex: 2, type: '' } - ] - }] + [ + { + line: '$SelectedObjectNames=@();', + tokens: [ + { startIndex: 0, type: 'variable.ps1' }, + { startIndex: 20, type: 'delimiter.ps1' }, + { startIndex: 21, type: '' }, + { startIndex: 22, type: 'delimiter.parenthesis.ps1' }, + { startIndex: 24, type: 'delimiter.ps1' } + ] + }, + { + line: '$XenCenterNodeSelected = 0;', + tokens: [ + { startIndex: 0, type: 'variable.ps1' }, + { startIndex: 22, type: '' }, + { startIndex: 23, type: 'delimiter.ps1' }, + { startIndex: 24, type: '' }, + { startIndex: 25, type: 'number.ps1' }, + { startIndex: 26, type: 'delimiter.ps1' } + ] + }, + { + line: + '#the object info array contains hashmaps, each of which represent a parameter set and describe a target in the XenCenter resource list', + tokens: [{ startIndex: 0, type: 'comment.ps1' }] + }, + { + line: 'foreach($parameterSet in $ObjInfoArray)', + tokens: [ + { startIndex: 0, type: 'keyword.foreach.ps1' }, + { startIndex: 7, type: 'delimiter.parenthesis.ps1' }, + { startIndex: 8, type: 'variable.ps1' }, + { startIndex: 21, type: '' }, + { startIndex: 22, type: 'keyword.in.ps1' }, + { startIndex: 24, type: '' }, + { startIndex: 25, type: 'variable.ps1' }, + { startIndex: 38, type: 'delimiter.parenthesis.ps1' } + ] + }, + { + line: '{', + tokens: [{ startIndex: 0, type: 'delimiter.curly.ps1' }] + }, + { + line: ' if ($parameterSet["class"] -eq "blank")', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 1, type: 'keyword.if.ps1' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'delimiter.parenthesis.ps1' }, + { startIndex: 5, type: 'variable.ps1' }, + { startIndex: 18, type: 'delimiter.square.ps1' }, + { startIndex: 19, type: 'string.ps1' }, + { startIndex: 26, type: 'delimiter.square.ps1' }, + { startIndex: 27, type: '' }, + { startIndex: 28, type: 'delimiter.ps1' }, + { startIndex: 29, type: '' }, + { startIndex: 32, type: 'string.ps1' }, + { startIndex: 39, type: 'delimiter.parenthesis.ps1' } + ] + }, + { + line: ' {', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 1, type: 'delimiter.curly.ps1' } + ] + }, + { + line: + ' #When the XenCenter node is selected a parameter set is created for each of your connected servers with the class and objUuid keys marked as blank', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'comment.ps1' } + ] + }, + { + line: ' if ($XenCenterNodeSelected)', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'keyword.if.ps1' }, + { startIndex: 4, type: '' }, + { startIndex: 5, type: 'delimiter.parenthesis.ps1' }, + { startIndex: 6, type: 'variable.ps1' }, + { startIndex: 28, type: 'delimiter.parenthesis.ps1' } + ] + }, + { + line: ' {', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'delimiter.curly.ps1' } + ] + }, + { + line: ' continue', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 3, type: 'keyword.continue.ps1' } + ] + }, + { + line: ' }', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'delimiter.curly.ps1' } + ] + }, + { + line: ' $XenCenterNodeSelected = 1;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'variable.ps1' }, + { startIndex: 24, type: '' }, + { startIndex: 25, type: 'delimiter.ps1' }, + { startIndex: 26, type: '' }, + { startIndex: 27, type: 'number.ps1' }, + { startIndex: 28, type: 'delimiter.ps1' } + ] + }, + { + line: ' $SelectedObjectNames += "XenCenter"', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'variable.ps1' }, + { startIndex: 22, type: '' }, + { startIndex: 23, type: 'delimiter.ps1' }, + { startIndex: 25, type: '' }, + { startIndex: 26, type: 'string.ps1' } + ] + }, + { + line: ' }', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 1, type: 'delimiter.curly.ps1' } + ] + }, + { + line: ' elseif ($parameterSet["sessionRef"] -eq "null")', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 1, type: 'keyword.elseif.ps1' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'delimiter.parenthesis.ps1' }, + { startIndex: 9, type: 'variable.ps1' }, + { startIndex: 22, type: 'delimiter.square.ps1' }, + { startIndex: 23, type: 'string.ps1' }, + { startIndex: 35, type: 'delimiter.square.ps1' }, + { startIndex: 36, type: '' }, + { startIndex: 37, type: 'delimiter.ps1' }, + { startIndex: 38, type: '' }, + { startIndex: 41, type: 'string.ps1' }, + { startIndex: 47, type: 'delimiter.parenthesis.ps1' } + ] + }, + { + line: ' {', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 1, type: 'delimiter.curly.ps1' } + ] + }, + { + line: + ' #When a disconnected server is selected there is no session information, we get null for everything except class', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'comment.ps1' } + ] + }, + { + line: ' }', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 1, type: 'delimiter.curly.ps1' } + ] + }, + { + line: ' $SelectedObjectNames += "a disconnected server"', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'variable.ps1' }, + { startIndex: 22, type: '' }, + { startIndex: 23, type: 'delimiter.ps1' }, + { startIndex: 25, type: '' }, + { startIndex: 26, type: 'string.ps1' } + ] + }, + { + line: ' else', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 1, type: 'keyword.else.ps1' } + ] + }, + { + line: ' {', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 1, type: 'delimiter.curly.ps1' } + ] + }, + { + line: + ' Connect-XenServer -url $parameterSet["url"] -opaqueref $parameterSet["sessionRef"]', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 20, type: 'delimiter.ps1' }, + { startIndex: 21, type: '' }, + { startIndex: 25, type: 'variable.ps1' }, + { startIndex: 38, type: 'delimiter.square.ps1' }, + { startIndex: 39, type: 'string.ps1' }, + { startIndex: 44, type: 'delimiter.square.ps1' }, + { startIndex: 45, type: '' }, + { startIndex: 46, type: 'delimiter.ps1' }, + { startIndex: 47, type: '' }, + { startIndex: 57, type: 'variable.ps1' }, + { startIndex: 70, type: 'delimiter.square.ps1' }, + { startIndex: 71, type: 'string.ps1' }, + { startIndex: 83, type: 'delimiter.square.ps1' } + ] + }, + { + line: ' #Use $class to determine which server objects to get', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'comment.ps1' } + ] + }, + { + line: + ' #-properties allows us to filter the results to just include the selected object', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'comment.ps1' } + ] + }, + { + line: + ' $exp = "Get-XenServer:{0} -properties @{{uuid=\'{1}\'}}" -f $parameterSet["class"], $parameterSet["objUuid"]', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'variable.ps1' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'delimiter.ps1' }, + { startIndex: 8, type: '' }, + { startIndex: 9, type: 'string.ps1' }, + { startIndex: 56, type: '' }, + { startIndex: 57, type: 'delimiter.ps1' }, + { startIndex: 58, type: '' }, + { startIndex: 60, type: 'variable.ps1' }, + { startIndex: 73, type: 'delimiter.square.ps1' }, + { startIndex: 74, type: 'string.ps1' }, + { startIndex: 81, type: 'delimiter.square.ps1' }, + { startIndex: 82, type: 'delimiter.ps1' }, + { startIndex: 83, type: '' }, + { startIndex: 84, type: 'variable.ps1' }, + { startIndex: 97, type: 'delimiter.square.ps1' }, + { startIndex: 98, type: 'string.ps1' }, + { startIndex: 107, type: 'delimiter.square.ps1' } + ] + }, + { + line: ' $obj = Invoke-Expression $exp', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'variable.ps1' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'delimiter.ps1' }, + { startIndex: 8, type: '' }, + { startIndex: 27, type: 'variable.ps1' } + ] + }, + { + line: ' $SelectedObjectNames += $obj.name_label;', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'variable.ps1' }, + { startIndex: 22, type: '' }, + { startIndex: 23, type: 'delimiter.ps1' }, + { startIndex: 25, type: '' }, + { startIndex: 26, type: 'variable.ps1' }, + { startIndex: 30, type: 'delimiter.ps1' }, + { startIndex: 31, type: '' }, + { startIndex: 41, type: 'delimiter.ps1' } + ] + }, + { + line: ' } ', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 1, type: 'delimiter.curly.ps1' }, + { startIndex: 2, type: '' } + ] + }, + { + line: '}', + tokens: [{ startIndex: 0, type: 'delimiter.curly.ps1' }] + }, + { + line: '', + tokens: [] + }, + { + line: '$test = "in string var$test"', + tokens: [ + { startIndex: 0, type: 'variable.ps1' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'delimiter.ps1' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'string.ps1' }, + { startIndex: 22, type: 'variable.ps1' }, + { startIndex: 27, type: 'string.ps1' } + ] + }, + { + line: "$another = 'not a $var'", + tokens: [ + { startIndex: 0, type: 'variable.ps1' }, + { startIndex: 8, type: '' }, + { startIndex: 9, type: 'delimiter.ps1' }, + { startIndex: 10, type: '' }, + { startIndex: 11, type: 'string.ps1' } + ] + }, + { + line: '$third = "a $var and not `$var string"', + tokens: [ + { startIndex: 0, type: 'variable.ps1' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'delimiter.ps1' }, + { startIndex: 8, type: '' }, + { startIndex: 9, type: 'string.ps1' }, + { startIndex: 12, type: 'variable.ps1' }, + { startIndex: 16, type: 'string.ps1' }, + { startIndex: 25, type: 'string.escape.ps1' }, + { startIndex: 27, type: 'string.ps1' } + ] + }, + { + line: '', + tokens: [] + }, + { + line: ':aLabel', + tokens: [{ startIndex: 0, type: 'metatag.ps1' }] + }, + { + line: '', + tokens: [] + }, + { + line: '<#', + tokens: [{ startIndex: 0, type: 'comment.ps1' }] + }, + { + line: '.SYNOPSIS', + tokens: [{ startIndex: 0, type: 'comment.keyword.synopsis.ps1' }] + }, + { + line: ' some text', + tokens: [{ startIndex: 0, type: 'comment.ps1' }] + }, + { + line: ' ', + tokens: [{ startIndex: 0, type: 'comment.ps1' }] + }, + { + line: '.LINK', + tokens: [{ startIndex: 0, type: 'comment.keyword.link.ps1' }] + }, + { + line: ' some more text', + tokens: [{ startIndex: 0, type: 'comment.ps1' }] + }, + { + line: '#>', + tokens: [{ startIndex: 0, type: 'comment.ps1' }] + }, + { + line: '', + tokens: [] + }, + { + line: '', + tokens: [] + }, + { + line: '$hereString = @"', + tokens: [ + { startIndex: 0, type: 'variable.ps1' }, + { startIndex: 11, type: '' }, + { startIndex: 12, type: 'delimiter.ps1' }, + { startIndex: 13, type: '' }, + { startIndex: 14, type: 'string.ps1' } + ] + }, + { + line: ' a string', + tokens: [{ startIndex: 0, type: 'string.ps1' }] + }, + { + line: ' still "@ a string $withVar', + tokens: [ + { startIndex: 0, type: 'string.ps1' }, + { startIndex: 20, type: 'variable.ps1' } + ] + }, + { + line: ' still a string `$noVar', + tokens: [ + { startIndex: 0, type: 'string.ps1' }, + { startIndex: 17, type: 'string.escape.ps1' }, + { startIndex: 19, type: 'string.ps1' } + ] + }, + { + line: '', + tokens: [] + }, + { + line: '"@ still a string', + tokens: [ + { startIndex: 0, type: 'string.ps1' }, + { startIndex: 2, type: '' } + ] + } + ] ]); diff --git a/src/powershell/powershell.ts b/src/powershell/powershell.ts index 21311c60..063aac32 100644 --- a/src/powershell/powershell.ts +++ b/src/powershell/powershell.ts @@ -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 = { ], 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 = { // 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 = { [/^:\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 = { // 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 = { [/#>/, 'comment', '@pop'], [/(\.)(@helpKeywords)(?!\w)/, { token: 'comment.keyword.$2' }], [/[\.#]/, 'comment'] - ], - }, + ] + } }; diff --git a/src/pug/pug.test.ts b/src/pug/pug.test.ts index 80f85662..01493497 100644 --- a/src/pug/pug.test.ts +++ b/src/pug/pug.test.ts @@ -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 = ""', - 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 = ""', + 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: '' } + ] + } + ] ]); diff --git a/src/pug/pug.ts b/src/pug/pug.ts index 26b1b77b..05bcb246 100644 --- a/src/pug/pug.ts +++ b/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 = { { 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 = { 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 = { { 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 = { // 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 = { [/[^#]+/, { 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 = { 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]+/, ''], - [/'] - }, - - brackets: [ - [''], - ['<', '>'], - ['{', '}'], - ['(', ')'] - ], - - autoClosingPairs: [ - { open: '{', close: '}' }, - { open: '[', close: ']' }, - { open: '(', close: ')' }, - { open: '"', close: '"' }, - { open: '\'', close: '\'' } - ], - - surroundingPairs: [ - { open: '"', close: '"' }, - { open: '\'', close: '\'' }, - { open: '<', close: '>' } - ], - - onEnterRules: [ - { - beforeText: new RegExp(`<(?!(?:${EMPTY_ELEMENTS.join('|')}))(\\w[\\w\\d]*)([^/>]*(?!/)>)[^<]*$`, 'i'), - afterText: /^<\/(\w[\w\d]*)\s*>$/i, - action: { indentAction: _monaco.languages.IndentAction.IndentOutdent } - }, - { - beforeText: new RegExp(`<(?!(?:${EMPTY_ELEMENTS.join('|')}))(\\w[\\w\\d]*)([^/>]*(?!/)>)[^<]*$`, 'i'), - action: { indentAction: _monaco.languages.IndentAction.Indent } - } - ], -}; - -export const language = { - defaultToken: '', - tokenPostfix: '', - // ignoreCase: true, - - // The main tokenizer for our languages - tokenizer: { - root: [ - [/@@/], // text - [/@[^@]/, { token: '@rematch', switchTo: '@razorInSimpleState.root' }], - [/)/, ['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' }]], - [/]+/, 'metatag.content.html'], - [/>/, 'metatag.html', '@pop'], - ], - - comment: [ - [/@[^@]/, { token: '@rematch', switchTo: '@razorInSimpleState.comment' }], - [/-->/, 'comment.html', '@pop'], - [/[^-]+/, 'comment.content.html'], - [/./, 'comment.content.html'] - ], - - otherTag: [ - [/@[^@]/, { token: '@rematch', switchTo: '@razorInSimpleState.otherTag' }], - [/\/?>/, 'delimiter.html', '@pop'], - [/"([^"]*)"/, 'attribute.value'], - [/'([^']*)'/, 'attribute.value'], - [/[\w\-]+/, 'attribute.name'], - [/=/, 'delimiter'], - [/[ \t\r\n]+/], // whitespace - ], - - // -- BEGIN ', + tokens: [ + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'attribute.name.html' }, + { startIndex: 12, type: 'delimiter.html' }, + { startIndex: 13, type: 'attribute.value.html' }, + { startIndex: 30, type: 'delimiter.html' }, + { startIndex: 31, type: 'keyword.js' }, + { startIndex: 34, type: '' }, + { startIndex: 35, type: 'identifier.js' }, + { startIndex: 36, type: 'delimiter.js' }, + { startIndex: 37, type: '' }, + { startIndex: 38, type: 'number.js' }, + { startIndex: 40, type: 'delimiter.js' }, + { startIndex: 41, type: 'delimiter.html' }, + { startIndex: 43, type: 'tag.html' }, + { startIndex: 49, type: 'delimiter.html' } + ] + } + ], - // Embedded Content #1 - [{ - line: '', - tokens: [ - { startIndex: 0, type: 'delimiter.html' }, - { startIndex: 1, type: 'tag.html' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'attribute.name.html' }, - { startIndex: 12, type: 'delimiter.html' }, - { startIndex: 13, type: 'attribute.value.html' }, - { startIndex: 30, type: 'delimiter.html' }, - { startIndex: 31, type: 'keyword.js' }, - { startIndex: 34, type: '' }, - { startIndex: 35, type: 'identifier.js' }, - { startIndex: 36, type: 'delimiter.js' }, - { startIndex: 37, type: '' }, - { startIndex: 38, type: 'number.js' }, - { startIndex: 40, type: 'delimiter.js' }, - { startIndex: 41, type: 'delimiter.html' }, - { startIndex: 43, type: 'tag.html' }, - { startIndex: 49, type: 'delimiter.html' } - ] - }], + // Embedded Content #2 + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 2, type: 'tag.html' }, + { startIndex: 8, type: 'delimiter.html' } + ] + } + ], - // Embedded Content #2 - [{ - line: '', - tokens: [ - { startIndex: 0, type: 'delimiter.html' }, - { startIndex: 2, type: 'tag.html' }, - { startIndex: 8, type: 'delimiter.html' } - ] - }], + // Embedded Content #3 + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 2, type: 'tag.html' }, + { startIndex: 8, type: 'delimiter.html' } + ] + } + ], - // Embedded Content #3 - [{ - line: '', + tokens: [ + { startIndex: 0, type: 'keyword.js' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'identifier.js' }, + { startIndex: 5, type: 'delimiter.js' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'number.js' }, + { startIndex: 9, type: 'delimiter.js' }, + { startIndex: 10, type: 'delimiter.html' }, + { startIndex: 12, type: 'tag.html' }, + { startIndex: 18, type: 'delimiter.html' } + ] + } + ], - ] - }, { - line: '', - tokens: [ - { startIndex: 0, type: 'delimiter.html' }, - { startIndex: 2, type: 'tag.html' }, - { startIndex: 8, type: 'delimiter.html' } - ] - }], + // Embedded Content #5 + [ + { + line: '', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 2, type: 'delimiter.html' }, + { startIndex: 4, type: 'tag.html' }, + { startIndex: 10, type: 'delimiter.html' } + ] + } + ], - // Embedded Content #4 - [{ - line: '', - tokens: [ - { startIndex: 0, type: 'keyword.js' }, - { startIndex: 3, type: '' }, - { startIndex: 4, type: 'identifier.js' }, - { startIndex: 5, type: 'delimiter.js' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'number.js' }, - { startIndex: 9, type: 'delimiter.js' }, - { startIndex: 10, type: 'delimiter.html' }, - { startIndex: 12, type: 'tag.html' }, - { startIndex: 18, type: 'delimiter.html' } - ] - }], + // Embedded Content #6 + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, + { startIndex: 7, type: 'delimiter.html' }, + { startIndex: 8, type: 'identifier.js' }, + { startIndex: 9, type: 'delimiter.html' }, + { startIndex: 11, type: 'tag.html' }, + { startIndex: 17, type: 'delimiter.html' }, + // { startIndex:18, type: 'delimiter.html' }, + { startIndex: 19, type: 'tag.html' }, + { startIndex: 25, type: 'delimiter.html' }, + { startIndex: 26, type: 'identifier.js' }, + { startIndex: 27, type: 'delimiter.html' }, + { startIndex: 29, type: 'tag.html' }, + { startIndex: 35, type: 'delimiter.html' } + ] + } + ], - // Embedded Content #5 - [{ - line: '', - tokens: [ - { startIndex: 0, type: '' }, - { startIndex: 2, type: 'delimiter.html' }, - { startIndex: 4, type: 'tag.html' }, - { startIndex: 10, type: 'delimiter.html' } - ] - }], + // Embedded Content #7 + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'attribute.name.html' }, + { startIndex: 12, type: 'delimiter.html' }, + { startIndex: 13, type: 'attribute.value.html' }, + { startIndex: 30, type: 'delimiter.html' }, + // { startIndex:31, type: 'delimiter.html' }, + { startIndex: 33, type: 'tag.html' }, + { startIndex: 39, type: 'delimiter.html' } + ] + } + ], - // Embedded Content #6 - [{ - line: '', - tokens: [ - { startIndex: 0, type: 'delimiter.html' }, - { startIndex: 1, type: 'tag.html' }, - { startIndex: 7, type: 'delimiter.html' }, - { startIndex: 8, type: 'identifier.js' }, - { startIndex: 9, type: 'delimiter.html' }, - { startIndex: 11, type: 'tag.html' }, - { startIndex: 17, type: 'delimiter.html' }, - // { startIndex:18, type: 'delimiter.html' }, - { startIndex: 19, type: 'tag.html' }, - { startIndex: 25, type: 'delimiter.html' }, - { startIndex: 26, type: 'identifier.js' }, - { startIndex: 27, type: 'delimiter.html' }, - { startIndex: 29, type: 'tag.html' }, - { startIndex: 35, type: 'delimiter.html' } - ] - }], + // Embedded Content #8 + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, + { startIndex: 7, type: 'delimiter.html' }, + { startIndex: 8, type: 'keyword.js' }, + { startIndex: 11, type: '' }, + { startIndex: 12, type: 'identifier.js' }, + { startIndex: 13, type: 'delimiter.js' }, + { startIndex: 14, type: '' }, + { startIndex: 15, type: 'number.js' }, + { startIndex: 17, type: 'delimiter.js' }, + { startIndex: 18, type: 'delimiter.html' }, + { startIndex: 20, type: 'tag.html' }, + { startIndex: 26, type: 'delimiter.html' } + ] + } + ], - // Embedded Content #7 - [{ - line: '', - tokens: [ - { startIndex: 0, type: 'delimiter.html' }, - { startIndex: 1, type: 'tag.html' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'attribute.name.html' }, - { startIndex: 12, type: 'delimiter.html' }, - { startIndex: 13, type: 'attribute.value.html' }, - { startIndex: 30, type: 'delimiter.html' }, - // { startIndex:31, type: 'delimiter.html' }, - { startIndex: 33, type: 'tag.html' }, - { startIndex: 39, type: 'delimiter.html' } - ] - }], + // Embedded Content #9 + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'attribute.name.html' }, + { startIndex: 12, type: 'delimiter.html' }, + { startIndex: 13, type: 'attribute.value.html' }, + { startIndex: 30, type: '' }, + { startIndex: 31, type: 'attribute.name.html' }, + { startIndex: 34, type: 'delimiter.html' }, + { startIndex: 35, type: 'attribute.value.html' }, + { startIndex: 44, type: 'delimiter.html' }, + // { startIndex:45, type: 'delimiter.html' }, + { startIndex: 47, type: 'tag.html' }, + { startIndex: 53, type: 'delimiter.html' } + ] + } + ], - // Embedded Content #8 - [{ - line: '', - tokens: [ - { startIndex: 0, type: 'delimiter.html' }, - { startIndex: 1, type: 'tag.html' }, - { startIndex: 7, type: 'delimiter.html' }, - { startIndex: 8, type: 'keyword.js' }, - { startIndex: 11, type: '' }, - { startIndex: 12, type: 'identifier.js' }, - { startIndex: 13, type: 'delimiter.js' }, - { startIndex: 14, type: '' }, - { startIndex: 15, type: 'number.js' }, - { startIndex: 17, type: 'delimiter.js' }, - { startIndex: 18, type: 'delimiter.html' }, - { startIndex: 20, type: 'tag.html' }, - { startIndex: 26, type: 'delimiter.html' } - ] - }], + // Tag with Attribute + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, + { startIndex: 4, type: '' }, + { startIndex: 5, type: 'attribute.name.html' }, + { startIndex: 8, type: 'delimiter.html' }, + { startIndex: 9, type: 'attribute.value.html' }, + { startIndex: 14, type: 'delimiter.html' } + ] + } + ], - // Embedded Content #9 - [{ - line: '', - tokens: [ - { startIndex: 0, type: 'delimiter.html' }, - { startIndex: 1, type: 'tag.html' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'attribute.name.html' }, - { startIndex: 12, type: 'delimiter.html' }, - { startIndex: 13, type: 'attribute.value.html' }, - { startIndex: 30, type: '' }, - { startIndex: 31, type: 'attribute.name.html' }, - { startIndex: 34, type: 'delimiter.html' }, - { startIndex: 35, type: 'attribute.value.html' }, - { startIndex: 44, type: 'delimiter.html' }, - // { startIndex:45, type: 'delimiter.html' }, - { startIndex: 47, type: 'tag.html' }, - { startIndex: 53, type: 'delimiter.html' } - ] - }], + // Tag with Empty Attribute Value + [ + { + line: "", + tokens: [ + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, + { startIndex: 4, type: '' }, + { startIndex: 5, type: 'attribute.name.html' }, + { startIndex: 8, type: 'delimiter.html' }, + { startIndex: 9, type: 'attribute.value.html' }, + { startIndex: 14, type: 'delimiter.html' } + ] + } + ], - // Tag with Attribute - [{ - line: '', - tokens: [ - { startIndex: 0, type: 'delimiter.html' }, - { startIndex: 1, type: 'tag.html' }, - { startIndex: 4, type: '' }, - { startIndex: 5, type: 'attribute.name.html' }, - { startIndex: 8, type: 'delimiter.html' }, - { startIndex: 9, type: 'attribute.value.html' }, - { startIndex: 14, type: 'delimiter.html' } - ] - }], + // Tag with empty attributes + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, + { startIndex: 4, type: '' }, + { startIndex: 5, type: 'attribute.name.html' }, + { startIndex: 8, type: 'delimiter.html' }, + { startIndex: 9, type: 'attribute.value.html' }, + { startIndex: 11, type: 'delimiter.html' } + ] + } + ], - // Tag with Empty Attribute Value - [{ - line: '', - tokens: [ - { startIndex: 0, type: 'delimiter.html' }, - { startIndex: 1, type: 'tag.html' }, - { startIndex: 4, type: '' }, - { startIndex: 5, type: 'attribute.name.html' }, - { startIndex: 8, type: 'delimiter.html' }, - { startIndex: 9, type: 'attribute.value.html' }, - { startIndex: 14, type: 'delimiter.html' } - ] - }], + // Tag with Attributes + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, + { startIndex: 4, type: '' }, + { startIndex: 5, type: 'attribute.name.html' }, + { startIndex: 8, type: 'delimiter.html' }, + { startIndex: 9, type: 'attribute.value.html' }, + { startIndex: 14, type: '' }, + { startIndex: 15, type: 'attribute.name.html' }, + { startIndex: 18, type: 'delimiter.html' }, + { startIndex: 19, type: 'attribute.value.html' }, + { startIndex: 24, type: 'delimiter.html' } + ] + } + ], - // Tag with empty attributes - [{ - line: '', - tokens: [ - { startIndex: 0, type: 'delimiter.html' }, - { startIndex: 1, type: 'tag.html' }, - { startIndex: 4, type: '' }, - { startIndex: 5, type: 'attribute.name.html' }, - { startIndex: 8, type: 'delimiter.html' }, - { startIndex: 9, type: 'attribute.value.html' }, - { startIndex: 11, type: 'delimiter.html' } - ] - }], + // Tag with Attributes, no quotes + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, + { startIndex: 4, type: '' }, + { startIndex: 5, type: 'attribute.name.html' }, + { startIndex: 8, type: 'delimiter.html' }, + { startIndex: 9, type: 'attribute.name.html' }, // slightly incorrect + { startIndex: 12, type: '' }, + { startIndex: 13, type: 'attribute.name.html' }, + { startIndex: 16, type: 'delimiter.html' }, + { startIndex: 17, type: 'attribute.name.html' }, // slightly incorrect + { startIndex: 24, type: 'delimiter.html' } + ] + } + ], - // Tag with Attributes - [{ - line: '', - tokens: [ - { startIndex: 0, type: 'delimiter.html' }, - { startIndex: 1, type: 'tag.html' }, - { startIndex: 4, type: '' }, - { startIndex: 5, type: 'attribute.name.html' }, - { startIndex: 8, type: 'delimiter.html' }, - { startIndex: 9, type: 'attribute.value.html' }, - { startIndex: 14, type: '' }, - { startIndex: 15, type: 'attribute.name.html' }, - { startIndex: 18, type: 'delimiter.html' }, - { startIndex: 19, type: 'attribute.value.html' }, - { startIndex: 24, type: 'delimiter.html' } - ] - }], + // Tag with Attribute And Whitespace + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, + { startIndex: 4, type: '' }, + { startIndex: 5, type: 'attribute.name.html' }, + { startIndex: 8, type: 'delimiter.html' }, + { startIndex: 9, type: '' }, + { startIndex: 11, type: 'attribute.value.html' }, + { startIndex: 16, type: 'delimiter.html' } + ] + } + ], - // Tag with Attributes, no quotes - [{ - line: '', - tokens: [ - { startIndex: 0, type: 'delimiter.html' }, - { startIndex: 1, type: 'tag.html' }, - { startIndex: 4, type: '' }, - { startIndex: 5, type: 'attribute.name.html' }, - { startIndex: 8, type: 'delimiter.html' }, - { startIndex: 9, type: 'attribute.name.html' }, // slightly incorrect - { startIndex: 12, type: '' }, - { startIndex: 13, type: 'attribute.name.html' }, - { startIndex: 16, type: 'delimiter.html' }, - { startIndex: 17, type: 'attribute.name.html' }, // slightly incorrect - { startIndex: 24, type: 'delimiter.html' } - ] - }], + // Tag with Attribute And Whitespace #2 + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, + { startIndex: 4, type: '' }, + { startIndex: 5, type: 'attribute.name.html' }, + { startIndex: 8, type: '' }, + { startIndex: 9, type: 'delimiter.html' }, + { startIndex: 10, type: '' }, + { startIndex: 11, type: 'attribute.value.html' }, + { startIndex: 16, type: 'delimiter.html' } + ] + } + ], - // Tag with Attribute And Whitespace - [{ - line: '', - tokens: [ - { startIndex: 0, type: 'delimiter.html' }, - { startIndex: 1, type: 'tag.html' }, - { startIndex: 4, type: '' }, - { startIndex: 5, type: 'attribute.name.html' }, - { startIndex: 8, type: 'delimiter.html' }, - { startIndex: 9, type: '' }, - { startIndex: 11, type: 'attribute.value.html' }, - { startIndex: 16, type: 'delimiter.html' } - ] - }], + // Tag with Name-Only-Attribute #1 + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, + { startIndex: 4, type: '' }, + { startIndex: 5, type: 'attribute.name.html' }, + { startIndex: 8, type: 'delimiter.html' } + ] + } + ], - // Tag with Attribute And Whitespace #2 - [{ - line: '', - tokens: [ - { startIndex: 0, type: 'delimiter.html' }, - { startIndex: 1, type: 'tag.html' }, - { startIndex: 4, type: '' }, - { startIndex: 5, type: 'attribute.name.html' }, - { startIndex: 8, type: '' }, - { startIndex: 9, type: 'delimiter.html' }, - { startIndex: 10, type: '' }, - { startIndex: 11, type: 'attribute.value.html' }, - { startIndex: 16, type: 'delimiter.html' } - ] - }], + // Tag with Name-Only-Attribute #2 + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, + { startIndex: 4, type: '' }, + { startIndex: 5, type: 'attribute.name.html' }, + { startIndex: 8, type: '' }, + { startIndex: 9, type: 'attribute.name.html' }, + { startIndex: 12, type: 'delimiter.html' } + ] + } + ], - // Tag with Name-Only-Attribute #1 - [{ - line: '', - tokens: [ - { startIndex: 0, type: 'delimiter.html' }, - { startIndex: 1, type: 'tag.html' }, - { startIndex: 4, type: '' }, - { startIndex: 5, type: 'attribute.name.html' }, - { startIndex: 8, type: 'delimiter.html' } - ] - }], + // Tag with Interesting Attribute Name + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, + { startIndex: 4, type: '' }, + { startIndex: 5, type: 'attribute.name.html' }, + { startIndex: 8, type: '' }, + { startIndex: 11, type: 'delimiter.html' }, + { startIndex: 12, type: 'attribute.value.html' }, + { startIndex: 17, type: 'delimiter.html' } + ] + } + ], - // Tag with Name-Only-Attribute #2 - [{ - line: '', - tokens: [ - { startIndex: 0, type: 'delimiter.html' }, - { startIndex: 1, type: 'tag.html' }, - { startIndex: 4, type: '' }, - { startIndex: 5, type: 'attribute.name.html' }, - { startIndex: 8, type: '' }, - { startIndex: 9, type: 'attribute.name.html' }, - { startIndex: 12, type: 'delimiter.html' } - ] - }], + // Tag with Angular Attribute Name + [ + { + line: + '', + tokens: [ + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, + { startIndex: 4, type: '' }, + { startIndex: 6, type: 'attribute.name.html' }, + { startIndex: 13, type: '' }, + { startIndex: 15, type: 'attribute.name.html' }, + { startIndex: 20, type: '' }, + { startIndex: 21, type: 'delimiter.html' }, + { startIndex: 22, type: 'attribute.value.html' }, + { startIndex: 27, type: '' }, + { startIndex: 29, type: 'attribute.name.html' }, + { startIndex: 34, type: '' }, + { startIndex: 35, type: 'delimiter.html' }, + { startIndex: 36, type: 'attribute.value.html' }, + { startIndex: 50, type: '' }, + { startIndex: 52, type: 'attribute.name.html' }, + { startIndex: 56, type: 'delimiter.html' }, + { startIndex: 57, type: 'attribute.value.html' }, + { startIndex: 72, type: 'delimiter.html' } + ] + } + ], - // Tag with Interesting Attribute Name - [{ - line: '', - tokens: [ - { startIndex: 0, type: 'delimiter.html' }, - { startIndex: 1, type: 'tag.html' }, - { startIndex: 4, type: '' }, - { startIndex: 5, type: 'attribute.name.html' }, - { startIndex: 8, type: '' }, - { startIndex: 11, type: 'delimiter.html' }, - { startIndex: 12, type: 'attribute.value.html' }, - { startIndex: 17, type: 'delimiter.html' } - ] - }], + // Tag with Invalid Attribute Value + [ + { + line: '', - tokens: [ - { startIndex: 0, type: 'delimiter.html' }, - { startIndex: 1, type: 'tag.html' }, - { startIndex: 4, type: '' }, - { startIndex: 6, type: 'attribute.name.html' }, - { startIndex: 13, type: '' }, - { startIndex: 15, type: 'attribute.name.html' }, - { startIndex: 20, type: '' }, - { startIndex: 21, type: 'delimiter.html' }, - { startIndex: 22, type: 'attribute.value.html' }, - { startIndex: 27, type: '' }, - { startIndex: 29, type: 'attribute.name.html' }, - { startIndex: 34, type: '' }, - { startIndex: 35, type: 'delimiter.html' }, - { startIndex: 36, type: 'attribute.value.html' }, - { startIndex: 50, type: '' }, - { startIndex: 52, type: 'attribute.name.html' }, - { startIndex: 56, type: 'delimiter.html' }, - { startIndex: 57, type: 'attribute.value.html' }, - { startIndex: 72, type: 'delimiter.html' } - ] - }], + // Simple Comment 1 + [ + { + line: '', + tokens: [ + { startIndex: 0, type: 'comment.html' }, + { startIndex: 4, type: 'comment.content.html' }, + { startIndex: 5, type: 'comment.html' } + ] + } + ], - // Tag with Invalid Attribute Value - [{ - line: '', + tokens: [ + { startIndex: 0, type: 'metatag.content.html' }, + { startIndex: 11, type: 'metatag.html' } + ] + } + ], - // Simple Doctype #2 - [{ - line: '', - tokens: [ - { startIndex: 0, type: 'metatag.html' }, - { startIndex: 9, type: 'metatag.content.html' }, - { startIndex: 11, type: 'metatag.html' } + // PR #14 + [ + { + line: 'asd', + tokens: [ + { startIndex: 0, type: 'delimiter.html' }, + { startIndex: 1, type: 'tag.html' }, + { startIndex: 9, type: 'delimiter.html' }, + { startIndex: 10, type: '' }, + { startIndex: 13, type: 'delimiter.html' }, + { startIndex: 15, type: 'tag.html' }, + { startIndex: 23, type: 'delimiter.html' } + ] + } ] - }], - - // Simple Doctype #4 - [{ - line: '', - tokens: [ - { startIndex: 0, type: 'metatag.content.html' }, - { startIndex: 11, type: 'metatag.html' } - ] - }], - - // PR #14 - [{ - line: 'asd', - tokens: [ - { startIndex: 0, type: 'delimiter.html' }, - { startIndex: 1, type: 'tag.html' }, - { startIndex: 9, type: 'delimiter.html' }, - { startIndex: 10, type: '' }, - { startIndex: 13, type: 'delimiter.html' }, - { startIndex: 15, type: 'tag.html' }, - { startIndex: 23, type: 'delimiter.html' } - ] - }] -]); + ] +); /** * Twig Tests */ -testTokenization(['twig'], [ - /** - * Comments - */ - [{ - line: '{# Hello World! #}', - tokens: [ - { startIndex: 0, type: 'comment.twig' }, +testTokenization( + ['twig'], + [ + /** + * Comments + */ + [ + { + line: '{# Hello World! #}', + tokens: [{ startIndex: 0, type: 'comment.twig' }] + } ], - }], - [{ - line: '{#Hello World!#}', - tokens: [ - { startIndex: 0, type: 'comment.twig' }, + [ + { + line: '{#Hello World!#}', + tokens: [{ startIndex: 0, type: 'comment.twig' }] + } ], - }], - /** - * Variables Tags - */ - // Whitespace - [{ - line: '{{}}', - tokens: [ - { startIndex: 0, type: 'delimiter.twig' }, + /** + * Variables Tags + */ + // Whitespace + [ + { + line: '{{}}', + tokens: [{ startIndex: 0, type: 'delimiter.twig' }] + } ], - }], - [{ - line: '{{ }}', - tokens: [ - { startIndex: 0, type: 'delimiter.twig' }, - { startIndex: 2, type: '' }, - { startIndex: 3, type: 'delimiter.twig' }, + [ + { + line: '{{ }}', + tokens: [ + { startIndex: 0, type: 'delimiter.twig' }, + { startIndex: 2, type: '' }, + { startIndex: 3, type: 'delimiter.twig' } + ] + } ], - }], - // Numbers - [{ - line: '{{1}}', - tokens: [ - { startIndex: 0, type: 'delimiter.twig' }, - { startIndex: 2, type: 'number.twig' }, - { startIndex: 3, type: 'delimiter.twig' }, + // Numbers + [ + { + line: '{{1}}', + tokens: [ + { startIndex: 0, type: 'delimiter.twig' }, + { startIndex: 2, type: 'number.twig' }, + { startIndex: 3, type: 'delimiter.twig' } + ] + } ], - }], - [{ - line: '{{ 1 }}', - tokens: [ - { startIndex: 0, type: 'delimiter.twig' }, - { startIndex: 2, type: '' }, - { startIndex: 3, type: 'number.twig' }, - { startIndex: 4, type: '' }, - { startIndex: 5, type: 'delimiter.twig' }, + [ + { + line: '{{ 1 }}', + tokens: [ + { startIndex: 0, type: 'delimiter.twig' }, + { startIndex: 2, type: '' }, + { startIndex: 3, type: 'number.twig' }, + { startIndex: 4, type: '' }, + { startIndex: 5, type: 'delimiter.twig' } + ] + } ], - }], - [{ - line: '{{ 1 }}', - tokens: [ - { startIndex: 0, type: 'delimiter.twig' }, - { startIndex: 2, type: '' }, - { startIndex: 3, type: 'number.twig' }, - { startIndex: 4, type: '' }, - { startIndex: 5, type: 'delimiter.twig' }, + [ + { + line: '{{ 1 }}', + tokens: [ + { startIndex: 0, type: 'delimiter.twig' }, + { startIndex: 2, type: '' }, + { startIndex: 3, type: 'number.twig' }, + { startIndex: 4, type: '' }, + { startIndex: 5, type: 'delimiter.twig' } + ] + } ], - }], - [{ - line: '{{ 1.1 }}', - tokens: [ - { startIndex: 0, type: 'delimiter.twig' }, - { startIndex: 2, type: '' }, - { startIndex: 3, type: 'number.twig' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'delimiter.twig' }, + [ + { + line: '{{ 1.1 }}', + tokens: [ + { startIndex: 0, type: 'delimiter.twig' }, + { startIndex: 2, type: '' }, + { startIndex: 3, type: 'number.twig' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'delimiter.twig' } + ] + } ], - }], - // Strings - [{ - line: "{{ 'hi' }}", - tokens: [ - { startIndex: 0, type: 'delimiter.twig' }, - { startIndex: 2, type: '' }, - { startIndex: 3, type: 'string.twig' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'delimiter.twig' }, + // Strings + [ + { + line: "{{ 'hi' }}", + tokens: [ + { startIndex: 0, type: 'delimiter.twig' }, + { startIndex: 2, type: '' }, + { startIndex: 3, type: 'string.twig' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'delimiter.twig' } + ] + } ], - }], - [{ - line: '{{ "hi" }}', - tokens: [ - { startIndex: 0, type: 'delimiter.twig' }, - { startIndex: 2, type: '' }, - { startIndex: 3, type: 'string.twig' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'delimiter.twig' }, + [ + { + line: '{{ "hi" }}', + tokens: [ + { startIndex: 0, type: 'delimiter.twig' }, + { startIndex: 2, type: '' }, + { startIndex: 3, type: 'string.twig' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'delimiter.twig' } + ] + } ], - }], - [{ - line: '{{ "hi #{1}" }}', - tokens: [ - { startIndex: 0, type: 'delimiter.twig' }, - { startIndex: 2, type: '' }, - { startIndex: 3, type: 'string.twig' }, - { startIndex: 9, type: 'number.twig' }, - { startIndex: 10, type: 'string.twig' }, - { startIndex: 12, type: '' }, - { startIndex: 13, type: 'delimiter.twig' }, + [ + { + line: '{{ "hi #{1}" }}', + tokens: [ + { startIndex: 0, type: 'delimiter.twig' }, + { startIndex: 2, type: '' }, + { startIndex: 3, type: 'string.twig' }, + { startIndex: 9, type: 'number.twig' }, + { startIndex: 10, type: 'string.twig' }, + { startIndex: 12, type: '' }, + { startIndex: 13, type: 'delimiter.twig' } + ] + } ], - }], - // Variables and functions - [{ - line: '{{ foo }}', - tokens: [ - { startIndex: 0, type: 'delimiter.twig' }, - { startIndex: 2, type: '' }, - { startIndex: 3, type: 'variable.twig' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'delimiter.twig' }, + // Variables and functions + [ + { + line: '{{ foo }}', + tokens: [ + { startIndex: 0, type: 'delimiter.twig' }, + { startIndex: 2, type: '' }, + { startIndex: 3, type: 'variable.twig' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'delimiter.twig' } + ] + } ], - }], - [{ - line: '{{ foo(42) }}', - tokens: [ - { startIndex: 0, type: 'delimiter.twig' }, - { startIndex: 2, type: '' }, - { startIndex: 3, type: 'variable.twig' }, - { startIndex: 6, type: 'delimiter.twig' }, - { startIndex: 7, type: 'number.twig' }, - { startIndex: 9, type: 'delimiter.twig' }, - { startIndex: 10, type: '' }, - { startIndex: 11, type: 'delimiter.twig' }, + [ + { + line: '{{ foo(42) }}', + tokens: [ + { startIndex: 0, type: 'delimiter.twig' }, + { startIndex: 2, type: '' }, + { startIndex: 3, type: 'variable.twig' }, + { startIndex: 6, type: 'delimiter.twig' }, + { startIndex: 7, type: 'number.twig' }, + { startIndex: 9, type: 'delimiter.twig' }, + { startIndex: 10, type: '' }, + { startIndex: 11, type: 'delimiter.twig' } + ] + } ], - }], - // Operators - [{ - line: '{{ 1 + 2 - 3 / 4 // 5 % 6 * 7 ** 8 }}', - tokens: [ - { startIndex: 0, type: 'delimiter.twig' }, - { startIndex: 2, type: '' }, - { startIndex: 3, type: 'number.twig' }, - { startIndex: 4, type: '' }, - { startIndex: 5, type: 'operators.twig' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'number.twig' }, - { startIndex: 8, type: '' }, - { startIndex: 9, type: 'operators.twig' }, - { startIndex: 10, type: '' }, - { startIndex: 11, type: 'number.twig' }, - { startIndex: 12, type: '' }, - { startIndex: 13, type: 'operators.twig' }, - { startIndex: 14, type: '' }, - { startIndex: 15, type: 'number.twig' }, - { startIndex: 16, type: '' }, - { startIndex: 17, type: 'operators.twig' }, - { startIndex: 19, type: '' }, - { startIndex: 20, type: 'number.twig' }, - { startIndex: 21, type: '' }, - { startIndex: 22, type: 'operators.twig' }, - { startIndex: 23, type: '' }, - { startIndex: 24, type: 'number.twig' }, - { startIndex: 25, type: '' }, - { startIndex: 26, type: 'operators.twig' }, - { startIndex: 27, type: '' }, - { startIndex: 28, type: 'number.twig' }, - { startIndex: 29, type: '' }, - { startIndex: 30, type: 'operators.twig' }, - { startIndex: 32, type: '' }, - { startIndex: 33, type: 'number.twig' }, - { startIndex: 34, type: '' }, - { startIndex: 35, type: 'delimiter.twig' }, + // Operators + [ + { + line: '{{ 1 + 2 - 3 / 4 // 5 % 6 * 7 ** 8 }}', + tokens: [ + { startIndex: 0, type: 'delimiter.twig' }, + { startIndex: 2, type: '' }, + { startIndex: 3, type: 'number.twig' }, + { startIndex: 4, type: '' }, + { startIndex: 5, type: 'operators.twig' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'number.twig' }, + { startIndex: 8, type: '' }, + { startIndex: 9, type: 'operators.twig' }, + { startIndex: 10, type: '' }, + { startIndex: 11, type: 'number.twig' }, + { startIndex: 12, type: '' }, + { startIndex: 13, type: 'operators.twig' }, + { startIndex: 14, type: '' }, + { startIndex: 15, type: 'number.twig' }, + { startIndex: 16, type: '' }, + { startIndex: 17, type: 'operators.twig' }, + { startIndex: 19, type: '' }, + { startIndex: 20, type: 'number.twig' }, + { startIndex: 21, type: '' }, + { startIndex: 22, type: 'operators.twig' }, + { startIndex: 23, type: '' }, + { startIndex: 24, type: 'number.twig' }, + { startIndex: 25, type: '' }, + { startIndex: 26, type: 'operators.twig' }, + { startIndex: 27, type: '' }, + { startIndex: 28, type: 'number.twig' }, + { startIndex: 29, type: '' }, + { startIndex: 30, type: 'operators.twig' }, + { startIndex: 32, type: '' }, + { startIndex: 33, type: 'number.twig' }, + { startIndex: 34, type: '' }, + { startIndex: 35, type: 'delimiter.twig' } + ] + } ], - }], - [{ - line: '{{ true and false or true and not false }}', - tokens: [ - { startIndex: 0, type: 'delimiter.twig' }, - { startIndex: 2, type: '' }, - { startIndex: 3, type: 'keyword.twig' }, - { startIndex: 7, type: '' }, - { startIndex: 8, type: 'operators.twig' }, - { startIndex: 11, type: '' }, - { startIndex: 12, type: 'keyword.twig' }, - { startIndex: 17, type: '' }, - { startIndex: 18, type: 'operators.twig' }, - { startIndex: 20, type: '' }, - { startIndex: 21, type: 'keyword.twig' }, - { startIndex: 25, type: '' }, - { startIndex: 26, type: 'operators.twig' }, - { startIndex: 29, type: '' }, - { startIndex: 30, type: 'operators.twig' }, - { startIndex: 33, type: '' }, - { startIndex: 34, type: 'keyword.twig' }, - { startIndex: 39, type: '' }, - { startIndex: 40, type: 'delimiter.twig' }, + [ + { + line: '{{ true and false or true and not false }}', + tokens: [ + { startIndex: 0, type: 'delimiter.twig' }, + { startIndex: 2, type: '' }, + { startIndex: 3, type: 'keyword.twig' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'operators.twig' }, + { startIndex: 11, type: '' }, + { startIndex: 12, type: 'keyword.twig' }, + { startIndex: 17, type: '' }, + { startIndex: 18, type: 'operators.twig' }, + { startIndex: 20, type: '' }, + { startIndex: 21, type: 'keyword.twig' }, + { startIndex: 25, type: '' }, + { startIndex: 26, type: 'operators.twig' }, + { startIndex: 29, type: '' }, + { startIndex: 30, type: 'operators.twig' }, + { startIndex: 33, type: '' }, + { startIndex: 34, type: 'keyword.twig' }, + { startIndex: 39, type: '' }, + { startIndex: 40, type: 'delimiter.twig' } + ] + } ], - }], - /** - * Block Tags - */ - [{ - line: '{%%}', - tokens: [ - { startIndex: 0, type: 'delimiter.twig' }, + /** + * Block Tags + */ + [ + { + line: '{%%}', + tokens: [{ startIndex: 0, type: 'delimiter.twig' }] + } ], - }], - [{ - line: '{% %}', - tokens: [ - { startIndex: 0, type: 'delimiter.twig' }, - { startIndex: 2, type: '' }, - { startIndex: 3, type: 'delimiter.twig' }, + [ + { + line: '{% %}', + tokens: [ + { startIndex: 0, type: 'delimiter.twig' }, + { startIndex: 2, type: '' }, + { startIndex: 3, type: 'delimiter.twig' } + ] + } ], - }], - [{ - line: '{% for item in navigation %}', - tokens: [ - { startIndex: 0, type: 'delimiter.twig' }, - { startIndex: 2, type: '' }, - { startIndex: 3, type: 'keyword.twig' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'variable.twig' }, - { startIndex: 11, type: '' }, - { startIndex: 12, type: 'operators.twig' }, - { startIndex: 14, type: '' }, - { startIndex: 15, type: 'variable.twig' }, - { startIndex: 25, type: '' }, - { startIndex: 26, type: 'delimiter.twig' }, + [ + { + line: '{% for item in navigation %}', + tokens: [ + { startIndex: 0, type: 'delimiter.twig' }, + { startIndex: 2, type: '' }, + { startIndex: 3, type: 'keyword.twig' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'variable.twig' }, + { startIndex: 11, type: '' }, + { startIndex: 12, type: 'operators.twig' }, + { startIndex: 14, type: '' }, + { startIndex: 15, type: 'variable.twig' }, + { startIndex: 25, type: '' }, + { startIndex: 26, type: 'delimiter.twig' } + ] + } ], - }], - [{ - line: '{% verbatim %}', - tokens: [ - { startIndex: 0, type: 'delimiter.twig' }, - { startIndex: 2, type: '' }, - { startIndex: 3, type: 'keyword.twig' }, - { startIndex: 11, type: '' }, - { startIndex: 12, type: 'delimiter.twig' }, + [ + { + line: '{% verbatim %}', + tokens: [ + { startIndex: 0, type: 'delimiter.twig' }, + { startIndex: 2, type: '' }, + { startIndex: 3, type: 'keyword.twig' }, + { startIndex: 11, type: '' }, + { startIndex: 12, type: 'delimiter.twig' } + ] + } ], - }], - [{ - line: '{% verbatim %}raw data{% endverbatim %}', - tokens: [ - { startIndex: 0, type: 'delimiter.twig' }, - { startIndex: 2, type: '' }, - { startIndex: 3, type: 'keyword.twig' }, - { startIndex: 11, type: '' }, - { startIndex: 12, type: 'delimiter.twig' }, - { startIndex: 14, type: 'string.twig' }, - { startIndex: 22, type: 'delimiter.twig' }, - { startIndex: 24, type: '' }, - { startIndex: 25, type: 'keyword.twig' }, - { startIndex: 36, type: '' }, - { startIndex: 37, type: 'delimiter.twig' }, - ], - }], -]); + [ + { + line: '{% verbatim %}raw data{% endverbatim %}', + tokens: [ + { startIndex: 0, type: 'delimiter.twig' }, + { startIndex: 2, type: '' }, + { startIndex: 3, type: 'keyword.twig' }, + { startIndex: 11, type: '' }, + { startIndex: 12, type: 'delimiter.twig' }, + { startIndex: 14, type: 'string.twig' }, + { startIndex: 22, type: 'delimiter.twig' }, + { startIndex: 24, type: '' }, + { startIndex: 25, type: 'keyword.twig' }, + { startIndex: 36, type: '' }, + { startIndex: 37, type: 'delimiter.twig' } + ] + } + ] + ] +); diff --git a/src/twig/twig.ts b/src/twig/twig.ts index de4f319b..8c1f002b 100644 --- a/src/twig/twig.ts +++ b/src/twig/twig.ts @@ -12,7 +12,7 @@ export const conf: IRichLanguageConfiguration = { wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\@\$\^\&\*\(\)\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\s]+)/g, comments: { - blockComment: ['{#', '#}'], + blockComment: ['{#', '#}'] }, brackets: [ @@ -24,7 +24,7 @@ export const conf: IRichLanguageConfiguration = { // HTML [''], - ['<', '>'], + ['<', '>'] ], autoClosingPairs: [ @@ -34,17 +34,17 @@ export const conf: IRichLanguageConfiguration = { { open: '[', close: ']' }, { open: '(', close: ')' }, { open: '"', close: '"' }, - { open: '\'', close: '\'' }, + { open: "'", close: "'" } ], surroundingPairs: [ { open: '"', close: '"' }, - { open: '\'', close: '\'' }, + { open: "'", close: "'" }, // HTML - { open: '<', close: '>' }, - ], -} + { open: '<', close: '>' } + ] +}; export const language = { defaultToken: '', @@ -53,14 +53,39 @@ export const language = { keywords: [ // (opening) tags - 'apply', 'autoescape', 'block', 'deprecated', 'do', 'embed', 'extends', - 'flush', 'for', 'from', 'if', 'import', 'include', 'macro', 'sandbox', - 'set', 'use', 'verbatim', 'with', + 'apply', + 'autoescape', + 'block', + 'deprecated', + 'do', + 'embed', + 'extends', + 'flush', + 'for', + 'from', + 'if', + 'import', + 'include', + 'macro', + 'sandbox', + 'set', + 'use', + 'verbatim', + 'with', // closing tags - 'endapply', 'endautoescape', 'endblock', 'endembed', 'endfor', 'endif', - 'endmacro', 'endsandbox', 'endset', 'endwith', + 'endapply', + 'endautoescape', + 'endblock', + 'endembed', + 'endfor', + 'endif', + 'endmacro', + 'endsandbox', + 'endset', + 'endwith', // literals - 'true', 'false', + 'true', + 'false' ], tokenizer: { @@ -76,13 +101,28 @@ export const language = { // HTML [/)/, ['delimiter.html', 'tag.html', '', 'delimiter.html']], - [/(<)(script)/, ['delimiter.html', { token: 'tag.html', next: '@script' }]], - [/(<)(style)/, ['delimiter.html', { token: 'tag.html', next: '@style' }]], - [/(<)((?:[\w\-]+:)?[\w\-]+)/, ['delimiter.html', { token: 'tag.html', next: '@otherTag' }]], - [/(<\/)((?:[\w\-]+:)?[\w\-]+)/, ['delimiter.html', { token: 'tag.html', next: '@otherTag' }]], + [ + /(<)((?:[\w\-]+:)?[\w\-]+)(\s*)(\/>)/, + ['delimiter.html', 'tag.html', '', 'delimiter.html'] + ], + [ + /(<)(script)/, + ['delimiter.html', { token: 'tag.html', next: '@script' }] + ], + [ + /(<)(style)/, + ['delimiter.html', { token: 'tag.html', next: '@style' }] + ], + [ + /(<)((?:[\w\-]+:)?[\w\-]+)/, + ['delimiter.html', { token: 'tag.html', next: '@otherTag' }] + ], + [ + /(<\/)((?:[\w\-]+:)?[\w\-]+)/, + ['delimiter.html', { token: 'tag.html', next: '@otherTag' }] + ], [/{ */ commentState: [ [/#}/, 'comment.twig', '@pop'], - [/./, 'comment.twig'], + [/./, 'comment.twig'] ], /** @@ -103,24 +143,30 @@ export const language = { // verbatim // Unlike other blocks, verbatim ehas its own state // transition to ensure we mark its contents as strings. - [/(verbatim)(\s*)([-~]?%})/, [ - 'keyword.twig', - '', - { token: 'delimiter.twig', next: '@rawDataState' }, - ]], + [ + /(verbatim)(\s*)([-~]?%})/, + [ + 'keyword.twig', + '', + { token: 'delimiter.twig', next: '@rawDataState' } + ] + ], { include: 'expression' } ], rawDataState: [ // endverbatim - [/({%[-~]?)(\s*)(endverbatim)(\s*)([-~]?%})/, [ - 'delimiter.twig', - '', - 'keyword.twig', - '', - { token: 'delimiter.twig', next: '@popall' }, - ]], - [/./, 'string.twig'], + [ + /({%[-~]?)(\s*)(endverbatim)(\s*)([-~]?%})/, + [ + 'delimiter.twig', + '', + 'keyword.twig', + '', + { token: 'delimiter.twig', next: '@popall' } + ] + ], + [/./, 'string.twig'] ], /** @@ -128,7 +174,7 @@ export const language = { */ variableState: [ [/[-~]?}}/, 'delimiter.twig', '@pop'], - { include: 'expression' }, + { include: 'expression' } ], stringState: [ @@ -137,13 +183,13 @@ export const language = { // interpolation start [/#{\s*/, 'string.twig', '@interpolationState'], // string part - [/[^#"\\]*(?:(?:\\.|#(?!\{))[^#"\\]*)*/, 'string.twig'], + [/[^#"\\]*(?:(?:\\.|#(?!\{))[^#"\\]*)*/, 'string.twig'] ], interpolationState: [ // interpolation end [/}/, 'string.twig', '@pop'], - { include: 'expression' }, + { include: 'expression' } ], /** @@ -167,18 +213,24 @@ export const language = { // operators - misc [/\||~|:|\.{1,2}|\?{1,2}/, 'operators.twig'], // names - [/[^\W\d][\w]*/, { - cases: { - '@keywords': 'keyword.twig', - '@default': 'variable.twig' + [ + /[^\W\d][\w]*/, + { + cases: { + '@keywords': 'keyword.twig', + '@default': 'variable.twig' + } } - }], + ], // numbers [/\d+(\.\d+)?/, 'number.twig'], // punctuation [/\(|\)|\[|\]|{|}|,/, 'delimiter.twig'], // strings - [/"([^#"\\]*(?:\\.[^#"\\]*)*)"|\'([^\'\\]*(?:\\.[^\'\\]*)*)\'/, 'string.twig'], + [ + /"([^#"\\]*(?:\\.[^#"\\]*)*)"|\'([^\'\\]*(?:\\.[^\'\\]*)*)\'/, + 'string.twig' + ], // opening double quoted string [/"/, 'string.twig', '@stringState'], @@ -188,7 +240,7 @@ export const language = { // arrow functions [/=>/, 'operators.twig'], // assignment - [/=/, 'operators.twig'], + [/=/, 'operators.twig'] ], /** @@ -196,7 +248,7 @@ export const language = { */ doctype: [ [/[^>]+/, 'metatag.content.html'], - [/>/, 'metatag.html', '@pop'], + [/>/, 'metatag.html', '@pop'] ], comment: [ @@ -211,7 +263,7 @@ export const language = { [/'([^']*)'/, 'attribute.value.html'], [/[\w\-]+/, 'attribute.name.html'], [/=/, 'delimiter.html'], - [/[ \t\r\n]+/], // whitespace + [/[ \t\r\n]+/] // whitespace ], // -- BEGIN