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,231 @@
|
|
|
1
|
+
# Operator precedence
|
|
2
|
+
|
|
3
|
+
a + b * c - d**3
|
|
4
|
+
a or b > 2 and c or d == None
|
|
5
|
+
a + b | c & d
|
|
6
|
+
|
|
7
|
+
==>
|
|
8
|
+
|
|
9
|
+
Script(
|
|
10
|
+
ExpressionStatement(BinaryExpression(BinaryExpression(VariableName, ArithOp,
|
|
11
|
+
BinaryExpression(VariableName, ArithOp, VariableName)), ArithOp, BinaryExpression(VariableName, ArithOp, Number))),
|
|
12
|
+
ExpressionStatement(BinaryExpression(BinaryExpression(VariableName, or,
|
|
13
|
+
BinaryExpression(BinaryExpression(VariableName, CompareOp, Number), and, VariableName)),
|
|
14
|
+
or, BinaryExpression(VariableName, CompareOp, None))),
|
|
15
|
+
ExpressionStatement(BinaryExpression(BinaryExpression(VariableName, ArithOp, VariableName), BitOp,
|
|
16
|
+
BinaryExpression(VariableName, BitOp, VariableName))))
|
|
17
|
+
|
|
18
|
+
# Strings
|
|
19
|
+
|
|
20
|
+
'foo' "bar"
|
|
21
|
+
b'baz'
|
|
22
|
+
'''long string
|
|
23
|
+
on two lines'''
|
|
24
|
+
|
|
25
|
+
"""also with double
|
|
26
|
+
|
|
27
|
+
quotes"""
|
|
28
|
+
|
|
29
|
+
==>
|
|
30
|
+
|
|
31
|
+
Script(ExpressionStatement(ContinuedString(String, String)),
|
|
32
|
+
ExpressionStatement(String),
|
|
33
|
+
ExpressionStatement(String),
|
|
34
|
+
ExpressionStatement(String))
|
|
35
|
+
|
|
36
|
+
# Raw string
|
|
37
|
+
|
|
38
|
+
r"foo\"" + r'\\'
|
|
39
|
+
|
|
40
|
+
==>
|
|
41
|
+
|
|
42
|
+
Script(ExpressionStatement(BinaryExpression(String,ArithOp,String)))
|
|
43
|
+
|
|
44
|
+
# Bracketed continued string
|
|
45
|
+
|
|
46
|
+
print('00300:'
|
|
47
|
+
'03630:')
|
|
48
|
+
|
|
49
|
+
==>
|
|
50
|
+
|
|
51
|
+
Script(ExpressionStatement(CallExpression(VariableName, ArgList(ContinuedString(String, String)))))
|
|
52
|
+
|
|
53
|
+
# Format strings
|
|
54
|
+
|
|
55
|
+
f'hello{22} abc\' {{ }} {d-1}'
|
|
56
|
+
f"double\" {quoted !s}"
|
|
57
|
+
f"""big long format
|
|
58
|
+
{string :foo}"""
|
|
59
|
+
f'''well {{ \x }} {2 :{bar}}'''
|
|
60
|
+
f"""one"{two}"three"""
|
|
61
|
+
f'{user=!s} {delta.days=:,d}'
|
|
62
|
+
|
|
63
|
+
==>
|
|
64
|
+
|
|
65
|
+
Script(ExpressionStatement(FormatString(FormatReplacement(Number),Escape,
|
|
66
|
+
FormatReplacement(BinaryExpression(VariableName, ArithOp, Number)))),
|
|
67
|
+
ExpressionStatement(FormatString(Escape,FormatReplacement(VariableName, FormatConversion))),
|
|
68
|
+
ExpressionStatement(FormatString(FormatReplacement(VariableName, FormatSpec))),
|
|
69
|
+
ExpressionStatement(FormatString(Escape,FormatReplacement(Number, FormatSpec(FormatReplacement(VariableName))))),
|
|
70
|
+
ExpressionStatement(FormatString(FormatReplacement(VariableName))),
|
|
71
|
+
ExpressionStatement(FormatString(
|
|
72
|
+
FormatReplacement(VariableName,FormatSelfDoc,FormatConversion),
|
|
73
|
+
FormatReplacement(MemberExpression(VariableName,PropertyName),FormatSelfDoc,FormatSpec))))
|
|
74
|
+
|
|
75
|
+
# Nested quote types
|
|
76
|
+
|
|
77
|
+
f"a{'b'}c"
|
|
78
|
+
|
|
79
|
+
==>
|
|
80
|
+
|
|
81
|
+
Script(ExpressionStatement(FormatString(FormatReplacement(String))))
|
|
82
|
+
|
|
83
|
+
# Lambda
|
|
84
|
+
|
|
85
|
+
something.map(lambda x: x + 1)
|
|
86
|
+
foo = lambda a, b = 0: a ^ b
|
|
87
|
+
|
|
88
|
+
==>
|
|
89
|
+
|
|
90
|
+
Script(
|
|
91
|
+
ExpressionStatement(CallExpression(MemberExpression(VariableName, PropertyName), ArgList(
|
|
92
|
+
LambdaExpression(lambda, ParamList(VariableName), BinaryExpression(VariableName, ArithOp, Number))))),
|
|
93
|
+
AssignStatement(VariableName, AssignOp, LambdaExpression(lambda, ParamList(VariableName, VariableName, AssignOp, Number),
|
|
94
|
+
BinaryExpression(VariableName, BitOp, VariableName))))
|
|
95
|
+
|
|
96
|
+
# Member expressions
|
|
97
|
+
|
|
98
|
+
x[1]
|
|
99
|
+
x.foo
|
|
100
|
+
x.if.True
|
|
101
|
+
|
|
102
|
+
==>
|
|
103
|
+
|
|
104
|
+
Script(
|
|
105
|
+
ExpressionStatement(MemberExpression(VariableName, Number)),
|
|
106
|
+
ExpressionStatement(MemberExpression(VariableName, PropertyName)),
|
|
107
|
+
ExpressionStatement(MemberExpression(MemberExpression(VariableName, PropertyName), PropertyName)))
|
|
108
|
+
|
|
109
|
+
# Call expressions
|
|
110
|
+
|
|
111
|
+
foo(x, y, **z) + bar(blah=20)
|
|
112
|
+
|
|
113
|
+
==>
|
|
114
|
+
|
|
115
|
+
Script(ExpressionStatement(BinaryExpression(
|
|
116
|
+
CallExpression(VariableName, ArgList(VariableName, VariableName, VariableName)),
|
|
117
|
+
ArithOp,
|
|
118
|
+
CallExpression(VariableName, ArgList(VariableName, AssignOp, Number)))))
|
|
119
|
+
|
|
120
|
+
# Collection expressions
|
|
121
|
+
|
|
122
|
+
[True, False, None]
|
|
123
|
+
{foo: 22, bar: False, **other}
|
|
124
|
+
{1, 2, 3}
|
|
125
|
+
(3)
|
|
126
|
+
(3,)
|
|
127
|
+
(3, 4)
|
|
128
|
+
|
|
129
|
+
==>
|
|
130
|
+
|
|
131
|
+
Script(
|
|
132
|
+
ExpressionStatement(ArrayExpression(Boolean, Boolean, None)),
|
|
133
|
+
ExpressionStatement(DictionaryExpression(VariableName, Number, VariableName, Boolean, VariableName)),
|
|
134
|
+
ExpressionStatement(SetExpression(Number, Number, Number)),
|
|
135
|
+
ExpressionStatement(ParenthesizedExpression(Number)),
|
|
136
|
+
ExpressionStatement(TupleExpression(Number)),
|
|
137
|
+
ExpressionStatement(TupleExpression(Number, Number)))
|
|
138
|
+
|
|
139
|
+
# Comprehension expressions
|
|
140
|
+
|
|
141
|
+
[i + 1 for i in range(1, 10) if x % 2 == 0]
|
|
142
|
+
(x for x in [3, 4])
|
|
143
|
+
{key: value for (key, value) in blah}
|
|
144
|
+
{a - b for a in foo for b in bar}
|
|
145
|
+
|
|
146
|
+
==>
|
|
147
|
+
|
|
148
|
+
Script(
|
|
149
|
+
ExpressionStatement(ArrayComprehensionExpression(
|
|
150
|
+
BinaryExpression(VariableName, ArithOp, Number),
|
|
151
|
+
for VariableName in CallExpression(VariableName, ArgList(Number, Number)),
|
|
152
|
+
if BinaryExpression(BinaryExpression(VariableName, ArithOp, Number), CompareOp, Number))),
|
|
153
|
+
ExpressionStatement(ComprehensionExpression(
|
|
154
|
+
VariableName, for, VariableName, in, ArrayExpression(Number, Number))),
|
|
155
|
+
ExpressionStatement(DictionaryComprehensionExpression(
|
|
156
|
+
VariableName, VariableName, for, TupleExpression(VariableName, VariableName) in VariableName)),
|
|
157
|
+
ExpressionStatement(SetComprehensionExpression(
|
|
158
|
+
BinaryExpression(VariableName, ArithOp, VariableName), for, VariableName, in, VariableName,
|
|
159
|
+
for, VariableName, in, VariableName)))
|
|
160
|
+
|
|
161
|
+
# Yield expressions
|
|
162
|
+
|
|
163
|
+
def foo():
|
|
164
|
+
yield 1
|
|
165
|
+
return 1 + (yield 2)
|
|
166
|
+
|
|
167
|
+
==>
|
|
168
|
+
|
|
169
|
+
Script(FunctionDefinition(def, VariableName, ParamList, Body(
|
|
170
|
+
YieldStatement(yield, Number),
|
|
171
|
+
ReturnStatement(return, BinaryExpression(Number, ArithOp, ParenthesizedExpression(YieldExpression(yield, Number)))))))
|
|
172
|
+
|
|
173
|
+
# Unary expressions
|
|
174
|
+
|
|
175
|
+
[-1, +2 * 3, ~2**2]
|
|
176
|
+
|
|
177
|
+
==>
|
|
178
|
+
|
|
179
|
+
Script(ExpressionStatement(ArrayExpression(
|
|
180
|
+
UnaryExpression(ArithOp, Number),
|
|
181
|
+
BinaryExpression(UnaryExpression(ArithOp, Number), ArithOp, Number),
|
|
182
|
+
UnaryExpression(BitOp, BinaryExpression(Number, ArithOp, Number)))))
|
|
183
|
+
|
|
184
|
+
# Await
|
|
185
|
+
|
|
186
|
+
await something()
|
|
187
|
+
|
|
188
|
+
==>
|
|
189
|
+
|
|
190
|
+
Script(ExpressionStatement(AwaitExpression(await, CallExpression(VariableName, ArgList))))
|
|
191
|
+
|
|
192
|
+
# Newlines in brackets
|
|
193
|
+
|
|
194
|
+
x = [
|
|
195
|
+
1, 2,
|
|
196
|
+
# And
|
|
197
|
+
3, 4,
|
|
198
|
+
]
|
|
199
|
+
|
|
200
|
+
==>
|
|
201
|
+
|
|
202
|
+
Script(AssignStatement(VariableName, AssignOp, ArrayExpression(Number, Number, Comment, Number, Number)))
|
|
203
|
+
|
|
204
|
+
# Too many commas in brackets
|
|
205
|
+
|
|
206
|
+
x = [
|
|
207
|
+
1, 2,,
|
|
208
|
+
]
|
|
209
|
+
|
|
210
|
+
==>
|
|
211
|
+
|
|
212
|
+
Script(AssignStatement(VariableName, AssignOp, ArrayExpression(Number, Number, ⚠)))
|
|
213
|
+
|
|
214
|
+
# Conditional expression
|
|
215
|
+
|
|
216
|
+
x = 5 if True else 1 if False else 0
|
|
217
|
+
|
|
218
|
+
==>
|
|
219
|
+
|
|
220
|
+
Script(AssignStatement(VariableName, AssignOp, ConditionalExpression(Number, if, Boolean, else,
|
|
221
|
+
ConditionalExpression(Number, if, Boolean, else, Number))))
|
|
222
|
+
|
|
223
|
+
# Exponent is R-to-L associative
|
|
224
|
+
|
|
225
|
+
2 ** 3 ** 2
|
|
226
|
+
|
|
227
|
+
==>
|
|
228
|
+
|
|
229
|
+
Script(ExpressionStatement(BinaryExpression(
|
|
230
|
+
Number,ArithOp("**"),
|
|
231
|
+
BinaryExpression(Number,ArithOp("**"),Number))))
|
|
@@ -0,0 +1,442 @@
|
|
|
1
|
+
# Function definition
|
|
2
|
+
|
|
3
|
+
def foo():
|
|
4
|
+
pass
|
|
5
|
+
def bar(a: str, b = 22, **c) -> num:
|
|
6
|
+
pass
|
|
7
|
+
|
|
8
|
+
==>
|
|
9
|
+
|
|
10
|
+
Script(
|
|
11
|
+
FunctionDefinition(def,VariableName,ParamList,Body(PassStatement(pass))),
|
|
12
|
+
FunctionDefinition(def,VariableName,ParamList(VariableName, TypeDef(VariableName), VariableName, AssignOp, Number, VariableName),
|
|
13
|
+
TypeDef(VariableName), Body(PassStatement(pass))))
|
|
14
|
+
|
|
15
|
+
# Single-line function definition
|
|
16
|
+
|
|
17
|
+
def foo(a, b): return a + b
|
|
18
|
+
|
|
19
|
+
==>
|
|
20
|
+
|
|
21
|
+
Script(FunctionDefinition(def,VariableName,ParamList(VariableName, VariableName),
|
|
22
|
+
Body(ReturnStatement(return, BinaryExpression(VariableName, ArithOp, VariableName)))))
|
|
23
|
+
|
|
24
|
+
# Return with no body
|
|
25
|
+
|
|
26
|
+
def foo(a, b):
|
|
27
|
+
a = b
|
|
28
|
+
return
|
|
29
|
+
|
|
30
|
+
==>
|
|
31
|
+
|
|
32
|
+
Script(FunctionDefinition(def,VariableName,ParamList(VariableName, VariableName),
|
|
33
|
+
Body(AssignStatement(VariableName, AssignOp, VariableName), ReturnStatement(return))))
|
|
34
|
+
|
|
35
|
+
# Conditional
|
|
36
|
+
|
|
37
|
+
if a: b()
|
|
38
|
+
|
|
39
|
+
if 1 + 3:
|
|
40
|
+
pass
|
|
41
|
+
elif 55 < 2:
|
|
42
|
+
pass
|
|
43
|
+
else:
|
|
44
|
+
pass
|
|
45
|
+
|
|
46
|
+
==>
|
|
47
|
+
|
|
48
|
+
Script(
|
|
49
|
+
IfStatement(if, VariableName, Body(ExpressionStatement(CallExpression(VariableName, ArgList))))
|
|
50
|
+
IfStatement(if, BinaryExpression(Number, ArithOp, Number), Body(PassStatement(pass)),
|
|
51
|
+
elif, BinaryExpression(Number, CompareOp, Number), Body(PassStatement(pass)),
|
|
52
|
+
else, Body(PassStatement(pass))))
|
|
53
|
+
|
|
54
|
+
# Assignment
|
|
55
|
+
|
|
56
|
+
a = 4
|
|
57
|
+
b: str = "hi"
|
|
58
|
+
c, d, e = None
|
|
59
|
+
f = g = False
|
|
60
|
+
h += 1
|
|
61
|
+
|
|
62
|
+
==>
|
|
63
|
+
|
|
64
|
+
Script(
|
|
65
|
+
AssignStatement(VariableName, AssignOp, Number),
|
|
66
|
+
AssignStatement(VariableName, TypeDef(VariableName), AssignOp, String),
|
|
67
|
+
AssignStatement(VariableName, VariableName, VariableName, AssignOp, None),
|
|
68
|
+
AssignStatement(VariableName, AssignOp, VariableName, AssignOp, Boolean),
|
|
69
|
+
UpdateStatement(VariableName, UpdateOp, Number))
|
|
70
|
+
|
|
71
|
+
# For loops
|
|
72
|
+
|
|
73
|
+
for a, b in woop():
|
|
74
|
+
doStuff(b, a)
|
|
75
|
+
|
|
76
|
+
==>
|
|
77
|
+
|
|
78
|
+
Script(ForStatement(for, VariableName, VariableName, in CallExpression(VariableName, ArgList),
|
|
79
|
+
Body(ExpressionStatement(CallExpression(VariableName, ArgList(VariableName, VariableName))))))
|
|
80
|
+
|
|
81
|
+
# Try statements
|
|
82
|
+
|
|
83
|
+
try:
|
|
84
|
+
pass
|
|
85
|
+
except SomeException as e:
|
|
86
|
+
pass
|
|
87
|
+
except OtherException:
|
|
88
|
+
pass
|
|
89
|
+
else:
|
|
90
|
+
pass
|
|
91
|
+
finally:
|
|
92
|
+
pass
|
|
93
|
+
|
|
94
|
+
==>
|
|
95
|
+
|
|
96
|
+
Script(TryStatement(
|
|
97
|
+
try, Body(PassStatement(pass)),
|
|
98
|
+
except, VariableName, as, VariableName, Body(PassStatement(pass)),
|
|
99
|
+
except VariableName, Body(PassStatement(pass)),
|
|
100
|
+
else Body(PassStatement(pass)),
|
|
101
|
+
finally Body(PassStatement(pass))))
|
|
102
|
+
|
|
103
|
+
# With statements
|
|
104
|
+
|
|
105
|
+
with open("x") as file:
|
|
106
|
+
pass
|
|
107
|
+
async with foo as bar:
|
|
108
|
+
pass
|
|
109
|
+
|
|
110
|
+
==>
|
|
111
|
+
|
|
112
|
+
Script(
|
|
113
|
+
WithStatement(with, CallExpression(VariableName, ArgList(String)), as, VariableName, Body(PassStatement(pass))),
|
|
114
|
+
WithStatement(async, with, VariableName, as, VariableName, Body(PassStatement(pass))))
|
|
115
|
+
|
|
116
|
+
# Class definition
|
|
117
|
+
|
|
118
|
+
class Foo:
|
|
119
|
+
prop = 0
|
|
120
|
+
def __init__(self):
|
|
121
|
+
pass
|
|
122
|
+
def plus(self):
|
|
123
|
+
self.prop += 1
|
|
124
|
+
|
|
125
|
+
class Bar(Foo): pass
|
|
126
|
+
|
|
127
|
+
==>
|
|
128
|
+
|
|
129
|
+
Script(
|
|
130
|
+
ClassDefinition(class, VariableName, Body(
|
|
131
|
+
AssignStatement(VariableName, AssignOp, Number),
|
|
132
|
+
FunctionDefinition(def, VariableName, ParamList(VariableName), Body(PassStatement(pass))),
|
|
133
|
+
FunctionDefinition(def, VariableName, ParamList(VariableName), Body(
|
|
134
|
+
UpdateStatement(MemberExpression(VariableName, PropertyName), UpdateOp, Number))))),
|
|
135
|
+
ClassDefinition(class, VariableName, ArgList(VariableName), Body(PassStatement(pass))))
|
|
136
|
+
|
|
137
|
+
# Scope statements
|
|
138
|
+
|
|
139
|
+
global a
|
|
140
|
+
nonlocal b, c
|
|
141
|
+
|
|
142
|
+
==>
|
|
143
|
+
|
|
144
|
+
Script(
|
|
145
|
+
ScopeStatement(global, VariableName),
|
|
146
|
+
ScopeStatement(nonlocal, VariableName, VariableName))
|
|
147
|
+
|
|
148
|
+
# Decorators
|
|
149
|
+
|
|
150
|
+
@Something.X
|
|
151
|
+
def f(): pass
|
|
152
|
+
|
|
153
|
+
@Other(arg1, arg2)
|
|
154
|
+
class C: pass
|
|
155
|
+
|
|
156
|
+
==>
|
|
157
|
+
|
|
158
|
+
Script(
|
|
159
|
+
DecoratedStatement(Decorator(At, VariableName, VariableName),
|
|
160
|
+
FunctionDefinition(def, VariableName, ParamList, Body(PassStatement(pass)))),
|
|
161
|
+
DecoratedStatement(Decorator(At, VariableName, ArgList(VariableName, VariableName)),
|
|
162
|
+
ClassDefinition(class, VariableName, Body(PassStatement(pass)))))
|
|
163
|
+
|
|
164
|
+
# Small statements
|
|
165
|
+
|
|
166
|
+
def x(): return 5
|
|
167
|
+
raise Exception("woop")
|
|
168
|
+
while False:
|
|
169
|
+
break
|
|
170
|
+
continue
|
|
171
|
+
assert 1 == 2
|
|
172
|
+
del x[2]
|
|
173
|
+
|
|
174
|
+
==>
|
|
175
|
+
|
|
176
|
+
Script(
|
|
177
|
+
FunctionDefinition(def, VariableName, ParamList, Body(ReturnStatement(return, Number))),
|
|
178
|
+
RaiseStatement(raise, CallExpression(VariableName, ArgList(String))),
|
|
179
|
+
WhileStatement(while, Boolean, Body(BreakStatement(break), ContinueStatement(continue))),
|
|
180
|
+
AssertStatement(assert, BinaryExpression(Number, CompareOp, Number)),
|
|
181
|
+
DeleteStatement(del, MemberExpression(VariableName, Number)))
|
|
182
|
+
|
|
183
|
+
# Import statements
|
|
184
|
+
|
|
185
|
+
import datetime
|
|
186
|
+
from something.other import one, two
|
|
187
|
+
|
|
188
|
+
==>
|
|
189
|
+
|
|
190
|
+
Script(
|
|
191
|
+
ImportStatement(import, VariableName),
|
|
192
|
+
ImportStatement(from, VariableName, VariableName, import VariableName, VariableName))
|
|
193
|
+
|
|
194
|
+
# One-line small statements
|
|
195
|
+
|
|
196
|
+
x; y(); z = 2
|
|
197
|
+
raise "oh"
|
|
198
|
+
|
|
199
|
+
==>
|
|
200
|
+
|
|
201
|
+
Script(
|
|
202
|
+
StatementGroup(
|
|
203
|
+
ExpressionStatement(VariableName),
|
|
204
|
+
ExpressionStatement(CallExpression(VariableName, ArgList)),
|
|
205
|
+
AssignStatement(VariableName, AssignOp, Number)),
|
|
206
|
+
RaiseStatement(raise, String))
|
|
207
|
+
|
|
208
|
+
# Nested bodies
|
|
209
|
+
|
|
210
|
+
def x():
|
|
211
|
+
ok
|
|
212
|
+
if not ok:
|
|
213
|
+
while True:
|
|
214
|
+
one
|
|
215
|
+
two
|
|
216
|
+
three
|
|
217
|
+
if None:
|
|
218
|
+
four
|
|
219
|
+
else:
|
|
220
|
+
five
|
|
221
|
+
six
|
|
222
|
+
seven
|
|
223
|
+
|
|
224
|
+
==>
|
|
225
|
+
|
|
226
|
+
Script(
|
|
227
|
+
FunctionDefinition(def, VariableName, ParamList, Body(
|
|
228
|
+
ExpressionStatement(VariableName),
|
|
229
|
+
IfStatement(if, UnaryExpression(not, VariableName), Body(
|
|
230
|
+
WhileStatement(while, Boolean, Body(
|
|
231
|
+
ExpressionStatement(VariableName),
|
|
232
|
+
ExpressionStatement(VariableName))))),
|
|
233
|
+
ExpressionStatement(VariableName),
|
|
234
|
+
IfStatement(if, None, Body(
|
|
235
|
+
ExpressionStatement(VariableName)
|
|
236
|
+
), else, Body(
|
|
237
|
+
ExpressionStatement(VariableName))),
|
|
238
|
+
ExpressionStatement(VariableName))),
|
|
239
|
+
ExpressionStatement(VariableName))
|
|
240
|
+
|
|
241
|
+
# Empty and commented lines
|
|
242
|
+
|
|
243
|
+
if None:
|
|
244
|
+
one
|
|
245
|
+
|
|
246
|
+
two
|
|
247
|
+
|
|
248
|
+
four
|
|
249
|
+
# comment
|
|
250
|
+
five
|
|
251
|
+
six
|
|
252
|
+
|
|
253
|
+
==>
|
|
254
|
+
|
|
255
|
+
Script(
|
|
256
|
+
IfStatement(if, None, Body(
|
|
257
|
+
ExpressionStatement(VariableName),
|
|
258
|
+
ExpressionStatement(VariableName),
|
|
259
|
+
ExpressionStatement(VariableName),
|
|
260
|
+
Comment,
|
|
261
|
+
ExpressionStatement(VariableName))),
|
|
262
|
+
ExpressionStatement(VariableName))
|
|
263
|
+
|
|
264
|
+
# Script ending in a comment
|
|
265
|
+
|
|
266
|
+
x = 1
|
|
267
|
+
|
|
268
|
+
# End
|
|
269
|
+
|
|
270
|
+
==>
|
|
271
|
+
|
|
272
|
+
Script(AssignStatement(VariableName,AssignOp,Number),Comment)
|
|
273
|
+
|
|
274
|
+
# Escaped newlines
|
|
275
|
+
|
|
276
|
+
x = 1 + \
|
|
277
|
+
2
|
|
278
|
+
|
|
279
|
+
==>
|
|
280
|
+
|
|
281
|
+
Script(AssignStatement(VariableName, AssignOp, BinaryExpression(Number, ArithOp, Number)))
|
|
282
|
+
|
|
283
|
+
# Python 2 compatibility
|
|
284
|
+
|
|
285
|
+
print "hi"
|
|
286
|
+
print(print.something)
|
|
287
|
+
|
|
288
|
+
try:
|
|
289
|
+
raise Exception, "foo"
|
|
290
|
+
except Exception, foo:
|
|
291
|
+
pass
|
|
292
|
+
|
|
293
|
+
==>
|
|
294
|
+
|
|
295
|
+
Script(
|
|
296
|
+
PrintStatement(print, String),
|
|
297
|
+
ExpressionStatement(CallExpression(VariableName, ArgList(MemberExpression(VariableName, PropertyName)))),
|
|
298
|
+
TryStatement(try, Body(RaiseStatement(raise, VariableName, String)),
|
|
299
|
+
except, VariableName, VariableName, Body(PassStatement(pass))))
|
|
300
|
+
|
|
301
|
+
# Require indentation on body
|
|
302
|
+
|
|
303
|
+
def foo():
|
|
304
|
+
pass
|
|
305
|
+
|
|
306
|
+
==>
|
|
307
|
+
|
|
308
|
+
Script(FunctionDefinition(def,VariableName,ParamList,Body(⚠)), PassStatement(pass))
|
|
309
|
+
|
|
310
|
+
# Nested else
|
|
311
|
+
|
|
312
|
+
if a:
|
|
313
|
+
if b:
|
|
314
|
+
pass
|
|
315
|
+
else:
|
|
316
|
+
pass
|
|
317
|
+
|
|
318
|
+
==>
|
|
319
|
+
|
|
320
|
+
Script(IfStatement(if, VariableName, Body(
|
|
321
|
+
IfStatement(if, VariableName, Body(PassStatement(pass)))),
|
|
322
|
+
else, Body(PassStatement(pass))))
|
|
323
|
+
|
|
324
|
+
# Self not reserved
|
|
325
|
+
|
|
326
|
+
self = True
|
|
327
|
+
|
|
328
|
+
==>
|
|
329
|
+
|
|
330
|
+
Script(AssignStatement(VariableName,AssignOp,Boolean))
|
|
331
|
+
|
|
332
|
+
# Trailing whitespace in block
|
|
333
|
+
|
|
334
|
+
def x():
|
|
335
|
+
one
|
|
336
|
+
|
|
337
|
+
two
|
|
338
|
+
|
|
339
|
+
==>
|
|
340
|
+
|
|
341
|
+
Script(FunctionDefinition(def,VariableName,ParamList,Body(ExpressionStatement(VariableName),ExpressionStatement(VariableName))))
|
|
342
|
+
|
|
343
|
+
# Can handle tab indentation
|
|
344
|
+
|
|
345
|
+
class Employee:
|
|
346
|
+
first_name: str
|
|
347
|
+
last_name: str
|
|
348
|
+
|
|
349
|
+
def __init__(self, a):
|
|
350
|
+
self.first_name = a
|
|
351
|
+
self.last_name = a
|
|
352
|
+
|
|
353
|
+
==>
|
|
354
|
+
|
|
355
|
+
Script(ClassDefinition(class,VariableName,Body(
|
|
356
|
+
AssignStatement(VariableName,TypeDef(VariableName)),
|
|
357
|
+
AssignStatement(VariableName,TypeDef(VariableName)),
|
|
358
|
+
FunctionDefinition(def,VariableName,ParamList(VariableName,VariableName),Body(
|
|
359
|
+
AssignStatement(MemberExpression(VariableName,PropertyName),AssignOp,VariableName),
|
|
360
|
+
AssignStatement(MemberExpression(VariableName,PropertyName),AssignOp,VariableName))))))
|
|
361
|
+
|
|
362
|
+
# Parses match statements
|
|
363
|
+
|
|
364
|
+
match foo:
|
|
365
|
+
case 1:
|
|
366
|
+
pass
|
|
367
|
+
case Point("a", True) as z | a.b | {x: None, **y}:
|
|
368
|
+
pass
|
|
369
|
+
case [a, b, *rest] | (p, q):
|
|
370
|
+
pass
|
|
371
|
+
case (1, 2) if bar == 2:
|
|
372
|
+
pass
|
|
373
|
+
|
|
374
|
+
==>
|
|
375
|
+
|
|
376
|
+
Script(MatchStatement(match,VariableName,MatchBody(
|
|
377
|
+
MatchClause(case,
|
|
378
|
+
LiteralPattern(Number),
|
|
379
|
+
Body(PassStatement(pass))),
|
|
380
|
+
MatchClause(case,
|
|
381
|
+
OrPattern(
|
|
382
|
+
AsPattern(
|
|
383
|
+
ClassPattern(VariableName,PatternArgList(LiteralPattern(String),LiteralPattern(Boolean))),
|
|
384
|
+
as,VariableName),
|
|
385
|
+
LogicOp,
|
|
386
|
+
AttributePattern(VariableName,PropertyName),
|
|
387
|
+
LogicOp,
|
|
388
|
+
MappingPattern(VariableName,LiteralPattern(None),CapturePattern(VariableName))),
|
|
389
|
+
Body(PassStatement(pass))),
|
|
390
|
+
MatchClause(case,
|
|
391
|
+
OrPattern(SequencePattern(
|
|
392
|
+
CapturePattern(VariableName),
|
|
393
|
+
CapturePattern(VariableName),
|
|
394
|
+
StarPattern(CapturePattern(VariableName))),
|
|
395
|
+
LogicOp,
|
|
396
|
+
SequencePattern(CapturePattern(VariableName),CapturePattern(VariableName))),
|
|
397
|
+
Body(PassStatement(pass))),
|
|
398
|
+
MatchClause(case,
|
|
399
|
+
SequencePattern(LiteralPattern(Number),LiteralPattern(Number)),
|
|
400
|
+
Guard(if,BinaryExpression(VariableName,CompareOp,Number)),
|
|
401
|
+
Body(PassStatement(pass))))))
|
|
402
|
+
|
|
403
|
+
# Type Params
|
|
404
|
+
|
|
405
|
+
class ClassA[T: str]:
|
|
406
|
+
def method1(self) -> T:
|
|
407
|
+
pass
|
|
408
|
+
|
|
409
|
+
def func[**T](a: T, b: T) -> T:
|
|
410
|
+
pass
|
|
411
|
+
|
|
412
|
+
==>
|
|
413
|
+
|
|
414
|
+
Script(
|
|
415
|
+
ClassDefinition(class,VariableName,
|
|
416
|
+
TypeParamList(TypeParam(VariableName,TypeDef(":",VariableName))),
|
|
417
|
+
Body(FunctionDefinition(def,VariableName,ParamList(VariableName),TypeDef(VariableName),
|
|
418
|
+
Body(PassStatement(pass))))),
|
|
419
|
+
FunctionDefinition(def,VariableName,TypeParamList(TypeParam(VariableName)),
|
|
420
|
+
ParamList(VariableName,TypeDef(VariableName),VariableName,TypeDef(VariableName)),
|
|
421
|
+
TypeDef(VariableName),
|
|
422
|
+
Body(PassStatement(pass))))
|
|
423
|
+
|
|
424
|
+
# Type Definition
|
|
425
|
+
|
|
426
|
+
type Point = tuple[float, float]
|
|
427
|
+
|
|
428
|
+
==>
|
|
429
|
+
|
|
430
|
+
Script(TypeDefinition(type,VariableName,MemberExpression(VariableName,VariableName,",",VariableName)))
|
|
431
|
+
|
|
432
|
+
# Rest arg with type
|
|
433
|
+
|
|
434
|
+
def f(*args: tuple[int]) -> int:
|
|
435
|
+
return 1
|
|
436
|
+
|
|
437
|
+
==>
|
|
438
|
+
|
|
439
|
+
Script(FunctionDefinition(def,VariableName,
|
|
440
|
+
ParamList(VariableName,TypeDef(MemberExpression(VariableName,VariableName))),
|
|
441
|
+
TypeDef(VariableName),
|
|
442
|
+
Body(ReturnStatement(return,Number))))
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import {parser} from "../dist/index.js"
|
|
2
|
+
import {fileTests} from "@lezer/generator/dist/test"
|
|
3
|
+
import {Tree, TreeFragment} from "@lezer/common"
|
|
4
|
+
|
|
5
|
+
describe("Incremental parsing", () => {
|
|
6
|
+
// See https://github.com/codemirror/codemirror.next/issues/394
|
|
7
|
+
it("doesn't reuse statements in the wrong body", () => {
|
|
8
|
+
let input = `class StreamWriter:
|
|
9
|
+
def __init__(self):
|
|
10
|
+
pass
|
|
11
|
+
|
|
12
|
+
def a():
|
|
13
|
+
pass
|
|
14
|
+
|
|
15
|
+
def b(self):
|
|
16
|
+
""" ${"big block comment to fill up the reuse size quota\n ".repeat(150)} """
|
|
17
|
+
pass
|
|
18
|
+
`
|
|
19
|
+
let ast = parser.parse(input)
|
|
20
|
+
let at = input.indexOf("pass")
|
|
21
|
+
input = input.slice(0, at) + " " + input.slice(at)
|
|
22
|
+
let cache = TreeFragment.applyChanges(TreeFragment.addTree(ast), [{fromA: at, toA: at, fromB: at, toB: at + 1}])
|
|
23
|
+
let ast2 = parser.parse(input, cache)
|
|
24
|
+
if (ast2.toString() != ast.toString()) throw new Error("Malformed tree")
|
|
25
|
+
|
|
26
|
+
let lastFunc = ast => {
|
|
27
|
+
let cur = ast.cursor(ast.length)
|
|
28
|
+
while (cur.type.name != "FunctionDefinition") cur.prev()
|
|
29
|
+
return cur.tree
|
|
30
|
+
}
|
|
31
|
+
if (lastFunc(ast) != lastFunc(ast2)) throw new Error("No reuse")
|
|
32
|
+
})
|
|
33
|
+
})
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {parser} from "../dist/index.js"
|
|
2
|
+
import {fileTests} from "@lezer/generator/dist/test"
|
|
3
|
+
|
|
4
|
+
import * as fs from "fs"
|
|
5
|
+
import * as path from "path"
|
|
6
|
+
import {fileURLToPath} from "url"
|
|
7
|
+
let caseDir = path.dirname(fileURLToPath(import.meta.url))
|
|
8
|
+
|
|
9
|
+
for (let file of fs.readdirSync(caseDir)) {
|
|
10
|
+
if (!/\.txt$/.test(file)) continue
|
|
11
|
+
|
|
12
|
+
let name = /^[^\.]*/.exec(file)[0]
|
|
13
|
+
describe(name, () => {
|
|
14
|
+
for (let {name, run} of fileTests(fs.readFileSync(path.join(caseDir, file), "utf8"), file))
|
|
15
|
+
it(name, () => run(parser))
|
|
16
|
+
})
|
|
17
|
+
}
|