Skip to content

Refactor CLI and filereader to allow PeTTa to work as a transpiler#155

Draft
rmgaray wants to merge 7 commits into
trueagi-io:mainfrom
rmgaray:rmgaray/refactor-as-compiler
Draft

Refactor CLI and filereader to allow PeTTa to work as a transpiler#155
rmgaray wants to merge 7 commits into
trueagi-io:mainfrom
rmgaray:rmgaray/refactor-as-compiler

Conversation

@rmgaray
Copy link
Copy Markdown

@rmgaray rmgaray commented Apr 2, 2026

PeTTa currently cannot be used as a transpiler because it does not output the generated Prolog clauses when translating MeTTa code. It also always executes all goals, which is not what we want when running it as a compiler. This PR fixes that:

  • Modified load_metta_file and other clauses to return the generated Prolog program in addition or instead of the execution results.
  • Added new runtime option to disable MeTTa code execution and refactored process_form to use it.
  • Modified the filereader module to take into account the already existing runtime option silent and disable the debug messages when interpreting/compiling.
  • Removed ad-hoc option parsing in fileloader.pl and introduced a more principled CLI using the optparse library. PeTTa has now two modes of operation: compiler and interpreter.
  • Generated 'add-atom' clauses for all MeTTa sexprs when compiling MeTTa programs.
  • Add runtime clauses to generated output
  • Modified translate_expr to print the results of each runnable. This is achieved by optionally adding a write clause at the end of each runnable body. This is only done for top-level MeTTa forms and whenever we are in compiler mode, not when interpreting MeTTa programs the usual way.
  • Make compiled clauses dynamic (we need this to fully support MeTTa).
  • Run all tests in compiled mode?

@rmgaray rmgaray force-pushed the rmgaray/refactor-as-compiler branch from 058eccf to ba8e65c Compare April 8, 2026 20:56
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