Class Iris
Javadoc 27 generates this reference during each site build from the exported packages and the annotation processor. The Java guide shows the API in use.
import static
dev.gecode.iris.build.Iris.*;.
Handles are typed constants that name entries: int2("machine") is an
IntField<List<long[]>>, and data.get(machine) returns a List<long[]>. Each
statement is a static method, which adds the statement to the innermost open block; a block
statement takes its body as a lambda, which runs with that block open. A scoped value holds the
open block, so a statement called outside a builder body throws IllegalStateException.
static final IntField<Long> n = int0("n");
static final IntField<long[]> x = int1("x");
static final Spec spec =
spec(
"numbers",
() -> {
read(n, atLeast(0));
repeat(n, () -> read(x, intType()));
});
A mistake that one statement shows throws BuildException at that call; the checks of
the whole spec throw it from Builder.build(). Either way its call site is the line of the
caller's code that made the statement.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <E> IntExprReturnsall(x in domain: body).static AlphabetReturnsalphabet "symbols".static <E> IntExprReturnsany(x in domain: body).static voidAn arm of the enclosing sections, with no body.static voidAn arm of the enclosing sections.static voidAn arm of the enclosing sections.static voidAn arm of the enclosing sections.static voidAn arm of the enclosing sections, with no body.static voidAn arm of the enclosing sections.static voidAn arm of the enclosing sections.static voidAn arm of the enclosing sections.static IntTypeatLeast(long lo) Returnslo.., the integers fromloup.static IntTypeatLeast(NumericExpr lo) Returnslo.., the integers fromloup.static IntTypeatMost(long hi) Returns..hi, the integers up tohi.static IntTypeatMost(NumericExpr hi) Returns..hi, the integers up tohi.static IntTypebelow(long hi) Returns..<hi, the integers belowhi.static IntTypebelow(NumericExpr hi) Returns..<hi, the integers belowhi.static Partblank()Returns{}, which matches a word without storing it.static BuilderBuilds a reader spec:bodyadds its statements.static BuilderBuilds a reader spec that starts withformat name.static PartReturns{x:type}, which readstypeinto the entry ofhandle.static voidcheck condition.static voidcheck condition "message".static voidcomment "text"....static IntExprReturnscount(domain).static <E> IntExprReturnscount(x in domain: body).static <H extends Field<?>>
Hdeclare(H handle) Declares the name ofhandle, a handle from a factory such asint0(String), in the open builder, and returns the handle.static IntExprReturnsdefined(name).static IntExprdefined(RecordExpr record) Returnsdefined(record).static IntExprdefined(RecordList records) Returnsdefined(records).static IntExprdefined(RecordName record) Returnsdefined(records), of the record list ofrecord.static FloatTypedefineType(String name, FloatType type) type name = type.static IntTypedefineType(String name, IntType type) type name = type, usable wherever a type is.static NumTypedefineType(String name, NumType type) type name = type.static StringTypedefineType(String name, StringType type) type name = type.static Discarddiscard()Returns_: a target that reads without storing, and{_}in a pattern.static PartReturns{_:type}, a discarded capture with a type.static IntExprReturnsdistinct(a, b, ...); of one array, whether its elements differ.static IntExprReturnsdistinct(a, b, ...).static DynFieldReturns the handle of an entry whose value type and depth are open, read as aValuethat is null when the entry is absent.static voidelse if condition { ... }, directly after anifThenorelseIfblock.static DynFieldelseReadIf(Field<?> target, Type<?> type) else if:type: the else branch is a declaration of the nameif, which the target must have.static voidexpect "text"....static voidfind "pattern".static FloatField<Double> Returns the handle of a single float.static FloatField<double[]> Returns the handle of an array of floats.static FloatField<List<double[]>> Returns the handle of a two-dimensional array of floats.static FloatField<List<List<double[]>>> Returns the handle of a three-dimensional array of floats.static FloatField<Value> Returns the handle of floats at any depth, read as aValue.static FloatTypeReturnsfloat.static voidformat name, a name of this format.static <H extends Field<?>>
Hforward(String name, Class<? extends HandleKind<H>> kind) Declares a name in the open builder and returns its handle, of the kindkindnames:Int.class,Real.class,Num.class,Str.classorDyn.class.static voidif condition { ... }.static voidignore trailing.static voidindex(long position) index position.static voidindex position.static voidinstances { ... }.Returns the handle of a single integer.static IntField<long[]> Returns the handle of an array of integers.Returns the handle of a two-dimensional array of integers.Returns the handle of a three-dimensional array of integers.Returns the handle of integers at any depth, read as aValue.static IntTypeintType()Returnsint.static ArmOptionlast()Returns thelastoption of an arm.static voidlet _ = value, which evaluatesvaluewithout storing it.static DynFieldlet x = value.static voidline "pattern".static voidlist(Discard target, ListReading reading) list _: type until end.static DynFieldlist(Field<?> target, ListReading reading) list x: type until end.static FloatExprlit(double value) Returns a float literal.static IntExprlit(long value) Returns an integer literal.static StringExprReturns a string literal.static IntExprReturnsmax(a, b, ...); of one array, its greatest element.static IntExprReturnsmax(a, b, ...).static IntExprReturnsmin(a, b, ...); of one array, its least element.static IntExprReturnsmin(a, b, ...).Returns the handle of a singlenum, aLongor aDoubleas the data decides.Returns the handle of an array ofnums.Returns the handle of a two-dimensional array ofnums.Returns the handle of a three-dimensional array ofnums.Returns the handle ofnums at any depth, read as aValue.static NumTypenumType()Returnsnum, an integer or a float as the data decides.static ArmOptionoptional()Returns theoptionaloption of an arm.static voidelse { ... }, directly after anifThenorelseIfblock.static <E> Over<E> Returnsdomain, whose comprehension variableOver.named(String)can name.static DynFieldparam p, whose value and type the caller decides.static DynFieldparam p = default.static PatternReturns a line pattern of text and parts.static Rangerange(long lo) static Rangerange(NumericExpr lo) static void_: type, reading a value without storing it.static DynFieldx: type, reading a value into the entry oftarget.static RecordNameReturns a record name, printed with names the builder chooses.static RecordNamerecordName(String each, String list) Returns a record name, printed aseachfor the current record andlistfor all of them.static PartReturns{$x}, which matches the current value ofhandle's entry.static voidrepeat(long count, RecordName record, Runnable body) repeat count { ... }, whose recordsrecordnames.static voidrepeat count { ... }.static voidrepeat(Expr count, RecordName record, Runnable body) repeat count { ... }, whose recordsrecordnames.static voidrepeat count { ... }.static voidrepeatUntil(Until until, RecordName record, Runnable body) repeat until "text"... { ... }, whose recordsrecordnames.static voidrepeatUntil(Until until, Runnable body) repeat until "text"... { ... }.static voidrepeatUntilEof(RecordName record, Runnable body) repeat until eof { ... }, whose recordsrecordnames.static voidrepeatUntilEof(Runnable body) repeat until eof { ... }.static StringTyperest()Returnsrest, the rest of the line.static PartReturns the trailing...of a pattern.static voidsections(SectionClause first, SectionClause second, SectionClause third, Runnable body) sections clause clause clause { ... }.static voidsections(SectionClause first, SectionClause second, Runnable body) sections clause clause { ... }.static voidsections(SectionClause clause, Runnable body) sections clause { ... }.static voidsections { ... }, whose body holds only arms.static voidsections(List<? extends SectionClause> clauses, Runnable body) sections clause... { ... }, with any number of clauses.static voidseparators(String characters) separators "characters".static voidlet x = valuethrough a handle whose type is open.static voidset(FloatField<?> handle, double value) let x = valuethrough a handle, keeping its type and depth.static voidset(FloatField<?> handle, FloatExpr value) let x = valuethrough a handle, keeping its type and depth.static voidlet x = valuethrough a handle, keeping its type and depth.static voidlet x = valuethrough a handle, keeping its type and depth.static voidlet x = valuethrough a handle, keeping its type and depth.static voidset(StringField<?> handle, StringExpr value) let x = valuethrough a handle, keeping its type and depth.static voidset(StringField<?> handle, String value) let x = valuethrough a handle, keeping its type and depth.static IntExprReturnssize(domain).static voidskipLine()skip line.static voidskipLines(long count) skip count lines.static voidskip count lines.static SectionClauseReturns theskip otherclause of sections.static SpecBuilds and parses a reader spec.static SpecBuilds and parses a reader spec that starts withformat name.static voidstop "text"....static StringField<String> Returns the handle of a single string.static StringField<List<String>> Returns the handle of an array of strings.static StringField<List<List<String>>> Returns the handle of a two-dimensional array of strings.static StringField<List<List<List<String>>>> Returns the handle of a three-dimensional array of strings.static StringField<Value> Returns the handle of strings at any depth, read as aValue.static <E> IntExprReturnssum(x in domain: body).static IntExprReturnssum(a, b, ...); of one array, the sum of its elements.static IntExprReturnssum(a, b, ...).static voidtokens "characters".static DynFieldDeclares a name that is deliberately left undefined, as incheck !defined(name), and returns its handle.static UntilReturns the terminatorsuntil "text"...of a repeat or sections.static PartReturns{:type}, which checks the text without storing it.static StringTypeword()Returnsword.
-
Method Details
-
builder
Builds a reader spec:bodyadds its statements.- Parameters:
body- the statements- Returns:
- the builder, whose
Builder.build()gives the spec - Throws:
BuildException- if a statement fails a check
-
builder
Builds a reader spec that starts withformat name.- Parameters:
format- the format namebody- the statements- Returns:
- the builder, whose
Builder.build()gives the spec - Throws:
BuildException- if a statement fails a check
-
spec
Builds and parses a reader spec.- Parameters:
body- the statements- Returns:
- the spec
- Throws:
BuildException- if a check fails, or the language rejects the text
-
spec
Builds and parses a reader spec that starts withformat name.- Parameters:
format- the format namebody- the statements- Returns:
- the spec
- Throws:
BuildException- if a check fails, or the language rejects the text
-
int0
Returns the handle of a single integer.- Parameters:
name- the entry name- Returns:
- the handle of a single integer
- Throws:
BuildException- ifnameis not an Iris name
-
int1
Returns the handle of an array of integers.- Parameters:
name- the entry name- Returns:
- the handle of an array of integers
- Throws:
BuildException- ifnameis not an Iris name
-
int2
Returns the handle of a two-dimensional array of integers.- Parameters:
name- the entry name- Returns:
- the handle of a two-dimensional array of integers
- Throws:
BuildException- ifnameis not an Iris name
-
int3
Returns the handle of a three-dimensional array of integers.- Parameters:
name- the entry name- Returns:
- the handle of a three-dimensional array of integers
- Throws:
BuildException- ifnameis not an Iris name
-
intN
-
float0
Returns the handle of a single float.- Parameters:
name- the entry name- Returns:
- the handle of a single float
- Throws:
BuildException- ifnameis not an Iris name
-
float1
Returns the handle of an array of floats.- Parameters:
name- the entry name- Returns:
- the handle of an array of floats
- Throws:
BuildException- ifnameis not an Iris name
-
float2
Returns the handle of a two-dimensional array of floats.- Parameters:
name- the entry name- Returns:
- the handle of a two-dimensional array of floats
- Throws:
BuildException- ifnameis not an Iris name
-
float3
Returns the handle of a three-dimensional array of floats.- Parameters:
name- the entry name- Returns:
- the handle of a three-dimensional array of floats
- Throws:
BuildException- ifnameis not an Iris name
-
floatN
Returns the handle of floats at any depth, read as aValue.- Parameters:
name- the entry namedepth- the depth- Returns:
- the handle of floats at any depth, read as a
Value - Throws:
BuildException- ifnameis not an Iris name
-
num0
Returns the handle of a singlenum, aLongor aDoubleas the data decides.- Parameters:
name- the entry name- Returns:
- the handle of a single
num, aLongor aDoubleas the data decides - Throws:
BuildException- ifnameis not an Iris name
-
num1
Returns the handle of an array ofnums.- Parameters:
name- the entry name- Returns:
- the handle of an array of
nums - Throws:
BuildException- ifnameis not an Iris name
-
num2
-
num3
-
numN
-
string0
Returns the handle of a single string.- Parameters:
name- the entry name- Returns:
- the handle of a single string
- Throws:
BuildException- ifnameis not an Iris name
-
string1
Returns the handle of an array of strings.- Parameters:
name- the entry name- Returns:
- the handle of an array of strings
- Throws:
BuildException- ifnameis not an Iris name
-
string2
Returns the handle of a two-dimensional array of strings.- Parameters:
name- the entry name- Returns:
- the handle of a two-dimensional array of strings
- Throws:
BuildException- ifnameis not an Iris name
-
string3
Returns the handle of a three-dimensional array of strings.- Parameters:
name- the entry name- Returns:
- the handle of a three-dimensional array of strings
- Throws:
BuildException- ifnameis not an Iris name
-
stringN
Returns the handle of strings at any depth, read as aValue.- Parameters:
name- the entry namedepth- the depth- Returns:
- the handle of strings at any depth, read as a
Value - Throws:
BuildException- ifnameis not an Iris name
-
dynamic
Returns the handle of an entry whose value type and depth are open, read as aValuethat is null when the entry is absent.- Parameters:
name- the entry name- Returns:
- the handle of an entry whose value type and depth are open, read as a
Valuethat is null when the entry is absent - Throws:
BuildException- ifnameis not an Iris name
-
forward
Declares a name in the open builder and returns its handle, of the kindkindnames:Int.class,Real.class,Num.class,Str.classorDyn.class. The handle is a required value at depth 0, or open forDyn.class, and belongs to this builder.forward("_", Str.class)is the handle of the entry thatstore _keeps.Builder.build()reports a handle that nothing defines, and a definition that does not have its type, unless an earlier one always precedes it.- Type Parameters:
H- the handle class- Parameters:
name- the entry name, which may be_kind- the kind of handle- Returns:
- the handle
- Throws:
BuildException- ifnameis not an Iris name or is already declared
-
undefined
Declares a name that is deliberately left undefined, as incheck !defined(name), and returns its handle. Defining it failsBuilder.build().- Parameters:
name- the entry name- Returns:
- the handle
- Throws:
BuildException- ifnameis not an Iris name or is already declared
-
declare
Declares the name ofhandle, a handle from a factory such asint0(String), in the open builder, and returns the handle. Its first use would declare the name too, but a use accepts a name that an equal handle declared before; this fails when anything has declared the name.A builder whose definitions take a name rather than a handle, such as the Kotlin builder, declares each name with it, so that a helper called twice with one name is an error rather than a redefinition. Redefinition goes through the handle.
- Type Parameters:
H- the handle class- Parameters:
handle- the handle to declare- Returns:
handle- Throws:
BuildException- if the name is already declared in this builderIllegalArgumentException- ifhandledoes not come from a factory
-
recordName
Returns a record name, printed with names the builder chooses.- Returns:
- a record name, printed with names the builder chooses
-
recordName
Returns a record name, printed aseachfor the current record andlistfor all of them.- Parameters:
each- theeachname, which may be_list- theasname, which may be_- Returns:
- a record name, printed as
eachfor the current record andlistfor all of them - Throws:
BuildException- if a name is not an Iris name
-
format
format name, a name of this format.- Parameters:
name- the format name
-
comment
-
stop
-
tokens
tokens "characters".- Parameters:
characters- the characters that are tokens of their own
-
separators
separators "characters".- Parameters:
characters- the characters that separate tokens
-
ignoreTrailing
public static void ignoreTrailing()ignore trailing. -
instances
instances { ... }.- Parameters:
body- the statements of one instance
-
read
-
read
-
list
list x: type until end.- Parameters:
target- the handle of the entryreading- the type and end, fromtype.until(end)- Returns:
- the handle of the name as this definition leaves it
-
list
list _: type until end.- Parameters:
target-discard()reading- the type and end, fromtype.until(end)
-
let
-
let
-
param
-
param
param p = default. A caller's value is a scalar, so the parameter is a scalar in its block when the default is one there: a scalar expression, or a handle of depth 0 at the top level. Any other default gives an open depth, which onlydynamic(name)accepts.- Parameters:
target- the handle of the parameterdefaultValue- the value when the caller gives none- Returns:
- the handle of the name as this definition leaves it
-
set
let x = valuethrough a handle, keeping its type and depth.- Parameters:
handle- the handlevalue- the value- Throws:
BuildException- ifvaluehas another depth than the handle
-
set
let x = valuethrough a handle, keeping its type and depth.- Parameters:
handle- the handlevalue- the value- Throws:
BuildException- if the handle is not a single value
-
set
let x = valuethrough a handle, keeping its type and depth.- Parameters:
handle- the handlevalue- the value- Throws:
BuildException- ifvaluehas another depth than the handle
-
set
let x = valuethrough a handle, keeping its type and depth.- Parameters:
handle- the handlevalue- the value- Throws:
BuildException- if the handle is not a single value
-
set
let x = valuethrough a handle, keeping its type and depth.- Parameters:
handle- the handlevalue- the value- Throws:
BuildException- ifvaluehas another depth than the handle
-
set
let x = valuethrough a handle, keeping its type and depth.- Parameters:
handle- the handlevalue- the value- Throws:
BuildException- ifvaluehas another depth than the handle
-
set
let x = valuethrough a handle, keeping its type and depth.- Parameters:
handle- the handlevalue- the value- Throws:
BuildException- if the handle is not a single value
-
set
-
defineType
type name = type, usable wherever a type is. The type it returns belongs to this declaration:Builder.build()reports a use where another declaration of the name is visible.- Parameters:
name- the type nametype- the type, without dimensions- Returns:
- the named type
-
defineType
-
defineType
-
defineType
type name = type.- Parameters:
name- the type nametype- the type, without dimensions- Returns:
- the named type
-
check
-
check
-
expect
-
line
line "pattern".- Parameters:
parts- the pattern: text, handles, parts and patterns, aspattern(Object...)takes
-
find
find "pattern".- Parameters:
parts- the pattern: text, handles, parts and patterns, aspattern(Object...)takes
-
skipLine
public static void skipLine()skip line. -
skipLines
-
skipLines
public static void skipLines(long count) skip count lines.- Parameters:
count- the number of lines
-
index
-
index
public static void index(long position) index position.- Parameters:
position- the position
-
repeat
-
repeat
repeat count { ... }.- Parameters:
count- the number of timesbody- the statements of one time
-
repeat
repeat count { ... }, whose recordsrecordnames.- Parameters:
count- the number of timesrecord- the record name, which no other repeat of this builder bindsbody- the statements of one time- Throws:
BuildException- if another repeat boundrecord
-
repeat
repeat count { ... }, whose recordsrecordnames.- Parameters:
count- the number of timesrecord- the record name, which no other repeat of this builder bindsbody- the statements of one time- Throws:
BuildException- if another repeat boundrecord
-
repeatUntilEof
repeat until eof { ... }.- Parameters:
body- the statements of one time
-
repeatUntilEof
repeat until eof { ... }, whose recordsrecordnames.- Parameters:
record- the record name, which no other repeat of this builder bindsbody- the statements of one time- Throws:
BuildException- if another repeat boundrecord
-
repeatUntil
repeat until "text"... { ... }.- Parameters:
until- the terminators, fromuntil(String, String...), with anystorebody- the statements of one time
-
repeatUntil
repeat until "text"... { ... }, whose recordsrecordnames.- Parameters:
until- the terminators, fromuntil(String, String...), with anystorerecord- the record name, which no other repeat of this builder bindsbody- the statements of one time- Throws:
BuildException- if another repeat boundrecord
-
until
-
skipOther
Returns theskip otherclause of sections.- Returns:
- the
skip otherclause of sections
-
sections
sections { ... }, whose body holds only arms.- Parameters:
body- the arms
-
sections
sections clause { ... }.- Parameters:
clause- the clausebody- the arms
-
sections
sections clause clause { ... }.- Parameters:
first- the first clausesecond- the second clausebody- the arms
-
sections
public static void sections(SectionClause first, SectionClause second, SectionClause third, Runnable body) sections clause clause clause { ... }.- Parameters:
first- the first clausesecond- the second clausethird- the third clausebody- the arms
-
sections
sections clause... { ... }, with any number of clauses.- Parameters:
clauses- the clauses, in orderbody- the arms
-
optional
Returns theoptionaloption of an arm.- Returns:
- the
optionaloption of an arm
-
last
Returns thelastoption of an arm.- Returns:
- the
lastoption of an arm
-
arm
-
arm
-
arm
-
arm
-
arm
-
arm
-
arm
-
arm
-
ifThen
-
elseIf
else if condition { ... }, directly after anifThenorelseIfblock.- Parameters:
condition- the conditionbody- the statements when it holds- Throws:
BuildException- if noifThenorelseIfblock comes just before
-
otherwise
else { ... }, directly after anifThenorelseIfblock.- Parameters:
body- the statements when no condition holds- Throws:
BuildException- if noifThenorelseIfblock comes just before
-
elseReadIf
else if:type: the else branch is a declaration of the nameif, which the target must have.- Parameters:
target- the handle of the entry namediftype- the type- Returns:
- the handle of the name as this definition leaves it
- Throws:
BuildException- if noifThenorelseIfblock comes just before, or the target has another name
-
intType
-
floatType
-
numType
Returnsnum, an integer or a float as the data decides.- Returns:
num, an integer or a float as the data decides
-
word
-
rest
Returnsrest, the rest of the line.- Returns:
rest, the rest of the line
-
alphabet
-
range
- Parameters:
lo- the lower bound- Returns:
lo.., whichRange.to(NumericExpr)andRange.below(NumericExpr)bound- Throws:
IllegalArgumentException- if the bound is a float
-
range
- Parameters:
lo- the lower bound- Returns:
lo.., whichRange.to(NumericExpr)andRange.below(NumericExpr)bound
-
atLeast
Returnslo.., the integers fromloup.- Parameters:
lo- the lower bound- Returns:
lo.., the integers fromloup- Throws:
IllegalArgumentException- if the bound is a float
-
atLeast
Returnslo.., the integers fromloup.- Parameters:
lo- the lower bound- Returns:
lo.., the integers fromloup
-
atMost
Returns..hi, the integers up tohi.- Parameters:
hi- the upper bound- Returns:
..hi, the integers up tohi- Throws:
IllegalArgumentException- if the bound is a float
-
atMost
Returns..hi, the integers up tohi.- Parameters:
hi- the upper bound- Returns:
..hi, the integers up tohi
-
below
Returns..<hi, the integers belowhi.- Parameters:
hi- the upper bound- Returns:
..<hi, the integers belowhi- Throws:
IllegalArgumentException- if the bound is a float
-
below
Returns..<hi, the integers belowhi.- Parameters:
hi- the upper bound- Returns:
..<hi, the integers belowhi
-
pattern
Returns a line pattern of text and parts.- Parameters:
parts- the parts:Stringtext; a handle, which is{x}and reads a word; aPartsuch ascapture(Field, Type);discard(), which is{_}; or another pattern- Returns:
- a line pattern of text and parts
- Throws:
IllegalArgumentException- for a part of another class
-
capture
-
ref
-
validate
-
blank
Returns{}, which matches a word without storing it.- Returns:
{}, which matches a word without storing it
-
discard
Returns_: a target that reads without storing, and{_}in a pattern.- Returns:
_: a target that reads without storing, and{_}in a pattern
-
discard
-
restOfLine
Returns the trailing...of a pattern.- Returns:
- the trailing
...of a pattern
-
lit
Returns an integer literal.- Parameters:
value- the integer- Returns:
- an integer literal
-
lit
Returns a float literal.- Parameters:
value- the float- Returns:
- a float literal
-
lit
Returns a string literal.- Parameters:
value- the string- Returns:
- a string literal
-
sum
-
sum
-
min
-
min
-
max
-
max
-
distinct
-
distinct
-
sum
-
all
-
any
-
count
-
count
-
size
-
defined
-
defined
Returnsdefined(records), of the record list ofrecord.- Parameters:
record- the record name- Returns:
defined(records), of the record list ofrecord
-
defined
Returnsdefined(records).- Parameters:
records- the record list- Returns:
defined(records)
-
defined
Returnsdefined(record).- Parameters:
record- the record- Returns:
defined(record)
-
over
Returnsdomain, whose comprehension variableOver.named(String)can name.- Type Parameters:
E- what the domain gives the body- Parameters:
domain- the domain- Returns:
domain, whose comprehension variableOver.named(String)can name
-