Abstract Syntax Tree (xonsh.ast
)
The xonsh abstract syntax tree node.
-
class
xonsh.ast.
CtxAwareTransformer
(parser)[source]
Transforms a xonsh AST based to use subprocess calls when
the first name in an expression statement is not known in the context.
This assumes that the expression statement is instead parseable as
a subprocess.
Parameters: | parser : xonsh.Parser
A parse instance to try to parse suprocess statements with.
|
-
ctxadd
(value)[source]
Adds a value the most recent context.
-
ctxremove
(value)[source]
Removes a value the most recent context.
-
ctxupdate
(iterable)[source]
Updated the most recent context.
-
ctxvisit
(node, inp, ctx, mode='exec')[source]
Transforms the node in a context-dependent way.
Parameters: | node : ast.AST
A syntax tree to transform.
input : str
The input code in string format.
ctx : dict
|
Returns: | node : ast.AST
|
-
generic_visit
(node)
-
insert_with_block_check
(node)[source]
Modifies a with statement node in-place to add an initial check
for whether or not the block should be executed. If the block is
not executed it will raise a XonshBlockError containing the required
information.
-
is_in_scope
(node)[source]
Determines whether or not the current node is in scope.
-
try_subproc_toks
(node, strip_expr=False)[source]
Tries to parse the line of the node as a subprocess.
-
visit
(node)
Visit a node.
-
visit_Assign
(node)[source]
Handle visiting an assignment statement.
-
visit_BoolOp
(node)[source]
Handle visiting an boolean operands, like and/or.
-
visit_ClassDef
(node)[source]
Handle visiting a class definition.
-
visit_Delete
(node)[source]
Handle visiting a del statement.
-
visit_Expr
(node)[source]
Handle visiting an expression.
-
visit_Expression
(node)[source]
Handle visiting an expression body.
-
visit_For
(node)[source]
Handle visiting a for statement.
-
visit_FunctionDef
(node)[source]
Handle visiting a function definition.
-
visit_Global
(node)[source]
Handle visiting a global statement.
-
visit_Import
(node)[source]
Handle visiting a import statement.
-
visit_ImportFrom
(node)[source]
Handle visiting a “from ... import ...” statement.
-
visit_Try
(node)[source]
Handle visiting a try statement.
-
visit_UnaryOp
(node)[source]
Handle visiting an unary operands, like not.
-
visit_With
(node)[source]
Handle visiting a with statement.
-
xonsh.ast.
gather_names
(node)[source]
Returns the set of all names present in the node’s tree.
-
xonsh.ast.
get_col
(node, default=-1)[source]
Gets the col_offset of a node, or returns the default
-
xonsh.ast.
get_id
(node, default=None)[source]
Gets the id attribute of a node, or returns a default.
-
xonsh.ast.
get_lineno
(node, default=0)[source]
Gets the lineno of a node or returns the default.
-
xonsh.ast.
has_elts
(x)[source]
Tests if x is an AST node with elements.
-
xonsh.ast.
isdescendable
(node)[source]
Deteremines whether or not a node is worth visiting. Currently only
UnaryOp and BoolOp nodes are visited.
-
xonsh.ast.
leftmostname
(node)[source]
Attempts to find the first name in the tree.
-
xonsh.ast.
max_col
(node)[source]
Returns the maximum col_offset of the node and all sub-nodes.
-
xonsh.ast.
max_line
(node)[source]
Computes the maximum lineno.
-
xonsh.ast.
min_col
(node)[source]
Computes the minimum col_offset.
-
xonsh.ast.
min_line
(node)[source]
Computes the minimum lineno.
-
xonsh.ast.
pdump
(s, **kwargs)[source]
performs a pretty dump of an AST node.
-
xonsh.ast.
pprint_ast
(s, *, sep=None, end=None, file=None, flush=False, **kwargs)[source]
Performs a pretty print of the AST nodes.
-
xonsh.ast.
xonsh_call
(name, args, lineno=None, col=None)[source]
Creates the AST node for calling a function of a given name.