Refactor CLI and filereader to allow PeTTa to work as a transpiler#155
Draft
rmgaray wants to merge 7 commits into
Draft
Refactor CLI and filereader to allow PeTTa to work as a transpiler#155rmgaray wants to merge 7 commits into
rmgaray wants to merge 7 commits into
Conversation
058eccf to
ba8e65c
Compare
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.
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:
load_metta_fileand other clauses to return the generated Prolog program in addition or instead of the execution results.process_formto use it.filereadermodule to take into account the already existing runtime optionsilentand disable the debug messages when interpreting/compiling.fileloader.pland introduced a more principled CLI using theoptparselibrary. PeTTa has now two modes of operation: compiler and interpreter.translate_exprto 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.