Add support for unparseable/encrypted files#309
Open
micprog wants to merge 2 commits into
Open
Conversation
IEEE-1735 encrypted IP makes slang trip at the surrounding `endmodule` even though the lexer skips the protect envelope itself. Previously, that error in any one file aborted the entire `bender script --top X` invocation because session.cpp threw on the first per-file error. bender-slang now collects per-tree pass/fail status instead of throwing on parse errors. System-load failures (file unreadable) are still fatal — only parse errors are tolerated. Diagnostics are still surfaced to stderr per file so users can see exactly what slang complained about. A new failed_tree_indices() bridge function lets the Rust side learn which trees had errors. apply_slang_filters builds a force_kept_paths set from those indices and unions it with the reachability-derived kept_paths during file filtering, then prints a clear warning per file: "slang reported parse errors in <path>; preserving in script output regardless of reachability". The tolerance is on by default with loud per-file warnings so real syntax bugs still get noticed; users wanting strict behavior can read stderr and act on it. The dangling-reference case (parent instantiates a module slang can't see) is already handled in analysis.cpp's DFS, which silently skips refs missing from the symbol table. Fixture: tests/pickle has a new `encrypted` target with three files — encrypted_ip.sv (realistic IEEE-1735 envelope around a module body), encrypted_user.sv (instantiates encrypted_ip via a dangling ref), and encrypted_top.sv. The test confirms all three survive `--top encrypted_top` even though slang fails to parse encrypted_ip.sv. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…iles Three follow-ups on the parse-error tolerance added in the previous commit: * script now prints a single summary warning at end of filtering: "warning: slang reported parse errors in N file(s); kept in script output: a.sv, b.sv" — instead of one stderr line per file, which got noisy on big designs. The diagnostic for each file still comes through (slang emits those itself). * script gains `--drop-unparseable`. Default behavior (keep) is unchanged. With the flag set, files slang couldn't parse are dropped from the output regardless of reachability; the summary warning's verb switches from "kept" to "dropped". Useful when the user knows the failures are real bugs in their RTL and wants the script to reflect that. * `--source-annotations` now emits `// UNPARSEABLE: slang reported parse errors` above each kept-but-failed file in the script, so a reader can spot them in the file list itself. Reuses the existing FileEntry.comment plumbing via a fresh `unparseable_comment` helper in emit_template. * pickle refuses on slang parse errors instead of silently emitting corrupt output: the slang printer reconstructs from the (partial) parse tree, and for encrypted protect envelopes that meant the base64 data block got mangled into something no downstream decrypt tool would accept. Pre-tolerance pickle threw automatically; now we check `failed_indices()` after parsing and surface a clear error pointing users at `bender script --top` for the file-list-only case. apply_slang_filters now returns the filtered groups alongside the set of kept-unparseable paths, which the caller threads into emit_template for the comment annotation. The retain predicate is unified into a single closure handling both the --top axis and the --drop-unparseable axis. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 task
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.
No description provided.