astx.base

astx.base

Source: packages/astx/src/astx/base.py

title: AST classes and functions.

Functions

is_using_jupyter_notebook() -> bool

title: Check if it is executed in a jupyter notebook.
returns:
  type: bool

Classes

SourceLocation

No docstring available.

ASTKind(Enum)

title: The expression kind class used for downcasting.

ASTMeta(type)

No docstring available.

AST

title: AST main expression class.
attributes:
  loc:
    type: SourceLocation
  kind:
    type: ASTKind
  comment:
    type: str
  parent:
    type: Optional[ASTNodes]
  ref:
    type: str

Methods

get_struct(self, simplified: bool=False) -> ReprStruct
title: Return a structure that represents the node object.
parameters:
  simplified:
    type: bool
returns:
  type: ReprStruct
to_yaml(self, simplified: bool=False) -> str
title: Return an yaml string that represents the object.
parameters:
  simplified:
    type: bool
returns:
  type: str
to_json(self, simplified: bool=False) -> str
title: Return an json string that represents the object.
parameters:
  simplified:
    type: bool
returns:
  type: str

ASTNodes(Generic[ASTType], AST)

title: AST with a list of nodes, supporting type-specific elements.
attributes:
  loc:
    type: SourceLocation
  kind:
    type: ASTKind
  comment:
    type: str
  parent:
    type: Optional[ASTNodes]
  ref:
    type: str
  name:
    type: str
  nodes:
    type: list[ASTType]
  position:
    type: int

Methods

append(self, value: ASTType) -> None
title: Append a new node to the stack.
parameters:
  value:
    type: ASTType
get_struct(self, simplified: bool=False) -> ReprStruct
title: Return a string that represents the object.
parameters:
  simplified:
    type: bool
returns:
  type: ReprStruct

Expr(AST)

title: AST main expression class.
attributes:
  loc:
    type: SourceLocation
  kind:
    type: ASTKind
  comment:
    type: str
  parent:
    type: Optional[ASTNodes]
  ref:
    type: str
  nbytes:
    type: int

ExprType(Expr)

title: ExprType expression class.
attributes:
  loc:
    type: SourceLocation
  kind:
    type: ASTKind
  comment:
    type: str
  parent:
    type: Optional[ASTNodes]
  ref:
    type: str
  nbytes:
    type: int

Methods

get_struct(self, simplified: bool=False) -> ReprStruct
title: Return a structure that represents the node object.
parameters:
  simplified:
    type: bool
returns:
  type: ReprStruct

Undefined(Expr)

title: Undefined expression class.
attributes:
  loc:
    type: SourceLocation
  kind:
    type: ASTKind
  comment:
    type: str
  parent:
    type: Optional[ASTNodes]
  ref:
    type: str
  nbytes:
    type: int

Methods

get_struct(self, simplified: bool=False) -> ReprStruct
title: Return a simple structure that represents the object.
parameters:
  simplified:
    type: bool
returns:
  type: ReprStruct

DataType(ExprType)

title: AST main expression class.
attributes:
  loc:
    type: SourceLocation
  kind:
    type: ASTKind
  comment:
    type: str
  parent:
    type: Optional[ASTNodes]
  ref:
    type: str
  nbytes:
    type: int
  type_:
    type: ExprType
  name:
    type: str
  _tmp_id:
    type: ClassVar[int]

Methods

get_struct(self, simplified: bool=False) -> ReprStruct
title: Return a simple structure that represents the object.
parameters:
  simplified:
    type: bool
returns:
  type: ReprStruct

OperatorType(DataType)

title: AST main expression class.
attributes:
  loc:
    type: SourceLocation
  kind:
    type: ASTKind
  comment:
    type: str
  parent:
    type: Optional[ASTNodes]
  ref:
    type: str
  nbytes:
    type: int
  type_:
    type: ExprType
  name:
    type: str
  _tmp_id:
    type: ClassVar[int]

StatementType(AST)

title: AST main expression class.
attributes:
  loc:
    type: SourceLocation
  kind:
    type: ASTKind
  comment:
    type: str
  parent:
    type: Optional[ASTNodes]
  ref:
    type: str

ParenthesizedExpr(DataType)

title: AST class for explicitly grouped expressions (parentheses retained).
attributes:
  loc:
    type: SourceLocation
  comment:
    type: str
  parent:
    type: Optional[ASTNodes]
  ref:
    type: str
  nbytes:
    type: int
  name:
    type: str
  _tmp_id:
    type: ClassVar[int]
  type_:
    type: DataType
  kind:
    type: ASTKind
  value:
    type: Expr

Methods

get_struct(self, simplified: bool=False) -> ReprStruct
title: Return the AST structure of the object.
parameters:
  simplified:
    type: bool
returns:
  type: ReprStruct