groove-dev 0.15.0 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/FILE-EDITOR-PLAN.md +253 -0
- package/node_modules/@codemirror/autocomplete/.github/workflows/dispatch.yml +16 -0
- package/node_modules/@codemirror/autocomplete/CHANGELOG.md +639 -0
- package/node_modules/@codemirror/autocomplete/LICENSE +21 -0
- package/node_modules/@codemirror/autocomplete/README.md +43 -0
- package/node_modules/@codemirror/autocomplete/dist/index.cjs +2151 -0
- package/node_modules/@codemirror/autocomplete/dist/index.d.cts +648 -0
- package/node_modules/@codemirror/autocomplete/dist/index.d.ts +648 -0
- package/node_modules/@codemirror/autocomplete/dist/index.js +2120 -0
- package/node_modules/@codemirror/autocomplete/package.json +41 -0
- package/node_modules/@codemirror/commands/.github/workflows/dispatch.yml +16 -0
- package/node_modules/@codemirror/commands/CHANGELOG.md +386 -0
- package/node_modules/@codemirror/commands/LICENSE +21 -0
- package/node_modules/@codemirror/commands/README.md +35 -0
- package/node_modules/@codemirror/commands/dist/index.cjs +1909 -0
- package/node_modules/@codemirror/commands/dist/index.d.cts +650 -0
- package/node_modules/@codemirror/commands/dist/index.d.ts +650 -0
- package/node_modules/@codemirror/commands/dist/index.js +1795 -0
- package/node_modules/@codemirror/commands/package.json +42 -0
- package/node_modules/@codemirror/lang-css/.github/workflows/dispatch.yml +16 -0
- package/node_modules/@codemirror/lang-css/CHANGELOG.md +106 -0
- package/node_modules/@codemirror/lang-css/LICENSE +21 -0
- package/node_modules/@codemirror/lang-css/README.md +50 -0
- package/node_modules/@codemirror/lang-css/dist/index.cjs +269 -0
- package/node_modules/@codemirror/lang-css/dist/index.d.cts +28 -0
- package/node_modules/@codemirror/lang-css/dist/index.d.ts +28 -0
- package/node_modules/@codemirror/lang-css/dist/index.js +264 -0
- package/node_modules/@codemirror/lang-css/package.json +42 -0
- package/node_modules/@codemirror/lang-html/.github/workflows/dispatch.yml +16 -0
- package/node_modules/@codemirror/lang-html/CHANGELOG.md +210 -0
- package/node_modules/@codemirror/lang-html/LICENSE +21 -0
- package/node_modules/@codemirror/lang-html/README.md +147 -0
- package/node_modules/@codemirror/lang-html/dist/index.cjs +667 -0
- package/node_modules/@codemirror/lang-html/dist/index.d.cts +115 -0
- package/node_modules/@codemirror/lang-html/dist/index.d.ts +115 -0
- package/node_modules/@codemirror/lang-html/dist/index.js +661 -0
- package/node_modules/@codemirror/lang-html/package.json +46 -0
- package/node_modules/@codemirror/lang-javascript/.github/workflows/dispatch.yml +16 -0
- package/node_modules/@codemirror/lang-javascript/CHANGELOG.md +206 -0
- package/node_modules/@codemirror/lang-javascript/LICENSE +21 -0
- package/node_modules/@codemirror/lang-javascript/README.md +125 -0
- package/node_modules/@codemirror/lang-javascript/dist/index.cjs +526 -0
- package/node_modules/@codemirror/lang-javascript/dist/index.d.cts +93 -0
- package/node_modules/@codemirror/lang-javascript/dist/index.d.ts +93 -0
- package/node_modules/@codemirror/lang-javascript/dist/index.js +513 -0
- package/node_modules/@codemirror/lang-javascript/package.json +45 -0
- package/node_modules/@codemirror/lang-json/.github/workflows/dispatch.yml +16 -0
- package/node_modules/@codemirror/lang-json/CHANGELOG.md +59 -0
- package/node_modules/@codemirror/lang-json/LICENSE +21 -0
- package/node_modules/@codemirror/lang-json/README.md +56 -0
- package/node_modules/@codemirror/lang-json/dist/index.cjs +68 -0
- package/node_modules/@codemirror/lang-json/dist/index.d.cts +22 -0
- package/node_modules/@codemirror/lang-json/dist/index.d.ts +22 -0
- package/node_modules/@codemirror/lang-json/dist/index.js +64 -0
- package/node_modules/@codemirror/lang-json/package.json +39 -0
- package/node_modules/@codemirror/lang-markdown/.github/workflows/dispatch.yml +16 -0
- package/node_modules/@codemirror/lang-markdown/CHANGELOG.md +246 -0
- package/node_modules/@codemirror/lang-markdown/LICENSE +21 -0
- package/node_modules/@codemirror/lang-markdown/README.md +162 -0
- package/node_modules/@codemirror/lang-markdown/dist/index.cjs +501 -0
- package/node_modules/@codemirror/lang-markdown/dist/index.d.cts +124 -0
- package/node_modules/@codemirror/lang-markdown/dist/index.d.ts +124 -0
- package/node_modules/@codemirror/lang-markdown/dist/index.js +492 -0
- package/node_modules/@codemirror/lang-markdown/package.json +44 -0
- package/node_modules/@codemirror/lang-python/.github/workflows/dispatch.yml +16 -0
- package/node_modules/@codemirror/lang-python/CHANGELOG.md +174 -0
- package/node_modules/@codemirror/lang-python/LICENSE +21 -0
- package/node_modules/@codemirror/lang-python/README.md +61 -0
- package/node_modules/@codemirror/lang-python/dist/index.cjs +313 -0
- package/node_modules/@codemirror/lang-python/dist/index.d.cts +26 -0
- package/node_modules/@codemirror/lang-python/dist/index.d.ts +26 -0
- package/node_modules/@codemirror/lang-python/dist/index.js +308 -0
- package/node_modules/@codemirror/lang-python/package.json +42 -0
- package/node_modules/@codemirror/language/.github/workflows/dispatch.yml +16 -0
- package/node_modules/@codemirror/language/CHANGELOG.md +412 -0
- package/node_modules/@codemirror/language/LICENSE +21 -0
- package/node_modules/@codemirror/language/README.md +66 -0
- package/node_modules/@codemirror/language/dist/index.cjs +2742 -0
- package/node_modules/@codemirror/language/dist/index.d.cts +1220 -0
- package/node_modules/@codemirror/language/dist/index.d.ts +1220 -0
- package/node_modules/@codemirror/language/dist/index.js +2687 -0
- package/node_modules/@codemirror/language/package.json +44 -0
- package/node_modules/@codemirror/lint/.github/workflows/dispatch.yml +16 -0
- package/node_modules/@codemirror/lint/CHANGELOG.md +318 -0
- package/node_modules/@codemirror/lint/LICENSE +21 -0
- package/node_modules/@codemirror/lint/README.md +18 -0
- package/node_modules/@codemirror/lint/dist/index.cjs +958 -0
- package/node_modules/@codemirror/lint/dist/index.d.cts +195 -0
- package/node_modules/@codemirror/lint/dist/index.d.ts +195 -0
- package/node_modules/@codemirror/lint/dist/index.js +945 -0
- package/node_modules/@codemirror/lint/package.json +40 -0
- package/node_modules/@codemirror/search/.github/workflows/dispatch.yml +16 -0
- package/node_modules/@codemirror/search/CHANGELOG.md +324 -0
- package/node_modules/@codemirror/search/LICENSE +21 -0
- package/node_modules/@codemirror/search/README.md +18 -0
- package/node_modules/@codemirror/search/dist/index.cjs +1237 -0
- package/node_modules/@codemirror/search/dist/index.d.cts +385 -0
- package/node_modules/@codemirror/search/dist/index.d.ts +385 -0
- package/node_modules/@codemirror/search/dist/index.js +1217 -0
- package/node_modules/@codemirror/search/package.json +40 -0
- package/node_modules/@codemirror/state/.github/workflows/dispatch.yml +16 -0
- package/node_modules/@codemirror/state/CHANGELOG.md +308 -0
- package/node_modules/@codemirror/state/LICENSE +21 -0
- package/node_modules/@codemirror/state/README.md +18 -0
- package/node_modules/@codemirror/state/dist/index.cjs +3922 -0
- package/node_modules/@codemirror/state/dist/index.d.cts +1713 -0
- package/node_modules/@codemirror/state/dist/index.d.ts +1713 -0
- package/node_modules/@codemirror/state/dist/index.js +3892 -0
- package/node_modules/@codemirror/state/package.json +38 -0
- package/node_modules/@codemirror/theme-one-dark/.github/workflows/dispatch.yml +16 -0
- package/node_modules/@codemirror/theme-one-dark/CHANGELOG.md +97 -0
- package/node_modules/@codemirror/theme-one-dark/LICENSE +21 -0
- package/node_modules/@codemirror/theme-one-dark/README.md +46 -0
- package/node_modules/@codemirror/theme-one-dark/dist/index.cjs +139 -0
- package/node_modules/@codemirror/theme-one-dark/dist/index.d.cts +39 -0
- package/node_modules/@codemirror/theme-one-dark/dist/index.d.ts +39 -0
- package/node_modules/@codemirror/theme-one-dark/dist/index.js +134 -0
- package/node_modules/@codemirror/theme-one-dark/package.json +41 -0
- package/node_modules/@codemirror/view/.github/workflows/dispatch.yml +16 -0
- package/node_modules/@codemirror/view/CHANGELOG.md +2284 -0
- package/node_modules/@codemirror/view/LICENSE +21 -0
- package/node_modules/@codemirror/view/README.md +37 -0
- package/node_modules/@codemirror/view/dist/index.cjs +11796 -0
- package/node_modules/@codemirror/view/dist/index.d.cts +2389 -0
- package/node_modules/@codemirror/view/dist/index.d.ts +2389 -0
- package/node_modules/@codemirror/view/dist/index.js +11745 -0
- package/node_modules/@codemirror/view/package.json +41 -0
- package/node_modules/@groove-dev/daemon/src/api.js +157 -2
- package/node_modules/@groove-dev/daemon/src/filewatcher.js +59 -0
- package/node_modules/@groove-dev/daemon/src/index.js +28 -1
- package/node_modules/@groove-dev/daemon/src/skills.js +20 -0
- package/node_modules/@groove-dev/gui/dist/assets/index-Dxg9hdf3.js +103 -0
- package/node_modules/@groove-dev/gui/dist/index.html +1 -1
- package/node_modules/@groove-dev/gui/package.json +15 -2
- package/node_modules/@groove-dev/gui/src/App.jsx +3 -0
- package/node_modules/@groove-dev/gui/src/components/CodeEditor.jsx +143 -0
- package/node_modules/@groove-dev/gui/src/components/EditorTabs.jsx +83 -0
- package/node_modules/@groove-dev/gui/src/components/FileTree.jsx +193 -0
- package/node_modules/@groove-dev/gui/src/stores/groove.js +158 -1
- package/node_modules/@groove-dev/gui/src/views/FileEditor.jsx +142 -0
- package/node_modules/@groove-dev/gui/src/views/SkillsMarketplace.jsx +112 -1
- package/node_modules/@lezer/common/LICENSE +21 -0
- package/node_modules/@lezer/common/README.md +14 -0
- package/node_modules/@lezer/common/dist/index.cjs +2209 -0
- package/node_modules/@lezer/common/dist/index.d.cts +1174 -0
- package/node_modules/@lezer/common/dist/index.d.ts +1174 -0
- package/node_modules/@lezer/common/dist/index.js +2196 -0
- package/node_modules/@lezer/common/package.json +32 -0
- package/node_modules/@lezer/css/CHANGELOG.md +307 -0
- package/node_modules/@lezer/css/LICENSE +21 -0
- package/node_modules/@lezer/css/README.md +6 -0
- package/node_modules/@lezer/css/dist/index.cjs +151 -0
- package/node_modules/@lezer/css/dist/index.d.cts +3 -0
- package/node_modules/@lezer/css/dist/index.d.ts +3 -0
- package/node_modules/@lezer/css/dist/index.js +147 -0
- package/node_modules/@lezer/css/package.json +36 -0
- package/node_modules/@lezer/css/rollup.config.js +16 -0
- package/node_modules/@lezer/css/src/css.grammar +290 -0
- package/node_modules/@lezer/css/src/highlight.js +36 -0
- package/node_modules/@lezer/css/src/parser.js +31 -0
- package/node_modules/@lezer/css/src/parser.terms.js +63 -0
- package/node_modules/@lezer/css/src/tokens.js +75 -0
- package/node_modules/@lezer/css/test/declarations.txt +241 -0
- package/node_modules/@lezer/css/test/selector.txt +178 -0
- package/node_modules/@lezer/css/test/statements.txt +227 -0
- package/node_modules/@lezer/css/test/test-css.js +16 -0
- package/node_modules/@lezer/highlight/LICENSE +21 -0
- package/node_modules/@lezer/highlight/README.md +14 -0
- package/node_modules/@lezer/highlight/dist/index.cjs +936 -0
- package/node_modules/@lezer/highlight/dist/index.d.cts +623 -0
- package/node_modules/@lezer/highlight/dist/index.d.ts +623 -0
- package/node_modules/@lezer/highlight/dist/index.js +927 -0
- package/node_modules/@lezer/highlight/package.json +31 -0
- package/node_modules/@lezer/html/CHANGELOG.md +303 -0
- package/node_modules/@lezer/html/LICENSE +21 -0
- package/node_modules/@lezer/html/README.md +37 -0
- package/node_modules/@lezer/html/dist/index.cjs +354 -0
- package/node_modules/@lezer/html/dist/index.d.cts +14 -0
- package/node_modules/@lezer/html/dist/index.d.ts +14 -0
- package/node_modules/@lezer/html/dist/index.js +349 -0
- package/node_modules/@lezer/html/package.json +37 -0
- package/node_modules/@lezer/html/rollup.config.js +16 -0
- package/node_modules/@lezer/html/src/.tern-port +1 -0
- package/node_modules/@lezer/html/src/content.js +87 -0
- package/node_modules/@lezer/html/src/highlight.js +15 -0
- package/node_modules/@lezer/html/src/html.grammar +181 -0
- package/node_modules/@lezer/html/src/index.js +2 -0
- package/node_modules/@lezer/html/src/parser.js +27 -0
- package/node_modules/@lezer/html/src/parser.terms.js +53 -0
- package/node_modules/@lezer/html/src/tokens.js +199 -0
- package/node_modules/@lezer/html/test/mixed.txt +69 -0
- package/node_modules/@lezer/html/test/tags.txt +370 -0
- package/node_modules/@lezer/html/test/test-html.js +29 -0
- package/node_modules/@lezer/html/test/test-incremental.js +97 -0
- package/node_modules/@lezer/html/test/vue.txt +56 -0
- package/node_modules/@lezer/javascript/CHANGELOG.md +485 -0
- package/node_modules/@lezer/javascript/LICENSE +21 -0
- package/node_modules/@lezer/javascript/README.md +14 -0
- package/node_modules/@lezer/javascript/dist/index.cjs +196 -0
- package/node_modules/@lezer/javascript/dist/index.d.cts +3 -0
- package/node_modules/@lezer/javascript/dist/index.d.ts +3 -0
- package/node_modules/@lezer/javascript/dist/index.js +192 -0
- package/node_modules/@lezer/javascript/package.json +36 -0
- package/node_modules/@lezer/javascript/rollup.config.js +16 -0
- package/node_modules/@lezer/javascript/src/highlight.js +62 -0
- package/node_modules/@lezer/javascript/src/javascript.grammar +735 -0
- package/node_modules/@lezer/javascript/src/parser.js +33 -0
- package/node_modules/@lezer/javascript/src/parser.terms.js +177 -0
- package/node_modules/@lezer/javascript/src/tokens.js +87 -0
- package/node_modules/@lezer/javascript/test/decorator.txt +64 -0
- package/node_modules/@lezer/javascript/test/expression.txt +686 -0
- package/node_modules/@lezer/javascript/test/jsx.txt +79 -0
- package/node_modules/@lezer/javascript/test/semicolon.txt +77 -0
- package/node_modules/@lezer/javascript/test/statement.txt +404 -0
- package/node_modules/@lezer/javascript/test/test-javascript.js +17 -0
- package/node_modules/@lezer/javascript/test/typescript.txt +401 -0
- package/node_modules/@lezer/json/CHANGELOG.md +79 -0
- package/node_modules/@lezer/json/LICENSE +21 -0
- package/node_modules/@lezer/json/README.md +7 -0
- package/node_modules/@lezer/json/dist/index.cjs +41 -0
- package/node_modules/@lezer/json/dist/index.d.cts +3 -0
- package/node_modules/@lezer/json/dist/index.d.ts +3 -0
- package/node_modules/@lezer/json/dist/index.js +37 -0
- package/node_modules/@lezer/json/package.json +36 -0
- package/node_modules/@lezer/json/rollup.config.js +15 -0
- package/node_modules/@lezer/json/src/highlight.js +12 -0
- package/node_modules/@lezer/json/src/json.grammar +38 -0
- package/node_modules/@lezer/json/src/parser.js +23 -0
- package/node_modules/@lezer/json/src/parser.terms.js +12 -0
- package/node_modules/@lezer/json/test/arrays.txt +34 -0
- package/node_modules/@lezer/json/test/literals.txt +23 -0
- package/node_modules/@lezer/json/test/numbers.txt +87 -0
- package/node_modules/@lezer/json/test/objects.txt +34 -0
- package/node_modules/@lezer/json/test/strings.txt +50 -0
- package/node_modules/@lezer/json/test/test-json.js +17 -0
- package/node_modules/@lezer/lr/LICENSE +21 -0
- package/node_modules/@lezer/lr/README.md +25 -0
- package/node_modules/@lezer/lr/dist/constants.d.ts +45 -0
- package/node_modules/@lezer/lr/dist/constants.js +5 -0
- package/node_modules/@lezer/lr/dist/index.cjs +1891 -0
- package/node_modules/@lezer/lr/dist/index.d.cts +303 -0
- package/node_modules/@lezer/lr/dist/index.d.ts +303 -0
- package/node_modules/@lezer/lr/dist/index.js +1884 -0
- package/node_modules/@lezer/lr/package.json +32 -0
- package/node_modules/@lezer/markdown/CHANGELOG.md +279 -0
- package/node_modules/@lezer/markdown/LICENSE +21 -0
- package/node_modules/@lezer/markdown/README.md +725 -0
- package/node_modules/@lezer/markdown/bin/build-readme.cjs +39 -0
- package/node_modules/@lezer/markdown/build.js +16 -0
- package/node_modules/@lezer/markdown/dist/index.cjs +2352 -0
- package/node_modules/@lezer/markdown/dist/index.d.cts +600 -0
- package/node_modules/@lezer/markdown/dist/index.d.ts +600 -0
- package/node_modules/@lezer/markdown/dist/index.js +2335 -0
- package/node_modules/@lezer/markdown/package.json +37 -0
- package/node_modules/@lezer/markdown/src/README.md +83 -0
- package/node_modules/@lezer/markdown/src/extension.ts +301 -0
- package/node_modules/@lezer/markdown/src/index.ts +5 -0
- package/node_modules/@lezer/markdown/src/markdown.ts +1961 -0
- package/node_modules/@lezer/markdown/src/nest.ts +46 -0
- package/node_modules/@lezer/markdown/test/compare-tree.ts +14 -0
- package/node_modules/@lezer/markdown/test/spec.ts +79 -0
- package/node_modules/@lezer/markdown/test/test-extension.ts +269 -0
- package/node_modules/@lezer/markdown/test/test-incremental.ts +265 -0
- package/node_modules/@lezer/markdown/test/test-markdown.ts +3574 -0
- package/node_modules/@lezer/markdown/test/test-nesting.ts +86 -0
- package/node_modules/@lezer/markdown/test/tsconfig.json +12 -0
- package/node_modules/@lezer/markdown/tsconfig.json +14 -0
- package/node_modules/@lezer/python/CHANGELOG.md +243 -0
- package/node_modules/@lezer/python/LICENSE +21 -0
- package/node_modules/@lezer/python/README.md +6 -0
- package/node_modules/@lezer/python/dist/index.cjs +330 -0
- package/node_modules/@lezer/python/dist/index.d.cts +3 -0
- package/node_modules/@lezer/python/dist/index.d.ts +3 -0
- package/node_modules/@lezer/python/dist/index.js +326 -0
- package/node_modules/@lezer/python/package.json +36 -0
- package/node_modules/@lezer/python/rollup.config.js +16 -0
- package/node_modules/@lezer/python/src/highlight.js +35 -0
- package/node_modules/@lezer/python/src/python.grammar +381 -0
- package/node_modules/@lezer/python/src/tokens.js +224 -0
- package/node_modules/@lezer/python/test/expression.txt +231 -0
- package/node_modules/@lezer/python/test/statement.txt +442 -0
- package/node_modules/@lezer/python/test/test-incremental.js +33 -0
- package/node_modules/@lezer/python/test/test-python.js +17 -0
- package/node_modules/@marijn/find-cluster-break/LICENSE +21 -0
- package/node_modules/@marijn/find-cluster-break/README.md +28 -0
- package/node_modules/@marijn/find-cluster-break/dist/index.cjs +85 -0
- package/node_modules/@marijn/find-cluster-break/dist/index.d.cts +15 -0
- package/node_modules/@marijn/find-cluster-break/package.json +35 -0
- package/node_modules/@marijn/find-cluster-break/rollup.config.js +7 -0
- package/node_modules/@marijn/find-cluster-break/src/index.d.ts +15 -0
- package/node_modules/@marijn/find-cluster-break/src/index.js +87 -0
- package/node_modules/@marijn/find-cluster-break/test/test-cluster.js +30 -0
- package/node_modules/crelt/LICENSE +19 -0
- package/node_modules/crelt/README.md +23 -0
- package/node_modules/crelt/dist/index.cjs +31 -0
- package/node_modules/crelt/dist/index.d.cts +4 -0
- package/node_modules/crelt/index.d.ts +4 -0
- package/node_modules/crelt/index.js +28 -0
- package/node_modules/crelt/package.json +35 -0
- package/node_modules/crelt/rollup.config.js +13 -0
- package/node_modules/style-mod/LICENSE +19 -0
- package/node_modules/style-mod/README.md +98 -0
- package/node_modules/style-mod/dist/style-mod.cjs +165 -0
- package/node_modules/style-mod/dist/style-mod.d.cts +16 -0
- package/node_modules/style-mod/package.json +39 -0
- package/node_modules/style-mod/src/README.md +34 -0
- package/node_modules/style-mod/src/style-mod.d.ts +16 -0
- package/node_modules/style-mod/src/style-mod.js +172 -0
- package/node_modules/style-mod/test/test-style-mod.js +104 -0
- package/node_modules/w3c-keyname/.tern-port +1 -0
- package/node_modules/w3c-keyname/LICENSE +19 -0
- package/node_modules/w3c-keyname/README.md +18 -0
- package/node_modules/w3c-keyname/index.cjs +127 -0
- package/node_modules/w3c-keyname/index.d.cts +5 -0
- package/node_modules/w3c-keyname/index.d.ts +5 -0
- package/node_modules/w3c-keyname/index.js +119 -0
- package/node_modules/w3c-keyname/package.json +37 -0
- package/package.json +1 -1
- package/packages/daemon/src/api.js +157 -2
- package/packages/daemon/src/filewatcher.js +59 -0
- package/packages/daemon/src/index.js +28 -1
- package/packages/daemon/src/skills.js +20 -0
- package/packages/gui/dist/assets/index-Dxg9hdf3.js +103 -0
- package/packages/gui/dist/index.html +1 -1
- package/packages/gui/package.json +15 -2
- package/packages/gui/src/App.jsx +3 -0
- package/packages/gui/src/components/CodeEditor.jsx +143 -0
- package/packages/gui/src/components/EditorTabs.jsx +83 -0
- package/packages/gui/src/components/FileTree.jsx +193 -0
- package/packages/gui/src/stores/groove.js +158 -1
- package/packages/gui/src/views/FileEditor.jsx +142 -0
- package/packages/gui/src/views/SkillsMarketplace.jsx +112 -1
- package/node_modules/@groove-dev/gui/dist/assets/index-CNCSwHwH.js +0 -74
- package/packages/gui/dist/assets/index-CNCSwHwH.js +0 -74
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
@precedence {
|
|
2
|
+
cond,
|
|
3
|
+
trail,
|
|
4
|
+
power @right,
|
|
5
|
+
prefix,
|
|
6
|
+
times @left,
|
|
7
|
+
plus @left,
|
|
8
|
+
shift @left,
|
|
9
|
+
bitand @left,
|
|
10
|
+
xor @left,
|
|
11
|
+
bitor @left,
|
|
12
|
+
compare @left,
|
|
13
|
+
as @left,
|
|
14
|
+
and @left,
|
|
15
|
+
or @left
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
@top Script { statement+ }
|
|
19
|
+
|
|
20
|
+
@skip { space | newlineBracketed | Comment | blankLine }
|
|
21
|
+
|
|
22
|
+
Decorator { At dottedName ArgList? newline }
|
|
23
|
+
|
|
24
|
+
FunctionDefinition {
|
|
25
|
+
kw<"async">? kw<"def"> VariableName TypeParamList?
|
|
26
|
+
ParamList
|
|
27
|
+
TypeDef { "->" test }?
|
|
28
|
+
Body
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
ParamList { "(" commaSep<param>? ")" }
|
|
32
|
+
|
|
33
|
+
TypeParamList { "[" commaSep<TypeParam> "]" }
|
|
34
|
+
|
|
35
|
+
TypeParam {
|
|
36
|
+
("*" | "**") VariableName |
|
|
37
|
+
VariableName TypeDef?
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
MatchStatement {
|
|
41
|
+
skw<"match"> "*"? expression MatchBody { ":" newline indent MatchClause+ (dedent | eof) }
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
MatchClause {
|
|
45
|
+
skw<"case"> commaSep<pattern> Guard { kw<"if"> test }? Body
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
pattern[@isGroup=Pattern] {
|
|
49
|
+
CapturePattern { VariableName } |
|
|
50
|
+
LiteralPattern |
|
|
51
|
+
AsPattern { pattern !as kw<"as"> VariableName } |
|
|
52
|
+
OrPattern { pattern (!or LogicOp{"|"} pattern)+ } |
|
|
53
|
+
AttributePattern |
|
|
54
|
+
SequencePattern |
|
|
55
|
+
MappingPattern |
|
|
56
|
+
StarPattern { "*" !prefix pattern } |
|
|
57
|
+
ClassPattern { (VariableName | AttributePattern) PatternArgList }
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
AttributePattern { VariableName ("." PropertyName)+ }
|
|
61
|
+
|
|
62
|
+
LiteralPattern {
|
|
63
|
+
ArithOp{"-"}? Number (ArithOp{"+"|"-"} Number)? |
|
|
64
|
+
String |
|
|
65
|
+
kw<"None"> |
|
|
66
|
+
@specialize[@name=Boolean]<identifier, "True" | "False">
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
PatternArgList { "(" commaSep<pattern | KeywordPattern { VariableName "=" pattern }> ")" }
|
|
70
|
+
|
|
71
|
+
SequencePattern { "[" commaSep<pattern> "]" | "(" commaSep<pattern> ")" }
|
|
72
|
+
|
|
73
|
+
MappingPattern { "{" commaSep<"**" pattern | (VariableName | LiteralPattern) ":" pattern> "}" }
|
|
74
|
+
|
|
75
|
+
ClassDefinition { kw<"class"> VariableName TypeParamList? ArgList? Body }
|
|
76
|
+
|
|
77
|
+
param { VariableName TypeDef? (AssignOp{"="} test)? | "*" (VariableName TypeDef?)? | "**" VariableName TypeDef? | "/" }
|
|
78
|
+
|
|
79
|
+
TypeDef { ":" test }
|
|
80
|
+
|
|
81
|
+
statement[@isGroup=Statement] { simpleStatement | compoundStatement }
|
|
82
|
+
|
|
83
|
+
simpleStatement {
|
|
84
|
+
smallStatement (newline | eof) |
|
|
85
|
+
StatementGroup { smallStatement (";" smallStatement?)+ (newline | eof) }
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
smallStatement {
|
|
89
|
+
AssignStatement { expressions (TypeDef? (AssignOp{"="} (YieldExpression | expressions))+ | TypeDef) } |
|
|
90
|
+
UpdateStatement { expressions UpdateOp (YieldExpression | commaSep<test>) } |
|
|
91
|
+
ExpressionStatement { expressions } |
|
|
92
|
+
DeleteStatement { kw<"del"> commaSep<expression> } |
|
|
93
|
+
PassStatement { kw<"pass"> } |
|
|
94
|
+
BreakStatement { kw<"break"> } |
|
|
95
|
+
ContinueStatement { kw<"continue"> } |
|
|
96
|
+
ReturnStatement { kw<"return"> commaSep<test | "*" expression>? } |
|
|
97
|
+
YieldStatement { yield } |
|
|
98
|
+
PrintStatement { printKeyword test } |
|
|
99
|
+
RaiseStatement { kw<"raise"> (test (kw<"from"> test | ("," test ("," test)?))?)? } |
|
|
100
|
+
ImportStatement |
|
|
101
|
+
ScopeStatement { (kw<"global"> | kw<"nonlocal">) commaSep<VariableName> } |
|
|
102
|
+
AssertStatement { kw<"assert"> commaSep<test> } |
|
|
103
|
+
TypeDefinition { skw<"type"> VariableName TypeParamList? "=" test }
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
expressions { commaSep<"*" expression | test> }
|
|
107
|
+
|
|
108
|
+
ImportStatement {
|
|
109
|
+
kw<"import"> (importList | importedNames) |
|
|
110
|
+
kw<"from"> (("." | "...")+ dottedName? | dottedName) kw<"import"> ("*" | importList | importedNames)
|
|
111
|
+
}
|
|
112
|
+
importedNames { commaSep<dottedName | dottedName kw<"as"> VariableName> }
|
|
113
|
+
importList[@export] { "(" importedNames ")" }
|
|
114
|
+
|
|
115
|
+
commaSep<expr> { expr ("," expr)* ","? }
|
|
116
|
+
|
|
117
|
+
compoundStatement {
|
|
118
|
+
IfStatement |
|
|
119
|
+
WhileStatement { kw<"while"> testNamed Body elseClause? } |
|
|
120
|
+
ForStatement { kw<"async">? kw<"for"> commaSep<"*"? expression> kw<"in"> commaSep<test> Body elseClause? } |
|
|
121
|
+
TryStatement |
|
|
122
|
+
WithStatement { kw<"async">? kw<"with"> commaSep<test (kw<"as"> VariableName)?> Body } |
|
|
123
|
+
FunctionDefinition |
|
|
124
|
+
ClassDefinition |
|
|
125
|
+
DecoratedStatement { Decorator+ (ClassDefinition | FunctionDefinition) } |
|
|
126
|
+
MatchStatement
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
elseClause { kw<"else"> Body }
|
|
130
|
+
|
|
131
|
+
IfStatement {
|
|
132
|
+
kw<"if"> testNamed Body
|
|
133
|
+
(kw<"elif"> testNamed? Body)*
|
|
134
|
+
elseClause?
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
TryStatement {
|
|
138
|
+
kw<"try"> Body
|
|
139
|
+
(kw<"except"> "*"? (test ((kw<"as"> | ",") VariableName)?)? Body)*
|
|
140
|
+
elseClause?
|
|
141
|
+
(kw<"finally"> Body)?
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
Body { ":" (simpleStatement | newline indent statement+ (dedent | eof)) }
|
|
145
|
+
|
|
146
|
+
lambdaParam { VariableName (AssignOp{"="} test)? | "*" VariableName? | "**" VariableName }
|
|
147
|
+
|
|
148
|
+
lambdaParams[@name="ParamList"] { (lambdaParam ("," lambdaParam)*)? }
|
|
149
|
+
|
|
150
|
+
test {
|
|
151
|
+
testInner |
|
|
152
|
+
ConditionalExpression { testInner !cond kw<"if"> testInner kw<"else"> test } |
|
|
153
|
+
LambdaExpression { kw<"lambda"> lambdaParams ":" test }
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
testNoCond {
|
|
157
|
+
testInner |
|
|
158
|
+
LambdaExpression { kw<"lambda"> lambdaParams ":" testNoCond }
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
testNamed {
|
|
162
|
+
test | NamedExpression { test AssignOp{":="} test }
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
testInner { binaryTest | unaryTest | expression }
|
|
166
|
+
|
|
167
|
+
binaryTest[@name="BinaryExpression"] {
|
|
168
|
+
testInner !or kw<"or"> testInner |
|
|
169
|
+
testInner !and kw<"and"> testInner |
|
|
170
|
+
testInner !compare (CompareOp | kw<"in"> | kw<"not"> kw<"in"> | kw<"is"> kw<"not">?) testInner
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
unaryTest[@name="UnaryExpression"] { kw<"not"> testInner }
|
|
174
|
+
|
|
175
|
+
expression[@isGroup=Expression] {
|
|
176
|
+
BinaryExpression |
|
|
177
|
+
UnaryExpression { !prefix (ArithOp{"+" | "-"} | BitOp{"~"}) expression } |
|
|
178
|
+
AwaitExpression { kw<"await"> expression } |
|
|
179
|
+
ParenthesizedExpression |
|
|
180
|
+
TupleExpression |
|
|
181
|
+
ComprehensionExpression |
|
|
182
|
+
ArrayExpression |
|
|
183
|
+
ArrayComprehensionExpression |
|
|
184
|
+
DictionaryExpression |
|
|
185
|
+
DictionaryComprehensionExpression |
|
|
186
|
+
SetExpression |
|
|
187
|
+
SetComprehensionExpression |
|
|
188
|
+
CallExpression { expression !trail ArgList } |
|
|
189
|
+
MemberExpression { expression !trail (subscript | "." PropertyName) } |
|
|
190
|
+
VariableName |
|
|
191
|
+
Number |
|
|
192
|
+
String | FormatString |
|
|
193
|
+
ContinuedString { (String | FormatString) (String | FormatString)+ } |
|
|
194
|
+
"..." |
|
|
195
|
+
kw<"None"> |
|
|
196
|
+
@specialize[@name=Boolean]<identifier, "True" | "False">
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
subscript[@export] {
|
|
200
|
+
"[" commaSep<testNamed | testNamed? ":" testNamed? (":" testNamed?)?> "]"
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
ParenthesizedExpression { "(" (testNamed | "*" expression | YieldExpression) ")" }
|
|
204
|
+
|
|
205
|
+
TupleExpression { "(" ((testNamed | "*" expression) (("," (testNamed | "*" expression))+ ","? | ","))? ")" }
|
|
206
|
+
ComprehensionExpression { "(" (testNamed | "*" expression) compFor ")" }
|
|
207
|
+
|
|
208
|
+
ArrayExpression { "[" commaSep<testNamed | "*" expression>? "]" }
|
|
209
|
+
ArrayComprehensionExpression { "[" (testNamed | "*" expression) compFor "]" }
|
|
210
|
+
|
|
211
|
+
DictionaryExpression { "{" commaSep<test ":" test | "**" expression>? "}" }
|
|
212
|
+
DictionaryComprehensionExpression { "{" (test ":" test | "**" expression) compFor "}" }
|
|
213
|
+
|
|
214
|
+
SetExpression { "{" commaSep<test | "*" expression> "}" }
|
|
215
|
+
SetComprehensionExpression { "{" (test | "*" expression) compFor "}" }
|
|
216
|
+
|
|
217
|
+
yield { kw<"yield"> (kw<"from"> test | commaSep<test | "*" expression>) }
|
|
218
|
+
|
|
219
|
+
YieldExpression { yield }
|
|
220
|
+
|
|
221
|
+
BinaryExpression {
|
|
222
|
+
expression !bitor BitOp{"|"} expression |
|
|
223
|
+
expression !xor BitOp{"^"} expression |
|
|
224
|
+
expression !bitand BitOp{"&"} expression |
|
|
225
|
+
expression !shift BitOp{"<<" | ">>"} expression |
|
|
226
|
+
expression !plus ArithOp{"+" | "-"} expression |
|
|
227
|
+
expression !times ArithOp{"*" | "@" | "/" | "%" | "//"} expression |
|
|
228
|
+
expression !power ArithOp{"**"} expression
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
ArgList { "(" commaSep<argument>? ")" }
|
|
232
|
+
|
|
233
|
+
argument { test compFor? | VariableName AssignOp{"=" | ":="} test compFor? | "**" test | "*" test }
|
|
234
|
+
|
|
235
|
+
compFor {
|
|
236
|
+
kw<"async">? kw<"for"> commaSep<expression> kw<"in"> testInner (compFor | compIf)?
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
compIf {
|
|
240
|
+
kw<"if"> testNoCond (compFor | compIf)?
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// FIXME Is it possible to distinguish between VariableName and VariableDefinition?
|
|
244
|
+
|
|
245
|
+
VariableName { identifier }
|
|
246
|
+
|
|
247
|
+
PropertyName { word }
|
|
248
|
+
|
|
249
|
+
dottedName { VariableName ("." VariableName)* }
|
|
250
|
+
|
|
251
|
+
kw<term> { @specialize[@name={term}]<identifier, term> }
|
|
252
|
+
|
|
253
|
+
skw<term> { @extend[@name={term}]<identifier, term> }
|
|
254
|
+
|
|
255
|
+
@skip {} {
|
|
256
|
+
String[isolate] {
|
|
257
|
+
(stringStart | stringStartD | stringStartL | stringStartLD |
|
|
258
|
+
stringStartR | stringStartRD | stringStartRL | stringStartRLD)
|
|
259
|
+
(stringContent | Escape)*
|
|
260
|
+
stringEnd
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
FormatString[isolate] {
|
|
264
|
+
(stringStartF | stringStartFD | stringStartFL | stringStartFLD |
|
|
265
|
+
stringStartFR | stringStartFRD | stringStartFRL | stringStartFRLD)
|
|
266
|
+
(stringContent | Escape | FormatReplacement)*
|
|
267
|
+
stringEnd
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
formatStringSpec { FormatSpec { ":" (formatStringSpecChars | nestedFormatReplacement)* } "}" }
|
|
271
|
+
|
|
272
|
+
blankLine {
|
|
273
|
+
blankLineStart space? Comment? (newline | eof)
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
formatReplacement<start> {
|
|
278
|
+
start
|
|
279
|
+
(YieldExpression | commaSep<"*"? test>)
|
|
280
|
+
FormatSelfDoc {"="}?
|
|
281
|
+
FormatConversion?
|
|
282
|
+
(formatStringSpec | "}")
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
FormatReplacement[isolate] { formatReplacement<replacementStart> }
|
|
286
|
+
nestedFormatReplacement[isolate,@name=FormatReplacement,@export] { formatReplacement<"{"> }
|
|
287
|
+
|
|
288
|
+
@context trackIndent from "./tokens.js"
|
|
289
|
+
|
|
290
|
+
@external tokens legacyPrint from "./tokens.js" { printKeyword[@name="print"] }
|
|
291
|
+
|
|
292
|
+
@external tokens indentation from "./tokens" { indent, dedent }
|
|
293
|
+
|
|
294
|
+
@external tokens newlines from "./tokens" { newline, blankLineStart, newlineBracketed, eof }
|
|
295
|
+
|
|
296
|
+
@external tokens strings from "./tokens" {
|
|
297
|
+
stringContent
|
|
298
|
+
Escape
|
|
299
|
+
replacementStart[@name="{"]
|
|
300
|
+
stringEnd
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
@tokens {
|
|
304
|
+
CompareOp { "<" | ">" | $[<>=!] "=" | "<>" }
|
|
305
|
+
|
|
306
|
+
UpdateOp { ($[+\-@%&|^] | "<<" | ">>" | "*" "*"? | "/" "/"?) "=" }
|
|
307
|
+
|
|
308
|
+
// String types are identified by letter suffixes:
|
|
309
|
+
// D: double quoted
|
|
310
|
+
// L: long string
|
|
311
|
+
// R: raw string
|
|
312
|
+
// F: format string
|
|
313
|
+
stringStart[@export] { stringPrefix? "'" }
|
|
314
|
+
stringStartD[@export] { stringPrefix? '"' }
|
|
315
|
+
stringStartL[@export] { stringPrefix? "'''" }
|
|
316
|
+
stringStartLD[@export] { stringPrefix? '"""' }
|
|
317
|
+
stringStartR[@export] { stringPrefixR "'" }
|
|
318
|
+
stringStartRD[@export] { stringPrefixR '"' }
|
|
319
|
+
stringStartRL[@export] { stringPrefixR "'''" }
|
|
320
|
+
stringStartRLD[@export] { stringPrefixR '"""' }
|
|
321
|
+
stringStartF[@export] { stringPrefixF "'" }
|
|
322
|
+
stringStartFD[@export] { stringPrefixF '"' }
|
|
323
|
+
stringStartFL[@export] { stringPrefixF "'''" }
|
|
324
|
+
stringStartFLD[@export] { stringPrefixF '"""' }
|
|
325
|
+
stringStartFR[@export] { stringPrefixFR "'" }
|
|
326
|
+
stringStartFRD[@export] { stringPrefixFR '"' }
|
|
327
|
+
stringStartFRL[@export] { stringPrefixFR "'''" }
|
|
328
|
+
stringStartFRLD[@export] { stringPrefixFR '"""' }
|
|
329
|
+
|
|
330
|
+
stringPrefix { $[uUbB] }
|
|
331
|
+
stringPrefixR { $[rR] $[bB]? | $[bB] $[rR] }
|
|
332
|
+
stringPrefixF { $[fF] }
|
|
333
|
+
stringPrefixFR { $[rR] $[fF] | $[fF] $[rR] }
|
|
334
|
+
|
|
335
|
+
// Give string quotes a higher precedence than identifiers, and long
|
|
336
|
+
// strings a higher precedence than short strings
|
|
337
|
+
@precedence { stringStartL, stringStart, identifier }
|
|
338
|
+
@precedence { stringStartLD, stringStartD, identifier }
|
|
339
|
+
@precedence { stringStartRL, stringStartR, identifier }
|
|
340
|
+
@precedence { stringStartRLD, stringStartRD, identifier }
|
|
341
|
+
@precedence { stringStartFL, stringStartF, identifier }
|
|
342
|
+
@precedence { stringStartFLD, stringStartFD, identifier }
|
|
343
|
+
@precedence { stringStartFRL, stringStartFR, identifier }
|
|
344
|
+
@precedence { stringStartFRLD, stringStartFRD, identifier }
|
|
345
|
+
|
|
346
|
+
identifierChar { @asciiLetter | $[_\u{a1}-\u{10ffff}] }
|
|
347
|
+
|
|
348
|
+
word { identifierChar (@digit | identifierChar)* }
|
|
349
|
+
|
|
350
|
+
identifier { word }
|
|
351
|
+
|
|
352
|
+
FormatConversion { "!" $[sra] }
|
|
353
|
+
|
|
354
|
+
formatStringSpecChars { ![{}]+ }
|
|
355
|
+
|
|
356
|
+
Number {
|
|
357
|
+
(@digit ("_" | @digit)* ("." @digit ("_" | @digit)*)? | "." @digit ("_" | @digit)*)
|
|
358
|
+
($[eE] $[+\-]? @digit ("_" | @digit)*)? $[jJ]? |
|
|
359
|
+
"0" $[bB] $[_01]+ |
|
|
360
|
+
"0" $[oO] $[_0-7]+ |
|
|
361
|
+
"0" $[xX] $[_0-9a-fA-F]+
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
Comment[isolate] { "#" ![\n\r]* }
|
|
365
|
+
|
|
366
|
+
space { ($[ \t\f] | "\\" $[\n\r])+ }
|
|
367
|
+
|
|
368
|
+
At { "@" }
|
|
369
|
+
|
|
370
|
+
"..."[@name=Ellipsis]
|
|
371
|
+
|
|
372
|
+
"("[@export=ParenL] ")"
|
|
373
|
+
"["[@export=BracketL] "]"
|
|
374
|
+
"{"[@export=BraceL] "}"
|
|
375
|
+
|
|
376
|
+
"." "," ";" ":" "@" "*" "**"
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
@external propSource pythonHighlighting from "./highlight"
|
|
380
|
+
|
|
381
|
+
@detectDelim
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import {ExternalTokenizer, ContextTracker} from "@lezer/lr"
|
|
2
|
+
import {
|
|
3
|
+
newline as newlineToken, eof, newlineBracketed, blankLineStart, indent, dedent, printKeyword,
|
|
4
|
+
ParenthesizedExpression, TupleExpression, ComprehensionExpression,
|
|
5
|
+
PatternArgList, SequencePattern, MappingPattern, TypeParamList,
|
|
6
|
+
ArrayExpression, ArrayComprehensionExpression, ArgList, ParamList, importList, subscript,
|
|
7
|
+
DictionaryExpression, DictionaryComprehensionExpression, SetExpression, SetComprehensionExpression,
|
|
8
|
+
String as StringTerm, FormatString, FormatReplacement, nestedFormatReplacement,
|
|
9
|
+
stringStart, stringStartD, stringStartL, stringStartLD,
|
|
10
|
+
stringStartR, stringStartRD, stringStartRL, stringStartRLD,
|
|
11
|
+
stringStartF, stringStartFD, stringStartFL, stringStartFLD,
|
|
12
|
+
stringStartFR, stringStartFRD, stringStartFRL, stringStartFRLD,
|
|
13
|
+
stringContent, Escape, replacementStart, stringEnd,
|
|
14
|
+
ParenL, BraceL, BracketL
|
|
15
|
+
} from "./parser.terms.js"
|
|
16
|
+
|
|
17
|
+
const newline = 10, carriageReturn = 13, space = 32, tab = 9, hash = 35, parenOpen = 40, dot = 46,
|
|
18
|
+
braceOpen = 123, braceClose = 125, singleQuote = 39, doubleQuote = 34, backslash = 92,
|
|
19
|
+
letter_o = 111, letter_x = 120, letter_N = 78, letter_u = 117, letter_U = 85
|
|
20
|
+
|
|
21
|
+
const bracketed = new Set([
|
|
22
|
+
ParenthesizedExpression, TupleExpression, ComprehensionExpression, importList, ArgList, ParamList,
|
|
23
|
+
ArrayExpression, ArrayComprehensionExpression, subscript,
|
|
24
|
+
SetExpression, SetComprehensionExpression, FormatString, FormatReplacement, nestedFormatReplacement,
|
|
25
|
+
DictionaryExpression, DictionaryComprehensionExpression,
|
|
26
|
+
SequencePattern, MappingPattern, PatternArgList, TypeParamList
|
|
27
|
+
])
|
|
28
|
+
|
|
29
|
+
function isLineBreak(ch) {
|
|
30
|
+
return ch == newline || ch == carriageReturn
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function isHex(ch) {
|
|
34
|
+
return ch >= 48 && ch <= 57 || ch >= 65 && ch <= 70 || ch >= 97 && ch <= 102
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export const newlines = new ExternalTokenizer((input, stack) => {
|
|
38
|
+
let prev
|
|
39
|
+
if (input.next < 0) {
|
|
40
|
+
input.acceptToken(eof)
|
|
41
|
+
} else if (stack.context.flags & cx_Bracketed) {
|
|
42
|
+
if (isLineBreak(input.next)) input.acceptToken(newlineBracketed, 1)
|
|
43
|
+
} else if (((prev = input.peek(-1)) < 0 || isLineBreak(prev)) &&
|
|
44
|
+
stack.canShift(blankLineStart)) {
|
|
45
|
+
let spaces = 0
|
|
46
|
+
while (input.next == space || input.next == tab) { input.advance(); spaces++ }
|
|
47
|
+
if (input.next == newline || input.next == carriageReturn || input.next == hash)
|
|
48
|
+
input.acceptToken(blankLineStart, -spaces)
|
|
49
|
+
} else if (isLineBreak(input.next)) {
|
|
50
|
+
input.acceptToken(newlineToken, 1)
|
|
51
|
+
}
|
|
52
|
+
}, {contextual: true})
|
|
53
|
+
|
|
54
|
+
export const indentation = new ExternalTokenizer((input, stack) => {
|
|
55
|
+
let context = stack.context
|
|
56
|
+
if (context.flags) return
|
|
57
|
+
let prev = input.peek(-1), depth
|
|
58
|
+
if (prev == newline || prev == carriageReturn) {
|
|
59
|
+
let depth = 0, chars = 0
|
|
60
|
+
for (;;) {
|
|
61
|
+
if (input.next == space) depth++
|
|
62
|
+
else if (input.next == tab) depth += 8 - (depth % 8)
|
|
63
|
+
else break
|
|
64
|
+
input.advance()
|
|
65
|
+
chars++
|
|
66
|
+
}
|
|
67
|
+
if (depth != context.indent &&
|
|
68
|
+
input.next != newline && input.next != carriageReturn && input.next != hash) {
|
|
69
|
+
if (depth < context.indent) input.acceptToken(dedent, -chars)
|
|
70
|
+
else input.acceptToken(indent)
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
// Flags used in Context objects
|
|
76
|
+
const cx_Bracketed = 1, cx_String = 2, cx_DoubleQuote = 4, cx_Long = 8, cx_Raw = 16, cx_Format = 32
|
|
77
|
+
|
|
78
|
+
function Context(parent, indent, flags) {
|
|
79
|
+
this.parent = parent
|
|
80
|
+
this.indent = indent
|
|
81
|
+
this.flags = flags
|
|
82
|
+
this.hash = (parent ? parent.hash + parent.hash << 8 : 0) + indent + (indent << 4) + flags + (flags << 6)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const topIndent = new Context(null, 0, 0)
|
|
86
|
+
|
|
87
|
+
function countIndent(space) {
|
|
88
|
+
let depth = 0
|
|
89
|
+
for (let i = 0; i < space.length; i++)
|
|
90
|
+
depth += space.charCodeAt(i) == tab ? 8 - (depth % 8) : 1
|
|
91
|
+
return depth
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const stringFlags = new Map([
|
|
95
|
+
[stringStart, 0],
|
|
96
|
+
[stringStartD, cx_DoubleQuote],
|
|
97
|
+
[stringStartL, cx_Long],
|
|
98
|
+
[stringStartLD, cx_Long | cx_DoubleQuote],
|
|
99
|
+
[stringStartR, cx_Raw],
|
|
100
|
+
[stringStartRD, cx_Raw | cx_DoubleQuote],
|
|
101
|
+
[stringStartRL, cx_Raw | cx_Long],
|
|
102
|
+
[stringStartRLD, cx_Raw | cx_Long | cx_DoubleQuote],
|
|
103
|
+
[stringStartF, cx_Format],
|
|
104
|
+
[stringStartFD, cx_Format | cx_DoubleQuote],
|
|
105
|
+
[stringStartFL, cx_Format | cx_Long],
|
|
106
|
+
[stringStartFLD, cx_Format | cx_Long | cx_DoubleQuote],
|
|
107
|
+
[stringStartFR, cx_Format | cx_Raw],
|
|
108
|
+
[stringStartFRD, cx_Format | cx_Raw | cx_DoubleQuote],
|
|
109
|
+
[stringStartFRL, cx_Format | cx_Raw | cx_Long],
|
|
110
|
+
[stringStartFRLD, cx_Format | cx_Raw | cx_Long | cx_DoubleQuote]
|
|
111
|
+
].map(([term, flags]) => [term, flags | cx_String]))
|
|
112
|
+
|
|
113
|
+
export const trackIndent = new ContextTracker({
|
|
114
|
+
start: topIndent,
|
|
115
|
+
reduce(context, term, _, input) {
|
|
116
|
+
if ((context.flags & cx_Bracketed) && bracketed.has(term) ||
|
|
117
|
+
(term == StringTerm || term == FormatString) && (context.flags & cx_String))
|
|
118
|
+
return context.parent
|
|
119
|
+
return context
|
|
120
|
+
},
|
|
121
|
+
shift(context, term, stack, input) {
|
|
122
|
+
if (term == indent)
|
|
123
|
+
return new Context(context, countIndent(input.read(input.pos, stack.pos)), 0)
|
|
124
|
+
if (term == dedent)
|
|
125
|
+
return context.parent
|
|
126
|
+
if (term == ParenL || term == BracketL || term == BraceL || term == replacementStart)
|
|
127
|
+
return new Context(context, 0, cx_Bracketed)
|
|
128
|
+
if (stringFlags.has(term))
|
|
129
|
+
return new Context(context, 0, stringFlags.get(term) | (context.flags & cx_Bracketed))
|
|
130
|
+
return context
|
|
131
|
+
},
|
|
132
|
+
hash(context) { return context.hash }
|
|
133
|
+
})
|
|
134
|
+
|
|
135
|
+
export const legacyPrint = new ExternalTokenizer(input => {
|
|
136
|
+
for (let i = 0; i < 5; i++) {
|
|
137
|
+
if (input.next != "print".charCodeAt(i)) return
|
|
138
|
+
input.advance()
|
|
139
|
+
}
|
|
140
|
+
if (/\w/.test(String.fromCharCode(input.next))) return
|
|
141
|
+
for (let off = 0;; off++) {
|
|
142
|
+
let next = input.peek(off)
|
|
143
|
+
if (next == space || next == tab) continue
|
|
144
|
+
if (next != parenOpen && next != dot && next != newline && next != carriageReturn && next != hash)
|
|
145
|
+
input.acceptToken(printKeyword)
|
|
146
|
+
return
|
|
147
|
+
}
|
|
148
|
+
})
|
|
149
|
+
|
|
150
|
+
export const strings = new ExternalTokenizer((input, stack) => {
|
|
151
|
+
let {flags} = stack.context
|
|
152
|
+
let quote = (flags & cx_DoubleQuote) ? doubleQuote : singleQuote
|
|
153
|
+
let long = (flags & cx_Long) > 0
|
|
154
|
+
let escapes = !(flags & cx_Raw)
|
|
155
|
+
let format = (flags & cx_Format) > 0
|
|
156
|
+
|
|
157
|
+
let start = input.pos
|
|
158
|
+
for (;;) {
|
|
159
|
+
if (input.next < 0) {
|
|
160
|
+
break
|
|
161
|
+
} else if (format && input.next == braceOpen) {
|
|
162
|
+
if (input.peek(1) == braceOpen) {
|
|
163
|
+
input.advance(2)
|
|
164
|
+
} else {
|
|
165
|
+
if (input.pos == start) {
|
|
166
|
+
input.acceptToken(replacementStart, 1)
|
|
167
|
+
return
|
|
168
|
+
}
|
|
169
|
+
break
|
|
170
|
+
}
|
|
171
|
+
} else if (escapes && input.next == backslash) {
|
|
172
|
+
if (input.pos == start) {
|
|
173
|
+
input.advance()
|
|
174
|
+
let escaped = input.next
|
|
175
|
+
if (escaped >= 0) {
|
|
176
|
+
input.advance()
|
|
177
|
+
skipEscape(input, escaped)
|
|
178
|
+
}
|
|
179
|
+
input.acceptToken(Escape)
|
|
180
|
+
return
|
|
181
|
+
}
|
|
182
|
+
break
|
|
183
|
+
} else if (input.next == backslash && !escapes && input.peek(1) > -1) {
|
|
184
|
+
// Raw strings still ignore escaped quotes, weirdly.
|
|
185
|
+
input.advance(2)
|
|
186
|
+
} else if (input.next == quote && (!long || input.peek(1) == quote && input.peek(2) == quote)) {
|
|
187
|
+
if (input.pos == start) {
|
|
188
|
+
input.acceptToken(stringEnd, long ? 3 : 1)
|
|
189
|
+
return
|
|
190
|
+
}
|
|
191
|
+
break
|
|
192
|
+
} else if (input.next == newline) {
|
|
193
|
+
if (long) {
|
|
194
|
+
input.advance()
|
|
195
|
+
} else if (input.pos == start) {
|
|
196
|
+
input.acceptToken(stringEnd)
|
|
197
|
+
return
|
|
198
|
+
}
|
|
199
|
+
break
|
|
200
|
+
} else {
|
|
201
|
+
input.advance()
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
if (input.pos > start) input.acceptToken(stringContent)
|
|
205
|
+
})
|
|
206
|
+
|
|
207
|
+
function skipEscape(input, ch) {
|
|
208
|
+
if (ch == letter_o) {
|
|
209
|
+
for (let i = 0; i < 2 && input.next >= 48 && input.next <= 55; i++) input.advance()
|
|
210
|
+
} else if (ch == letter_x) {
|
|
211
|
+
for (let i = 0; i < 2 && isHex(input.next); i++) input.advance()
|
|
212
|
+
} else if (ch == letter_u) {
|
|
213
|
+
for (let i = 0; i < 4 && isHex(input.next); i++) input.advance()
|
|
214
|
+
} else if (ch == letter_U) {
|
|
215
|
+
for (let i = 0; i < 8 && isHex(input.next); i++) input.advance()
|
|
216
|
+
} else if (ch == letter_N) {
|
|
217
|
+
if (input.next == braceOpen) {
|
|
218
|
+
input.advance()
|
|
219
|
+
while (input.next >= 0 && input.next != braceClose && input.next != singleQuote &&
|
|
220
|
+
input.next != doubleQuote && input.next != newline) input.advance()
|
|
221
|
+
if (input.next == braceClose) input.advance()
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|