Closed mgree closed 1 year ago
PR #673 completes a part of the above requirements, defining classes for all command_nodes (but not for arguments, redirections, etc). It also cleans up many places where there was mixed use of typed and untyped AST objects, only using the typed ones now.
It should be straightforward to extend this to its own separate shasta library, while also defining the rest of the classes now that the initial structure is there. The two modules that will need straightforward modification are:
Then we would also need to make a few straightforward modifications to ast_to_ast.py and ast_to_ir.py so that they access fields and not indices of the unstructured objects.
PR #675 extends PaSh to use the new ASTs throughout.
@mgree I have two questions:
pretty()
function, do you mean that this (https://github.com/mgree/libdash/blob/master/libdash/printer.py) should be moved out of libdash and into shasta?I'd say in shasta, on both counts!
Closing this! Will make an issue in libdash to be updated to import shasta, return proper ASTs, and remove the printer.
Pash currently uses ASTs in three forms:
["Command", [n.ncmd.linno, to_assigns (n.ncmd.assign), to_args (n.ncmd.args), redirs (n.ncmd.redirect)]]
AstNode
objects withconstructor
enum field and variously named argumentsWe should have just one, well structured AST, from libdash on down.
We should use this representation uniformly. We propose the following restructuring:
shasta
library that definesCommand
,ArgChar
, withpretty()
(for pretty printing as shell) andjson()
(for rendering as JSON)libdash
depend onshasta
and produce appropriate ASTspash
use these ASTs throughout