arx.parser.base
arx.parser.base
Source: packages/arx/src/arx/parser/base.py
title: Shared parser mixin base.
summary: >-
Declare parser state and cross-mixin method contracts so the parser can be
split by concern while keeping the public Parser API stable.Classes
ParserMixinBase
title: Shared parser mixin contract.
attributes:
bin_op_precedence:
type: dict[str, int]
indent_level:
type: int
list_scopes:
type: list[set[str]]
known_class_names:
type: set[str]
tensor_scopes:
type: list[dict[str, TensorBinding | None]]
dataframe_scopes:
type: list[dict[str, DataFrameBinding | None]]
return_type_scopes:
type: list[astx.DataType]
template_type_scopes:
type: list[dict[str, astx.DataType]]
type_aliases:
type: dict[str, astx.DataType]
value_scopes:
type: list[set[str]]
tokens:
type: TokenListMethods
get_tok_precedence(self) -> int
title: Get the precedence of the pending binary operator token.
returns:
type: intparse_expression(self) -> astx.AST
title: Parse one expression.
returns:
type: astx.ASTparse_block(self, allow_docstring: bool=False, declared_names: tuple[str, ...]=(), declared_lists: tuple[str, ...]=(), declared_tensors: dict[str, TensorBinding | None] | None=None, declared_dataframes: dict[str, DataFrameBinding | None] | None=None) -> astx.Block
title: Parse one block of nodes.
parameters:
allow_docstring:
type: bool
declared_names:
type: tuple[str, Ellipsis]
declared_lists:
type: tuple[str, Ellipsis]
declared_tensors:
type: dict[str, TensorBinding | None] | None
declared_dataframes:
type: dict[str, DataFrameBinding | None] | None
returns:
type: astx.Blockparse_type(self, *, allow_template_vars: bool=True, allow_union: bool=False, type_context: TypeUseContext=TypeUseContext.GENERAL) -> astx.DataType
title: Parse one type annotation.
parameters:
allow_template_vars:
type: bool
allow_union:
type: bool
type_context:
type: TypeUseContext
returns:
type: astx.DataTypeis_type_alias_decl_start(self) -> bool
title: Return whether the current token starts a type alias.
returns:
type: boolparse_type_alias_decl(self) -> None
title: Parse one top-level type alias declaration.parse_function(self, template_params: tuple[astx.TemplateParam, ...]=()) -> astx.FunctionDef
title: Parse one function definition.
parameters:
template_params:
type: tuple[astx.TemplateParam, Ellipsis]
returns:
type: astx.FunctionDefparse_extern(self) -> astx.FunctionPrototype
title: Parse one extern declaration.
returns:
type: astx.FunctionPrototypeparse_import_stmt(self) -> astx.ImportStmt | astx.ImportFromStmt
title: Parse one import statement.
returns:
type: astx.ImportStmt | astx.ImportFromStmtparse_class_decl(self, annotations: ParsedAnnotation | None=None) -> astx.ClassDefStmt
title: Parse one class declaration.
parameters:
annotations:
type: ParsedAnnotation | None
returns:
type: astx.ClassDefStmtparse_declaration_prefixes(self, *, body_indent: int | None=None) -> ParsedDeclarationPrefixes
title: Parse declaration prefixes before one declaration.
parameters:
body_indent:
type: int | None
returns:
type: ParsedDeclarationPrefixesparse_template_argument_list(self) -> tuple[astx.DataType, ...]
title: Parse one explicit template-argument list.
returns:
type: tuple[astx.DataType, Ellipsis]parse_if_stmt(self) -> astx.IfStmt
title: Parse one if expression.
returns:
type: astx.IfStmtparse_while_stmt(self) -> astx.WhileStmt
title: Parse one while expression.
returns:
type: astx.WhileStmtparse_for_stmt(self) -> astx.AST
title: Parse one for-loop expression.
returns:
type: astx.ASTparse_var_expr(self) -> astx.VariableDeclaration
title: Parse one typed variable declaration.
returns:
type: astx.VariableDeclarationparse_assert_stmt(self) -> astx.AssertStmt
title: Parse one fatal assertion statement.
returns:
type: astx.AssertStmtparse_return_function(self) -> astx.FunctionReturn
title: Parse one return expression.
returns:
type: astx.FunctionReturnparse_prototype(self, expect_colon: bool) -> astx.FunctionPrototype
title: Parse one function or extern prototype.
parameters:
expect_colon:
type: bool
returns:
type: astx.FunctionPrototype