You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This would accept Go AST provided by the user. Currently, the two supported pathways, compile a file and compile a function body, are equivalent to passing in an *ast.File or an *ast.BlockStmt, respectively. The new function could explicitly support only a File or BlockStmt input, though the existing (*Interpreter).ast may handle arbitrary (valid) ASTs.
I wrote a relatively small patch for this. Would you accept this as a PR?
Background
I'm playing around with writing a Go-/Yaegi-based shell. I want to support string interpolation and other features foreign to Go. This would require manipulation of the AST. While I could generate source, I would much prefer to directly pass the modified AST to Yaegi.
Workarounds
Parsing the source, modifying the AST, writing it back out to a buffer, and handing that buffer to Yaegi, which would parse the source again.
The text was updated successfully, but these errors were encountered:
Thanks for this proposal. It is ok to me, as the standard lib AST format is stable and already in use by many tools / libraries in the Go ecosystem. The patch looks good too.
Adds CompileAST, which can be used to compile Go AST directly. This
allows users to delegate parsing of source to their own code instead of
relying on the interpreter.
CLoses#1251
Proposal
This would accept Go AST provided by the user. Currently, the two supported pathways, compile a file and compile a function body, are equivalent to passing in an
*ast.File
or an*ast.BlockStmt
, respectively. The new function could explicitly support only a File or BlockStmt input, though the existing(*Interpreter).ast
may handle arbitrary (valid) ASTs.I wrote a relatively small patch for this. Would you accept this as a PR?
Background
I'm playing around with writing a Go-/Yaegi-based shell. I want to support string interpolation and other features foreign to Go. This would require manipulation of the AST. While I could generate source, I would much prefer to directly pass the modified AST to Yaegi.
Workarounds
Parsing the source, modifying the AST, writing it back out to a buffer, and handing that buffer to Yaegi, which would parse the source again.
The text was updated successfully, but these errors were encountered: