Skip to content

Conversation

@charles-cooper
Copy link
Contributor

Fixes #21

Summary

  • Introduces intermediate jsonAST datatype that mirrors JSON structure exactly
  • Moves all semantic decisions (msg.sender recognition, loop bounds, etc.) into HOL translation functions
  • Simplifies vyperTestLib.sml from 1435 to 507 lines by replacing ad-hoc parsing with principled pipeline

Architecture

JSON → jsonASTLib.sml → jsonAST terms → jsonToVyperTheory.translate_module → vyperAST terms
         (SML parser)      (intermediate)        (HOL translation)            (target)

New Files

File Purpose LOC
jsonASTScript.sml Intermediate AST datatypes ~175
jsonASTLib.sml + .sig JSON → jsonAST parser ~860 + 230
jsonToVyperScript.sml jsonAST → vyperAST translation (HOL) ~495

Test plan

  • All theories build successfully with Holmake
  • vyperTestLib.sml typechecks with new pipeline
  • Full test suite (requires Vyper test exports)

🤖 Generated with Claude Code

charles-cooper and others added 2 commits December 18, 2025 21:27
Introduces a separation between JSON parsing and semantic translation:

- jsonASTScript.sml: HOL datatypes mirroring Vyper JSON AST structure
- jsonASTLib.sml/sig: SML parser that maps JSON to jsonAST HOL terms
- jsonToVyperScript.sml: HOL translation from jsonAST to vyperAST

The jsonAST layer captures JSON structure without semantic decisions.
Translation to vyperAST handles msg.sender recognition, loop bounds, etc.

Phase 4 (integration with vyperTestLib) pending.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Phase 4: Integration
- Add jsonASTLib and jsonToVyperTheory dependencies
- Create toplevels_via_jsonast decoder using new pipeline:
  JSON → annotated_ast → translate_module (EVAL) → vyperAST
- Replace old toplevels decoder usage in deployment decoder

Phase 5: Cleanup
- Remove ~930 lines of old JSON-to-vyperAST decoders
- Keep: jsonAST pipeline, call/deployment/trace decoders,
  ABI decoders, test infrastructure
- vyperTestLib.sml reduced from 1435 to 507 lines

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Copy link
Member

@xrchz xrchz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy with this if we get some evidence that all the tests (from the Vyper test export) that used to pass still pass.

- jsonASTLib.sml: Make Int type field optional for array indices/sizes
- jsonASTLib.sml: Fix keywords field handling with orElse pattern
- jsonASTLib.sml: Add new json_arg format (ast_type:"arg")
- vyperTestLib.sml: Update paths to use vyper-test-exports symlink
- vyperTestLib.sml: Add error message to decode failure output
- tests/vyperTestDefs*Script.sml: Regenerated test definitions

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
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.

Refactor: Introduce intermediate JSON-matching AST for cleaner parser/translation separation

3 participants