-
Notifications
You must be signed in to change notification settings - Fork 24
Make StrataCoreToGoto accept a user-specified Strata Core file #404
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
It was previously hard-coded to a single test. Turn it into a workflow that accepts *.core.st files as command-line arguments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Updates the StrataCoreToGoto executable so it can translate a user-specified Strata Core source file (*.core.st) into CBMC-compatible GOTO JSON outputs, instead of being hard-coded to the SimpleAdd test case.
Changes:
- Replace hard-coded SimpleAdd program import/entrypoint with a CLI that reads and elaborates a
.core.stfile. - Add basic CLI options (
--output-dir,--program-name) and derive default output names from the input filename. - Update the SimpleAdd CBMC helper script to invoke the new CLI form.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| StrataTest/Backends/CBMC/SimpleAdd/mkGotoBin.sh | Switches the script to call StrataCoreToGoto with an explicit input .core.st file and output directory. |
| StrataCoreToGoto.lean | Implements new CLI parsing, file loading/elaboration, and JSON output file naming for StrataCoreToGoto. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| let symTabFile := s!"{dir}/{programName}.symtab.json" | ||
| let gotoFile := s!"{dir}/{programName}.goto.json" | ||
| CoreToGOTO.writeToGotoJson (programName := programName) |
Copilot
AI
Feb 10, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The output paths are built via string concatenation ("{dir}/{programName}..."). If --program-name contains path separators or .., this can write outside --output-dir (path traversal / unintended overwrites). Consider validating programName to be a simple filename (no separators) and building paths with System.FilePath joins instead of hard-coded "/".
| let dir := opts.outputDir | ||
| let text ← Strata.Util.readInputSource file | ||
| let inputCtx := Lean.Parser.mkInputContext text (Strata.Util.displayName file) | ||
| let dctx := Elab.LoadedDialects.builtin | ||
| let dctx := dctx.addDialect! Core | ||
| let leanEnv ← Lean.mkEmptyEnvironment 0 | ||
| match Strata.Elab.elabProgram dctx leanEnv inputCtx with | ||
| | .ok pgm => | ||
| let symTabFile := s!"{dir}/{programName}.symtab.json" | ||
| let gotoFile := s!"{dir}/{programName}.goto.json" | ||
| CoreToGOTO.writeToGotoJson (programName := programName) | ||
| (symTabFileName := symTabFile) | ||
| (gotoFileName := gotoFile) | ||
| pgm | ||
| IO.println s!"Written {symTabFile} and {gotoFile}" |
Copilot
AI
Feb 10, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--output-dir is not created before writing files; if the directory doesn't exist, IO.FS.writeFile will raise an exception and the tool will exit without a clean error message/exit code. Consider calling IO.FS.createDirAll on the output directory (or catching IO.Error around the write) and returning 1 with a helpful message when creation/writes fail.
Description of changes:
It was previously hard-coded to a single test. Turn it into a workflow that accepts a *.core.st file as command-line argument.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.