Skip to content

Conversation

@tautschnig
Copy link
Contributor

@tautschnig tautschnig commented Feb 10, 2026

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.

It was previously hard-coded to a single test. Turn it into a workflow
that accepts *.core.st files as command-line arguments.
Copilot AI review requested due to automatic review settings February 10, 2026 14:55
@tautschnig tautschnig requested a review from a team as a code owner February 10, 2026 14:55
Copy link
Contributor

Copilot AI left a 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.st file.
  • 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.

Comment on lines +63 to +65
let symTabFile := s!"{dir}/{programName}.symtab.json"
let gotoFile := s!"{dir}/{programName}.goto.json"
CoreToGOTO.writeToGotoJson (programName := programName)
Copy link

Copilot AI Feb 10, 2026

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 "/".

Copilot uses AI. Check for mistakes.
Comment on lines +55 to +69
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}"
Copy link

Copilot AI Feb 10, 2026

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.

Copilot uses AI. Check for mistakes.
@tautschnig tautschnig changed the title Make StrataCoreToGoto accept user-specified Strata Core files Make StrataCoreToGoto accept a user-specified Strata Core file Feb 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant