@backbencher/brain 0.0.0-stage → 0.1.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/CHANGELOG.md +298 -0
- package/EMBEDDINGS.md +355 -0
- package/LICENSE +21 -0
- package/README.md +415 -2
- package/bin/bb +13 -0
- package/dist/analysis-exclusions-7ZJDXOVZ.js +35 -0
- package/dist/brain-index-health-KY7K552E.js +17 -0
- package/dist/brain-relationship-enrichment-QH7OOHUF.js +558 -0
- package/dist/brain.sql-EIM4WS4D.js +29 -0
- package/dist/chunk-2BSKD7O3.js +40 -0
- package/dist/chunk-2DE27DVC.js +1314 -0
- package/dist/chunk-2RRBMNBQ.js +322 -0
- package/dist/chunk-2RTN2DFU.js +711 -0
- package/dist/chunk-2WXYNLBA.js +29 -0
- package/dist/chunk-3CTFIJJB.js +17 -0
- package/dist/chunk-3LFTSMIV.js +174 -0
- package/dist/chunk-47HKX4AJ.js +930 -0
- package/dist/chunk-4H22TLOT.js +543 -0
- package/dist/chunk-5SD45FLC.js +818 -0
- package/dist/chunk-66A5ZFYA.js +1758 -0
- package/dist/chunk-6AIRWAO2.js +247 -0
- package/dist/chunk-6WNGD3NN.js +196 -0
- package/dist/chunk-7AN7U5IZ.js +371 -0
- package/dist/chunk-BHB7BYYI.js +626 -0
- package/dist/chunk-BQ3OVQ3P.js +125 -0
- package/dist/chunk-CW4XXSNN.js +1479 -0
- package/dist/chunk-D2Q4Y47A.js +53 -0
- package/dist/chunk-DIYAGQJL.js +34 -0
- package/dist/chunk-DYM4FQEE.js +90 -0
- package/dist/chunk-EWMWK7WN.js +75 -0
- package/dist/chunk-FVVQTSIM.js +3427 -0
- package/dist/chunk-FWSL4VG6.js +1290 -0
- package/dist/chunk-GBI7V7KY.js +69 -0
- package/dist/chunk-GEFFO6O2.js +152 -0
- package/dist/chunk-HOWAQXJO.js +236 -0
- package/dist/chunk-HQSPJDHI.js +613 -0
- package/dist/chunk-IFZNR5UJ.js +2863 -0
- package/dist/chunk-J4PMBXQQ.js +336 -0
- package/dist/chunk-KAET47ZL.js +125 -0
- package/dist/chunk-KCDECRJY.js +440 -0
- package/dist/chunk-KLK3PBTO.js +1119 -0
- package/dist/chunk-L5TDYKYK.js +76 -0
- package/dist/chunk-MLKGABMK.js +9 -0
- package/dist/chunk-OWISBAOF.js +61 -0
- package/dist/chunk-PJTNGD3Z.js +6924 -0
- package/dist/chunk-QLK6ED4Q.js +235 -0
- package/dist/chunk-R2GW4F6R.js +19 -0
- package/dist/chunk-RCMTFSEF.js +87 -0
- package/dist/chunk-RH7KC5HU.js +12050 -0
- package/dist/chunk-RM3PY6TG.js +376 -0
- package/dist/chunk-ROMM6KMC.js +433 -0
- package/dist/chunk-SK6YVHFZ.js +211 -0
- package/dist/chunk-SM7RFQRO.js +214 -0
- package/dist/chunk-UFE77L67.js +782 -0
- package/dist/chunk-UGR4QIGS.js +67 -0
- package/dist/chunk-UUNHHX4M.js +13 -0
- package/dist/chunk-V44PGPA6.js +2104 -0
- package/dist/chunk-VL52PL2T.js +71 -0
- package/dist/chunk-VURYFIHW.js +201 -0
- package/dist/chunk-XJKJYIPP.js +7436 -0
- package/dist/chunk-YI6FF2ZR.js +340 -0
- package/dist/cli/index.js +37 -0
- package/dist/config-HZAAYDP3.js +10 -0
- package/dist/content-search-642F7E5V.js +593 -0
- package/dist/database-TCTZDLE5.js +9 -0
- package/dist/doctor-GXCKSJOX.js +395 -0
- package/dist/edit-engine-KM7MPFEC.js +51 -0
- package/dist/engine-42TZFNIZ.js +11 -0
- package/dist/engine-LO6L4JLQ.js +18 -0
- package/dist/fingerprint-XDXFRWO6.js +33 -0
- package/dist/framework-intelligence-DWFCKV44.js +860 -0
- package/dist/freshness-3K6VU5OT.js +174 -0
- package/dist/graph-engine-PL5YA7BA.js +21 -0
- package/dist/graph_request-MM4REP6H.js +350 -0
- package/dist/impact_request-WDE47IZ5.js +68 -0
- package/dist/index-space-IUUN5WYV.js +15 -0
- package/dist/index-status-6BD7UBHR.js +34 -0
- package/dist/index.js +159 -0
- package/dist/instance-FO6QZRLH.js +19 -0
- package/dist/language-detection-DFCAU5DZ.js +11 -0
- package/dist/lsp/server.js +4301 -0
- package/dist/mcp/server.js +132 -0
- package/dist/onboard-DIQZV2NW.js +161 -0
- package/dist/override-companion-pass-XR7MHTP7.js +117 -0
- package/dist/parallel-indexer-4PW3AFXP.js +88 -0
- package/dist/pool-worker.js +1153 -0
- package/dist/project-health-ZS5TS2Z6.js +94 -0
- package/dist/project-index-5SDPHITE.js +57 -0
- package/dist/project-registry-DGZBIZS7.js +355 -0
- package/dist/real-bash-analyzer-SXSV67E2.js +2201 -0
- package/dist/real-c-analyzer-SY7FTZ6W.js +5942 -0
- package/dist/real-clean-analyzer-IGDHHLZK.js +3470 -0
- package/dist/real-clojure-analyzer-4OH7IWLB.js +2818 -0
- package/dist/real-cpp-analyzer-7LTDRJRJ.js +4101 -0
- package/dist/real-csharp-analyzer-KICU3TLH.js +3298 -0
- package/dist/real-css-analyzer-HPU277Q6.js +15 -0
- package/dist/real-dart-analyzer-7LZ5LCMW.js +3944 -0
- package/dist/real-elixir-analyzer-BE3MEVZO.js +2192 -0
- package/dist/real-erlang-analyzer-BZMAKYBK.js +1731 -0
- package/dist/real-fsharp-analyzer-5QLTOV3E.js +2390 -0
- package/dist/real-go-analyzer-POD7MZQR.js +4126 -0
- package/dist/real-graphql-analyzer-MAQRZ6QW.js +1442 -0
- package/dist/real-groovy-analyzer-MEWSUPMJ.js +2285 -0
- package/dist/real-haskell-analyzer-I5L2GR3Y.js +2533 -0
- package/dist/real-hcl-analyzer-DBOPXSWJ.js +725 -0
- package/dist/real-html-analyzer-O63XZLZD.js +1759 -0
- package/dist/real-java-analyzer-CHCW3EKA.js +4677 -0
- package/dist/real-javascript-analyzer-QAAJQYZE.js +14 -0
- package/dist/real-json-analyzer-UGBR7YQN.js +1640 -0
- package/dist/real-julia-analyzer-35Q4GHOZ.js +2085 -0
- package/dist/real-kotlin-analyzer-GRAYCWW2.js +3956 -0
- package/dist/real-lua-analyzer-5BAPDZDF.js +1957 -0
- package/dist/real-makefile-analyzer-YJKAHNAS.js +920 -0
- package/dist/real-markdown-analyzer-UKUQZO4F.js +1215 -0
- package/dist/real-matlab-analyzer-FVIKQZKG.js +480 -0
- package/dist/real-nim-analyzer-M7FAIABG.js +3603 -0
- package/dist/real-objective-c-analyzer-XMYQIGQI.js +1518 -0
- package/dist/real-perl-analyzer-ZLY6M2DZ.js +1865 -0
- package/dist/real-php-analyzer-KI2ZAM7X.js +9368 -0
- package/dist/real-powershell-analyzer-B3T5ZP6U.js +2915 -0
- package/dist/real-protobuf-analyzer-23OZ75XV.js +867 -0
- package/dist/real-python-analyzer-I4TIUB6D.js +4880 -0
- package/dist/real-r-analyzer-FJZJXXS6.js +2596 -0
- package/dist/real-ruby-analyzer-M3UFIVTQ.js +2429 -0
- package/dist/real-rust-analyzer-LVSONPAN.js +3359 -0
- package/dist/real-scala-analyzer-CWPI33Q2.js +3293 -0
- package/dist/real-scss-analyzer-TGRJQ7TH.js +1515 -0
- package/dist/real-solidity-analyzer-4P2VBVWA.js +2608 -0
- package/dist/real-sql-analyzer-J7DYZOZR.js +3840 -0
- package/dist/real-svelte-analyzer-NHEN2SX5.js +2532 -0
- package/dist/real-swift-analyzer-2NSYULWI.js +2311 -0
- package/dist/real-toml-analyzer-L3C66L7Q.js +929 -0
- package/dist/real-typescript-analyzer-FTC6ETRQ.js +14 -0
- package/dist/real-vb-analyzer-ORY7LAQS.js +3145 -0
- package/dist/real-vba-analyzer-JH2TTUFI.js +466 -0
- package/dist/real-vue-analyzer-OO4FUGBV.js +2680 -0
- package/dist/real-xml-analyzer-6CQVR477.js +2405 -0
- package/dist/real-yaml-analyzer-J6MQG3YX.js +3528 -0
- package/dist/real-zig-analyzer-EFKCPJNU.js +2430 -0
- package/dist/regex-search-OPTLKUN5.js +239 -0
- package/dist/rules-I453JTRC.js +152 -0
- package/dist/scoped-path-MJYWJZQX.js +11 -0
- package/dist/setup-show-Y5GB5KXA.js +15 -0
- package/dist/setup-wizard-G5YYR5T6.js +24 -0
- package/dist/symbol-search-KB4MU4SI.js +16 -0
- package/dist/taint-YOTN5X55.js +202 -0
- package/dist/taint-analyzer-N7YLZU3N.js +163 -0
- package/dist/tool-handlers-G4NAGJIH.js +72 -0
- package/dist/tool-registry-BPEJNSZG.js +17 -0
- package/dist/tool-validation-RF675A3C.js +32 -0
- package/dist/type-inference-4Y7WTMFE.js +13 -0
- package/dist/vector-binary-LMY4QGAN.js +19 -0
- package/dist/version-LXGNFO37.js +9 -0
- package/dist/wasm-NMWO3WXY.js +16 -0
- package/docs/EMBEDDINGS.md +132 -0
- package/docs/README.md +178 -0
- package/docs/data/m10-baseline.json +602 -0
- package/docs/data/m10-benchmark-baseline.json +57 -0
- package/docs/data/m10-benchmark-last-run.json +127 -0
- package/docs/data/m10-final-audit.json +215 -0
- package/docs/data/m12-final-audit.json +138 -0
- package/docs/data/m12-surface-matrix.json +50 -0
- package/docs/data/public-tools.json +1902 -0
- package/docs/indexing/DEAD-ASSETS.md +88 -0
- package/docs/indexing/INDEXER-REVIEW.md +634 -0
- package/docs/indexing/PERFORMANCE-FINDINGS.md +106 -0
- package/docs/indexing/README.md +427 -0
- package/docs/indexing/discovery-matrix.md +41 -0
- package/docs/indexing/embeddings.md +325 -0
- package/docs/indexing/environment-variables.md +77 -0
- package/docs/indexing/performance.md +323 -0
- package/docs/indexing/resume.md +345 -0
- package/docs/indexing/troubleshooting.md +391 -0
- package/docs/man/bb.1 +190 -0
- package/docs/tools/bb_analyze.md +147 -0
- package/docs/tools/bb_annotate.md +110 -0
- package/docs/tools/bb_annotations.md +106 -0
- package/docs/tools/bb_ask.md +101 -0
- package/docs/tools/bb_cross_language.md +103 -0
- package/docs/tools/bb_doc.md +169 -0
- package/docs/tools/bb_edit.md +185 -0
- package/docs/tools/bb_graph.md +169 -0
- package/docs/tools/bb_health.md +156 -0
- package/docs/tools/bb_impact.md +117 -0
- package/docs/tools/bb_index.md +108 -0
- package/docs/tools/bb_migrate.md +135 -0
- package/docs/tools/bb_patterns.md +140 -0
- package/docs/tools/bb_search.md +150 -0
- package/docs/tools/bb_security.md +100 -0
- package/docs/tools/bb_visualize.md +184 -0
- package/grammars/README.md +57 -0
- package/grammars/THIRD-PARTY-NOTICES.md +50 -0
- package/grammars/tree-sitter-c/LICENSE +21 -0
- package/grammars/tree-sitter-clojure/LICENSE.md +21 -0
- package/grammars/tree-sitter-cpp/LICENSE +21 -0
- package/grammars/tree-sitter-csharp/LICENSE +21 -0
- package/grammars/tree-sitter-css/LICENSE +21 -0
- package/grammars/tree-sitter-css/README.md +21 -0
- package/grammars/tree-sitter-dart/LICENSE +20 -0
- package/grammars/tree-sitter-dart-upstream/LICENSE +20 -0
- package/grammars/tree-sitter-dart-upstream/README.md +18 -0
- package/grammars/tree-sitter-elixir/LICENSE +176 -0
- package/grammars/tree-sitter-elixir/README.md +11 -0
- package/grammars/tree-sitter-fsharp/LICENSE +21 -0
- package/grammars/tree-sitter-fsharp/README.md +45 -0
- package/grammars/tree-sitter-graphql/LICENSE +21 -0
- package/grammars/tree-sitter-graphql/README.md +106 -0
- package/grammars/tree-sitter-groovy/LICENSE +21 -0
- package/grammars/tree-sitter-groovy/README.md +4 -0
- package/grammars/tree-sitter-haskell/LICENSE +21 -0
- package/grammars/tree-sitter-haskell/README.md +394 -0
- package/grammars/tree-sitter-hcl/CHANGELOG.md +102 -0
- package/grammars/tree-sitter-hcl/LICENSE +201 -0
- package/grammars/tree-sitter-hcl/README.md +39 -0
- package/grammars/tree-sitter-html/LICENSE +21 -0
- package/grammars/tree-sitter-html/README.md +21 -0
- package/grammars/tree-sitter-julia/LICENSE +21 -0
- package/grammars/tree-sitter-julia/README.md +24 -0
- package/grammars/tree-sitter-kotlin/LICENSE +9 -0
- package/grammars/tree-sitter-lua/LICENSE.md +21 -0
- package/grammars/tree-sitter-lua/README.md +29 -0
- package/grammars/tree-sitter-make/LICENSE +21 -0
- package/grammars/tree-sitter-matlab/LICENSE +19 -0
- package/grammars/tree-sitter-matlab/README.md +99 -0
- package/grammars/tree-sitter-nim/LICENSE +373 -0
- package/grammars/tree-sitter-nim/README.md +46 -0
- package/grammars/tree-sitter-objc/LICENSE +21 -0
- package/grammars/tree-sitter-objc/README.md +20 -0
- package/grammars/tree-sitter-perl/LICENSE +7 -0
- package/grammars/tree-sitter-perl/README.md +100 -0
- package/grammars/tree-sitter-powershell/LICENSE +21 -0
- package/grammars/tree-sitter-powershell/README.md +7 -0
- package/grammars/tree-sitter-proto/LICENSE +21 -0
- package/grammars/tree-sitter-proto/README.md +105 -0
- package/grammars/tree-sitter-r/LICENSE +9 -0
- package/grammars/tree-sitter-r/README.md +66 -0
- package/grammars/tree-sitter-ruby/LICENSE +22 -0
- package/grammars/tree-sitter-scss/LICENSE +21 -0
- package/grammars/tree-sitter-scss/README.md +17 -0
- package/grammars/tree-sitter-solidity/LICENSE +7 -0
- package/grammars/tree-sitter-sql/LICENSE +21 -0
- package/grammars/tree-sitter-typescript/LICENSE +21 -0
- package/grammars/tree-sitter-vba/LICENSE +21 -0
- package/grammars/tree-sitter-vba/README.md +738 -0
- package/grammars/tree-sitter-vbnet/LICENSE +21 -0
- package/grammars/tree-sitter-vbnet/README.md +322 -0
- package/grammars/tree-sitter-xml/LICENSE +19 -0
- package/grammars/tree-sitter-yaml/LICENSE +20 -0
- package/grammars/tree-sitter-yaml/README.md +21 -0
- package/package.json +184 -4
- package/wasm/dart.wasm +0 -0
- package/wasm/tree-sitter-bash.wasm +0 -0
- package/wasm/tree-sitter-c.wasm +0 -0
- package/wasm/tree-sitter-c_sharp.wasm +0 -0
- package/wasm/tree-sitter-clean.wasm +0 -0
- package/wasm/tree-sitter-clojure.wasm +0 -0
- package/wasm/tree-sitter-core_schema.wasm +0 -0
- package/wasm/tree-sitter-cpp.wasm +0 -0
- package/wasm/tree-sitter-css.wasm +0 -0
- package/wasm/tree-sitter-dart.wasm +0 -0
- package/wasm/tree-sitter-elisp.wasm +0 -0
- package/wasm/tree-sitter-elixir.wasm +0 -0
- package/wasm/tree-sitter-elm.wasm +0 -0
- package/wasm/tree-sitter-embedded_template.wasm +0 -0
- package/wasm/tree-sitter-erlang.wasm +0 -0
- package/wasm/tree-sitter-fsharp.wasm +0 -0
- package/wasm/tree-sitter-fsharp_signature.wasm +0 -0
- package/wasm/tree-sitter-go.wasm +0 -0
- package/wasm/tree-sitter-graphql.wasm +0 -0
- package/wasm/tree-sitter-groovy.wasm +0 -0
- package/wasm/tree-sitter-haskell.wasm +0 -0
- package/wasm/tree-sitter-hcl.wasm +0 -0
- package/wasm/tree-sitter-html.wasm +0 -0
- package/wasm/tree-sitter-java.wasm +0 -0
- package/wasm/tree-sitter-javascript.wasm +0 -0
- package/wasm/tree-sitter-json.wasm +0 -0
- package/wasm/tree-sitter-json_schema.wasm +0 -0
- package/wasm/tree-sitter-julia.wasm +0 -0
- package/wasm/tree-sitter-kotlin.wasm +0 -0
- package/wasm/tree-sitter-lua.wasm +0 -0
- package/wasm/tree-sitter-make.wasm +0 -0
- package/wasm/tree-sitter-markdown.wasm +0 -0
- package/wasm/tree-sitter-markdown_inline.wasm +0 -0
- package/wasm/tree-sitter-matlab.wasm +0 -0
- package/wasm/tree-sitter-nim.wasm +0 -0
- package/wasm/tree-sitter-objc.wasm +0 -0
- package/wasm/tree-sitter-ocaml.wasm +0 -0
- package/wasm/tree-sitter-perl.wasm +0 -0
- package/wasm/tree-sitter-php.wasm +0 -0
- package/wasm/tree-sitter-php_only.wasm +0 -0
- package/wasm/tree-sitter-powershell.wasm +0 -0
- package/wasm/tree-sitter-protobuf.wasm +0 -0
- package/wasm/tree-sitter-python.wasm +0 -0
- package/wasm/tree-sitter-ql.wasm +0 -0
- package/wasm/tree-sitter-r.wasm +0 -0
- package/wasm/tree-sitter-rescript.wasm +0 -0
- package/wasm/tree-sitter-ruby.wasm +0 -0
- package/wasm/tree-sitter-rust.wasm +0 -0
- package/wasm/tree-sitter-scala.wasm +0 -0
- package/wasm/tree-sitter-scss.wasm +0 -0
- package/wasm/tree-sitter-solidity.wasm +0 -0
- package/wasm/tree-sitter-sql.wasm +0 -0
- package/wasm/tree-sitter-svelte.wasm +0 -0
- package/wasm/tree-sitter-swift.wasm +0 -0
- package/wasm/tree-sitter-systemrdl.wasm +0 -0
- package/wasm/tree-sitter-terraform.wasm +0 -0
- package/wasm/tree-sitter-tlaplus.wasm +0 -0
- package/wasm/tree-sitter-toml.wasm +0 -0
- package/wasm/tree-sitter-tsx.wasm +0 -0
- package/wasm/tree-sitter-typescript.wasm +0 -0
- package/wasm/tree-sitter-vba.wasm +0 -0
- package/wasm/tree-sitter-vbnet.wasm +0 -0
- package/wasm/tree-sitter-vue.wasm +0 -0
- package/wasm/tree-sitter-xml.wasm +0 -0
- package/wasm/tree-sitter-yaml.wasm +0 -0
- package/wasm/tree-sitter-zig.wasm +0 -0
- package/wasm/tree-sitter.wasm +0 -0
- package/wasm/tsx.wasm +0 -0
- package/wasm/typescript.wasm +0 -0
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# tree-sitter-graphql — vendored, patched, and pinned
|
|
2
|
+
|
|
3
|
+
This directory is the **source of the wasm the product loads**:
|
|
4
|
+
`wasm/tree-sitter-graphql.wasm`. It is not a mirror of upstream; it is
|
|
5
|
+
upstream plus a measured patch, and the patch is a reviewable diff because
|
|
6
|
+
`grammar.js` is **generated** from `grammar.upstream.js` by `port.py`.
|
|
7
|
+
|
|
8
|
+
## Why the tree is shaped this way
|
|
9
|
+
|
|
10
|
+
| file | role |
|
|
11
|
+
|---|---|
|
|
12
|
+
| `grammar.upstream.js` | `github.com/bkegley/tree-sitter-graphql` @ `ee5ce96`, verbatim. The port always reads this, so `python3 port.py` is idempotent. |
|
|
13
|
+
| `port.py` | the patch, as code: the PascalCase rename and four FIX hunks, each anchored to upstream's exact text and each refusing to write a half-ported grammar. |
|
|
14
|
+
| `grammar.js` | the generated, patched grammar. **This is what `tree-sitter generate` reads.** |
|
|
15
|
+
| `src/node-types.json`, `src/grammar.json` | generated, and tracked ON PURPOSE: `script/m14/verify-grammar-pins.ts` uses the pair for its offline source↔wasm proof. |
|
|
16
|
+
| `src/parser.c` | generated, 283 KB, **not** tracked. `tree-sitter generate` rebuilds it. |
|
|
17
|
+
| `tree-sitter.json`, `package.json` | ABI 15 build config and npm metadata. `package.json` deliberately has no `"type"` field: the repository root is `"type": "module"`, and `grammar.js` is CommonJS `module.exports`, so without a local `package.json` the CLI cannot load it. |
|
|
18
|
+
|
|
19
|
+
## Divergence 1 — the rule names are PascalCase, and that is a contract
|
|
20
|
+
|
|
21
|
+
Upstream names its rules `snake_case` (`object_type_definition`). This
|
|
22
|
+
repository's rules are `PascalCase` (`ObjectTypeDefinition`), because:
|
|
23
|
+
|
|
24
|
+
- `src/ast/real-graphql-analyzer.ts` dispatches on `node.type === "ObjectTypeDefinition"`.
|
|
25
|
+
Under upstream's spelling **every construct falls through the analyzer's
|
|
26
|
+
default arm** and the file yields nothing.
|
|
27
|
+
- `script/m12/graphql-node-types-compare.ts`, the m12 shape-safety artifact, the
|
|
28
|
+
m14/m60 language lanes and every stored symbol row assume the PascalCase
|
|
29
|
+
spelling.
|
|
30
|
+
- The wasm this repository vendored **before** this work already exposed
|
|
31
|
+
PascalCase names (built with an older tree-sitter CLI, which PascalCases rule
|
|
32
|
+
names on the analyzer's behalf). The rename preserves that surface rather than
|
|
33
|
+
breaking it.
|
|
34
|
+
|
|
35
|
+
The rename is a mechanical `snake_case → PascalCase` map over 71 rules, pinned
|
|
36
|
+
to the vendored wasm's own `language.nodeTypeForId` table, with `source_file`,
|
|
37
|
+
`comment` and `comma` held lower-case because that is what the previous wasm
|
|
38
|
+
exposed for them.
|
|
39
|
+
|
|
40
|
+
**Upstream's `main` is not a drop-in.** The A/B is in
|
|
41
|
+
`bb_tests/graphql/out/extraction-ab.json`; the measured result of a
|
|
42
|
+
PascalCase-only port is that the analyzer's whole string-literal contract
|
|
43
|
+
becomes dead. That is why this is a *patched port* and not an upgrade.
|
|
44
|
+
|
|
45
|
+
## Divergence 2 — four specification constructs upstream rejects
|
|
46
|
+
|
|
47
|
+
Each FIX in `port.py` is anchored to a row in the 113-construct battery
|
|
48
|
+
(`bb_tests/graphql/probe/grammar-gaps.mts`) and each was measured, not reasoned.
|
|
49
|
+
|
|
50
|
+
| # | construct | specification | what upstream's rule does | the patch |
|
|
51
|
+
|---|---|---|---|---|
|
|
52
|
+
| FIX 1 | `extend schema { query: Q mutation: M }`, and `extend schema @link(…)` with no body | §3.18 | one `root_operation_type_definition`, and the body is mandatory | `repeat1(...)` inside an optional body, with `prec.right` to resolve the `{` ambiguity (the same resolution every other `*_type_extension` in this grammar already uses) |
|
|
53
|
+
| FIX 2 | `extend scalar S` with no directive | §3.17 | `$.directives` is `repeat1`, so a directive is **mandatory** | `optional($.directives)` |
|
|
54
|
+
| FIX 3 | `{ f @a @b }` — two directives on one field selection | §3.3 | `optional($.directive)`, singular | `optional($.directives)` |
|
|
55
|
+
| FIX 4 | `\"` and `\\` in a `"…"` string; `\"""` in a `"""…"""` block string | §2.9.4 | the short string's regex forbids every backslash, and the block string has no accepting path for `\"""` | short string: `[^"\\\n]` or `\\` + any non-newline; block string: a quote is consumable only when it is not the closing delimiter, and a backslash always consumes the next character |
|
|
56
|
+
|
|
57
|
+
FIX 4 was measured twice. The first attempt wrote the short string's escape as
|
|
58
|
+
`\\[^\\\n]`, whose character class excludes the backslash **itself**, so `\"`,
|
|
59
|
+
`\/` and `\n` all parsed and `\\` did not — 4 of 7 escape probes green. The
|
|
60
|
+
second attempt uses `\\[^\n]`.
|
|
61
|
+
|
|
62
|
+
**Still a gap, deliberately not fixed:** the block-string rule accepts
|
|
63
|
+
`"""a\""""` as the block string `a"` followed by a stray quote. graphql-js agrees
|
|
64
|
+
(`BlockStringValue` is greedy to the last `"""`), so tightening it would make
|
|
65
|
+
this grammar disagree with the reference implementation. Recorded, not hidden.
|
|
66
|
+
|
|
67
|
+
## Regenerating the wasm
|
|
68
|
+
|
|
69
|
+
```sh
|
|
70
|
+
cd grammars/tree-sitter-graphql
|
|
71
|
+
python3 port.py # upstream + the patch -> grammar.js
|
|
72
|
+
tree-sitter generate # -> src/{parser.c,grammar.json,node-types.json}
|
|
73
|
+
tree-sitter build --wasm -o ../../wasm/tree-sitter-graphql.wasm
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
`tree-sitter build --wasm` needs emscripten; with only docker present it uses
|
|
77
|
+
`emscripten/emsdk` through docker automatically. The CLI must be ≥ 0.25 for the
|
|
78
|
+
`tree-sitter.json`/ABI-15 path; the bb_tests copy at
|
|
79
|
+
`/home/ishaq2321/bb_tests/node_modules/tree-sitter-cli` is 0.25.1.
|
|
80
|
+
|
|
81
|
+
**After regenerating, re-run every gate** — the wasm hash is pinned and the
|
|
82
|
+
extraction changes:
|
|
83
|
+
|
|
84
|
+
```sh
|
|
85
|
+
/home/ishaq2321/bb_tests/graphql/run-all.sh --corpus
|
|
86
|
+
cd /home/ishaq2321/backbencher-brain && bun script/m14/verify-grammar-pins.ts --write
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## What the patch bought, measured
|
|
90
|
+
|
|
91
|
+
47 real `.graphql` files across four repositories, the same analyzer under both
|
|
92
|
+
grammars (`bb_tests/graphql/out/extraction-ab.json`):
|
|
93
|
+
|
|
94
|
+
| | previous wasm | wired wasm | delta |
|
|
95
|
+
|---|---|---|---|
|
|
96
|
+
| files with a grammar error | **12 / 47** | **4 / 47** | **−8** |
|
|
97
|
+
| grammar error nodes | **20** | **7** | **−13** |
|
|
98
|
+
| symbols | 8,743 | **8,747** | +4 |
|
|
99
|
+
| relationships | 16,861 | **16,937** | +76 |
|
|
100
|
+
|
|
101
|
+
Every delta is enumerated and adjudicated in `REVIEW.md` §E. The direction is
|
|
102
|
+
uniform, and the previous wasm's losses include a class of **phantom facts**: on
|
|
103
|
+
`neo4j-graphql/.../apollo-federation-subgraph-compatibility/schema.graphql` a
|
|
104
|
+
described `extend type User` degraded to ERROR, and the analyzer then published
|
|
105
|
+
`anonymous_operation_1566 → Int`, `→ ID`, `→ @external` and `→ @requires` —
|
|
106
|
+
four invented references — while losing five real `User` field symbols.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) Amaan Qureshi <amaanq12@gmail.com>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2014 Max Brunsfeld
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
# tree-sitter-haskell
|
|
2
|
+
|
|
3
|
+
[![CI][ci]](https://github.com/tree-sitter/tree-sitter-haskell/actions/workflows/ci.yml)
|
|
4
|
+
[![discord][discord]](https://discord.gg/w7nTvsVJhm)
|
|
5
|
+
[![matrix][matrix]](https://matrix.to/#/#tree-sitter-chat:matrix.org)
|
|
6
|
+
[![crates][crates]](https://crates.io/crates/tree-sitter-haskell)
|
|
7
|
+
[![npm][npm]](https://www.npmjs.com/package/tree-sitter-haskell)
|
|
8
|
+
[![pypi][pypi]](https://pypi.org/project/tree-sitter-haskell)
|
|
9
|
+
|
|
10
|
+
Haskell grammar for [tree-sitter].
|
|
11
|
+
|
|
12
|
+
# References
|
|
13
|
+
|
|
14
|
+
- [Haskell 2010 Language Report – Syntax References][ref]
|
|
15
|
+
- [GHC Language Extensions][ext]
|
|
16
|
+
|
|
17
|
+
# Supported Language Extensions
|
|
18
|
+
|
|
19
|
+
These extensions are supported ✅, unsupported ❌ or not applicable because they don't involve parsing ➖️:
|
|
20
|
+
|
|
21
|
+
- AllowAmbiguousTypes ➖️
|
|
22
|
+
- ApplicativeDo ➖️
|
|
23
|
+
- Arrows ❌
|
|
24
|
+
- BangPatterns ✅
|
|
25
|
+
- BinaryLiterals ✅
|
|
26
|
+
- BlockArguments ✅
|
|
27
|
+
- CApiFFI ✅
|
|
28
|
+
- ConstrainedClassMethods ✅
|
|
29
|
+
- ConstraintKinds ✅
|
|
30
|
+
- CPP ✅
|
|
31
|
+
- CUSKs ✅
|
|
32
|
+
- DataKinds ✅
|
|
33
|
+
- DatatypeContexts ✅
|
|
34
|
+
- DefaultSignatures ✅
|
|
35
|
+
- DeriveAnyClass ➖️
|
|
36
|
+
- DeriveDataTypeable ➖️
|
|
37
|
+
- DeriveFoldable ➖️
|
|
38
|
+
- DeriveFunctor ➖️
|
|
39
|
+
- DeriveGeneric ➖️
|
|
40
|
+
- DeriveLift ➖️
|
|
41
|
+
- DeriveTraversable ➖️
|
|
42
|
+
- DerivingStrategies ✅
|
|
43
|
+
- DerivingVia ✅
|
|
44
|
+
- DisambiguateRecordFields ➖️
|
|
45
|
+
- DuplicateRecordFields ➖️
|
|
46
|
+
- EmptyCase ✅
|
|
47
|
+
- EmptyDataDecls ✅
|
|
48
|
+
- EmptyDataDeriving ✅
|
|
49
|
+
- ExistentialQuantification ✅
|
|
50
|
+
- ExplicitForAll ✅
|
|
51
|
+
- ExplicitNamespaces ✅
|
|
52
|
+
- ExtendedDefaultRules ➖️
|
|
53
|
+
- FlexibleContexts ✅
|
|
54
|
+
- FlexibleInstances ✅
|
|
55
|
+
- ForeignFunctionInterface ✅
|
|
56
|
+
- FunctionalDependencies ✅
|
|
57
|
+
- GADTs ✅
|
|
58
|
+
- GADTSyntax ✅
|
|
59
|
+
- GeneralisedNewtypeDeriving ➖️
|
|
60
|
+
- GHCForeignImportPrim ✅
|
|
61
|
+
- Haskell2010 ➖️
|
|
62
|
+
- Haskell98 ➖️
|
|
63
|
+
- HexFloatLiterals ✅
|
|
64
|
+
- ImplicitParams ✅
|
|
65
|
+
- ImplicitPrelude ➖️
|
|
66
|
+
- ImportQualifiedPost ✅
|
|
67
|
+
- ImpredicativeTypes ➖️
|
|
68
|
+
- IncoherentInstances ➖️
|
|
69
|
+
- InstanceSigs ✅
|
|
70
|
+
- InterruptibleFFI ✅
|
|
71
|
+
- KindSignatures ✅
|
|
72
|
+
- LambdaCase ✅
|
|
73
|
+
- LexicalNegation ❌
|
|
74
|
+
- LiberalTypeSynonyms ✅
|
|
75
|
+
- LinearTypes ✅
|
|
76
|
+
- ListTuplePuns ✅
|
|
77
|
+
- MagicHash ✅
|
|
78
|
+
- Modifiers ❌
|
|
79
|
+
- MonadComprehensions ➖️
|
|
80
|
+
- MonadFailDesugaring ➖️
|
|
81
|
+
- MonoLocalBinds ➖️
|
|
82
|
+
- MonomorphismRestriction ➖️
|
|
83
|
+
- MultiParamTypeClasses ✅
|
|
84
|
+
- MultiWayIf ✅
|
|
85
|
+
- NamedFieldPuns ✅
|
|
86
|
+
- NamedWildCards ✅
|
|
87
|
+
- NegativeLiterals ➖️
|
|
88
|
+
- NondecreasingIndentation ✅
|
|
89
|
+
- NPlusKPatterns ➖️
|
|
90
|
+
- NullaryTypeClasses ✅
|
|
91
|
+
- NumDecimals ➖️
|
|
92
|
+
- NumericUnderscores ✅
|
|
93
|
+
- OverlappingInstances ➖️
|
|
94
|
+
- OverloadedLabels ✅
|
|
95
|
+
- OverloadedLists ➖️
|
|
96
|
+
- OverloadedRecordDot ✅
|
|
97
|
+
- OverloadedRecordUpdate ✅
|
|
98
|
+
- OverloadedStrings ➖️
|
|
99
|
+
- PackageImports ✅
|
|
100
|
+
- ParallelListComp ✅
|
|
101
|
+
- PartialTypeSignatures ✅
|
|
102
|
+
- PatternGuards ✅
|
|
103
|
+
- PatternSynonyms ✅
|
|
104
|
+
- PolyKinds ➖️
|
|
105
|
+
- PostfixOperators ➖️
|
|
106
|
+
- QualifiedDo ✅
|
|
107
|
+
- QuantifiedConstraints ✅
|
|
108
|
+
- QuasiQuotes ✅
|
|
109
|
+
- Rank2Types ✅
|
|
110
|
+
- RankNTypes ✅
|
|
111
|
+
- RebindableSyntax ➖️
|
|
112
|
+
- RecordWildCards ➖️
|
|
113
|
+
- RecursiveDo ✅
|
|
114
|
+
- RequiredTypeArguments ✅
|
|
115
|
+
- RoleAnnotations ✅
|
|
116
|
+
- Safe ➖️
|
|
117
|
+
- ScopedTypeVariables ✅
|
|
118
|
+
- StandaloneDeriving ✅
|
|
119
|
+
- StandaloneKindSignatures ✅
|
|
120
|
+
- StarIsType ✅
|
|
121
|
+
- StaticPointers ❌
|
|
122
|
+
- Strict ➖️
|
|
123
|
+
- StrictData ✅
|
|
124
|
+
- TemplateHaskell ✅
|
|
125
|
+
- TemplateHaskellQuotes ✅
|
|
126
|
+
- TraditionalRecordSyntax ➖️
|
|
127
|
+
- TransformListComp ✅
|
|
128
|
+
- Trustworthy ➖️
|
|
129
|
+
- TupleSections ✅
|
|
130
|
+
- TypeAbstractions ✅
|
|
131
|
+
- TypeApplications ✅
|
|
132
|
+
- TypeData ✅
|
|
133
|
+
- TypeFamilies ✅
|
|
134
|
+
- TypeFamilyDependencies ✅
|
|
135
|
+
- TypeInType ✅
|
|
136
|
+
- TypeOperators ✅
|
|
137
|
+
- TypeSynonymInstances ➖️
|
|
138
|
+
- UnboxedSums ✅
|
|
139
|
+
- UnboxedTuples ✅
|
|
140
|
+
- UndecidableInstances ➖️
|
|
141
|
+
- UndecidableSuperClasses ➖️
|
|
142
|
+
- UnicodeSyntax ✅
|
|
143
|
+
- UnliftedFFITypes ➖️
|
|
144
|
+
- UnliftedNewtypes ✅
|
|
145
|
+
- Unsafe ➖️
|
|
146
|
+
- ViewPatterns ✅
|
|
147
|
+
|
|
148
|
+
# Bugs
|
|
149
|
+
|
|
150
|
+
## CPP
|
|
151
|
+
|
|
152
|
+
Preprocessor `#elif` and `#else` directives cannot be handled correctly, since the parser state would have to be
|
|
153
|
+
manually reset to what it was at the `#if`.
|
|
154
|
+
As a workaround, the code blocks in the alternative branches are parsed as part of the directives.
|
|
155
|
+
|
|
156
|
+
# Querying
|
|
157
|
+
|
|
158
|
+
The grammar contains several [supertypes](https://tree-sitter.github.io/tree-sitter/using-parsers#static-node-types),
|
|
159
|
+
which group multiple other node types under a single name.
|
|
160
|
+
|
|
161
|
+
Supertype names do not occur as extra nodes in parse trees, but they can be used in queries in special ways:
|
|
162
|
+
|
|
163
|
+
- As an alias, matching any of their subtypes
|
|
164
|
+
- As prefix for one of their subtypes, matching its symbol only when it occurs as a production of the supertype
|
|
165
|
+
|
|
166
|
+
For example, the query `(expression)` matches the nodes `infix`, `record`, `projection`, `constructor`, and the second
|
|
167
|
+
and third `variable` in this tree for `cats <> Cat {mood = moods.sleepy}`:
|
|
168
|
+
|
|
169
|
+
```
|
|
170
|
+
(infix
|
|
171
|
+
(variable)
|
|
172
|
+
(operator)
|
|
173
|
+
(record
|
|
174
|
+
(constructor)
|
|
175
|
+
(field_update
|
|
176
|
+
(field_name (variable))
|
|
177
|
+
(projection (variable) (field_name (variable)))))))))
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
The two occurrences of `variable` in `field_name` (`mood` and `sleepy`) are not expressions, but record field names part
|
|
181
|
+
of a composite `record` expression.
|
|
182
|
+
|
|
183
|
+
Matching `variable` nodes specifically that are expressions is possible with the second special form.
|
|
184
|
+
A query for `(expression/variable)` will match only the other two, `cats` and `moods`.
|
|
185
|
+
|
|
186
|
+
The grammar's supertypes consist of the following sets:
|
|
187
|
+
|
|
188
|
+
- [`expression`](./grammar/exp.js)
|
|
189
|
+
|
|
190
|
+
Rules that are valid in any expression position, excluding type applications, explicit types and expression
|
|
191
|
+
signatures.
|
|
192
|
+
|
|
193
|
+
- [`pattern`](./grammar/pat.js)
|
|
194
|
+
|
|
195
|
+
Rules that are valid in any pattern position, excluding type binders, explicit types and pattern signatures.
|
|
196
|
+
|
|
197
|
+
- [`type`](./grammar/type.js)
|
|
198
|
+
|
|
199
|
+
Types that are either atomic (have no ambiguous associativity, like bracketed constructs, variables and type
|
|
200
|
+
constructors), applied types or infix types.
|
|
201
|
+
|
|
202
|
+
- [`quantified_type`](./grammar/type.js)
|
|
203
|
+
|
|
204
|
+
Types prefixed with a `forall`, context or function parameter.
|
|
205
|
+
|
|
206
|
+
- [`constraint`](./grammar/constraint.js)
|
|
207
|
+
|
|
208
|
+
Almost the same rules as `type`, but mirrored for use in contexts.
|
|
209
|
+
|
|
210
|
+
- [`constraints`](./grammar/constraints.js)
|
|
211
|
+
|
|
212
|
+
Analog of `quantified_type`, for constraints with `forall` or context.
|
|
213
|
+
|
|
214
|
+
- [`type_param`](./grammar/type.js)
|
|
215
|
+
|
|
216
|
+
Atomic nodes in type and class heads, like the three nodes following `A` in `data A @k a (b :: k)`.
|
|
217
|
+
|
|
218
|
+
- [`declaration`](./grammar/module.js)
|
|
219
|
+
|
|
220
|
+
All top-level declarations, like functions and data types.
|
|
221
|
+
|
|
222
|
+
- [`decl`](./grammar/decl.js)
|
|
223
|
+
|
|
224
|
+
Shorthand for declarations that are also valid in local bindings (`let` and `where`) and in class and instance bodies,
|
|
225
|
+
except for fixity declarations.
|
|
226
|
+
Consists of `signature`, `function` and `bind`.
|
|
227
|
+
|
|
228
|
+
- [`class_decl` and `instance_decl`](./grammar/class.js)
|
|
229
|
+
|
|
230
|
+
All declarations that are valid in classes and instances, which includes associated type and data families.
|
|
231
|
+
|
|
232
|
+
- [`statement`](./grammar/exp.js)
|
|
233
|
+
|
|
234
|
+
Different forms of `do`-notation statements.
|
|
235
|
+
|
|
236
|
+
- [`qualifier`](./grammar/exp.js)
|
|
237
|
+
|
|
238
|
+
Different forms of list comprehension qualifiers.
|
|
239
|
+
|
|
240
|
+
- [`guard`](./grammar/exp.js)
|
|
241
|
+
|
|
242
|
+
Different forms of guards in function equations and case alternatives.
|
|
243
|
+
|
|
244
|
+
# Development
|
|
245
|
+
|
|
246
|
+
The main driver for generating and testing the parser for this grammar is the [tree-sitter CLI][cli].
|
|
247
|
+
Other components of the project require additional tools, described below.
|
|
248
|
+
|
|
249
|
+
Some are made available through `npm` – for example, `npx tree-sitter` runs the CLI.
|
|
250
|
+
If you don't have `tree-sitter` available otherwise, prefix all the commands in the following sections with `npx`.
|
|
251
|
+
|
|
252
|
+
## Output path
|
|
253
|
+
|
|
254
|
+
The CLI writes the shared library containing the parser to the directory denoted by `$TREE_SITTER_LIBDIR`.
|
|
255
|
+
If that variable is unset, it defaults to `$HOME/.cache/tree-sitter/lib`.
|
|
256
|
+
|
|
257
|
+
In order to avoid clobbering this global directory with development versions, you can set the env var to a local path:
|
|
258
|
+
|
|
259
|
+
```
|
|
260
|
+
export TREE_SITTER_LIBDIR=$PWD/.lib
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
## The grammar
|
|
264
|
+
|
|
265
|
+
The javascript file `grammar.js` contains the entry point into the grammar's production rules.
|
|
266
|
+
Please consult the [tree-sitter documentation][grammar-docs] for a comprehensive introduction to the syntax and
|
|
267
|
+
semantics.
|
|
268
|
+
|
|
269
|
+
Parsing starts with the first item in the `rules` field:
|
|
270
|
+
|
|
271
|
+
```javascript
|
|
272
|
+
{
|
|
273
|
+
rules: {
|
|
274
|
+
haskell: $ => seq(
|
|
275
|
+
optional($.header),
|
|
276
|
+
optional($._body),
|
|
277
|
+
),
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
## Generating the parser
|
|
283
|
+
|
|
284
|
+
The first step in the development workflow converts the javascript rule definitions to C code in `src/parser.c`:
|
|
285
|
+
|
|
286
|
+
```
|
|
287
|
+
$ tree-sitter generate
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
Two byproducts of this process are written to `src/grammar.json` and `src/node-types.json`.
|
|
291
|
+
|
|
292
|
+
## Compiling the parser
|
|
293
|
+
|
|
294
|
+
The C code is automatically compiled by most of the test tools mentioned below, but you can instruct tree-sitter to do
|
|
295
|
+
it in one go:
|
|
296
|
+
|
|
297
|
+
```
|
|
298
|
+
$ tree-sitter generate --build
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
If you've set `$TREE_SITTER_LIBDIR` as mentioned above, the shared object will be written to `$PWD/.lib/haskell.so`.
|
|
302
|
+
|
|
303
|
+
Aside from the generated `src/parser.c`, tree-sitter will also compile and link `src/scanner.c` into this object.
|
|
304
|
+
This file contains the _external scanner_, which is a custom extension of the built-in lexer whose purpose is to handle
|
|
305
|
+
language constructs that cannot be expressed (efficiently) in the javascript grammar, like Haskell layouts.
|
|
306
|
+
|
|
307
|
+
### WebAssembly
|
|
308
|
+
|
|
309
|
+
The parser can be compiled to WebAssembly as well, which requires `emscripten`:
|
|
310
|
+
|
|
311
|
+
```
|
|
312
|
+
$ tree-sitter build --wasm
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
The resulting binary is written to `$PWD/tree-sitter-haskell.wasm`.
|
|
316
|
+
|
|
317
|
+
## Testing the parser
|
|
318
|
+
|
|
319
|
+
The most fundamental test infrastructure for tree-sitter grammars consists of a set of code snippets with associated
|
|
320
|
+
reference ASTs stored in `./test/corpus/*.txt`.
|
|
321
|
+
|
|
322
|
+
```
|
|
323
|
+
$ tree-sitter test
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
Individual tests can be run by specifying (a substring of) their description with `-f`:
|
|
327
|
+
|
|
328
|
+
```
|
|
329
|
+
$ tree-sitter test -f 'module: exports empty'
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
The project contains several other types of tests:
|
|
333
|
+
|
|
334
|
+
- `test/parse/run.bash [update] [test names ...]` parses the files in `test/parse/*.hs` and compares the output with
|
|
335
|
+
`test/parse/*.target`.
|
|
336
|
+
If `update` is specified as the first argument, it will update the `.target` file for the first failing test.
|
|
337
|
+
|
|
338
|
+
- `test/query/run.bash [update] [test names ...]` parses the files in `test/query/*.hs`, applies the queries in
|
|
339
|
+
`test/query/*.query` and compares the output with `test/query/*.target`, similar to `test/parse`.
|
|
340
|
+
|
|
341
|
+
- `test/rust/parse-test.rs` contains a few tests that use tree-sitter's Rust API to extract the test ranges for
|
|
342
|
+
terminals in a slightly more convenient way.
|
|
343
|
+
This requires `cargo` to be installed, and can be executed with `cargo test` (which also runs the tests in
|
|
344
|
+
`bindings/rust`).
|
|
345
|
+
|
|
346
|
+
- `test/parse-libs [wasm]` clones a set of Haskell libraries to `test/libs` and parses the entire codebase.
|
|
347
|
+
When invoked as `test/parse-libs wasm`, it will use the WebAssembly parser.
|
|
348
|
+
This requires `bc` to be installed.
|
|
349
|
+
|
|
350
|
+
- `test/parse-lib name [wasm]` parses only the library `name` in that directory (without cloning the repository).
|
|
351
|
+
|
|
352
|
+
### Debugging
|
|
353
|
+
|
|
354
|
+
The shared library built by `tree-sitter test` includes debug symbols, so if the scanner segfaults you can just run
|
|
355
|
+
`coredumpctl debug` to inspect the backtrace and memory:
|
|
356
|
+
|
|
357
|
+
```
|
|
358
|
+
newline_lookahead () at src/scanner.c:2583
|
|
359
|
+
2583 ((Newline *) 0)->indent = 5;
|
|
360
|
+
(gdb) bt
|
|
361
|
+
#0 newline_lookahead () at src/scanner.c:2583
|
|
362
|
+
#1 0x00007ffff7a0740e in newline_start () at src/scanner.c:2604
|
|
363
|
+
#2 scan () at src/scanner.c:2646
|
|
364
|
+
#3 eval () at src/scanner.c:2684
|
|
365
|
+
#4 tree_sitter_haskell_external_scanner_scan (payload=<optimized out>, lexer=<optimized out>,
|
|
366
|
+
valid_symbols=<optimized out>) at src/scanner.c:2724
|
|
367
|
+
#5 0x0000555555772488 in ts_parser.lex ()
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
For more control, launch `gdb tree-sitter` and start the process with `run test -f 'some test'`, and set a breakpoint
|
|
371
|
+
with `break tree_sitter_haskell_external_scanner_scan`.
|
|
372
|
+
|
|
373
|
+
To disable optimizations, run `tree-sitter test --debug-build`.
|
|
374
|
+
|
|
375
|
+
#### Tracing
|
|
376
|
+
|
|
377
|
+
The `test` and `parse` commands offer two modes for obtaining detailed information about the parsing process.
|
|
378
|
+
|
|
379
|
+
With `tree-sitter test --debug`, every lexer step and shift/reduce action is printed to stderr.
|
|
380
|
+
|
|
381
|
+
With `tree-sitter test --debug-graph`, the CLI will generate an HTML file showing a graph representation of every step.
|
|
382
|
+
This requires `graphviz` to be installed.
|
|
383
|
+
|
|
384
|
+
[tree-sitter]: https://github.com/tree-sitter/tree-sitter
|
|
385
|
+
[ref]: https://www.haskell.org/onlinereport/haskell2010/haskellch10.html
|
|
386
|
+
[ext]: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/exts/table.html
|
|
387
|
+
[cli]: https://github.com/tree-sitter/tree-sitter/tree/master/cli
|
|
388
|
+
[grammar-docs]: https://tree-sitter.github.io/tree-sitter/creating-parsers#writing-the-grammar
|
|
389
|
+
[ci]: https://img.shields.io/github/actions/workflow/status/tree-sitter/tree-sitter-haskell/ci.yml?logo=github&label=CI
|
|
390
|
+
[discord]: https://img.shields.io/discord/1063097320771698699?logo=discord&label=discord
|
|
391
|
+
[matrix]: https://img.shields.io/matrix/tree-sitter-chat%3Amatrix.org?logo=matrix&label=matrix
|
|
392
|
+
[npm]: https://img.shields.io/npm/v/tree-sitter-haskell?logo=npm
|
|
393
|
+
[crates]: https://img.shields.io/crates/v/tree-sitter-haskell?logo=rust
|
|
394
|
+
[pypi]: https://img.shields.io/pypi/v/tree-sitter-haskell?logo=pypi&logoColor=ffd242
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 1.2.0 - 2025-06-15
|
|
4
|
+
|
|
5
|
+
feat:
|
|
6
|
+
* namespaced identitifers
|
|
7
|
+
|
|
8
|
+
fix:
|
|
9
|
+
* precedence of unary operators and expressions
|
|
10
|
+
|
|
11
|
+
housekeeping:
|
|
12
|
+
* regenerate with tree-sitter-cli 0.25.6
|
|
13
|
+
* add bindings
|
|
14
|
+
|
|
15
|
+
## 1.1.0 - 2023-07-25
|
|
16
|
+
|
|
17
|
+
feature
|
|
18
|
+
* add dialects so we can have different queries in `nvim-treesitter`
|
|
19
|
+
|
|
20
|
+
fix:
|
|
21
|
+
* fix ci acceptance workflow
|
|
22
|
+
|
|
23
|
+
housekeeping:
|
|
24
|
+
* reformat using LSPs, ditch editorconfig
|
|
25
|
+
|
|
26
|
+
## 1.0.0 - 2022-12-02
|
|
27
|
+
|
|
28
|
+
breaking:
|
|
29
|
+
* remove `template_if_branch` and `template_else_branch`
|
|
30
|
+
|
|
31
|
+
fix:
|
|
32
|
+
* fix precedence in template expressions
|
|
33
|
+
|
|
34
|
+
## 0.7.0 - 2022-06-02
|
|
35
|
+
|
|
36
|
+
housekeeping:
|
|
37
|
+
* bump tree-sitter dependency to 0.20.6
|
|
38
|
+
* regenerate parser
|
|
39
|
+
* fix clang+windows CI job
|
|
40
|
+
|
|
41
|
+
fix:
|
|
42
|
+
* allow empty string literals
|
|
43
|
+
|
|
44
|
+
## 0.6.0 - 2021-09-20
|
|
45
|
+
|
|
46
|
+
feature:
|
|
47
|
+
* add template for expressions
|
|
48
|
+
* add template if expressions
|
|
49
|
+
|
|
50
|
+
cleanup:
|
|
51
|
+
* move fuzzing instrumentation to different repository
|
|
52
|
+
|
|
53
|
+
## 0.5.0 - 2021-09-15
|
|
54
|
+
|
|
55
|
+
feature:
|
|
56
|
+
* unhide `(block|object|tuple)_(start|end)` tokens
|
|
57
|
+
|
|
58
|
+
fix:
|
|
59
|
+
* remove empty `template_directive` block because it causes issues for semgrep
|
|
60
|
+
|
|
61
|
+
## 0.4.0 - 2021-07-02
|
|
62
|
+
|
|
63
|
+
feature:
|
|
64
|
+
* add named "key" and "val" fields to left and right side of object elements
|
|
65
|
+
* unhide the `template_interpolation_(start|end)` and `quoted_template_(start|end)` tokens
|
|
66
|
+
|
|
67
|
+
## 0.3.2 - 2021-07-01
|
|
68
|
+
|
|
69
|
+
fix:
|
|
70
|
+
* add a build step to CI to make sure the scanner is compilable
|
|
71
|
+
* add fuzzing instrumentation
|
|
72
|
+
|
|
73
|
+
## 0.3.1 - 2021-06-30
|
|
74
|
+
|
|
75
|
+
fix:
|
|
76
|
+
* dont use c struct initializer syntax in src/scanner.cc
|
|
77
|
+
|
|
78
|
+
## 0.3.0 - 2021-06-28
|
|
79
|
+
|
|
80
|
+
fix:
|
|
81
|
+
* correct expression for identifiers
|
|
82
|
+
* allow empty template interpolations
|
|
83
|
+
* allow empty templates
|
|
84
|
+
* fix crash when `context_stack.size()` exceeds `CHAR_MAX`
|
|
85
|
+
* fix crash when `heredoc_identifier.size()` exceeds `CHAR_MAX`
|
|
86
|
+
|
|
87
|
+
quality:
|
|
88
|
+
* add fuzzing
|
|
89
|
+
|
|
90
|
+
## 0.2.0 - 2021-06-26
|
|
91
|
+
|
|
92
|
+
feature:
|
|
93
|
+
* add quoted templates and heredoc templates
|
|
94
|
+
* still missing template directives though
|
|
95
|
+
|
|
96
|
+
quality:
|
|
97
|
+
* collect corpus of real world hcl files from github
|
|
98
|
+
* add github actions
|
|
99
|
+
|
|
100
|
+
## 0.1.0 - 2021-06-13
|
|
101
|
+
|
|
102
|
+
* initial version
|