# loki.ir.nodes.stmt_nodes module

Generic and specific statement node type definitions.

class GenericStmt(text: str, source: Source | str | None = None, label: str | None = None)

  Bases: `LeafNode`, `_GenericStmtBase`

  Catch-all generic node for corner-cases.

  This is provided as a fallback for any statements that do not have an appropriate representation in the IR. These can either be language features for which support was not yet added, or statements that are not relevant in Loki’s scope of applications. This node retains the text of the statement in the original source as-is.

  Parameters:

    - text (str) – The statement as a string.

    - **kwargs (optional) – Other parameters that are passed on to the parent class constructor.

  keyword = None

class ImplicitStmt(text: str | Tuple[Expression, ...] | None = 'NONE', source: Source | str | None = None, label: str | None = None)

  Bases: `GenericStmt`

  `GenericStmt` node that represents the `IMPLICIT` statement.

  Parameters:

    - text (str or `Expression`, optional) – Either a tuple of variable specifiers or a string; default: `NONE`

    - **kwargs (optional) – Other parameters that are passed on to the parent class constructor.

  keyword = 'IMPLICIT'
  text: str | Tuple[Expression, ...] | None = 'NONE'
  classmethod ensure_str_or_tuple(value)

class SaveStmt(text: Tuple[Expression, ...] | None = (), source: Source | str | None = None, label: str | None = None)

  Bases: `GenericStmt`

  `GenericStmt` node that represents the `SAVE` statement.

  Parameters:

    - text (str or `Expression`, optional) – Either a tuple of variable specifiers or a string; default: `NONE`

    - **kwargs (optional) – Other parameters that are passed on to the parent class constructor.

  keyword = 'SAVE'
  text: Tuple[Expression, ...] | None = ()
  classmethod ensure_tuple(value)

class PublicStmt(text: Tuple[Expression, ...] | None = (), source: Source | str | None = None, label: str | None = None)

  Bases: `GenericStmt`

  `GenericStmt` node that represents the `PUBLIC` specifier.

  Parameters:

    - text (str or tuple of `Expression`, optional) – Either a tuple of variable specifiers or a string; default: `NONE`

    - **kwargs (optional) – Other parameters that are passed on to the parent class constructor.

  keyword = 'PUBLIC'
  text: Tuple[Expression, ...] | None = ()
  classmethod ensure_tuple(value)

class PrivateStmt(text: Tuple[Expression, ...] | None = (), source: Source | str | None = None, label: str | None = None)

  Bases: `GenericStmt`

  `GenericStmt` node that represents the `PRIVATE` specifier.

  Parameters:

    - text (str or tuple of `Expression`, optional) – Either a tuple of variable specifiers or a string; default: `NONE`

    - **kwargs (optional) – Other parameters that are passed on to the parent class constructor.

  keyword = 'PRIVATE'
  text: Tuple[Expression, ...] | None = ()
  classmethod ensure_tuple(value)

class CommonStmt(text: Tuple[Expression, ...], source: Source | str | None = None, label: str | None = None)

  Bases: `GenericStmt`

  `GenericStmt` node that represents the `COMMON` specifier.

  Parameters:

    - text (str or tuple of `Expression`, optional) – Either a tuple of variable specifiers or a string; default: `NONE`

    - **kwargs (optional) – Other parameters that are passed on to the parent class constructor.

  keyword = 'COMMON'
  text: Tuple[Expression, ...]
  classmethod ensure_tuple(value)

class ContainsStmt(text: None = None, source: Source | str | None = None, label: str | None = None)

  Bases: `GenericStmt`

  `GenericStmt` node that represents the `CONTAINS` specifier.

  Parameters:

    **kwargs (optional) – Other parameters that are passed on to the parent class constructor.

  keyword = 'CONTAINS'
  text: None = None

class ReturnStmt(text: None = None, source: Source | str | None = None, label: str | None = None)

  Bases: `GenericStmt`

  `GenericStmt` node that represents the `RETURN` specifier.

  Parameters:

    **kwargs (optional) – Other parameters that are passed on to the parent class constructor.

  keyword = 'RETURN'
  text: None = None

class CycleStmt(text: None = None, source: Source | str | None = None, label: str | None = None)

  Bases: `GenericStmt`

  `GenericStmt` node that represents the `CYCLE` specifier.

  Parameters:

    **kwargs (optional) – Other parameters that are passed on to the parent class constructor.

  keyword = 'CYCLE'
  text: None = None

class ContinueStmt(text: str = '', source: Source | str | None = None, label: str | None = None)

  Bases: `GenericStmt`

  `GenericStmt` node that represents the `CONTINUE` specifier.

  Parameters:

    **kwargs (optional) – Other parameters that are passed on to the parent class constructor.

  keyword = 'CONTINUE'
  text: str = ''

class StopStmt(text: Expression | str | None = '', source: Source | str | None = None, label: str | None = None)

  Bases: `GenericStmt`

  `GenericStmt` node that represents the `STOP` specifier.

  Parameters:

    - text (str, optional) – The optional error code (integer or character) returned on stopping.

    - **kwargs (optional) – Other parameters that are passed on to the parent class constructor.

  keyword = 'STOP'
  text: Expression | str | None = ''
  classmethod ensure_literal(value)

class ExitStmt(text: Expression | str | None = '', source: Source | str | None = None, label: str | None = None)

  Bases: `GenericStmt`

  `GenericStmt` node that represents the `EXIT` specifier.

  Parameters:

    **kwargs (optional) – Other parameters that are passed on to the parent class constructor.

  keyword = 'EXIT'
  text: Expression | str | None = ''
  classmethod ensure_literal(value)

class GotoStmt(text: str, source: Source | str | None = None, label: str | None = None)

  Bases: `GenericStmt`

  `GenericStmt` node that represents the `GO TO` specifier.

  Parameters:

    **kwargs (optional) – Other parameters that are passed on to the parent class constructor.

  keyword = 'GO TO'
  text: str

class PrintStmt(source: Source | str | None = None, label: str | None = None, values: Tuple[Expression | str, ...] = ())

  Bases: `GenericStmt`

  `GenericStmt` node that represents the `PRINT` specifier.

  Parameters:

    - values (tuple of str or `Expression`) – Tuple of print specifier and variable specifiers.

    - **kwargs (optional) – Other parameters that are passed on to the parent class constructor.

  keyword = 'PRINT'
  text: str
  values: Tuple[Expression | str, ...] = ()
  classmethod disallow_text_argument(data)

    Ensure the alternating construcotr arguments are used.

  classmethod ensure_tuple(value)
  classmethod require_values(value)
  property args

    Ensure safe cloning by excluding derived `text` property from `args`.

class FormatStmt(source: Source | str | None = None, label: str | None = None, values: Tuple[Expression | str, ...] | None = ())

  Bases: `GenericStmt`

  `GenericStmt` node that represents the `FORMAT` specifier.

  Parameters:

    - values (tuple of str or `Expression`, optional) – Tuple of format specifiers.

    - **kwargs (optional) – Other parameters that are passed on to the parent class constructor.

  keyword = 'FORMAT'
  text: str
  values: Tuple[Expression | str, ...] | None = ()
  classmethod disallow_text_argument(data)

    Ensure the alternating construcotr arguments are used.

  classmethod ensure_tuple(value)
  property args

    Ensure safe cloning by excluding derived `text` property from `args`.