Module refinery.lib.scripts.ps1.model

PowerShell AST node types.

Expand source code Browse git
"""
PowerShell AST node types.
"""
from __future__ import annotations

import enum

from dataclasses import dataclass, field
from typing import Generator

from refinery.lib.scripts import Block, Expression, Node, Statement


class Ps1ScopeModifier(enum.Enum):
    NONE     = ''          # noqa
    GLOBAL   = 'global'    # noqa
    LOCAL    = 'local'     # noqa
    SCRIPT   = 'script'    # noqa
    PRIVATE  = 'private'   # noqa
    USING    = 'using'     # noqa
    ENV      = 'env'       # noqa
    VARIABLE = 'variable'  # noqa
    FUNCTION = 'function'  # noqa
    ALIAS    = 'alias'     # noqa
    DRIVE    = 'drive'     # noqa


class Ps1CommandArgumentKind(enum.Enum):
    POSITIONAL = 'positional'
    NAMED = 'named'
    SWITCH = 'switch'


class Ps1AccessKind(enum.Enum):
    INSTANCE = '.'
    STATIC = '::'


@dataclass(repr=False)
class Ps1Variable(Expression):
    name: str = ''
    scope: Ps1ScopeModifier = Ps1ScopeModifier.NONE
    braced: bool = False
    splatted: bool = False

    def children(self) -> Generator[Node, None, None]:
        yield from ()


@dataclass(repr=False)
class Ps1IntegerLiteral(Expression):
    value: int = 0
    raw: str = '0'

    def children(self) -> Generator[Node, None, None]:
        yield from ()


@dataclass(repr=False)
class Ps1RealLiteral(Expression):
    value: float = 0.0
    raw: str = '0.0'

    def children(self) -> Generator[Node, None, None]:
        yield from ()


@dataclass(repr=False)
class Ps1StringLiteral(Expression):
    value: str = ''
    raw: str = "''"

    def children(self) -> Generator[Node, None, None]:
        yield from ()


@dataclass(repr=False)
class Ps1ExpandableString(Expression):
    """
    An expandable (double-quoted) string with interleaved text and expression
    parts. Text segments are `Ps1StringLiteral`, expression segments are any
    `Expression` node.
    """
    parts: list[Expression] = field(default_factory=list)
    raw: str = '""'

    def __post_init__(self):
        self._adopt(*self.parts)

    def children(self) -> Generator[Node, None, None]:
        yield from self.parts


@dataclass(repr=False)
class Ps1HereString(Expression):
    value: str = ''
    raw: str = ''
    expandable: bool = False

    def children(self) -> Generator[Node, None, None]:
        yield from ()


@dataclass(repr=False)
class Ps1ExpandableHereString(Expression):
    parts: list[Expression] = field(default_factory=list)
    raw: str = ''

    def __post_init__(self):
        self._adopt(*self.parts)

    def children(self) -> Generator[Node, None, None]:
        yield from self.parts


@dataclass(repr=False)
class Ps1BinaryExpression(Expression):
    left: Expression | None = None
    operator: str = ''
    right: Expression | None = None

    def __post_init__(self):
        self._adopt(self.left, self.right)

    def children(self) -> Generator[Node, None, None]:
        if self.left is not None:
            yield self.left
        if self.right is not None:
            yield self.right


@dataclass(repr=False)
class Ps1UnaryExpression(Expression):
    operator: str = ''
    operand: Expression | None = None
    prefix: bool = True

    def __post_init__(self):
        self._adopt(self.operand)

    def children(self) -> Generator[Node, None, None]:
        if self.operand is not None:
            yield self.operand


@dataclass(repr=False)
class Ps1TypeExpression(Expression):
    name: str = ''

    def children(self) -> Generator[Node, None, None]:
        yield from ()


@dataclass(repr=False)
class Ps1CastExpression(Expression):
    type_name: str = ''
    operand: Expression | None = None

    def __post_init__(self):
        self._adopt(self.operand)

    def children(self) -> Generator[Node, None, None]:
        if self.operand is not None:
            yield self.operand


@dataclass(repr=False)
class Ps1MemberAccess(Expression):
    object: Expression | None = None
    member: str | Expression = ''
    access: Ps1AccessKind = Ps1AccessKind.INSTANCE

    def __post_init__(self):
        self._adopt(self.object)
        if isinstance(self.member, Expression):
            self._adopt(self.member)

    def children(self) -> Generator[Node, None, None]:
        if self.object is not None:
            yield self.object
        if isinstance(self.member, Expression):
            yield self.member


@dataclass(repr=False)
class Ps1IndexExpression(Expression):
    object: Expression | None = None
    index: Expression | None = None

    def __post_init__(self):
        self._adopt(self.object, self.index)

    def children(self) -> Generator[Node, None, None]:
        if self.object is not None:
            yield self.object
        if self.index is not None:
            yield self.index


@dataclass(repr=False)
class Ps1InvokeMember(Expression):
    object: Expression | None = None
    member: str | Expression = ''
    arguments: list[Expression] = field(default_factory=list)
    access: Ps1AccessKind = Ps1AccessKind.INSTANCE

    def __post_init__(self):
        self._adopt(self.object, *self.arguments)
        if isinstance(self.member, Expression):
            self._adopt(self.member)

    def children(self) -> Generator[Node, None, None]:
        if self.object is not None:
            yield self.object
        if isinstance(self.member, Expression):
            yield self.member
        yield from self.arguments


@dataclass(repr=False)
class Ps1CommandArgument(Node):
    kind: Ps1CommandArgumentKind = Ps1CommandArgumentKind.POSITIONAL
    name: str = ''
    value: Expression | None = None

    def __post_init__(self):
        self._adopt(self.value)

    def children(self) -> Generator[Node, None, None]:
        if self.value is not None:
            yield self.value


@dataclass(repr=False)
class Ps1CommandInvocation(Expression):
    name: Expression | None = None
    arguments: list[Ps1CommandArgument | Expression] = field(default_factory=list)
    invocation_operator: str = ''

    def __post_init__(self):
        self._adopt(self.name, *self.arguments)

    def children(self) -> Generator[Node, None, None]:
        if self.name is not None:
            yield self.name
        yield from self.arguments


@dataclass(repr=False)
class Ps1CallExpression(Expression):
    callee: Expression | None = None
    arguments: list[Expression] = field(default_factory=list)

    def __post_init__(self):
        self._adopt(self.callee, *self.arguments)

    def children(self) -> Generator[Node, None, None]:
        if self.callee is not None:
            yield self.callee
        yield from self.arguments


@dataclass(repr=False)
class Ps1AssignmentExpression(Expression):
    target: Expression | None = None
    operator: str = '='
    value: Expression | None = None

    def __post_init__(self):
        self._adopt(self.target, self.value)

    def children(self) -> Generator[Node, None, None]:
        if self.target is not None:
            yield self.target
        if self.value is not None:
            yield self.value


@dataclass(repr=False)
class Ps1ArrayLiteral(Expression):
    elements: list[Expression] = field(default_factory=list)

    def __post_init__(self):
        self._adopt(*self.elements)

    def children(self) -> Generator[Node, None, None]:
        yield from self.elements


@dataclass(repr=False)
class Ps1ArrayExpression(Expression):
    body: list[Statement] = field(default_factory=list)

    def __post_init__(self):
        self._adopt(*self.body)

    def children(self) -> Generator[Node, None, None]:
        yield from self.body


@dataclass(repr=False)
class Ps1HashLiteral(Expression):
    pairs: list[tuple[Expression, Expression]] = field(default_factory=list)

    def __post_init__(self):
        for k, v in self.pairs:
            self._adopt(k, v)

    def children(self) -> Generator[Node, None, None]:
        for k, v in self.pairs:
            yield k
            yield v


@dataclass(repr=False)
class Ps1SubExpression(Expression):
    body: list[Statement] = field(default_factory=list)

    def __post_init__(self):
        self._adopt(*self.body)

    def children(self) -> Generator[Node, None, None]:
        yield from self.body


@dataclass(repr=False)
class Ps1ParenExpression(Expression):
    expression: Expression | None = None

    def __post_init__(self):
        self._adopt(self.expression)

    def children(self) -> Generator[Node, None, None]:
        if self.expression is not None:
            yield self.expression


@dataclass(repr=False)
class Ps1ScriptBlock(Expression):
    param_block: Ps1ParamBlock | None = None
    begin_block: Block | None = None
    process_block: Block | None = None
    end_block: Block | None = None
    dynamicparam_block: Block | None = None
    body: list[Statement] = field(default_factory=list)

    def __post_init__(self):
        self._adopt(
            self.param_block,
            self.begin_block,
            self.process_block,
            self.end_block,
            self.dynamicparam_block,
            *self.body,
        )

    def children(self) -> Generator[Node, None, None]:
        if self.param_block is not None:
            yield self.param_block
        if self.begin_block is not None:
            yield self.begin_block
        if self.process_block is not None:
            yield self.process_block
        if self.end_block is not None:
            yield self.end_block
        if self.dynamicparam_block is not None:
            yield self.dynamicparam_block
        yield from self.body


@dataclass(repr=False)
class Ps1RangeExpression(Expression):
    start: Expression | None = None
    end: Expression | None = None

    def __post_init__(self):
        self._adopt(self.start, self.end)

    def children(self) -> Generator[Node, None, None]:
        if self.start is not None:
            yield self.start
        if self.end is not None:
            yield self.end


@dataclass(repr=False)
class Ps1Attribute(Node):
    name: str = ''
    positional_args: list[Expression] = field(default_factory=list)
    named_args: list[tuple[str, Expression]] = field(default_factory=list)

    def __post_init__(self):
        self._adopt(*self.positional_args)
        for _, v in self.named_args:
            self._adopt(v)

    def children(self) -> Generator[Node, None, None]:
        yield from self.positional_args
        for _, v in self.named_args:
            yield v


@dataclass(repr=False)
class Ps1ParameterDeclaration(Node):
    variable: Ps1Variable | None = None
    attributes: list[Ps1Attribute | Ps1TypeExpression] = field(default_factory=list)
    default_value: Expression | None = None

    def __post_init__(self):
        self._adopt(self.variable, *self.attributes, self.default_value)

    def children(self) -> Generator[Node, None, None]:
        yield from self.attributes
        if self.variable is not None:
            yield self.variable
        if self.default_value is not None:
            yield self.default_value


@dataclass(repr=False)
class Ps1ParamBlock(Node):
    parameters: list[Ps1ParameterDeclaration] = field(default_factory=list)
    attributes: list[Ps1Attribute] = field(default_factory=list)

    def __post_init__(self):
        self._adopt(*self.parameters, *self.attributes)

    def children(self) -> Generator[Node, None, None]:
        yield from self.attributes
        yield from self.parameters


@dataclass(repr=False)
class Ps1Redirection(Node):
    operator: str = '>'
    target: Expression | None = None

    def __post_init__(self):
        self._adopt(self.target)

    def children(self) -> Generator[Node, None, None]:
        if self.target is not None:
            yield self.target


@dataclass(repr=False)
class Ps1PipelineElement(Node):
    expression: Expression | None = None
    redirections: list[Ps1Redirection] = field(default_factory=list)

    def __post_init__(self):
        self._adopt(self.expression, *self.redirections)

    def children(self) -> Generator[Node, None, None]:
        if self.expression is not None:
            yield self.expression
        yield from self.redirections


@dataclass(repr=False)
class Ps1Pipeline(Statement):
    elements: list[Ps1PipelineElement] = field(default_factory=list)

    def __post_init__(self):
        self._adopt(*self.elements)

    def children(self) -> Generator[Node, None, None]:
        yield from self.elements


@dataclass(repr=False)
class Ps1ExpressionStatement(Statement):
    expression: Expression | None = None

    def __post_init__(self):
        self._adopt(self.expression)

    def children(self) -> Generator[Node, None, None]:
        if self.expression is not None:
            yield self.expression


@dataclass(repr=False)
class Ps1IfStatement(Statement):
    clauses: list[tuple[Expression, Block]] = field(default_factory=list)
    else_block: Block | None = None

    def __post_init__(self):
        for cond, body in self.clauses:
            self._adopt(cond, body)
        self._adopt(self.else_block)

    def children(self) -> Generator[Node, None, None]:
        for cond, body in self.clauses:
            yield cond
            yield body
        if self.else_block is not None:
            yield self.else_block


@dataclass(repr=False)
class Ps1WhileLoop(Statement):
    condition: Expression | None = None
    body: Block | None = None
    label: str | None = None

    def __post_init__(self):
        self._adopt(self.condition, self.body)

    def children(self) -> Generator[Node, None, None]:
        if self.condition is not None:
            yield self.condition
        if self.body is not None:
            yield self.body


@dataclass(repr=False)
class Ps1DoWhileLoop(Statement):
    condition: Expression | None = None
    body: Block | None = None
    label: str | None = None

    def __post_init__(self):
        self._adopt(self.condition, self.body)

    def children(self) -> Generator[Node, None, None]:
        if self.body is not None:
            yield self.body
        if self.condition is not None:
            yield self.condition


@dataclass(repr=False)
class Ps1DoUntilLoop(Statement):
    condition: Expression | None = None
    body: Block | None = None
    label: str | None = None

    def __post_init__(self):
        self._adopt(self.condition, self.body)

    def children(self) -> Generator[Node, None, None]:
        if self.body is not None:
            yield self.body
        if self.condition is not None:
            yield self.condition


@dataclass(repr=False)
class Ps1ForLoop(Statement):
    initializer: Expression | None = None
    condition: Expression | None = None
    iterator: Expression | None = None
    body: Block | None = None
    label: str | None = None

    def __post_init__(self):
        self._adopt(self.initializer, self.condition, self.iterator, self.body)

    def children(self) -> Generator[Node, None, None]:
        if self.initializer is not None:
            yield self.initializer
        if self.condition is not None:
            yield self.condition
        if self.iterator is not None:
            yield self.iterator
        if self.body is not None:
            yield self.body


@dataclass(repr=False)
class Ps1ForEachLoop(Statement):
    variable: Expression | None = None
    iterable: Expression | None = None
    body: Block | None = None
    parallel: bool = False
    label: str | None = None

    def __post_init__(self):
        self._adopt(self.variable, self.iterable, self.body)

    def children(self) -> Generator[Node, None, None]:
        if self.variable is not None:
            yield self.variable
        if self.iterable is not None:
            yield self.iterable
        if self.body is not None:
            yield self.body


@dataclass(repr=False)
class Ps1SwitchStatement(Statement):
    value: Expression | None = None
    clauses: list[tuple[Expression | None, Block]] = field(default_factory=list)
    regex: bool = False
    wildcard: bool = False
    exact: bool = False
    case_sensitive: bool = False
    file: bool = False
    label: str | None = None

    def __post_init__(self):
        self._adopt(self.value)
        for cond, body in self.clauses:
            self._adopt(cond, body)

    def children(self) -> Generator[Node, None, None]:
        if self.value is not None:
            yield self.value
        for cond, body in self.clauses:
            if cond is not None:
                yield cond
            yield body


@dataclass(repr=False)
class Ps1CatchClause(Node):
    types: list[str] = field(default_factory=list)
    body: Block | None = None

    def __post_init__(self):
        self._adopt(self.body)

    def children(self) -> Generator[Node, None, None]:
        if self.body is not None:
            yield self.body


@dataclass(repr=False)
class Ps1TryCatchFinally(Statement):
    try_block: Block | None = None
    catch_clauses: list[Ps1CatchClause] = field(default_factory=list)
    finally_block: Block | None = None

    def __post_init__(self):
        self._adopt(self.try_block, *self.catch_clauses, self.finally_block)

    def children(self) -> Generator[Node, None, None]:
        if self.try_block is not None:
            yield self.try_block
        yield from self.catch_clauses
        if self.finally_block is not None:
            yield self.finally_block


@dataclass(repr=False)
class Ps1TrapStatement(Statement):
    type_name: str = ''
    body: Block | None = None

    def __post_init__(self):
        self._adopt(self.body)

    def children(self) -> Generator[Node, None, None]:
        if self.body is not None:
            yield self.body


@dataclass(repr=False)
class Ps1FunctionDefinition(Statement):
    name: str = ''
    is_filter: bool = False
    body: Ps1ScriptBlock | None = None

    def __post_init__(self):
        self._adopt(self.body)

    def children(self) -> Generator[Node, None, None]:
        if self.body is not None:
            yield self.body


@dataclass(repr=False)
class Ps1ReturnStatement(Statement):
    pipeline: Expression | None = None

    def __post_init__(self):
        self._adopt(self.pipeline)

    def children(self) -> Generator[Node, None, None]:
        if self.pipeline is not None:
            yield self.pipeline


@dataclass(repr=False)
class Ps1ThrowStatement(Statement):
    pipeline: Expression | None = None

    def __post_init__(self):
        self._adopt(self.pipeline)

    def children(self) -> Generator[Node, None, None]:
        if self.pipeline is not None:
            yield self.pipeline


@dataclass(repr=False)
class Ps1BreakStatement(Statement):
    label: Expression | None = None

    def __post_init__(self):
        self._adopt(self.label)

    def children(self) -> Generator[Node, None, None]:
        if self.label is not None:
            yield self.label


@dataclass(repr=False)
class Ps1ContinueStatement(Statement):
    label: Expression | None = None

    def __post_init__(self):
        self._adopt(self.label)

    def children(self) -> Generator[Node, None, None]:
        if self.label is not None:
            yield self.label


@dataclass(repr=False)
class Ps1ExitStatement(Statement):
    pipeline: Expression | None = None

    def __post_init__(self):
        self._adopt(self.pipeline)

    def children(self) -> Generator[Node, None, None]:
        if self.pipeline is not None:
            yield self.pipeline


@dataclass(repr=False)
class Ps1DataSection(Statement):
    name: str = ''
    commands: list[Expression] = field(default_factory=list)
    body: Block | None = None

    def __post_init__(self):
        for cmd in self.commands:
            self._adopt(cmd)
        self._adopt(self.body)

    def children(self) -> Generator[Node, None, None]:
        yield from self.commands
        if self.body is not None:
            yield self.body


@dataclass(repr=False)
class Ps1ErrorNode(Node):
    text: str = ''
    message: str = ''

    def children(self) -> Generator[Node, None, None]:
        yield from ()


@dataclass(repr=False)
class Ps1Script(Statement):
    param_block: Ps1ParamBlock | None = None
    begin_block: Block | None = None
    process_block: Block | None = None
    end_block: Block | None = None
    dynamicparam_block: Block | None = None
    body: list[Statement] = field(default_factory=list)

    def __post_init__(self):
        self._adopt(
            self.param_block,
            self.begin_block,
            self.process_block,
            self.end_block,
            self.dynamicparam_block,
            *self.body,
        )

    def children(self) -> Generator[Node, None, None]:
        if self.param_block is not None:
            yield self.param_block
        if self.begin_block is not None:
            yield self.begin_block
        if self.process_block is not None:
            yield self.process_block
        if self.end_block is not None:
            yield self.end_block
        if self.dynamicparam_block is not None:
            yield self.dynamicparam_block
        yield from self.body

Classes

class Ps1ScopeModifier (*args, **kwds)

Create a collection of name/value pairs.

Example enumeration:

>>> class Color(Enum):
...     RED = 1
...     BLUE = 2
...     GREEN = 3

Access them by:

  • attribute access:

Color.RED

  • value lookup:

Color(1)

  • name lookup:

Color['RED']

Enumerations can be iterated over, and know how many members they have:

>>> len(Color)
3
>>> list(Color)
[<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]

Methods can be added to enumerations, and members can have their own attributes – see the documentation for details.

Expand source code Browse git
class Ps1ScopeModifier(enum.Enum):
    NONE     = ''          # noqa
    GLOBAL   = 'global'    # noqa
    LOCAL    = 'local'     # noqa
    SCRIPT   = 'script'    # noqa
    PRIVATE  = 'private'   # noqa
    USING    = 'using'     # noqa
    ENV      = 'env'       # noqa
    VARIABLE = 'variable'  # noqa
    FUNCTION = 'function'  # noqa
    ALIAS    = 'alias'     # noqa
    DRIVE    = 'drive'     # noqa

Ancestors

  • enum.Enum

Class variables

var NONE

The type of the None singleton.

var GLOBAL

The type of the None singleton.

var LOCAL

The type of the None singleton.

var SCRIPT

The type of the None singleton.

var PRIVATE

The type of the None singleton.

var USING

The type of the None singleton.

var ENV

The type of the None singleton.

var VARIABLE

The type of the None singleton.

var FUNCTION

The type of the None singleton.

var ALIAS

The type of the None singleton.

var DRIVE

The type of the None singleton.

class Ps1CommandArgumentKind (*args, **kwds)

Create a collection of name/value pairs.

Example enumeration:

>>> class Color(Enum):
...     RED = 1
...     BLUE = 2
...     GREEN = 3

Access them by:

  • attribute access:

Color.RED

  • value lookup:

Color(1)

  • name lookup:

Color['RED']

Enumerations can be iterated over, and know how many members they have:

>>> len(Color)
3
>>> list(Color)
[<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]

Methods can be added to enumerations, and members can have their own attributes – see the documentation for details.

Expand source code Browse git
class Ps1CommandArgumentKind(enum.Enum):
    POSITIONAL = 'positional'
    NAMED = 'named'
    SWITCH = 'switch'

Ancestors

  • enum.Enum

Class variables

var POSITIONAL

The type of the None singleton.

var NAMED

The type of the None singleton.

var SWITCH

The type of the None singleton.

class Ps1AccessKind (*args, **kwds)

Create a collection of name/value pairs.

Example enumeration:

>>> class Color(Enum):
...     RED = 1
...     BLUE = 2
...     GREEN = 3

Access them by:

  • attribute access:

Color.RED

  • value lookup:

Color(1)

  • name lookup:

Color['RED']

Enumerations can be iterated over, and know how many members they have:

>>> len(Color)
3
>>> list(Color)
[<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]

Methods can be added to enumerations, and members can have their own attributes – see the documentation for details.

Expand source code Browse git
class Ps1AccessKind(enum.Enum):
    INSTANCE = '.'
    STATIC = '::'

Ancestors

  • enum.Enum

Class variables

var INSTANCE

The type of the None singleton.

var STATIC

The type of the None singleton.

class Ps1Variable (offset=-1, parent=None, leading_comments=<factory>, name='', scope=Ps1ScopeModifier.NONE, braced=False, splatted=False)

Ps1Variable(offset: 'int' = -1, parent: 'Node | None' = None, leading_comments: 'list[str]' = , name: 'str' = '', scope: 'Ps1ScopeModifier' = , braced: 'bool' = False, splatted: 'bool' = False)

Expand source code Browse git
@dataclass(repr=False)
class Ps1Variable(Expression):
    name: str = ''
    scope: Ps1ScopeModifier = Ps1ScopeModifier.NONE
    braced: bool = False
    splatted: bool = False

    def children(self) -> Generator[Node, None, None]:
        yield from ()

Ancestors

Instance variables

var name

The type of the None singleton.

var scope

The type of the None singleton.

var braced

The type of the None singleton.

var splatted

The type of the None singleton.

Methods

def children(self)
Expand source code Browse git
def children(self) -> Generator[Node, None, None]:
    yield from ()

Inherited members

class Ps1IntegerLiteral (offset=-1, parent=None, leading_comments=<factory>, value=0, raw='0')

Ps1IntegerLiteral(offset: 'int' = -1, parent: 'Node | None' = None, leading_comments: 'list[str]' = , value: 'int' = 0, raw: 'str' = '0')

Expand source code Browse git
@dataclass(repr=False)
class Ps1IntegerLiteral(Expression):
    value: int = 0
    raw: str = '0'

    def children(self) -> Generator[Node, None, None]:
        yield from ()

Ancestors

Instance variables

var value

The type of the None singleton.

var raw

The type of the None singleton.

Methods

def children(self)
Expand source code Browse git
def children(self) -> Generator[Node, None, None]:
    yield from ()

Inherited members

class Ps1RealLiteral (offset=-1, parent=None, leading_comments=<factory>, value=0.0, raw='0.0')

Ps1RealLiteral(offset: 'int' = -1, parent: 'Node | None' = None, leading_comments: 'list[str]' = , value: 'float' = 0.0, raw: 'str' = '0.0')

Expand source code Browse git
@dataclass(repr=False)
class Ps1RealLiteral(Expression):
    value: float = 0.0
    raw: str = '0.0'

    def children(self) -> Generator[Node, None, None]:
        yield from ()

Ancestors

Instance variables

var value

The type of the None singleton.

var raw

The type of the None singleton.

Methods

def children(self)
Expand source code Browse git
def children(self) -> Generator[Node, None, None]:
    yield from ()

Inherited members

class Ps1StringLiteral (offset=-1, parent=None, leading_comments=<factory>, value='', raw="''")

Ps1StringLiteral(offset: 'int' = -1, parent: 'Node | None' = None, leading_comments: 'list[str]' = , value: 'str' = '', raw: 'str' = "''")

Expand source code Browse git
@dataclass(repr=False)
class Ps1StringLiteral(Expression):
    value: str = ''
    raw: str = "''"

    def children(self) -> Generator[Node, None, None]:
        yield from ()

Ancestors

Instance variables

var value

The type of the None singleton.

var raw

The type of the None singleton.

Methods

def children(self)
Expand source code Browse git
def children(self) -> Generator[Node, None, None]:
    yield from ()

Inherited members

class Ps1ExpandableString (offset=-1, parent=None, leading_comments=<factory>, parts=<factory>, raw='""')

An expandable (double-quoted) string with interleaved text and expression parts. Text segments are Ps1StringLiteral, expression segments are any Expression node.

Expand source code Browse git
@dataclass(repr=False)
class Ps1ExpandableString(Expression):
    """
    An expandable (double-quoted) string with interleaved text and expression
    parts. Text segments are `Ps1StringLiteral`, expression segments are any
    `Expression` node.
    """
    parts: list[Expression] = field(default_factory=list)
    raw: str = '""'

    def __post_init__(self):
        self._adopt(*self.parts)

    def children(self) -> Generator[Node, None, None]:
        yield from self.parts

Ancestors

Instance variables

var parts

The type of the None singleton.

var raw

The type of the None singleton.

Methods

def children(self)
Expand source code Browse git
def children(self) -> Generator[Node, None, None]:
    yield from self.parts

Inherited members

class Ps1HereString (offset=-1, parent=None, leading_comments=<factory>, value='', raw='', expandable=False)

Ps1HereString(offset: 'int' = -1, parent: 'Node | None' = None, leading_comments: 'list[str]' = , value: 'str' = '', raw: 'str' = '', expandable: 'bool' = False)

Expand source code Browse git
@dataclass(repr=False)
class Ps1HereString(Expression):
    value: str = ''
    raw: str = ''
    expandable: bool = False

    def children(self) -> Generator[Node, None, None]:
        yield from ()

Ancestors

Instance variables

var value

The type of the None singleton.

var raw

The type of the None singleton.

var expandable

The type of the None singleton.

Methods

def children(self)
Expand source code Browse git
def children(self) -> Generator[Node, None, None]:
    yield from ()

Inherited members

class Ps1ExpandableHereString (offset=-1, parent=None, leading_comments=<factory>, parts=<factory>, raw='')

Ps1ExpandableHereString(offset: 'int' = -1, parent: 'Node | None' = None, leading_comments: 'list[str]' = , parts: 'list[Expression]' = , raw: 'str' = '')

Expand source code Browse git
@dataclass(repr=False)
class Ps1ExpandableHereString(Expression):
    parts: list[Expression] = field(default_factory=list)
    raw: str = ''

    def __post_init__(self):
        self._adopt(*self.parts)

    def children(self) -> Generator[Node, None, None]:
        yield from self.parts

Ancestors

Instance variables

var parts

The type of the None singleton.

var raw

The type of the None singleton.

Methods

def children(self)
Expand source code Browse git
def children(self) -> Generator[Node, None, None]:
    yield from self.parts

Inherited members

class Ps1BinaryExpression (offset=-1, parent=None, leading_comments=<factory>, left=None, operator='', right=None)

Ps1BinaryExpression(offset: 'int' = -1, parent: 'Node | None' = None, leading_comments: 'list[str]' = , left: 'Expression | None' = None, operator: 'str' = '', right: 'Expression | None' = None)

Expand source code Browse git
@dataclass(repr=False)
class Ps1BinaryExpression(Expression):
    left: Expression | None = None
    operator: str = ''
    right: Expression | None = None

    def __post_init__(self):
        self._adopt(self.left, self.right)

    def children(self) -> Generator[Node, None, None]:
        if self.left is not None:
            yield self.left
        if self.right is not None:
            yield self.right

Ancestors

Instance variables

var left

The type of the None singleton.

var operator

The type of the None singleton.

var right

The type of the None singleton.

Methods

def children(self)
Expand source code Browse git
def children(self) -> Generator[Node, None, None]:
    if self.left is not None:
        yield self.left
    if self.right is not None:
        yield self.right

Inherited members

class Ps1UnaryExpression (offset=-1, parent=None, leading_comments=<factory>, operator='', operand=None, prefix=True)

Ps1UnaryExpression(offset: 'int' = -1, parent: 'Node | None' = None, leading_comments: 'list[str]' = , operator: 'str' = '', operand: 'Expression | None' = None, prefix: 'bool' = True)

Expand source code Browse git
@dataclass(repr=False)
class Ps1UnaryExpression(Expression):
    operator: str = ''
    operand: Expression | None = None
    prefix: bool = True

    def __post_init__(self):
        self._adopt(self.operand)

    def children(self) -> Generator[Node, None, None]:
        if self.operand is not None:
            yield self.operand

Ancestors

Instance variables

var operator

The type of the None singleton.

var operand

The type of the None singleton.

var prefix

The type of the None singleton.

Methods

def children(self)
Expand source code Browse git
def children(self) -> Generator[Node, None, None]:
    if self.operand is not None:
        yield self.operand

Inherited members

class Ps1TypeExpression (offset=-1, parent=None, leading_comments=<factory>, name='')

Ps1TypeExpression(offset: 'int' = -1, parent: 'Node | None' = None, leading_comments: 'list[str]' = , name: 'str' = '')

Expand source code Browse git
@dataclass(repr=False)
class Ps1TypeExpression(Expression):
    name: str = ''

    def children(self) -> Generator[Node, None, None]:
        yield from ()

Ancestors

Instance variables

var name

The type of the None singleton.

Methods

def children(self)
Expand source code Browse git
def children(self) -> Generator[Node, None, None]:
    yield from ()

Inherited members

class Ps1CastExpression (offset=-1, parent=None, leading_comments=<factory>, type_name='', operand=None)

Ps1CastExpression(offset: 'int' = -1, parent: 'Node | None' = None, leading_comments: 'list[str]' = , type_name: 'str' = '', operand: 'Expression | None' = None)

Expand source code Browse git
@dataclass(repr=False)
class Ps1CastExpression(Expression):
    type_name: str = ''
    operand: Expression | None = None

    def __post_init__(self):
        self._adopt(self.operand)

    def children(self) -> Generator[Node, None, None]:
        if self.operand is not None:
            yield self.operand

Ancestors

Instance variables

var type_name

The type of the None singleton.

var operand

The type of the None singleton.

Methods

def children(self)
Expand source code Browse git
def children(self) -> Generator[Node, None, None]:
    if self.operand is not None:
        yield self.operand

Inherited members

class Ps1MemberAccess (offset=-1, parent=None, leading_comments=<factory>, object=None, member='', access=Ps1AccessKind.INSTANCE)

Ps1MemberAccess(offset: 'int' = -1, parent: 'Node | None' = None, leading_comments: 'list[str]' = , object: 'Expression | None' = None, member: 'str | Expression' = '', access: 'Ps1AccessKind' = )

Expand source code Browse git
@dataclass(repr=False)
class Ps1MemberAccess(Expression):
    object: Expression | None = None
    member: str | Expression = ''
    access: Ps1AccessKind = Ps1AccessKind.INSTANCE

    def __post_init__(self):
        self._adopt(self.object)
        if isinstance(self.member, Expression):
            self._adopt(self.member)

    def children(self) -> Generator[Node, None, None]:
        if self.object is not None:
            yield self.object
        if isinstance(self.member, Expression):
            yield self.member

Ancestors

Instance variables

var object

The type of the None singleton.

var member

The type of the None singleton.

var access

The type of the None singleton.

Methods

def children(self)
Expand source code Browse git
def children(self) -> Generator[Node, None, None]:
    if self.object is not None:
        yield self.object
    if isinstance(self.member, Expression):
        yield self.member

Inherited members

class Ps1IndexExpression (offset=-1, parent=None, leading_comments=<factory>, object=None, index=None)

Ps1IndexExpression(offset: 'int' = -1, parent: 'Node | None' = None, leading_comments: 'list[str]' = , object: 'Expression | None' = None, index: 'Expression | None' = None)

Expand source code Browse git
@dataclass(repr=False)
class Ps1IndexExpression(Expression):
    object: Expression | None = None
    index: Expression | None = None

    def __post_init__(self):
        self._adopt(self.object, self.index)

    def children(self) -> Generator[Node, None, None]:
        if self.object is not None:
            yield self.object
        if self.index is not None:
            yield self.index

Ancestors

Instance variables

var object

The type of the None singleton.

var index

The type of the None singleton.

Methods

def children(self)
Expand source code Browse git
def children(self) -> Generator[Node, None, None]:
    if self.object is not None:
        yield self.object
    if self.index is not None:
        yield self.index

Inherited members

class Ps1InvokeMember (offset=-1, parent=None, leading_comments=<factory>, object=None, member='', arguments=<factory>, access=Ps1AccessKind.INSTANCE)

Ps1InvokeMember(offset: 'int' = -1, parent: 'Node | None' = None, leading_comments: 'list[str]' = , object: 'Expression | None' = None, member: 'str | Expression' = '', arguments: 'list[Expression]' = , access: 'Ps1AccessKind' = )

Expand source code Browse git
@dataclass(repr=False)
class Ps1InvokeMember(Expression):
    object: Expression | None = None
    member: str | Expression = ''
    arguments: list[Expression] = field(default_factory=list)
    access: Ps1AccessKind = Ps1AccessKind.INSTANCE

    def __post_init__(self):
        self._adopt(self.object, *self.arguments)
        if isinstance(self.member, Expression):
            self._adopt(self.member)

    def children(self) -> Generator[Node, None, None]:
        if self.object is not None:
            yield self.object
        if isinstance(self.member, Expression):
            yield self.member
        yield from self.arguments

Ancestors

Instance variables

var arguments

The type of the None singleton.

var object

The type of the None singleton.

var member

The type of the None singleton.

var access

The type of the None singleton.

Methods

def children(self)
Expand source code Browse git
def children(self) -> Generator[Node, None, None]:
    if self.object is not None:
        yield self.object
    if isinstance(self.member, Expression):
        yield self.member
    yield from self.arguments

Inherited members

class Ps1CommandArgument (offset=-1, parent=None, leading_comments=<factory>, kind=Ps1CommandArgumentKind.POSITIONAL, name='', value=None)

Ps1CommandArgument(offset: 'int' = -1, parent: 'Node | None' = None, leading_comments: 'list[str]' = , kind: 'Ps1CommandArgumentKind' = , name: 'str' = '', value: 'Expression | None' = None)

Expand source code Browse git
@dataclass(repr=False)
class Ps1CommandArgument(Node):
    kind: Ps1CommandArgumentKind = Ps1CommandArgumentKind.POSITIONAL
    name: str = ''
    value: Expression | None = None

    def __post_init__(self):
        self._adopt(self.value)

    def children(self) -> Generator[Node, None, None]:
        if self.value is not None:
            yield self.value

Ancestors

Instance variables

var kind

The type of the None singleton.

var name

The type of the None singleton.

var value

The type of the None singleton.

Methods

def children(self)
Expand source code Browse git
def children(self) -> Generator[Node, None, None]:
    if self.value is not None:
        yield self.value

Inherited members

class Ps1CommandInvocation (offset=-1, parent=None, leading_comments=<factory>, name=None, arguments=<factory>, invocation_operator='')

Ps1CommandInvocation(offset: 'int' = -1, parent: 'Node | None' = None, leading_comments: 'list[str]' = , name: 'Expression | None' = None, arguments: 'list[Ps1CommandArgument | Expression]' = , invocation_operator: 'str' = '')

Expand source code Browse git
@dataclass(repr=False)
class Ps1CommandInvocation(Expression):
    name: Expression | None = None
    arguments: list[Ps1CommandArgument | Expression] = field(default_factory=list)
    invocation_operator: str = ''

    def __post_init__(self):
        self._adopt(self.name, *self.arguments)

    def children(self) -> Generator[Node, None, None]:
        if self.name is not None:
            yield self.name
        yield from self.arguments

Ancestors

Instance variables

var arguments

The type of the None singleton.

var name

The type of the None singleton.

var invocation_operator

The type of the None singleton.

Methods

def children(self)
Expand source code Browse git
def children(self) -> Generator[Node, None, None]:
    if self.name is not None:
        yield self.name
    yield from self.arguments

Inherited members

class Ps1CallExpression (offset=-1, parent=None, leading_comments=<factory>, callee=None, arguments=<factory>)

Ps1CallExpression(offset: 'int' = -1, parent: 'Node | None' = None, leading_comments: 'list[str]' = , callee: 'Expression | None' = None, arguments: 'list[Expression]' = )

Expand source code Browse git
@dataclass(repr=False)
class Ps1CallExpression(Expression):
    callee: Expression | None = None
    arguments: list[Expression] = field(default_factory=list)

    def __post_init__(self):
        self._adopt(self.callee, *self.arguments)

    def children(self) -> Generator[Node, None, None]:
        if self.callee is not None:
            yield self.callee
        yield from self.arguments

Ancestors

Instance variables

var arguments

The type of the None singleton.

var callee

The type of the None singleton.

Methods

def children(self)
Expand source code Browse git
def children(self) -> Generator[Node, None, None]:
    if self.callee is not None:
        yield self.callee
    yield from self.arguments

Inherited members

class Ps1AssignmentExpression (offset=-1, parent=None, leading_comments=<factory>, target=None, operator='=', value=None)

Ps1AssignmentExpression(offset: 'int' = -1, parent: 'Node | None' = None, leading_comments: 'list[str]' = , target: 'Expression | None' = None, operator: 'str' = '=', value: 'Expression | None' = None)

Expand source code Browse git
@dataclass(repr=False)
class Ps1AssignmentExpression(Expression):
    target: Expression | None = None
    operator: str = '='
    value: Expression | None = None

    def __post_init__(self):
        self._adopt(self.target, self.value)

    def children(self) -> Generator[Node, None, None]:
        if self.target is not None:
            yield self.target
        if self.value is not None:
            yield self.value

Ancestors

Instance variables

var target

The type of the None singleton.

var operator

The type of the None singleton.

var value

The type of the None singleton.

Methods

def children(self)
Expand source code Browse git
def children(self) -> Generator[Node, None, None]:
    if self.target is not None:
        yield self.target
    if self.value is not None:
        yield self.value

Inherited members

class Ps1ArrayLiteral (offset=-1, parent=None, leading_comments=<factory>, elements=<factory>)

Ps1ArrayLiteral(offset: 'int' = -1, parent: 'Node | None' = None, leading_comments: 'list[str]' = , elements: 'list[Expression]' = )

Expand source code Browse git
@dataclass(repr=False)
class Ps1ArrayLiteral(Expression):
    elements: list[Expression] = field(default_factory=list)

    def __post_init__(self):
        self._adopt(*self.elements)

    def children(self) -> Generator[Node, None, None]:
        yield from self.elements

Ancestors

Instance variables

var elements

The type of the None singleton.

Methods

def children(self)
Expand source code Browse git
def children(self) -> Generator[Node, None, None]:
    yield from self.elements

Inherited members

class Ps1ArrayExpression (offset=-1, parent=None, leading_comments=<factory>, body=<factory>)

Ps1ArrayExpression(offset: 'int' = -1, parent: 'Node | None' = None, leading_comments: 'list[str]' = , body: 'list[Statement]' = )

Expand source code Browse git
@dataclass(repr=False)
class Ps1ArrayExpression(Expression):
    body: list[Statement] = field(default_factory=list)

    def __post_init__(self):
        self._adopt(*self.body)

    def children(self) -> Generator[Node, None, None]:
        yield from self.body

Ancestors

Instance variables

var body

The type of the None singleton.

Methods

def children(self)
Expand source code Browse git
def children(self) -> Generator[Node, None, None]:
    yield from self.body

Inherited members

class Ps1HashLiteral (offset=-1, parent=None, leading_comments=<factory>, pairs=<factory>)

Ps1HashLiteral(offset: 'int' = -1, parent: 'Node | None' = None, leading_comments: 'list[str]' = , pairs: 'list[tuple[Expression, Expression]]' = )

Expand source code Browse git
@dataclass(repr=False)
class Ps1HashLiteral(Expression):
    pairs: list[tuple[Expression, Expression]] = field(default_factory=list)

    def __post_init__(self):
        for k, v in self.pairs:
            self._adopt(k, v)

    def children(self) -> Generator[Node, None, None]:
        for k, v in self.pairs:
            yield k
            yield v

Ancestors

Instance variables

var pairs

The type of the None singleton.

Methods

def children(self)
Expand source code Browse git
def children(self) -> Generator[Node, None, None]:
    for k, v in self.pairs:
        yield k
        yield v

Inherited members

class Ps1SubExpression (offset=-1, parent=None, leading_comments=<factory>, body=<factory>)

Ps1SubExpression(offset: 'int' = -1, parent: 'Node | None' = None, leading_comments: 'list[str]' = , body: 'list[Statement]' = )

Expand source code Browse git
@dataclass(repr=False)
class Ps1SubExpression(Expression):
    body: list[Statement] = field(default_factory=list)

    def __post_init__(self):
        self._adopt(*self.body)

    def children(self) -> Generator[Node, None, None]:
        yield from self.body

Ancestors

Instance variables

var body

The type of the None singleton.

Methods

def children(self)
Expand source code Browse git
def children(self) -> Generator[Node, None, None]:
    yield from self.body

Inherited members

class Ps1ParenExpression (offset=-1, parent=None, leading_comments=<factory>, expression=None)

Ps1ParenExpression(offset: 'int' = -1, parent: 'Node | None' = None, leading_comments: 'list[str]' = , expression: 'Expression | None' = None)

Expand source code Browse git
@dataclass(repr=False)
class Ps1ParenExpression(Expression):
    expression: Expression | None = None

    def __post_init__(self):
        self._adopt(self.expression)

    def children(self) -> Generator[Node, None, None]:
        if self.expression is not None:
            yield self.expression

Ancestors

Instance variables

var expression

The type of the None singleton.

Methods

def children(self)
Expand source code Browse git
def children(self) -> Generator[Node, None, None]:
    if self.expression is not None:
        yield self.expression

Inherited members

class Ps1ScriptBlock (offset=-1, parent=None, leading_comments=<factory>, param_block=None, begin_block=None, process_block=None, end_block=None, dynamicparam_block=None, body=<factory>)

Ps1ScriptBlock(offset: 'int' = -1, parent: 'Node | None' = None, leading_comments: 'list[str]' = , param_block: 'Ps1ParamBlock | None' = None, begin_block: 'Block | None' = None, process_block: 'Block | None' = None, end_block: 'Block | None' = None, dynamicparam_block: 'Block | None' = None, body: 'list[Statement]' = )

Expand source code Browse git
@dataclass(repr=False)
class Ps1ScriptBlock(Expression):
    param_block: Ps1ParamBlock | None = None
    begin_block: Block | None = None
    process_block: Block | None = None
    end_block: Block | None = None
    dynamicparam_block: Block | None = None
    body: list[Statement] = field(default_factory=list)

    def __post_init__(self):
        self._adopt(
            self.param_block,
            self.begin_block,
            self.process_block,
            self.end_block,
            self.dynamicparam_block,
            *self.body,
        )

    def children(self) -> Generator[Node, None, None]:
        if self.param_block is not None:
            yield self.param_block
        if self.begin_block is not None:
            yield self.begin_block
        if self.process_block is not None:
            yield self.process_block
        if self.end_block is not None:
            yield self.end_block
        if self.dynamicparam_block is not None:
            yield self.dynamicparam_block
        yield from self.body

Ancestors

Instance variables

var body

The type of the None singleton.

var param_block

The type of the None singleton.

var begin_block

The type of the None singleton.

var process_block

The type of the None singleton.

var end_block

The type of the None singleton.

var dynamicparam_block

The type of the None singleton.

Methods

def children(self)
Expand source code Browse git
def children(self) -> Generator[Node, None, None]:
    if self.param_block is not None:
        yield self.param_block
    if self.begin_block is not None:
        yield self.begin_block
    if self.process_block is not None:
        yield self.process_block
    if self.end_block is not None:
        yield self.end_block
    if self.dynamicparam_block is not None:
        yield self.dynamicparam_block
    yield from self.body

Inherited members

class Ps1RangeExpression (offset=-1, parent=None, leading_comments=<factory>, start=None, end=None)

Ps1RangeExpression(offset: 'int' = -1, parent: 'Node | None' = None, leading_comments: 'list[str]' = , start: 'Expression | None' = None, end: 'Expression | None' = None)

Expand source code Browse git
@dataclass(repr=False)
class Ps1RangeExpression(Expression):
    start: Expression | None = None
    end: Expression | None = None

    def __post_init__(self):
        self._adopt(self.start, self.end)

    def children(self) -> Generator[Node, None, None]:
        if self.start is not None:
            yield self.start
        if self.end is not None:
            yield self.end

Ancestors

Instance variables

var start

The type of the None singleton.

var end

The type of the None singleton.

Methods

def children(self)
Expand source code Browse git
def children(self) -> Generator[Node, None, None]:
    if self.start is not None:
        yield self.start
    if self.end is not None:
        yield self.end

Inherited members

class Ps1Attribute (offset=-1, parent=None, leading_comments=<factory>, name='', positional_args=<factory>, named_args=<factory>)

Ps1Attribute(offset: 'int' = -1, parent: 'Node | None' = None, leading_comments: 'list[str]' = , name: 'str' = '', positional_args: 'list[Expression]' = , named_args: 'list[tuple[str, Expression]]' = )

Expand source code Browse git
@dataclass(repr=False)
class Ps1Attribute(Node):
    name: str = ''
    positional_args: list[Expression] = field(default_factory=list)
    named_args: list[tuple[str, Expression]] = field(default_factory=list)

    def __post_init__(self):
        self._adopt(*self.positional_args)
        for _, v in self.named_args:
            self._adopt(v)

    def children(self) -> Generator[Node, None, None]:
        yield from self.positional_args
        for _, v in self.named_args:
            yield v

Ancestors

Instance variables

var positional_args

The type of the None singleton.

var named_args

The type of the None singleton.

var name

The type of the None singleton.

Methods

def children(self)
Expand source code Browse git
def children(self) -> Generator[Node, None, None]:
    yield from self.positional_args
    for _, v in self.named_args:
        yield v

Inherited members

class Ps1ParameterDeclaration (offset=-1, parent=None, leading_comments=<factory>, variable=None, attributes=<factory>, default_value=None)

Ps1ParameterDeclaration(offset: 'int' = -1, parent: 'Node | None' = None, leading_comments: 'list[str]' = , variable: 'Ps1Variable | None' = None, attributes: 'list[Ps1Attribute | Ps1TypeExpression]' = , default_value: 'Expression | None' = None)

Expand source code Browse git
@dataclass(repr=False)
class Ps1ParameterDeclaration(Node):
    variable: Ps1Variable | None = None
    attributes: list[Ps1Attribute | Ps1TypeExpression] = field(default_factory=list)
    default_value: Expression | None = None

    def __post_init__(self):
        self._adopt(self.variable, *self.attributes, self.default_value)

    def children(self) -> Generator[Node, None, None]:
        yield from self.attributes
        if self.variable is not None:
            yield self.variable
        if self.default_value is not None:
            yield self.default_value

Ancestors

Instance variables

var attributes

The type of the None singleton.

var variable

The type of the None singleton.

var default_value

The type of the None singleton.

Methods

def children(self)
Expand source code Browse git
def children(self) -> Generator[Node, None, None]:
    yield from self.attributes
    if self.variable is not None:
        yield self.variable
    if self.default_value is not None:
        yield self.default_value

Inherited members

class Ps1ParamBlock (offset=-1, parent=None, leading_comments=<factory>, parameters=<factory>, attributes=<factory>)

Ps1ParamBlock(offset: 'int' = -1, parent: 'Node | None' = None, leading_comments: 'list[str]' = , parameters: 'list[Ps1ParameterDeclaration]' = , attributes: 'list[Ps1Attribute]' = )

Expand source code Browse git
@dataclass(repr=False)
class Ps1ParamBlock(Node):
    parameters: list[Ps1ParameterDeclaration] = field(default_factory=list)
    attributes: list[Ps1Attribute] = field(default_factory=list)

    def __post_init__(self):
        self._adopt(*self.parameters, *self.attributes)

    def children(self) -> Generator[Node, None, None]:
        yield from self.attributes
        yield from self.parameters

Ancestors

Instance variables

var parameters

The type of the None singleton.

var attributes

The type of the None singleton.

Methods

def children(self)
Expand source code Browse git
def children(self) -> Generator[Node, None, None]:
    yield from self.attributes
    yield from self.parameters

Inherited members

class Ps1Redirection (offset=-1, parent=None, leading_comments=<factory>, operator='>', target=None)

Ps1Redirection(offset: 'int' = -1, parent: 'Node | None' = None, leading_comments: 'list[str]' = , operator: 'str' = '>', target: 'Expression | None' = None)

Expand source code Browse git
@dataclass(repr=False)
class Ps1Redirection(Node):
    operator: str = '>'
    target: Expression | None = None

    def __post_init__(self):
        self._adopt(self.target)

    def children(self) -> Generator[Node, None, None]:
        if self.target is not None:
            yield self.target

Ancestors

Instance variables

var operator

The type of the None singleton.

var target

The type of the None singleton.

Methods

def children(self)
Expand source code Browse git
def children(self) -> Generator[Node, None, None]:
    if self.target is not None:
        yield self.target

Inherited members

class Ps1PipelineElement (offset=-1, parent=None, leading_comments=<factory>, expression=None, redirections=<factory>)

Ps1PipelineElement(offset: 'int' = -1, parent: 'Node | None' = None, leading_comments: 'list[str]' = , expression: 'Expression | None' = None, redirections: 'list[Ps1Redirection]' = )

Expand source code Browse git
@dataclass(repr=False)
class Ps1PipelineElement(Node):
    expression: Expression | None = None
    redirections: list[Ps1Redirection] = field(default_factory=list)

    def __post_init__(self):
        self._adopt(self.expression, *self.redirections)

    def children(self) -> Generator[Node, None, None]:
        if self.expression is not None:
            yield self.expression
        yield from self.redirections

Ancestors

Instance variables

var redirections

The type of the None singleton.

var expression

The type of the None singleton.

Methods

def children(self)
Expand source code Browse git
def children(self) -> Generator[Node, None, None]:
    if self.expression is not None:
        yield self.expression
    yield from self.redirections

Inherited members

class Ps1Pipeline (offset=-1, parent=None, leading_comments=<factory>, elements=<factory>)

Ps1Pipeline(offset: 'int' = -1, parent: 'Node | None' = None, leading_comments: 'list[str]' = , elements: 'list[Ps1PipelineElement]' = )

Expand source code Browse git
@dataclass(repr=False)
class Ps1Pipeline(Statement):
    elements: list[Ps1PipelineElement] = field(default_factory=list)

    def __post_init__(self):
        self._adopt(*self.elements)

    def children(self) -> Generator[Node, None, None]:
        yield from self.elements

Ancestors

Instance variables

var elements

The type of the None singleton.

Methods

def children(self)
Expand source code Browse git
def children(self) -> Generator[Node, None, None]:
    yield from self.elements

Inherited members

class Ps1ExpressionStatement (offset=-1, parent=None, leading_comments=<factory>, expression=None)

Ps1ExpressionStatement(offset: 'int' = -1, parent: 'Node | None' = None, leading_comments: 'list[str]' = , expression: 'Expression | None' = None)

Expand source code Browse git
@dataclass(repr=False)
class Ps1ExpressionStatement(Statement):
    expression: Expression | None = None

    def __post_init__(self):
        self._adopt(self.expression)

    def children(self) -> Generator[Node, None, None]:
        if self.expression is not None:
            yield self.expression

Ancestors

Instance variables

var expression

The type of the None singleton.

Methods

def children(self)
Expand source code Browse git
def children(self) -> Generator[Node, None, None]:
    if self.expression is not None:
        yield self.expression

Inherited members

class Ps1IfStatement (offset=-1, parent=None, leading_comments=<factory>, clauses=<factory>, else_block=None)

Ps1IfStatement(offset: 'int' = -1, parent: 'Node | None' = None, leading_comments: 'list[str]' = , clauses: 'list[tuple[Expression, Block]]' = , else_block: 'Block | None' = None)

Expand source code Browse git
@dataclass(repr=False)
class Ps1IfStatement(Statement):
    clauses: list[tuple[Expression, Block]] = field(default_factory=list)
    else_block: Block | None = None

    def __post_init__(self):
        for cond, body in self.clauses:
            self._adopt(cond, body)
        self._adopt(self.else_block)

    def children(self) -> Generator[Node, None, None]:
        for cond, body in self.clauses:
            yield cond
            yield body
        if self.else_block is not None:
            yield self.else_block

Ancestors

Instance variables

var clauses

The type of the None singleton.

var else_block

The type of the None singleton.

Methods

def children(self)
Expand source code Browse git
def children(self) -> Generator[Node, None, None]:
    for cond, body in self.clauses:
        yield cond
        yield body
    if self.else_block is not None:
        yield self.else_block

Inherited members

class Ps1WhileLoop (offset=-1, parent=None, leading_comments=<factory>, condition=None, body=None, label=None)

Ps1WhileLoop(offset: 'int' = -1, parent: 'Node | None' = None, leading_comments: 'list[str]' = , condition: 'Expression | None' = None, body: 'Block | None' = None, label: 'str | None' = None)

Expand source code Browse git
@dataclass(repr=False)
class Ps1WhileLoop(Statement):
    condition: Expression | None = None
    body: Block | None = None
    label: str | None = None

    def __post_init__(self):
        self._adopt(self.condition, self.body)

    def children(self) -> Generator[Node, None, None]:
        if self.condition is not None:
            yield self.condition
        if self.body is not None:
            yield self.body

Ancestors

Instance variables

var condition

The type of the None singleton.

var body

The type of the None singleton.

var label

The type of the None singleton.

Methods

def children(self)
Expand source code Browse git
def children(self) -> Generator[Node, None, None]:
    if self.condition is not None:
        yield self.condition
    if self.body is not None:
        yield self.body

Inherited members

class Ps1DoWhileLoop (offset=-1, parent=None, leading_comments=<factory>, condition=None, body=None, label=None)

Ps1DoWhileLoop(offset: 'int' = -1, parent: 'Node | None' = None, leading_comments: 'list[str]' = , condition: 'Expression | None' = None, body: 'Block | None' = None, label: 'str | None' = None)

Expand source code Browse git
@dataclass(repr=False)
class Ps1DoWhileLoop(Statement):
    condition: Expression | None = None
    body: Block | None = None
    label: str | None = None

    def __post_init__(self):
        self._adopt(self.condition, self.body)

    def children(self) -> Generator[Node, None, None]:
        if self.body is not None:
            yield self.body
        if self.condition is not None:
            yield self.condition

Ancestors

Instance variables

var condition

The type of the None singleton.

var body

The type of the None singleton.

var label

The type of the None singleton.

Methods

def children(self)
Expand source code Browse git
def children(self) -> Generator[Node, None, None]:
    if self.body is not None:
        yield self.body
    if self.condition is not None:
        yield self.condition

Inherited members

class Ps1DoUntilLoop (offset=-1, parent=None, leading_comments=<factory>, condition=None, body=None, label=None)

Ps1DoUntilLoop(offset: 'int' = -1, parent: 'Node | None' = None, leading_comments: 'list[str]' = , condition: 'Expression | None' = None, body: 'Block | None' = None, label: 'str | None' = None)

Expand source code Browse git
@dataclass(repr=False)
class Ps1DoUntilLoop(Statement):
    condition: Expression | None = None
    body: Block | None = None
    label: str | None = None

    def __post_init__(self):
        self._adopt(self.condition, self.body)

    def children(self) -> Generator[Node, None, None]:
        if self.body is not None:
            yield self.body
        if self.condition is not None:
            yield self.condition

Ancestors

Instance variables

var condition

The type of the None singleton.

var body

The type of the None singleton.

var label

The type of the None singleton.

Methods

def children(self)
Expand source code Browse git
def children(self) -> Generator[Node, None, None]:
    if self.body is not None:
        yield self.body
    if self.condition is not None:
        yield self.condition

Inherited members

class Ps1ForLoop (offset=-1, parent=None, leading_comments=<factory>, initializer=None, condition=None, iterator=None, body=None, label=None)

Ps1ForLoop(offset: 'int' = -1, parent: 'Node | None' = None, leading_comments: 'list[str]' = , initializer: 'Expression | None' = None, condition: 'Expression | None' = None, iterator: 'Expression | None' = None, body: 'Block | None' = None, label: 'str | None' = None)

Expand source code Browse git
@dataclass(repr=False)
class Ps1ForLoop(Statement):
    initializer: Expression | None = None
    condition: Expression | None = None
    iterator: Expression | None = None
    body: Block | None = None
    label: str | None = None

    def __post_init__(self):
        self._adopt(self.initializer, self.condition, self.iterator, self.body)

    def children(self) -> Generator[Node, None, None]:
        if self.initializer is not None:
            yield self.initializer
        if self.condition is not None:
            yield self.condition
        if self.iterator is not None:
            yield self.iterator
        if self.body is not None:
            yield self.body

Ancestors

Instance variables

var initializer

The type of the None singleton.

var condition

The type of the None singleton.

var iterator

The type of the None singleton.

var body

The type of the None singleton.

var label

The type of the None singleton.

Methods

def children(self)
Expand source code Browse git
def children(self) -> Generator[Node, None, None]:
    if self.initializer is not None:
        yield self.initializer
    if self.condition is not None:
        yield self.condition
    if self.iterator is not None:
        yield self.iterator
    if self.body is not None:
        yield self.body

Inherited members

class Ps1ForEachLoop (offset=-1, parent=None, leading_comments=<factory>, variable=None, iterable=None, body=None, parallel=False, label=None)

Ps1ForEachLoop(offset: 'int' = -1, parent: 'Node | None' = None, leading_comments: 'list[str]' = , variable: 'Expression | None' = None, iterable: 'Expression | None' = None, body: 'Block | None' = None, parallel: 'bool' = False, label: 'str | None' = None)

Expand source code Browse git
@dataclass(repr=False)
class Ps1ForEachLoop(Statement):
    variable: Expression | None = None
    iterable: Expression | None = None
    body: Block | None = None
    parallel: bool = False
    label: str | None = None

    def __post_init__(self):
        self._adopt(self.variable, self.iterable, self.body)

    def children(self) -> Generator[Node, None, None]:
        if self.variable is not None:
            yield self.variable
        if self.iterable is not None:
            yield self.iterable
        if self.body is not None:
            yield self.body

Ancestors

Instance variables

var variable

The type of the None singleton.

var iterable

The type of the None singleton.

var body

The type of the None singleton.

var parallel

The type of the None singleton.

var label

The type of the None singleton.

Methods

def children(self)
Expand source code Browse git
def children(self) -> Generator[Node, None, None]:
    if self.variable is not None:
        yield self.variable
    if self.iterable is not None:
        yield self.iterable
    if self.body is not None:
        yield self.body

Inherited members

class Ps1SwitchStatement (offset=-1, parent=None, leading_comments=<factory>, value=None, clauses=<factory>, regex=False, wildcard=False, exact=False, case_sensitive=False, file=False, label=None)

Ps1SwitchStatement(offset: 'int' = -1, parent: 'Node | None' = None, leading_comments: 'list[str]' = , value: 'Expression | None' = None, clauses: 'list[tuple[Expression | None, Block]]' = , regex: 'bool' = False, wildcard: 'bool' = False, exact: 'bool' = False, case_sensitive: 'bool' = False, file: 'bool' = False, label: 'str | None' = None)

Expand source code Browse git
@dataclass(repr=False)
class Ps1SwitchStatement(Statement):
    value: Expression | None = None
    clauses: list[tuple[Expression | None, Block]] = field(default_factory=list)
    regex: bool = False
    wildcard: bool = False
    exact: bool = False
    case_sensitive: bool = False
    file: bool = False
    label: str | None = None

    def __post_init__(self):
        self._adopt(self.value)
        for cond, body in self.clauses:
            self._adopt(cond, body)

    def children(self) -> Generator[Node, None, None]:
        if self.value is not None:
            yield self.value
        for cond, body in self.clauses:
            if cond is not None:
                yield cond
            yield body

Ancestors

Instance variables

var clauses

The type of the None singleton.

var value

The type of the None singleton.

var regex

The type of the None singleton.

var wildcard

The type of the None singleton.

var exact

The type of the None singleton.

var case_sensitive

The type of the None singleton.

var file

The type of the None singleton.

var label

The type of the None singleton.

Methods

def children(self)
Expand source code Browse git
def children(self) -> Generator[Node, None, None]:
    if self.value is not None:
        yield self.value
    for cond, body in self.clauses:
        if cond is not None:
            yield cond
        yield body

Inherited members

class Ps1CatchClause (offset=-1, parent=None, leading_comments=<factory>, types=<factory>, body=None)

Ps1CatchClause(offset: 'int' = -1, parent: 'Node | None' = None, leading_comments: 'list[str]' = , types: 'list[str]' = , body: 'Block | None' = None)

Expand source code Browse git
@dataclass(repr=False)
class Ps1CatchClause(Node):
    types: list[str] = field(default_factory=list)
    body: Block | None = None

    def __post_init__(self):
        self._adopt(self.body)

    def children(self) -> Generator[Node, None, None]:
        if self.body is not None:
            yield self.body

Ancestors

Instance variables

var types

The type of the None singleton.

var body

The type of the None singleton.

Methods

def children(self)
Expand source code Browse git
def children(self) -> Generator[Node, None, None]:
    if self.body is not None:
        yield self.body

Inherited members

class Ps1TryCatchFinally (offset=-1, parent=None, leading_comments=<factory>, try_block=None, catch_clauses=<factory>, finally_block=None)

Ps1TryCatchFinally(offset: 'int' = -1, parent: 'Node | None' = None, leading_comments: 'list[str]' = , try_block: 'Block | None' = None, catch_clauses: 'list[Ps1CatchClause]' = , finally_block: 'Block | None' = None)

Expand source code Browse git
@dataclass(repr=False)
class Ps1TryCatchFinally(Statement):
    try_block: Block | None = None
    catch_clauses: list[Ps1CatchClause] = field(default_factory=list)
    finally_block: Block | None = None

    def __post_init__(self):
        self._adopt(self.try_block, *self.catch_clauses, self.finally_block)

    def children(self) -> Generator[Node, None, None]:
        if self.try_block is not None:
            yield self.try_block
        yield from self.catch_clauses
        if self.finally_block is not None:
            yield self.finally_block

Ancestors

Instance variables

var catch_clauses

The type of the None singleton.

var try_block

The type of the None singleton.

var finally_block

The type of the None singleton.

Methods

def children(self)
Expand source code Browse git
def children(self) -> Generator[Node, None, None]:
    if self.try_block is not None:
        yield self.try_block
    yield from self.catch_clauses
    if self.finally_block is not None:
        yield self.finally_block

Inherited members

class Ps1TrapStatement (offset=-1, parent=None, leading_comments=<factory>, type_name='', body=None)

Ps1TrapStatement(offset: 'int' = -1, parent: 'Node | None' = None, leading_comments: 'list[str]' = , type_name: 'str' = '', body: 'Block | None' = None)

Expand source code Browse git
@dataclass(repr=False)
class Ps1TrapStatement(Statement):
    type_name: str = ''
    body: Block | None = None

    def __post_init__(self):
        self._adopt(self.body)

    def children(self) -> Generator[Node, None, None]:
        if self.body is not None:
            yield self.body

Ancestors

Instance variables

var type_name

The type of the None singleton.

var body

The type of the None singleton.

Methods

def children(self)
Expand source code Browse git
def children(self) -> Generator[Node, None, None]:
    if self.body is not None:
        yield self.body

Inherited members

class Ps1FunctionDefinition (offset=-1, parent=None, leading_comments=<factory>, name='', is_filter=False, body=None)

Ps1FunctionDefinition(offset: 'int' = -1, parent: 'Node | None' = None, leading_comments: 'list[str]' = , name: 'str' = '', is_filter: 'bool' = False, body: 'Ps1ScriptBlock | None' = None)

Expand source code Browse git
@dataclass(repr=False)
class Ps1FunctionDefinition(Statement):
    name: str = ''
    is_filter: bool = False
    body: Ps1ScriptBlock | None = None

    def __post_init__(self):
        self._adopt(self.body)

    def children(self) -> Generator[Node, None, None]:
        if self.body is not None:
            yield self.body

Ancestors

Instance variables

var name

The type of the None singleton.

var is_filter

The type of the None singleton.

var body

The type of the None singleton.

Methods

def children(self)
Expand source code Browse git
def children(self) -> Generator[Node, None, None]:
    if self.body is not None:
        yield self.body

Inherited members

class Ps1ReturnStatement (offset=-1, parent=None, leading_comments=<factory>, pipeline=None)

Ps1ReturnStatement(offset: 'int' = -1, parent: 'Node | None' = None, leading_comments: 'list[str]' = , pipeline: 'Expression | None' = None)

Expand source code Browse git
@dataclass(repr=False)
class Ps1ReturnStatement(Statement):
    pipeline: Expression | None = None

    def __post_init__(self):
        self._adopt(self.pipeline)

    def children(self) -> Generator[Node, None, None]:
        if self.pipeline is not None:
            yield self.pipeline

Ancestors

Instance variables

var pipeline

The type of the None singleton.

Methods

def children(self)
Expand source code Browse git
def children(self) -> Generator[Node, None, None]:
    if self.pipeline is not None:
        yield self.pipeline

Inherited members

class Ps1ThrowStatement (offset=-1, parent=None, leading_comments=<factory>, pipeline=None)

Ps1ThrowStatement(offset: 'int' = -1, parent: 'Node | None' = None, leading_comments: 'list[str]' = , pipeline: 'Expression | None' = None)

Expand source code Browse git
@dataclass(repr=False)
class Ps1ThrowStatement(Statement):
    pipeline: Expression | None = None

    def __post_init__(self):
        self._adopt(self.pipeline)

    def children(self) -> Generator[Node, None, None]:
        if self.pipeline is not None:
            yield self.pipeline

Ancestors

Instance variables

var pipeline

The type of the None singleton.

Methods

def children(self)
Expand source code Browse git
def children(self) -> Generator[Node, None, None]:
    if self.pipeline is not None:
        yield self.pipeline

Inherited members

class Ps1BreakStatement (offset=-1, parent=None, leading_comments=<factory>, label=None)

Ps1BreakStatement(offset: 'int' = -1, parent: 'Node | None' = None, leading_comments: 'list[str]' = , label: 'Expression | None' = None)

Expand source code Browse git
@dataclass(repr=False)
class Ps1BreakStatement(Statement):
    label: Expression | None = None

    def __post_init__(self):
        self._adopt(self.label)

    def children(self) -> Generator[Node, None, None]:
        if self.label is not None:
            yield self.label

Ancestors

Instance variables

var label

The type of the None singleton.

Methods

def children(self)
Expand source code Browse git
def children(self) -> Generator[Node, None, None]:
    if self.label is not None:
        yield self.label

Inherited members

class Ps1ContinueStatement (offset=-1, parent=None, leading_comments=<factory>, label=None)

Ps1ContinueStatement(offset: 'int' = -1, parent: 'Node | None' = None, leading_comments: 'list[str]' = , label: 'Expression | None' = None)

Expand source code Browse git
@dataclass(repr=False)
class Ps1ContinueStatement(Statement):
    label: Expression | None = None

    def __post_init__(self):
        self._adopt(self.label)

    def children(self) -> Generator[Node, None, None]:
        if self.label is not None:
            yield self.label

Ancestors

Instance variables

var label

The type of the None singleton.

Methods

def children(self)
Expand source code Browse git
def children(self) -> Generator[Node, None, None]:
    if self.label is not None:
        yield self.label

Inherited members

class Ps1ExitStatement (offset=-1, parent=None, leading_comments=<factory>, pipeline=None)

Ps1ExitStatement(offset: 'int' = -1, parent: 'Node | None' = None, leading_comments: 'list[str]' = , pipeline: 'Expression | None' = None)

Expand source code Browse git
@dataclass(repr=False)
class Ps1ExitStatement(Statement):
    pipeline: Expression | None = None

    def __post_init__(self):
        self._adopt(self.pipeline)

    def children(self) -> Generator[Node, None, None]:
        if self.pipeline is not None:
            yield self.pipeline

Ancestors

Instance variables

var pipeline

The type of the None singleton.

Methods

def children(self)
Expand source code Browse git
def children(self) -> Generator[Node, None, None]:
    if self.pipeline is not None:
        yield self.pipeline

Inherited members

class Ps1DataSection (offset=-1, parent=None, leading_comments=<factory>, name='', commands=<factory>, body=None)

Ps1DataSection(offset: 'int' = -1, parent: 'Node | None' = None, leading_comments: 'list[str]' = , name: 'str' = '', commands: 'list[Expression]' = , body: 'Block | None' = None)

Expand source code Browse git
@dataclass(repr=False)
class Ps1DataSection(Statement):
    name: str = ''
    commands: list[Expression] = field(default_factory=list)
    body: Block | None = None

    def __post_init__(self):
        for cmd in self.commands:
            self._adopt(cmd)
        self._adopt(self.body)

    def children(self) -> Generator[Node, None, None]:
        yield from self.commands
        if self.body is not None:
            yield self.body

Ancestors

Instance variables

var commands

The type of the None singleton.

var name

The type of the None singleton.

var body

The type of the None singleton.

Methods

def children(self)
Expand source code Browse git
def children(self) -> Generator[Node, None, None]:
    yield from self.commands
    if self.body is not None:
        yield self.body

Inherited members

class Ps1ErrorNode (offset=-1, parent=None, leading_comments=<factory>, text='', message='')

Ps1ErrorNode(offset: 'int' = -1, parent: 'Node | None' = None, leading_comments: 'list[str]' = , text: 'str' = '', message: 'str' = '')

Expand source code Browse git
@dataclass(repr=False)
class Ps1ErrorNode(Node):
    text: str = ''
    message: str = ''

    def children(self) -> Generator[Node, None, None]:
        yield from ()

Ancestors

Instance variables

var text

The type of the None singleton.

var message

The type of the None singleton.

Methods

def children(self)
Expand source code Browse git
def children(self) -> Generator[Node, None, None]:
    yield from ()

Inherited members

class Ps1Script (offset=-1, parent=None, leading_comments=<factory>, param_block=None, begin_block=None, process_block=None, end_block=None, dynamicparam_block=None, body=<factory>)

Ps1Script(offset: 'int' = -1, parent: 'Node | None' = None, leading_comments: 'list[str]' = , param_block: 'Ps1ParamBlock | None' = None, begin_block: 'Block | None' = None, process_block: 'Block | None' = None, end_block: 'Block | None' = None, dynamicparam_block: 'Block | None' = None, body: 'list[Statement]' = )

Expand source code Browse git
@dataclass(repr=False)
class Ps1Script(Statement):
    param_block: Ps1ParamBlock | None = None
    begin_block: Block | None = None
    process_block: Block | None = None
    end_block: Block | None = None
    dynamicparam_block: Block | None = None
    body: list[Statement] = field(default_factory=list)

    def __post_init__(self):
        self._adopt(
            self.param_block,
            self.begin_block,
            self.process_block,
            self.end_block,
            self.dynamicparam_block,
            *self.body,
        )

    def children(self) -> Generator[Node, None, None]:
        if self.param_block is not None:
            yield self.param_block
        if self.begin_block is not None:
            yield self.begin_block
        if self.process_block is not None:
            yield self.process_block
        if self.end_block is not None:
            yield self.end_block
        if self.dynamicparam_block is not None:
            yield self.dynamicparam_block
        yield from self.body

Ancestors

Instance variables

var body

The type of the None singleton.

var param_block

The type of the None singleton.

var begin_block

The type of the None singleton.

var process_block

The type of the None singleton.

var end_block

The type of the None singleton.

var dynamicparam_block

The type of the None singleton.

Methods

def children(self)
Expand source code Browse git
def children(self) -> Generator[Node, None, None]:
    if self.param_block is not None:
        yield self.param_block
    if self.begin_block is not None:
        yield self.begin_block
    if self.process_block is not None:
        yield self.process_block
    if self.end_block is not None:
        yield self.end_block
    if self.dynamicparam_block is not None:
        yield self.dynamicparam_block
    yield from self.body

Inherited members