Repository navigation
Conversation
Expose desugaring entry points that use a caller-provided context so language integrations can inspect context-owned data after translation. The context remains isolated through YEAST's existing clone-on-rule behavior and no longer needs to be `Send + Sync`. This also makes it so that we can use `Rc<RefCell<...>>` instead of `Arc<Mutex<...>>` and thus avoid a bunch of pointless locking.
Return the TRAP labels allocated for each reachable YEAST `OutputId`. An output node may occur in multiple structural positions, so retain every occurrence label. Separate output-AST extraction from parsing and desugaring so language pipelines can run work after labels have been assigned.
Keep each language's parser, desugarer, context type, schema, and optional post-extraction callback behind one private pipeline object. This type-erases the context once without duplicating parser or desugarer state, while retaining explicit parse and desugar entry points for extractor tests.
Restore the TRAP writer to its pre-attempt state when a matching language extractor returns an error. This prevents partial AST or post-extraction tuples from leaking into later successful language output. Extend the driver test with a write-then-fail attempt followed by a successful fallback.
Add a generated side-table relation and façade getter for extractor-provided string values.
Collect Swift string values in the per-file YEAST context and emit them after AST extraction for every structural occurrence label. For now "interpreted" just means "quotes stripped". At a later point, we should replace this with code that evaluates strings in the same way that Swift does.
tausbn
force-pushed
the
tausbn/yeast-post-extract-side-tables
branch
from
November 26, 2026 22:51
6be870c to
3f37bb2
Compare
tausbn
marked this pull request as ready for review
November 27, 2026 11:32
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The one-to-many OutputId mapping lacks an extraction-level regression verifying that a literal reused under two parents produces distinct TRAP labels, correct parent/index information, and interpreted-value tuples for both occurrences.
1 open issue
What changed in this PR
Adds post-extraction hooks to the shared desugaring pipeline, enabling side tables populated from language-specific context. Swift uses this mechanism to expose string values through the unified QL library.
Changes:
- Track every TRAP label associated with an output node, including reused nodes.
- Add Swift string-value collection, schema generation, and QL accessors.
- Update desugaring callers and restore TRAP output after failed extraction attempts.
| File | Description |
|---|---|
| unified/​ql/​lib/​unified.dbscheme | Adds the string-value relation. |
| unified/​ql/​lib/​codeql/​unified/​internal/​FacadeAst.qll | Reads string values from the new relation. |
| unified/​extractor/​tests/​swift_syntax_pipeline.rs | Uses the language-level desugaring API. |
| unified/​extractor/​tests/​location_tests.rs | Updates parsing and desugaring calls. |
| unified/​extractor/​tests/​corpus_tests.rs | Updates corpus helpers to the new API. |
| unified/​extractor/​string_values.dbscheme | Defines the side-table schema fragment. |
| unified/​extractor/​src/​languages/​swift/​swift.rs | Collects string values and emits side-table tuples. |
| unified/​extractor/​src/​generator.rs | Appends the side-table schema during generation. |
| unified/​extractor/​BUILD.bazel | Includes the schema fragment as compile-time data. |
| shared/​yeast/​src/​lib.rs | Adds desugaring with caller-provided context. |
| shared/​tree-sitter-extractor/​src/​trap.rs | Makes TRAP writers cloneable for rollback. |
| shared/​tree-sitter-extractor/​src/​extractor/​mod.rs | Returns output-node-to-TRAP-label mappings. |
| shared/​tree-sitter-extractor/​src/​extractor/​driver.rs | Restores failed output and tests fallback extraction. |
| shared/​tree-sitter-extractor/​src/​extractor/​desugaring.rs | Introduces the pipeline builder and post-extraction hook. |
Review effort: Balanced (adaptive)
| let recurse = self.enter_node(node); | ||
| if recurse { | ||
| let label = self.stack.last().expect("entered node must be on stack").0; | ||
| self.output_labels.entry(id).or_default().push(label); |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Adds support for specifying a piece of code that runs after normal extraction has taken place, with access to things like the
trap_writer. This enables us to easily add "side tables" to an analysis, by explicitly tracking the tuples we want to emit inside the user context, and then at the end callingadd_tuplefor each of them.This mechanism is very flexible -- the current implementation just adds a simple table for specifying interpreted string values for Swift strings, but in general you can stuff anything that
add_tupleunderstands into these tables.One wrinkle that one should be aware of when reviewing this: because we allow nodes to appear in multiple places in the output AST -- e.g. when we store an
OutputIdin the context and later use it, as we do in Swift -- there is in general not a 1-1 correspondence betweenOutputIds and TRAP IDs. So, when we output the AST, we also record for eachOutputIdthe list of TRAP IDs that it corresponds to. We can't simply reuse the TRAP IDs, because these entities may have different parents and indices.It may be desirable at some point to enforce that the result of desugaring is an actual tree, but for now I expect the difference to be negligible. Almost all
OutputIds will in fact correspond to a single TRAP ID.Can be reviewed commit-by-commit.