shell.ast package¶
Submodules¶
shell.ast.conditions module¶
Conditions¶
# Classes
Condition
├── ElseCondition
│ ├── Else
│ └── ElseIf
├── If
├── IfThen
├── IfThenElse
└── Then
Example code:
# An inline if-then clause
if $a > 10 then print high
if $a > 10 then print high else print low
# A multi-line if-then-else clause
a = 10
if $a > 10 then
print large
else if $a == 10
print medium
else
print small
- class shell.ast.conditions.Condition(condition=None, then=None, otherwise=None)[source]¶
Bases:
Node
- class shell.ast.conditions.Else(condition=None, then=None, otherwise=None)[source]¶
Bases:
ElseCondition
- class shell.ast.conditions.ElseCondition(condition=None, then=None, otherwise=None)[source]¶
Bases:
Condition
- class shell.ast.conditions.ElseIf(condition=None, then=None, otherwise=None)[source]¶
Bases:
ElseCondition
- class shell.ast.conditions.ElseIfThen(condition=None, then=None, otherwise=None)[source]¶
Bases:
ElseCondition
- class shell.ast.conditions.IfThen(condition=None, then=None, otherwise=None)[source]¶
Bases:
Condition
shell.ast.function_definition module¶
shell.ast.infix module¶
- class shell.ast.infix.Assign(lhs: Node, rhs: Node, op: str)[source]¶
Bases:
Infix
Assign a value to a variable.
# static assignment a = 10 # left- and right-hand evaluation b <- range 10 range 10 -> c
- property key: Node¶
- property value: Node¶
- class shell.ast.infix.BashPipe(lhs: Node, rhs: Node, op: str)[source]¶
Bases:
Infix
Pipe
echo abcde | egrep -o 'a??'
- class shell.ast.infix.Map(lhs: Node, rhs: Node)[source]¶
Bases:
Infix
Apply a function to each element of a sequence.
range 10 >>= echo The value is $ .
shell.ast.node module¶
- class shell.ast.node.Node(data='')[source]¶
Bases:
UserString
A node (edge) of an abstract syntax tree (AST).
shell.ast.nodes module¶
Nodes¶
A container class for Node’s. See shell.grammer.parser
# Tree
Lines
└── Nodes
└── Node
Node¶
An “edge” of the AST.
Subclasses of Node:
Node
├── Condition
│ ├── ElseCondition
│ │ ├── Else
│ │ └── ElseIf
│ ├── If
│ ├── IfThen
│ ├── IfThenElse
│ └── Then
├── Infix
│ ├── Assign
│ ├── BashPipe
│ ├── BinaryExpression
│ ├── LogicExpression
│ ├── Map
│ └── Pipe
└── Term
├── Method
├── Quoted
├── Variable
└── Word
shell.ast.set_definition module¶
shell.ast.term module¶
Term¶
# Classes
Term
├── Method # f()
├── Quoted # "abc"
├── Variable $x
└── Word