|
3 | 3 | This is a CodeQL extractor based on tree-sitter. |
4 | 4 |
|
5 | 5 | ## Building |
6 | | -To build the extractor, run `scripts/create-extractor-pack.sh` |
7 | | - |
8 | | -## Editing the Swift grammar |
9 | | -The vendored tree-sitter-swift grammar lives at |
10 | | -`extractor/tree-sitter-swift/`. After editing `grammar.js` (or any other |
11 | | -grammar source), run `scripts/regenerate-grammar.sh` to: |
12 | | -- regenerate `extractor/tree-sitter-swift/src/{parser.c, grammar.json, |
13 | | - node-types.json}` (and the `src/tree_sitter/*.h` headers) via |
14 | | - `tree-sitter generate`; and |
15 | | -- refresh `extractor/tree-sitter-swift/node-types.yml`, the |
16 | | - human-readable companion to `src/node-types.json` produced by yeast's |
17 | | - `node_types_yaml` binary. |
18 | | - |
19 | | -`node-types.yml` is the recommended review surface for grammar changes — |
20 | | -it shows the impact of a grammar tweak on the named node kinds, fields, |
21 | | -and child types in a form much easier to read than the raw JSON. |
22 | | - |
23 | | -## Extractor Testing |
24 | | -- To run extractor tests, run `cargo test` in the `extractor` directory. |
| 6 | +- To build the extractor, run `scripts/create-extractor-pack.sh` |
| 7 | + |
| 8 | +## Swift Parser |
| 9 | +- The Swift parser is defined by `extractor/tree-sitter-swift/grammar.js` and can be edited if needed. |
| 10 | + |
| 11 | +- After editing the grammar, always run `scripts/regenerate-grammar.sh`. |
| 12 | + |
| 13 | +- The raw parse tree is described by `extractor/tree-sitter-swift/node-types.yml` and should be reviewed after grammar changes. |
| 14 | + |
| 15 | +## AST Mapping |
| 16 | +- The target AST shape is described by `extractor/ast_types.yml`. |
| 17 | + |
| 18 | +- The mapping from the parse tree to the target AST is found in `extractor/src/languages/swift/swift.rs` |
| 19 | + |
| 20 | +- To run tests for the parser and mapping, run `cargo test` in the `extractor` directory. |
25 | 21 |
|
26 | 22 | - Do not edit the printed ASTs in `extractor/test/corpus` directly. To regenerate the ASTs, run `scripts/update-corpus.sh`. |
27 | 23 |
|
|
0 commit comments