Skip to content
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

Expose verb AST with new verb_ast builtin. #72

Open
ctoth opened this issue Dec 7, 2022 · 1 comment
Open

Expose verb AST with new verb_ast builtin. #72

ctoth opened this issue Dec 7, 2022 · 1 comment

Comments

@ctoth
Copy link
Contributor

ctoth commented Dec 7, 2022

In order to programmatically edit MOOcode from within the MOO it is necessary to expose a representation of the AST.

I propose a new verb_ast(obj, vrb) builtin which returns a map of maps, each representing an AST node.
While it would be possible to render the AST maps back into MOOcode server-side, I also propose a set_verb_ast builtin which will work equivalently to set_verb_code, just with AST nodes.

Implementation

Similar to the existing unparse infrastructure we can add functions like unparse_stmt_ast which call down into subfunctions like unparse_scatter_ast and so on.

Would such a patch be accepted?

@whitten
Copy link

whitten commented Mar 2, 2023

If you are going to expose the Abstract Syntax Tree (AST) to code written in MOOlang, you are going to need to decide what representation the code will receive.

what do you mean by the datatype ‘map of maps’ ?
A natural representation form might be a list of lists, with the leaf nodes as strings how is this different ?
A different form might be as a WAIF, or even as a full MOO object.

If you think this is interesting enough to design, just start implementing it.
Waiting for another person’s pre-acceptance of the code is just a frustrating life strategy.
I have many bruises and never completely done projects to testify that boldly doing things works better.

On a related note, if you add an AST as a datatype, you might setup the preconditions to allow MOOlang to incorporate Lisp style macros, which would be, in my opinion, a fabulous next step in MOOlang programming.
Please think about how to support such in the design phase of this built-in.

Dave Whitten
713-870-3834

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

No branches or pull requests

2 participants