Skip to content

Python spec builder API reference

The public API of the spec builder gecode_iris.build, imported in the guide as ib. pdoc 16.0.0 generates it during each site build from the builder's type stubs and docstrings, and shows each typed overload of a statement. The guide shows the builder in use, and the package reference covers the specs and data it builds.

Build reader specs from Python code, with typed handles.

A SpecBuilder is the root scope of a spec. Each statement is a method call, a block is a with statement, and every definition returns a handle that later statements use in expressions and that data[handle] reads from the data with the type it promises.

A handle's type parameter is the value data[handle] gives: int for an integer, list[int] for an array or for an integer read in a repeat, and int | None for an entry that may be absent. Scopes carry their depth in their class, Scope0 to Scope3, and their presence in their parameter: Required when their statements always execute and None when they may not. Inside more than three repeats, ScopeN gives DynField handles.

Python operators build Iris expressions, except for division, remainder and power, which are div(), rem() and pow(), and the logical operators, which are &, | and ~. Line patterns are t-strings on Python 3.14 and later, and tuples of text and parts on every version.

A mistake that a builder can find raises BuildError at the call that made it, or from build(), and names the caller's file and line. Errors while reading a built spec name the call site of their statement in gecode_iris.Error.call_site.

Alphabet

alphabet "symbols": reads each symbol as its index. blank, strip and base add options in call order.

Alphabet.blank

def blank(self, characters: str) -> Alphabet:

blank "characters".

Alphabet.strip

def strip(self, characters: str) -> Alphabet:

strip "characters".

Alphabet.base

def base(self, value: int) -> Alphabet:

base value.

ArmGuard

class ArmGuard(typing.Generic[_S_co]):

The guard of an arm: with gives the arm's block.

Arms

class Arms(typing.Generic[_R_co, _O_co]):

The block of a sections statement, which holds only arms: _R_co is the scope of a required arm and _O_co of an optional one.

Arms.arm

def arm( self, pattern: str | tuple[str | Field[Any] | Part | Discard, ...] | string.templatelib.Template, *, optional: Literal[False] = False, last: bool = False) -> ArmGuard[_R_co]:
def arm( self, pattern: str | tuple[str | Field[Any] | Part | Discard, ...] | string.templatelib.Template, *, optional: bool, last: bool = False) -> ArmGuard[_O_co]:

An arm with this pattern; with gives it a block. What an optional arm defines may be absent, and sections end after a last arm.

Block

class Block(typing.Generic[_S_co]):

The guard of a block statement: with gives the block's scope. A guard that is never entered writes an empty block.

BuildError

class BuildError(builtins.Exception):
BuildError( kind: Literal['scope', 'provenance', 'redefinition', 'unprintable', 'binding', 'spec'], message: str, call_site: CallSite | None, text: str | None = None, error: gecode_iris.Error | None = None)

Why a reader spec could not be built.

kind names the builder check that failed, or is "spec" when the emitted text failed to parse; then error is the language error, which is also the __cause__. str(error) shows the language code and message, the line of emitted text, and the call site.

BuildError.kind

kind: Literal['scope', 'provenance', 'redefinition', 'unprintable', 'binding', 'spec']

The check that failed: scope, provenance, redefinition, unprintable, binding, or spec for a language error.

BuildError.message

message: str

The message of a builder check, without the call site. For a spec error it is the language diagnostic, with its location and excerpt, less the call site line.

BuildError.call_site

call_site: CallSite | None

The host code of the statement that failed.

BuildError.text

text: str | None

The emitted text, when the language rejected it.

BuildError.error

error: gecode_iris.Error | None

The language error, when the emitted text was rejected.

BuildError.from_error

@classmethod
def from_error(cls, error: gecode_iris.Error, text: str) -> BuildError:

The error for emitted text that the language rejected.

BuildError.emitted_line

emitted_line: str | None

The line of emitted text that the language error points at.

BuildErrorKind

BuildErrorKind: TypeAlias = Literal['scope', 'provenance', 'redefinition', 'unprintable', 'binding', 'spec']

The value of BuildError.kind: the builder check that failed, or spec when the language rejected the emitted text.

CallSite

class CallSite(typing.NamedTuple):
CallSite(filename: str, line: int, function: str)

A place in the host program: where a builder statement was called.

str(site) is file:line.

CallSite.filename

filename: str

Alias for field number 0

CallSite.line

line: int

Alias for field number 1

CallSite.function

function: str

Alias for field number 2

Discard

class Discard:

The discard _: a target that reads without storing, and {_} in a pattern.

DynExpr

class DynExpr(gecode_iris.build.Expr):

An expression with no static type, which every operator accepts.

DynExpr.field

def field( self, handle: IntField[typing.Any]) -> IntLookup:
def field( self, handle: FloatField[typing.Any]) -> FloatLookup:
def field( self, handle: NumField[typing.Any]) -> NumLookup:
def field( self, handle: StrField[typing.Any]) -> StrLookup:
def field(self, handle: DynField) -> DynExpr:

self.name, the field handle of the record this selects.

DynField

A handle whose value type or depth is open.

DynField.field

def field( self, handle: IntField[typing.Any]) -> IntLookup:
def field( self, handle: FloatField[typing.Any]) -> FloatLookup:
def field( self, handle: NumField[typing.Any]) -> NumLookup:
def field( self, handle: StrField[typing.Any]) -> StrLookup:
def field(self, handle: DynField) -> DynExpr:

self.name, the field handle of the record this selects.

Eol

class Eol:

The end-of-line marker of a list.

Expr

class Expr:

An Iris expression. Operators build larger expressions; bool() is an error, so that a comparison is never taken for a Python condition.

Expr.dynamic

def dynamic(self) -> DynExpr:

This expression with no static type, accepted anywhere.

Field

class Field(gecode_iris.build.Expr, typing.Generic[_T_co]):

A typed handle: the name of an entry. data[handle] reads its value, of type _T_co.

In the builder a handle is an expression; after reading it is a key.

Field.name

name: str

The entry name.

FloatExpr

class FloatExpr(gecode_iris.build.Expr):

A float expression.

FloatField

A handle of a float entry.

FloatField.field

def field( self, handle: IntField[typing.Any]) -> IntLookup:
def field( self, handle: FloatField[typing.Any]) -> FloatLookup:
def field( self, handle: NumField[typing.Any]) -> NumLookup:
def field( self, handle: StrField[typing.Any]) -> StrLookup:
def field(self, handle: DynField) -> DynExpr:

self.name, the field handle of the record this selects.

FloatLookup

class FloatLookup(gecode_iris.build.FloatExpr):

A float lookup, which may be an array.

FloatLookup.field

def field( self, handle: IntField[typing.Any]) -> IntLookup:
def field( self, handle: FloatField[typing.Any]) -> FloatLookup:
def field( self, handle: NumField[typing.Any]) -> NumLookup:
def field( self, handle: StrField[typing.Any]) -> StrLookup:
def field(self, handle: DynField) -> DynExpr:

self.name, the field handle of the record this selects.

FloatType

class FloatType(gecode_iris.build.Type[_U]):

A type that reads floats.

FloatType.dim

def dim( self, size: int | IntExpr | DynExpr) -> FloatType[list[_U]]:

Add a dimension: x[size]: type.

FloatType.dims

def dims( self, size: int | IntExpr | DynExpr, /) -> FloatType[list[_U]]:
def dims( self, first: int | IntExpr | DynExpr, second: int | IntExpr | DynExpr, /) -> FloatType[list[list[_U]]]:
def dims( self, first: int | IntExpr | DynExpr, second: int | IntExpr | DynExpr, third: int | IntExpr | DynExpr, /) -> FloatType[list[list[list[_U]]]]:
def dims( self, *sizes: int | IntExpr | DynExpr) -> FloatType[typing.Any]:

Add several dimensions, as many as known only at run time.

FloatType.layout

def layout( self, layout: int | float | str | Expr) -> FloatType[_U]:

layout expression: a matrix layout name such as "LOWER_COL".

FloatType.offset

def offset( self, offset: int | IntExpr | DynExpr) -> FloatType[_U]:

offset expression.

FloatType.until

def until( self, end: int | float | str | Expr | Eol) -> ListReading[FloatType[_U]]:

A list of this type ending at end: a sentinel, or ib.eol.

IntExpr

class IntExpr(gecode_iris.build.Expr):

An integer expression.

IntField

A handle of an integer entry.

IntField.field

def field( self, handle: IntField[typing.Any]) -> IntLookup:
def field( self, handle: FloatField[typing.Any]) -> FloatLookup:
def field( self, handle: NumField[typing.Any]) -> NumLookup:
def field( self, handle: StrField[typing.Any]) -> StrLookup:
def field(self, handle: DynField) -> DynExpr:

self.name, the field handle of the record this selects.

IntLookup

class IntLookup(gecode_iris.build.IntExpr):

An integer lookup, such as an index or a field: it may be an array.

IntLookup.field

def field( self, handle: IntField[typing.Any]) -> IntLookup:
def field( self, handle: FloatField[typing.Any]) -> FloatLookup:
def field( self, handle: NumField[typing.Any]) -> NumLookup:
def field( self, handle: StrField[typing.Any]) -> StrLookup:
def field(self, handle: DynField) -> DynExpr:

self.name, the field handle of the record this selects.

IntType

class IntType(gecode_iris.build.Type[_U]):

A type that reads integers.

IntType.dim

def dim( self, size: int | IntExpr | DynExpr) -> IntType[list[_U]]:

Add a dimension: x[size]: type.

IntType.dims

def dims( self, size: int | IntExpr | DynExpr, /) -> IntType[list[_U]]:
def dims( self, first: int | IntExpr | DynExpr, second: int | IntExpr | DynExpr, /) -> IntType[list[list[_U]]]:
def dims( self, first: int | IntExpr | DynExpr, second: int | IntExpr | DynExpr, third: int | IntExpr | DynExpr, /) -> IntType[list[list[list[_U]]]]:
def dims( self, *sizes: int | IntExpr | DynExpr) -> IntType[typing.Any]:

Add several dimensions, as many as known only at run time.

IntType.layout

def layout( self, layout: int | float | str | Expr) -> IntType[_U]:

layout expression: a matrix layout name such as "LOWER_COL".

IntType.offset

def offset( self, offset: int | IntExpr | DynExpr) -> IntType[_U]:

offset expression.

IntType.until

def until( self, end: int | float | str | Expr | Eol) -> ListReading[IntType[_U]]:

A list of this type ending at end: a sentinel, or ib.eol.

ListReading

class ListReading(typing.Generic[_U]):

The type and end of a list statement; the parameter is the type.

ListReading.offset

def offset( self, offset: int | IntExpr | DynExpr) -> ListReading[_U]:

offset expression, after the list's end.

Maybe

Maybe: TypeAlias = None

The presence of a scope whose statements may not execute.

NumExpr

class NumExpr(gecode_iris.build.Expr):

A num expression: an int or a float, decided by the data.

NumField

A handle of a num entry.

NumField.field

def field( self, handle: IntField[typing.Any]) -> IntLookup:
def field( self, handle: FloatField[typing.Any]) -> FloatLookup:
def field( self, handle: NumField[typing.Any]) -> NumLookup:
def field( self, handle: StrField[typing.Any]) -> StrLookup:
def field(self, handle: DynField) -> DynExpr:

self.name, the field handle of the record this selects.

NumLookup

class NumLookup(gecode_iris.build.NumExpr):

A num lookup, which may be an array.

NumLookup.field

def field( self, handle: IntField[typing.Any]) -> IntLookup:
def field( self, handle: FloatField[typing.Any]) -> FloatLookup:
def field( self, handle: NumField[typing.Any]) -> NumLookup:
def field( self, handle: StrField[typing.Any]) -> StrLookup:
def field(self, handle: DynField) -> DynExpr:

self.name, the field handle of the record this selects.

NumType

class NumType(gecode_iris.build.Type[_U]):

A type that reads ints or floats, decided by the data.

NumType.dim

def dim( self, size: int | IntExpr | DynExpr) -> NumType[list[_U]]:

Add a dimension: x[size]: type.

NumType.dims

def dims( self, size: int | IntExpr | DynExpr, /) -> NumType[list[_U]]:
def dims( self, first: int | IntExpr | DynExpr, second: int | IntExpr | DynExpr, /) -> NumType[list[list[_U]]]:
def dims( self, first: int | IntExpr | DynExpr, second: int | IntExpr | DynExpr, third: int | IntExpr | DynExpr, /) -> NumType[list[list[list[_U]]]]:
def dims( self, *sizes: int | IntExpr | DynExpr) -> NumType[typing.Any]:

Add several dimensions, as many as known only at run time.

NumType.layout

def layout( self, layout: int | float | str | Expr) -> NumType[_U]:

layout expression: a matrix layout name such as "LOWER_COL".

NumType.offset

def offset( self, offset: int | IntExpr | DynExpr) -> NumType[_U]:

offset expression.

NumType.until

def until( self, end: int | float | str | Expr | Eol) -> ListReading[NumType[_U]]:

A list of this type ending at end: a sentinel, or ib.eol.

Part

class Part:

A part of a pattern other than text or a capture handle.

Record

class Record:

The records of a repeat. record[field] is the field of the current record, record.list all the records, and a comprehension over a record gives its body one record at a time.

Record.list

list: RecordList

All the records of this repeat, printed as its as name.

Record.records

def records(self, inner: Record) -> RecordList:

The records of the nested repeat inner in the current record.

RecordExpr

class RecordExpr:

One record: selected by index, or a comprehension's variable. record[field] looks up one of its fields.

RecordExpr.at

def at( self, index: int | IntExpr | DynExpr) -> RecordExpr:

self[index], for a record that is itself a list.

RecordExpr.records

def records(self, inner: Record) -> RecordList:

The records of the nested repeat inner in this record.

RecordList

class RecordList:

A list of records: all the records of a repeat, or a nested list. records[i] selects one.

Required

Required: TypeAlias = NoReturn

The presence of a scope whose statements always execute: T | Required is T.

Scope

class Scope(typing.Generic[_N_co]):

An open block, with the statements whose types do not depend on its depth. A scope accepts statements only while it is the innermost open block.

Scope.set

def set( self, handle: Field[typing.Any], value: int | float | str | Expr) -> None:

let x = value through a handle, keeping its type.

The value must have the handle's value type and, where both are known, its depth. To change either, use let with the handle as the target, which returns a DynField.

Scope.check

def check( self, condition: int | Expr, message: str | None = None) -> None:

check condition, with an optional message for when it fails.

Scope.expect

def expect(self, *words: str) -> None:

expect "text"....

Scope.line

def line( self, pattern: str | tuple[str | Field[Any] | Part | Discard, ...] | string.templatelib.Template) -> None:

line "pattern".

Scope.find

def find( self, pattern: str | tuple[str | Field[Any] | Part | Discard, ...] | string.templatelib.Template) -> None:

find "pattern".

Scope.skip_line

def skip_line(self) -> None:

skip line.

Scope.skip_lines

def skip_lines( self, count: int | IntExpr | DynExpr) -> None:

skip count lines.

Scope.index

def index( self, position: int | IntExpr | DynExpr) -> None:

index position.

Scope.define_type

def define_type( self, name: str, ty: IntType[_U]) -> IntType[_U]:
def define_type( self, name: str, ty: FloatType[_U]) -> FloatType[_U]:
def define_type( self, name: str, ty: NumType[_U]) -> NumType[_U]:
def define_type( self, name: str, ty: StrType[_U]) -> StrType[_U]:

type name = type, usable wherever a type is. The type it returns belongs to this declaration: build() reports a use where another declaration of the name is visible.

Scope.forward

def forward(self, name: str, kind: type[_F]) -> _F:

A handle for a name that a later statement defines, of the handle type kind, such as ib.IntField[list[int]] or ib.DynField.

Scope.undefined

def undefined(self, name: str) -> DynField:

A handle for a name deliberately left undefined.

Scope.forward_record

def forward_record(self, each: str, list: str) -> Record:

The record of a repeat that comes later in the text, printed with the names given here. Bind it with record_as.

Scope0

A scope outside every repeat. _N is Required when its statements always execute and None when they may not.

Scope0.read

def read( self, target: str, ty: IntType[_U]) -> IntField[_U | _N_co]:
def read( self, target: str, ty: FloatType[_U]) -> FloatField[_U | _N_co]:
def read( self, target: str, ty: NumType[_U]) -> NumField[_U | _N_co]:
def read( self, target: str, ty: StrType[_U]) -> StrField[_U | _N_co]:
def read( self, target: Field[typing.Any], ty: Type[typing.Any]) -> DynField:
def read( self, target: Discard, ty: Type[typing.Any]) -> None:

x: type, reading a value into target: a new name, a handle to bind or redefine, or ib.discard().

Scope0.else_read_if

def else_read_if( self, target: str, ty: IntType[_U]) -> IntField[_U | None]:
def else_read_if( self, target: str, ty: FloatType[_U]) -> FloatField[_U | None]:
def else_read_if( self, target: str, ty: NumType[_U]) -> NumField[_U | None]:
def else_read_if( self, target: str, ty: StrType[_U]) -> StrField[_U | None]:
def else_read_if( self, target: Field[typing.Any], ty: Type[typing.Any]) -> DynField:

else if:type: the else branch is a declaration of the name if, which the target must have.

Scope0.list

def list( self, target: str, reading: ListReading[IntType[_U]]) -> IntField[list[_U] | _N_co]:
def list( self, target: str, reading: ListReading[FloatType[_U]]) -> FloatField[list[_U] | _N_co]:
def list( self, target: str, reading: ListReading[NumType[_U]]) -> NumField[list[_U] | _N_co]:
def list( self, target: str, reading: ListReading[StrType[_U]]) -> StrField[list[_U] | _N_co]:
def list( self, target: Field[typing.Any], reading: ListReading[typing.Any]) -> DynField:
def list( self, target: Discard, reading: ListReading[typing.Any]) -> None:

list x: type until end.

Scope0.let

def let( self, target: str, value: IntField[_U]) -> IntField[_U | _N_co]:
def let( self, target: str, value: IntLookup) -> IntField[gecode_iris.Value | _N_co]:
def let( self, target: str, value: int | IntExpr) -> IntField[int | _N_co]:
def let( self, target: str, value: FloatField[_U]) -> FloatField[_U | _N_co]:
def let( self, target: str, value: FloatLookup) -> FloatField[gecode_iris.Value | _N_co]:
def let( self, target: str, value: float | FloatExpr) -> FloatField[float | _N_co]:
def let( self, target: str, value: NumField[_U]) -> NumField[_U | _N_co]:
def let( self, target: str, value: NumLookup) -> NumField[gecode_iris.Value | _N_co]:
def let( self, target: str, value: NumExpr) -> NumField[int | float | _N_co]:
def let( self, target: str, value: StrField[_U]) -> StrField[_U | _N_co]:
def let( self, target: str, value: StrLookup) -> StrField[gecode_iris.Value | _N_co]:
def let( self, target: str, value: str | StrExpr) -> StrField[str | _N_co]:
def let( self, target: str, value: DynExpr) -> DynField:
def let( self, target: Field[typing.Any], value: int | float | str | Expr) -> DynField:

let x = value.

Scope0.param

def param( self, target: str | Field[Any]) -> DynField:
def param( self, target: str, default: IntField[int | None]) -> IntField[int | _N_co]:
def param( self, target: str, default: IntLookup) -> IntField[gecode_iris.Value | _N_co]:
def param( self, target: str, default: int | IntExpr) -> IntField[int | _N_co]:
def param( self, target: str, default: FloatField[float | None]) -> FloatField[float | _N_co]:
def param( self, target: str, default: FloatLookup) -> FloatField[gecode_iris.Value | _N_co]:
def param( self, target: str, default: float | FloatExpr) -> FloatField[float | _N_co]:
def param( self, target: str, default: NumField[int | float | None]) -> NumField[int | float | _N_co]:
def param( self, target: str, default: NumLookup) -> NumField[gecode_iris.Value | _N_co]:
def param( self, target: str, default: NumExpr) -> NumField[int | float | _N_co]:
def param( self, target: str, default: StrField[str | None]) -> StrField[str | _N_co]:
def param( self, target: str, default: StrLookup) -> StrField[gecode_iris.Value | _N_co]:
def param( self, target: str, default: str | StrExpr) -> StrField[str | _N_co]:
def param( self, target: str, default: DynExpr) -> DynField:
def param( self, target: Field[typing.Any], default: int | float | str | Expr) -> DynField:

param p, whose type the caller decides, or param p = default.

Scope0.capture

def capture( self, name: str, ty: None = None) -> StrField[str | _N_co]:
def capture( self, name: str, ty: IntType[_U]) -> IntField[_U | _N_co]:
def capture( self, name: str, ty: FloatType[_U]) -> FloatField[_U | _N_co]:
def capture( self, name: str, ty: NumType[_U]) -> NumField[_U | _N_co]:
def capture( self, name: str, ty: StrType[_U]) -> StrField[_U | _N_co]:

A handle for a pattern to bind, at this scope's depth and presence. Without a type the capture is {x}, which reads a word.

Scope0.optional_capture

def optional_capture( self, name: str, ty: None = None) -> StrField[str | None]:
def optional_capture( self, name: str, ty: IntType[_U]) -> IntField[_U | None]:
def optional_capture( self, name: str, ty: FloatType[_U]) -> FloatField[_U | None]:
def optional_capture( self, name: str, ty: NumType[_U]) -> NumField[_U | None]:
def optional_capture( self, name: str, ty: StrType[_U]) -> StrField[_U | None]:

capture for an optional arm or a conditional block.

Scope0.repeat

def repeat( self, count: int | IntExpr | DynExpr) -> Block[Scope1[_N_co]]:

repeat count { ... }, whose block is the next depth.

Scope0.repeat_until_eof

def repeat_until_eof(self) -> Block[Scope1[_N_co]]:

repeat until eof { ... }.

Scope0.repeat_until

def repeat_until( self, *terminators: str, store: str | Field[Any] | Discard | None = None) -> Block[Scope1[_N_co]]:

repeat until "text"... { ... }. store keeps the terminator that ended it in a name; to read it, pass a handle from forward.

Scope0.sections

def sections( self, *, until: str | tuple[str, ...] = (), skip_other: bool = False, store: str | Field[Any] | Discard | None = None) -> SectionsGuard[Scope0[_N_co], Scope0[NoneType]]:

sections: entering it gives the block of arms. until and skip_other add clauses in that order; chain .until() and .skip_other() for any other order.

Scope0.if_

def if_( self, condition: int | Expr) -> Block[Scope0[NoneType]]:

if condition { ... }. What its block defines may be absent.

Scope0.else_if

def else_if( self, condition: int | Expr) -> Block[Scope0[NoneType]]:

else if condition { ... }, directly after an if_ block.

Scope0.else_

def else_(self) -> Block[Scope0[NoneType]]:

else { ... }, directly after an if_ or else_if block.

Scope1

A scope inside one repeat: its definitions are lists.

Scope1.read

def read( self, target: str, ty: IntType[_U]) -> IntField[list[_U] | _N_co]:
def read( self, target: str, ty: FloatType[_U]) -> FloatField[list[_U] | _N_co]:
def read( self, target: str, ty: NumType[_U]) -> NumField[list[_U] | _N_co]:
def read( self, target: str, ty: StrType[_U]) -> StrField[list[_U] | _N_co]:
def read( self, target: Field[typing.Any], ty: Type[typing.Any]) -> DynField:
def read( self, target: Discard, ty: Type[typing.Any]) -> None:

x: type, reading a value into target: a new name, a handle to bind or redefine, or ib.discard().

Scope1.else_read_if

def else_read_if( self, target: str, ty: IntType[_U]) -> IntField[list[_U] | None]:
def else_read_if( self, target: str, ty: FloatType[_U]) -> FloatField[list[_U] | None]:
def else_read_if( self, target: str, ty: NumType[_U]) -> NumField[list[_U] | None]:
def else_read_if( self, target: str, ty: StrType[_U]) -> StrField[list[_U] | None]:
def else_read_if( self, target: Field[typing.Any], ty: Type[typing.Any]) -> DynField:

else if:type: the else branch is a declaration of the name if, which the target must have.

Scope1.list

def list( self, target: str, reading: ListReading[IntType[_U]]) -> IntField[list[list[_U]] | _N_co]:
def list( self, target: str, reading: ListReading[FloatType[_U]]) -> FloatField[list[list[_U]] | _N_co]:
def list( self, target: str, reading: ListReading[NumType[_U]]) -> NumField[list[list[_U]] | _N_co]:
def list( self, target: str, reading: ListReading[StrType[_U]]) -> StrField[list[list[_U]] | _N_co]:
def list( self, target: Field[typing.Any], reading: ListReading[typing.Any]) -> DynField:
def list( self, target: Discard, reading: ListReading[typing.Any]) -> None:

list x: type until end.

Scope1.let

def let( self, target: str, value: IntLookup) -> IntField[gecode_iris.Value | _N_co]:
def let( self, target: str, value: int | IntExpr) -> IntField[list[int] | _N_co]:
def let( self, target: str, value: FloatLookup) -> FloatField[gecode_iris.Value | _N_co]:
def let( self, target: str, value: float | FloatExpr) -> FloatField[list[float] | _N_co]:
def let( self, target: str, value: NumLookup) -> NumField[gecode_iris.Value | _N_co]:
def let( self, target: str, value: NumExpr) -> NumField[list[int | float] | _N_co]:
def let( self, target: str, value: StrLookup) -> StrField[gecode_iris.Value | _N_co]:
def let( self, target: str, value: str | StrExpr) -> StrField[list[str] | _N_co]:
def let( self, target: str, value: DynExpr) -> DynField:
def let( self, target: Field[typing.Any], value: int | float | str | Expr) -> DynField:

let x = value.

Scope1.param

def param( self, target: str | Field[Any]) -> DynField:
def param( self, target: str, default: IntLookup) -> IntField[gecode_iris.Value | _N_co]:
def param( self, target: str, default: int | IntExpr) -> IntField[list[int] | _N_co]:
def param( self, target: str, default: FloatLookup) -> FloatField[gecode_iris.Value | _N_co]:
def param( self, target: str, default: float | FloatExpr) -> FloatField[list[float] | _N_co]:
def param( self, target: str, default: NumLookup) -> NumField[gecode_iris.Value | _N_co]:
def param( self, target: str, default: NumExpr) -> NumField[list[int | float] | _N_co]:
def param( self, target: str, default: StrLookup) -> StrField[gecode_iris.Value | _N_co]:
def param( self, target: str, default: str | StrExpr) -> StrField[list[str] | _N_co]:
def param( self, target: str, default: DynExpr) -> DynField:
def param( self, target: Field[typing.Any], default: int | float | str | Expr) -> DynField:

param p, whose type the caller decides, or param p = default.

Scope1.capture

def capture( self, name: str, ty: None = None) -> StrField[list[str] | _N_co]:
def capture( self, name: str, ty: IntType[_U]) -> IntField[list[_U] | _N_co]:
def capture( self, name: str, ty: FloatType[_U]) -> FloatField[list[_U] | _N_co]:
def capture( self, name: str, ty: NumType[_U]) -> NumField[list[_U] | _N_co]:
def capture( self, name: str, ty: StrType[_U]) -> StrField[list[_U] | _N_co]:

A handle for a pattern to bind, at this scope's depth and presence. Without a type the capture is {x}, which reads a word.

Scope1.optional_capture

def optional_capture( self, name: str, ty: None = None) -> StrField[list[str] | None]:
def optional_capture( self, name: str, ty: IntType[_U]) -> IntField[list[_U] | None]:
def optional_capture( self, name: str, ty: FloatType[_U]) -> FloatField[list[_U] | None]:
def optional_capture( self, name: str, ty: NumType[_U]) -> NumField[list[_U] | None]:
def optional_capture( self, name: str, ty: StrType[_U]) -> StrField[list[_U] | None]:

capture for an optional arm or a conditional block.

Scope1.repeat

def repeat( self, count: int | IntExpr | DynExpr) -> Block[Scope2[_N_co]]:

repeat count { ... }, whose block is the next depth.

Scope1.repeat_until_eof

def repeat_until_eof(self) -> Block[Scope2[_N_co]]:

repeat until eof { ... }.

Scope1.repeat_until

def repeat_until( self, *terminators: str, store: str | Field[Any] | Discard | None = None) -> Block[Scope2[_N_co]]:

repeat until "text"... { ... }. store keeps the terminator that ended it in a name; to read it, pass a handle from forward.

Scope1.sections

def sections( self, *, until: str | tuple[str, ...] = (), skip_other: bool = False, store: str | Field[Any] | Discard | None = None) -> SectionsGuard[Scope1[_N_co], Scope1[NoneType]]:

sections: entering it gives the block of arms. until and skip_other add clauses in that order; chain .until() and .skip_other() for any other order.

Scope1.if_

def if_( self, condition: int | Expr) -> Block[Scope1[NoneType]]:

if condition { ... }. What its block defines may be absent.

Scope1.else_if

def else_if( self, condition: int | Expr) -> Block[Scope1[NoneType]]:

else if condition { ... }, directly after an if_ block.

Scope1.else_

def else_(self) -> Block[Scope1[NoneType]]:

else { ... }, directly after an if_ or else_if block.

Scope1.record

record: Record

The record of the nearest repeat.

Scope1.each_name

def each_name(self, name: str) -> None:

Print this repeat's each name as name, which may be _.

Scope1.as_name

def as_name(self, name: str) -> None:

Print this repeat's as name as name, which may be _.

Scope1.record_as

def record_as(self, record: Record) -> None:

Bind this repeat to a record from forward_record.

Scope2

A scope inside two repeats.

Scope2.read

def read( self, target: str, ty: IntType[_U]) -> IntField[list[list[_U]] | _N_co]:
def read( self, target: str, ty: FloatType[_U]) -> FloatField[list[list[_U]] | _N_co]:
def read( self, target: str, ty: NumType[_U]) -> NumField[list[list[_U]] | _N_co]:
def read( self, target: str, ty: StrType[_U]) -> StrField[list[list[_U]] | _N_co]:
def read( self, target: Field[typing.Any], ty: Type[typing.Any]) -> DynField:
def read( self, target: Discard, ty: Type[typing.Any]) -> None:

x: type, reading a value into target: a new name, a handle to bind or redefine, or ib.discard().

Scope2.else_read_if

def else_read_if( self, target: str, ty: IntType[_U]) -> IntField[list[list[_U]] | None]:
def else_read_if( self, target: str, ty: FloatType[_U]) -> FloatField[list[list[_U]] | None]:
def else_read_if( self, target: str, ty: NumType[_U]) -> NumField[list[list[_U]] | None]:
def else_read_if( self, target: str, ty: StrType[_U]) -> StrField[list[list[_U]] | None]:
def else_read_if( self, target: Field[typing.Any], ty: Type[typing.Any]) -> DynField:

else if:type: the else branch is a declaration of the name if, which the target must have.

Scope2.list

def list( self, target: str, reading: ListReading[IntType[_U]]) -> IntField[list[list[list[_U]]] | _N_co]:
def list( self, target: str, reading: ListReading[FloatType[_U]]) -> FloatField[list[list[list[_U]]] | _N_co]:
def list( self, target: str, reading: ListReading[NumType[_U]]) -> NumField[list[list[list[_U]]] | _N_co]:
def list( self, target: str, reading: ListReading[StrType[_U]]) -> StrField[list[list[list[_U]]] | _N_co]:
def list( self, target: Field[typing.Any], reading: ListReading[typing.Any]) -> DynField:
def list( self, target: Discard, reading: ListReading[typing.Any]) -> None:

list x: type until end.

Scope2.let

def let( self, target: str, value: IntLookup) -> IntField[gecode_iris.Value | _N_co]:
def let( self, target: str, value: int | IntExpr) -> IntField[list[list[int]] | _N_co]:
def let( self, target: str, value: FloatLookup) -> FloatField[gecode_iris.Value | _N_co]:
def let( self, target: str, value: float | FloatExpr) -> FloatField[list[list[float]] | _N_co]:
def let( self, target: str, value: NumLookup) -> NumField[gecode_iris.Value | _N_co]:
def let( self, target: str, value: NumExpr) -> NumField[list[list[int | float]] | _N_co]:
def let( self, target: str, value: StrLookup) -> StrField[gecode_iris.Value | _N_co]:
def let( self, target: str, value: str | StrExpr) -> StrField[list[list[str]] | _N_co]:
def let( self, target: str, value: DynExpr) -> DynField:
def let( self, target: Field[typing.Any], value: int | float | str | Expr) -> DynField:

let x = value.

Scope2.param

def param( self, target: str | Field[Any]) -> DynField:
def param( self, target: str, default: IntLookup) -> IntField[gecode_iris.Value | _N_co]:
def param( self, target: str, default: int | IntExpr) -> IntField[list[list[int]] | _N_co]:
def param( self, target: str, default: FloatLookup) -> FloatField[gecode_iris.Value | _N_co]:
def param( self, target: str, default: float | FloatExpr) -> FloatField[list[list[float]] | _N_co]:
def param( self, target: str, default: NumLookup) -> NumField[gecode_iris.Value | _N_co]:
def param( self, target: str, default: NumExpr) -> NumField[list[list[int | float]] | _N_co]:
def param( self, target: str, default: StrLookup) -> StrField[gecode_iris.Value | _N_co]:
def param( self, target: str, default: str | StrExpr) -> StrField[list[list[str]] | _N_co]:
def param( self, target: str, default: DynExpr) -> DynField:
def param( self, target: Field[typing.Any], default: int | float | str | Expr) -> DynField:

param p, whose type the caller decides, or param p = default.

Scope2.capture

def capture( self, name: str, ty: None = None) -> StrField[list[list[str]] | _N_co]:
def capture( self, name: str, ty: IntType[_U]) -> IntField[list[list[_U]] | _N_co]:
def capture( self, name: str, ty: FloatType[_U]) -> FloatField[list[list[_U]] | _N_co]:
def capture( self, name: str, ty: NumType[_U]) -> NumField[list[list[_U]] | _N_co]:
def capture( self, name: str, ty: StrType[_U]) -> StrField[list[list[_U]] | _N_co]:

A handle for a pattern to bind, at this scope's depth and presence. Without a type the capture is {x}, which reads a word.

Scope2.optional_capture

def optional_capture( self, name: str, ty: None = None) -> StrField[list[list[str]] | None]:
def optional_capture( self, name: str, ty: IntType[_U]) -> IntField[list[list[_U]] | None]:
def optional_capture( self, name: str, ty: FloatType[_U]) -> FloatField[list[list[_U]] | None]:
def optional_capture( self, name: str, ty: NumType[_U]) -> NumField[list[list[_U]] | None]:
def optional_capture( self, name: str, ty: StrType[_U]) -> StrField[list[list[_U]] | None]:

capture for an optional arm or a conditional block.

Scope2.repeat

def repeat( self, count: int | IntExpr | DynExpr) -> Block[Scope3[_N_co]]:

repeat count { ... }, whose block is the next depth.

Scope2.repeat_until_eof

def repeat_until_eof(self) -> Block[Scope3[_N_co]]:

repeat until eof { ... }.

Scope2.repeat_until

def repeat_until( self, *terminators: str, store: str | Field[Any] | Discard | None = None) -> Block[Scope3[_N_co]]:

repeat until "text"... { ... }. store keeps the terminator that ended it in a name; to read it, pass a handle from forward.

Scope2.sections

def sections( self, *, until: str | tuple[str, ...] = (), skip_other: bool = False, store: str | Field[Any] | Discard | None = None) -> SectionsGuard[Scope2[_N_co], Scope2[NoneType]]:

sections: entering it gives the block of arms. until and skip_other add clauses in that order; chain .until() and .skip_other() for any other order.

Scope2.if_

def if_( self, condition: int | Expr) -> Block[Scope2[NoneType]]:

if condition { ... }. What its block defines may be absent.

Scope2.else_if

def else_if( self, condition: int | Expr) -> Block[Scope2[NoneType]]:

else if condition { ... }, directly after an if_ block.

Scope2.else_

def else_(self) -> Block[Scope2[NoneType]]:

else { ... }, directly after an if_ or else_if block.

Scope2.record

record: Record

The record of the nearest repeat.

Scope2.each_name

def each_name(self, name: str) -> None:

Print this repeat's each name as name, which may be _.

Scope2.as_name

def as_name(self, name: str) -> None:

Print this repeat's as name as name, which may be _.

Scope2.record_as

def record_as(self, record: Record) -> None:

Bind this repeat to a record from forward_record.

Scope3

A scope inside three repeats, the deepest with typed handles.

Scope3.read

def read( self, target: str, ty: IntType[_U]) -> IntField[list[list[list[_U]]] | _N_co]:
def read( self, target: str, ty: FloatType[_U]) -> FloatField[list[list[list[_U]]] | _N_co]:
def read( self, target: str, ty: NumType[_U]) -> NumField[list[list[list[_U]]] | _N_co]:
def read( self, target: str, ty: StrType[_U]) -> StrField[list[list[list[_U]]] | _N_co]:
def read( self, target: Field[typing.Any], ty: Type[typing.Any]) -> DynField:
def read( self, target: Discard, ty: Type[typing.Any]) -> None:

x: type, reading a value into target: a new name, a handle to bind or redefine, or ib.discard().

Scope3.else_read_if

def else_read_if( self, target: str, ty: IntType[_U]) -> IntField[list[list[list[_U]]] | None]:
def else_read_if( self, target: str, ty: FloatType[_U]) -> FloatField[list[list[list[_U]]] | None]:
def else_read_if( self, target: str, ty: NumType[_U]) -> NumField[list[list[list[_U]]] | None]:
def else_read_if( self, target: str, ty: StrType[_U]) -> StrField[list[list[list[_U]]] | None]:
def else_read_if( self, target: Field[typing.Any], ty: Type[typing.Any]) -> DynField:

else if:type: the else branch is a declaration of the name if, which the target must have.

Scope3.list

def list( self, target: str, reading: ListReading[IntType[_U]]) -> IntField[list[list[list[list[_U]]]] | _N_co]:
def list( self, target: str, reading: ListReading[FloatType[_U]]) -> FloatField[list[list[list[list[_U]]]] | _N_co]:
def list( self, target: str, reading: ListReading[NumType[_U]]) -> NumField[list[list[list[list[_U]]]] | _N_co]:
def list( self, target: str, reading: ListReading[StrType[_U]]) -> StrField[list[list[list[list[_U]]]] | _N_co]:
def list( self, target: Field[typing.Any], reading: ListReading[typing.Any]) -> DynField:
def list( self, target: Discard, reading: ListReading[typing.Any]) -> None:

list x: type until end.

Scope3.let

def let( self, target: str, value: IntLookup) -> IntField[gecode_iris.Value | _N_co]:
def let( self, target: str, value: int | IntExpr) -> IntField[list[list[list[int]]] | _N_co]:
def let( self, target: str, value: FloatLookup) -> FloatField[gecode_iris.Value | _N_co]:
def let( self, target: str, value: float | FloatExpr) -> FloatField[list[list[list[float]]] | _N_co]:
def let( self, target: str, value: NumLookup) -> NumField[gecode_iris.Value | _N_co]:
def let( self, target: str, value: NumExpr) -> NumField[list[list[list[int | float]]] | _N_co]:
def let( self, target: str, value: StrLookup) -> StrField[gecode_iris.Value | _N_co]:
def let( self, target: str, value: str | StrExpr) -> StrField[list[list[list[str]]] | _N_co]:
def let( self, target: str, value: DynExpr) -> DynField:
def let( self, target: Field[typing.Any], value: int | float | str | Expr) -> DynField:

let x = value.

Scope3.param

def param( self, target: str | Field[Any]) -> DynField:
def param( self, target: str, default: IntLookup) -> IntField[gecode_iris.Value | _N_co]:
def param( self, target: str, default: int | IntExpr) -> IntField[list[list[list[int]]] | _N_co]:
def param( self, target: str, default: FloatLookup) -> FloatField[gecode_iris.Value | _N_co]:
def param( self, target: str, default: float | FloatExpr) -> FloatField[list[list[list[float]]] | _N_co]:
def param( self, target: str, default: NumLookup) -> NumField[gecode_iris.Value | _N_co]:
def param( self, target: str, default: NumExpr) -> NumField[list[list[list[int | float]]] | _N_co]:
def param( self, target: str, default: StrLookup) -> StrField[gecode_iris.Value | _N_co]:
def param( self, target: str, default: str | StrExpr) -> StrField[list[list[list[str]]] | _N_co]:
def param( self, target: str, default: DynExpr) -> DynField:
def param( self, target: Field[typing.Any], default: int | float | str | Expr) -> DynField:

param p, whose type the caller decides, or param p = default.

Scope3.capture

def capture( self, name: str, ty: None = None) -> StrField[list[list[list[str]]] | _N_co]:
def capture( self, name: str, ty: IntType[_U]) -> IntField[list[list[list[_U]]] | _N_co]:
def capture( self, name: str, ty: FloatType[_U]) -> FloatField[list[list[list[_U]]] | _N_co]:
def capture( self, name: str, ty: NumType[_U]) -> NumField[list[list[list[_U]]] | _N_co]:
def capture( self, name: str, ty: StrType[_U]) -> StrField[list[list[list[_U]]] | _N_co]:

A handle for a pattern to bind, at this scope's depth and presence. Without a type the capture is {x}, which reads a word.

Scope3.optional_capture

def optional_capture( self, name: str, ty: None = None) -> StrField[list[list[list[str]]] | None]:
def optional_capture( self, name: str, ty: IntType[_U]) -> IntField[list[list[list[_U]]] | None]:
def optional_capture( self, name: str, ty: FloatType[_U]) -> FloatField[list[list[list[_U]]] | None]:
def optional_capture( self, name: str, ty: NumType[_U]) -> NumField[list[list[list[_U]]] | None]:
def optional_capture( self, name: str, ty: StrType[_U]) -> StrField[list[list[list[_U]]] | None]:

capture for an optional arm or a conditional block.

Scope3.repeat

def repeat( self, count: int | IntExpr | DynExpr) -> Block[ScopeN[_N_co]]:

repeat count { ... }, whose block is the next depth.

Scope3.repeat_until_eof

def repeat_until_eof(self) -> Block[ScopeN[_N_co]]:

repeat until eof { ... }.

Scope3.repeat_until

def repeat_until( self, *terminators: str, store: str | Field[Any] | Discard | None = None) -> Block[ScopeN[_N_co]]:

repeat until "text"... { ... }. store keeps the terminator that ended it in a name; to read it, pass a handle from forward.

Scope3.sections

def sections( self, *, until: str | tuple[str, ...] = (), skip_other: bool = False, store: str | Field[Any] | Discard | None = None) -> SectionsGuard[Scope3[_N_co], Scope3[NoneType]]:

sections: entering it gives the block of arms. until and skip_other add clauses in that order; chain .until() and .skip_other() for any other order.

Scope3.if_

def if_( self, condition: int | Expr) -> Block[Scope3[NoneType]]:

if condition { ... }. What its block defines may be absent.

Scope3.else_if

def else_if( self, condition: int | Expr) -> Block[Scope3[NoneType]]:

else if condition { ... }, directly after an if_ block.

Scope3.else_

def else_(self) -> Block[Scope3[NoneType]]:

else { ... }, directly after an if_ or else_if block.

Scope3.record

record: Record

The record of the nearest repeat.

Scope3.each_name

def each_name(self, name: str) -> None:

Print this repeat's each name as name, which may be _.

Scope3.as_name

def as_name(self, name: str) -> None:

Print this repeat's as name as name, which may be _.

Scope3.record_as

def record_as(self, record: Record) -> None:

Bind this repeat to a record from forward_record.

ScopeN

A scope inside more repeats than handles can type: its definitions give DynField, and dimensions still nest.

ScopeN.read

def read( self, target: str, ty: IntType[_U]) -> DynField:
def read( self, target: str, ty: FloatType[_U]) -> DynField:
def read( self, target: str, ty: NumType[_U]) -> DynField:
def read( self, target: str, ty: StrType[_U]) -> DynField:
def read( self, target: Field[typing.Any], ty: Type[typing.Any]) -> DynField:
def read( self, target: Discard, ty: Type[typing.Any]) -> None:

x: type, reading a value into target: a new name, a handle to bind or redefine, or ib.discard().

ScopeN.else_read_if

def else_read_if( self, target: str, ty: IntType[_U]) -> DynField:
def else_read_if( self, target: str, ty: FloatType[_U]) -> DynField:
def else_read_if( self, target: str, ty: NumType[_U]) -> DynField:
def else_read_if( self, target: str, ty: StrType[_U]) -> DynField:
def else_read_if( self, target: Field[typing.Any], ty: Type[typing.Any]) -> DynField:

else if:type: the else branch is a declaration of the name if, which the target must have.

ScopeN.list

def list( self, target: str, reading: ListReading[IntType[_U]]) -> DynField:
def list( self, target: str, reading: ListReading[FloatType[_U]]) -> DynField:
def list( self, target: str, reading: ListReading[NumType[_U]]) -> DynField:
def list( self, target: str, reading: ListReading[StrType[_U]]) -> DynField:
def list( self, target: Field[typing.Any], reading: ListReading[typing.Any]) -> DynField:
def list( self, target: Discard, reading: ListReading[typing.Any]) -> None:

list x: type until end.

ScopeN.let

def let( self, target: str, value: int | IntExpr) -> DynField:
def let( self, target: str, value: float | FloatExpr) -> DynField:
def let( self, target: str, value: NumExpr) -> DynField:
def let( self, target: str, value: str | StrExpr) -> DynField:
def let( self, target: str, value: DynExpr) -> DynField:
def let( self, target: Field[typing.Any], value: int | float | str | Expr) -> DynField:

let x = value.

ScopeN.param

def param( self, target: str | Field[Any]) -> DynField:
def param( self, target: str, default: int | IntExpr) -> DynField:
def param( self, target: str, default: float | FloatExpr) -> DynField:
def param( self, target: str, default: NumExpr) -> DynField:
def param( self, target: str, default: str | StrExpr) -> DynField:
def param( self, target: str, default: DynExpr) -> DynField:
def param( self, target: Field[typing.Any], default: int | float | str | Expr) -> DynField:

param p, whose type the caller decides, or param p = default.

ScopeN.capture

def capture(self, name: str, ty: None = None) -> DynField:
def capture( self, name: str, ty: IntType[_U]) -> DynField:
def capture( self, name: str, ty: FloatType[_U]) -> DynField:
def capture( self, name: str, ty: NumType[_U]) -> DynField:
def capture( self, name: str, ty: StrType[_U]) -> DynField:

A handle for a pattern to bind, at this scope's depth and presence. Without a type the capture is {x}, which reads a word.

ScopeN.optional_capture

def optional_capture(self, name: str, ty: None = None) -> DynField:
def optional_capture( self, name: str, ty: IntType[_U]) -> DynField:
def optional_capture( self, name: str, ty: FloatType[_U]) -> DynField:
def optional_capture( self, name: str, ty: NumType[_U]) -> DynField:
def optional_capture( self, name: str, ty: StrType[_U]) -> DynField:

capture for an optional arm or a conditional block.

ScopeN.repeat

def repeat( self, count: int | IntExpr | DynExpr) -> Block[ScopeN[_N_co]]:

repeat count { ... }, whose block is the next depth.

ScopeN.repeat_until_eof

def repeat_until_eof(self) -> Block[ScopeN[_N_co]]:

repeat until eof { ... }.

ScopeN.repeat_until

def repeat_until( self, *terminators: str, store: str | Field[Any] | Discard | None = None) -> Block[ScopeN[_N_co]]:

repeat until "text"... { ... }. store keeps the terminator that ended it in a name; to read it, pass a handle from forward.

ScopeN.sections

def sections( self, *, until: str | tuple[str, ...] = (), skip_other: bool = False, store: str | Field[Any] | Discard | None = None) -> SectionsGuard[ScopeN[_N_co], ScopeN[NoneType]]:

sections: entering it gives the block of arms. until and skip_other add clauses in that order; chain .until() and .skip_other() for any other order.

ScopeN.if_

def if_( self, condition: int | Expr) -> Block[ScopeN[NoneType]]:

if condition { ... }. What its block defines may be absent.

ScopeN.else_if

def else_if( self, condition: int | Expr) -> Block[ScopeN[NoneType]]:

else if condition { ... }, directly after an if_ block.

ScopeN.else_

def else_(self) -> Block[ScopeN[NoneType]]:

else { ... }, directly after an if_ or else_if block.

ScopeN.record

record: Record

The record of the nearest repeat.

ScopeN.each_name

def each_name(self, name: str) -> None:

Print this repeat's each name as name, which may be _.

ScopeN.as_name

def as_name(self, name: str) -> None:

Print this repeat's as name as name, which may be _.

ScopeN.record_as

def record_as(self, record: Record) -> None:

Bind this repeat to a record from forward_record.

SectionsGuard

class SectionsGuard(gecode_iris.build.Block[gecode_iris.build.Arms[_R_co, _O_co]], typing.Generic[_R_co, _O_co]):

The guard of sections: clauses chain, and with gives the arms.

SectionsGuard.until

def until( self, *terminators: str, store: str | Field[Any] | Discard | None = None) -> SectionsGuard[_R_co, _O_co]:

until "text"..., with store x keeping the terminator; to read it, pass a handle from forward.

SectionsGuard.skip_other

def skip_other(self) -> SectionsGuard[_R_co, _O_co]:

skip other.

SpecBuilder

SpecBuilder(format: str | None = None)

Builds a reader spec. It is the root scope, with the settings and statements that only the top level allows.

SpecBuilder.format

def format(self, name: str) -> None:

format name, a name of this format.

SpecBuilder.comment

def comment(self, *markers: str) -> None:

comment "text"....

SpecBuilder.stop

def stop(self, *markers: str) -> None:

stop "text"....

SpecBuilder.tokens

def tokens(self, characters: str) -> None:

tokens "characters".

SpecBuilder.separators

def separators(self, characters: str) -> None:

separators "characters".

SpecBuilder.ignore_trailing

def ignore_trailing(self) -> None:

ignore trailing.

SpecBuilder.instances

def instances( self) -> Block[Scope0[typing.NoReturn]]:

instances { ... }.

SpecBuilder.source

def source(self) -> str:

The text this builder emits, without parsing it.

SpecBuilder.build

def build(self) -> gecode_iris.Spec:

Print the text and parse it. The spec is an ordinary one, whose errors while reading name the call site of their statement.

StrExpr

class StrExpr(gecode_iris.build.Expr):

A string expression.

StrField

A handle of a string entry.

StrField.field

def field( self, handle: IntField[typing.Any]) -> IntLookup:
def field( self, handle: FloatField[typing.Any]) -> FloatLookup:
def field( self, handle: NumField[typing.Any]) -> NumLookup:
def field( self, handle: StrField[typing.Any]) -> StrLookup:
def field(self, handle: DynField) -> DynExpr:

self.name, the field handle of the record this selects.

StrLookup

class StrLookup(gecode_iris.build.StrExpr):

A string lookup, which may be an array.

StrLookup.field

def field( self, handle: IntField[typing.Any]) -> IntLookup:
def field( self, handle: FloatField[typing.Any]) -> FloatLookup:
def field( self, handle: NumField[typing.Any]) -> NumLookup:
def field( self, handle: StrField[typing.Any]) -> StrLookup:
def field(self, handle: DynField) -> DynExpr:

self.name, the field handle of the record this selects.

StrType

class StrType(gecode_iris.build.Type[_U]):

A type that reads strings.

StrType.dim

def dim( self, size: int | IntExpr | DynExpr) -> StrType[list[_U]]:

Add a dimension: x[size]: type.

StrType.dims

def dims( self, size: int | IntExpr | DynExpr, /) -> StrType[list[_U]]:
def dims( self, first: int | IntExpr | DynExpr, second: int | IntExpr | DynExpr, /) -> StrType[list[list[_U]]]:
def dims( self, first: int | IntExpr | DynExpr, second: int | IntExpr | DynExpr, third: int | IntExpr | DynExpr, /) -> StrType[list[list[list[_U]]]]:
def dims( self, *sizes: int | IntExpr | DynExpr) -> StrType[typing.Any]:

Add several dimensions, as many as known only at run time.

StrType.layout

def layout( self, layout: int | float | str | Expr) -> StrType[_U]:

layout expression: a matrix layout name such as "LOWER_COL".

StrType.offset

def offset( self, offset: int | IntExpr | DynExpr) -> StrType[_U]:

offset expression.

StrType.until

def until( self, end: int | float | str | Expr | Eol) -> ListReading[StrType[_U]]:

A list of this type ending at end: a sentinel, or ib.eol.

Type

class Type(typing.Generic[_U]):

A reading type, whose parameter is the value it reads, with a list for each dimension.

all

def all( domain: gecode_iris.build._Domain[_I], body: Callable[[_I], int | Expr]) -> IntExpr:

all(x in domain: body).

alphabet

def alphabet( symbols: str, *, blank: str | None = None, strip: str | None = None, base: int | None = None) -> Alphabet:

alphabet "symbols", with the options given, in this order.

any

def any( domain: gecode_iris.build._Domain[_I], body: Callable[[_I], int | Expr]) -> IntExpr:

any(x in domain: body).

at_least

def at_least( lo: int | IntExpr | DynExpr) -> IntType[int]:

lo.., the integers from lo up.

bind

def bind( handle: Field[typing.Any], ty: Type[Any] | None = None) -> Part:

{x:type}, binding a forward or redefined handle; without a type, {x}, which reads a word.

blank

def blank() -> Part:

{}, which matches a word without storing it.

count

def count( domain: gecode_iris.build._Domain[_I], body: Callable[[_I], int | Expr] | None = None) -> IntExpr:

count(domain), or count(x in domain: body) given a function.

declared

def declared(name: str, kind: type[_F]) -> _F:

A handle for the entry name of a text spec, of the handle type kind, such as ib.IntField[list[int]] or ib.DynField.

iris gen --lang python SPEC prints one per entry. The handle reads data as a builder's handle does, but no builder accepts it, since it comes from none.

defined

def defined( name: Expr | Record | RecordList | RecordExpr) -> IntExpr:

defined(name): a handle, record, record list or comprehension variable. defined(record) tests the record list.

discard

def discard() -> Discard:

_: read a value without storing it, or {_} in a pattern.

discard_as

def discard_as(ty: Type[typing.Any]) -> Part:

{_:type}, a discarded capture with a type.

distinct

def distinct(*arguments: float | Expr) -> IntExpr:

distinct(a, b, ...).

div

def div( left: int | IntExpr | DynExpr, right: int | IntExpr | DynExpr) -> IntExpr:

left / right, Iris integer division.

eol

eol: Eol = ib.eol

until eol: a list that ends with its line.

float_

float_: FloatType[float]

float.

int_

int_: IntType[int]

int.

int_range

def int_range( lo: int | IntExpr | DynExpr | None = None, hi: int | IntExpr | DynExpr | None = None, *, below: int | IntExpr | DynExpr | None = None) -> IntType[int]:

lo..hi, both included, or lo..<below. Either end may be left out, but not both.

lit

def lit(value: int) -> IntExpr:
def lit(value: float) -> FloatExpr:
def lit(value: str) -> StrExpr:

An Iris literal: an int in the 64-bit range, a float or a str.

max

def max(*arguments: float | Expr) -> IntExpr:

max(a, b, ...).

min

def min(*arguments: float | Expr) -> IntExpr:

min(a, b, ...).

num

num: NumType[int | float]

num: an int or a float, decided by the data.

over

def over( domain: gecode_iris.build._Domain[_I], name: str | None = None) -> gecode_iris.build._Over[_I]:

domain, with its comprehension variable printed as name.

pow

def pow( base: int | IntExpr | DynExpr, exponent: int | IntExpr | DynExpr) -> IntExpr:

base ^ exponent.

ref

def ref(handle: Field[typing.Any]) -> Part:

{$x}, matching the current value of x.

rem

def rem( left: int | IntExpr | DynExpr, right: int | IntExpr | DynExpr) -> IntExpr:

left % right, the Iris remainder.

rest

rest: StrType[str]

rest: the rest of the line.

rest_of_line

rest_of_line: Part

The trailing ... of a pattern.

size

def size( domain: gecode_iris.build._Domain[typing.Any]) -> IntExpr:

size(domain).

sum

def sum( domain: gecode_iris.build._Domain[_I], body: Callable[[_I], int | Expr], /) -> IntExpr:
def sum(*arguments: float | Expr) -> IntExpr:

sum(a, b, ...), or sum(x in domain: body) given a domain and a function of its variable.

track_caller

def track_caller(function: _C) -> _C:

Make a helper function report its caller's line as the call site of the statements it writes, as builder methods do.

validate

def validate(ty: Type[typing.Any]) -> Part:

{:type}, which checks the text without storing it.

word

word: StrType[str]

word: one token.

gecode

Gecode's host constants, for ranges and checks.

gecode.INT_MAX

INT_MAX: IntExpr

gecode.int_max, 2147483646.

gecode.INT_MIN

INT_MIN: IntExpr

gecode.int_min, -2147483646.