[ library(flatzinc_parser) | Reference Manual | Alphabetic Index ]

read_item(+Stream, -Item)

Read one item from a FlatZinc input stream
Stream
ECLiPSe stream name or handle
Item
Output: an ECLiPSe term that describes the FlatZinc item

Description

Reads one FlatZinc item (up to and including the terminating semicolon) from Stream, and returns it as an ECLiPSe structure. Fails when end_of_file has been reached.

Modes and Determinism

Fail Conditions

Fails if end_of_file is reached

Exceptions

(fz_abort)
syntax error

Examples

    ?- read_item(input, Item).
    > float: x=3.14;
    Item = float : x = 3.14
    Yes (0.00s cpu)

    ?- read_item(input, Item).
    > solve minimize x;
    Item = minimize(solve, x)
    Yes (0.03s cpu)

    ?- read_item(input, Item).
    > var int: i::foo::bar;
    Item = var(int) : (i :: (foo :: bar))
    Yes (0.02s cpu)

    ?- read_item(input, Item).
    > constraint int_lt(x[2], 3);
    Item = constraint(int_lt(subscript(x, [2]), 3))
    Yes (0.00s cpu)

    ?- read_item(input, Item).
    > set of  int: s={1,2,3};
    Item = (set of int) : s = {[1, 2, 3]}
    Yes (0.05s cpu)

    ?- read_item(input, Item).
    > array [1..3] of var int: a;
    Item = (array([1 .. 3]) of var(int)) : a
    Yes (0.03s cpu)

    ?- read_item(input, Item).
    > var 1..5: i;
    Item = var(1 .. 5) : i
    Yes (0.03s cpu)