lib(flatzinc_syntax)



This module provides a quick way to enable ECLiPSe to read FlatZinc items.
FlatZinc Syntax is sufficiently close to ECLiPSe syntax to allow the normal
ECLiPSe parser to read FlatZinc, provided a number of syntax options are set.
The way to use this library is to load it

:- lib(flatzinc_syntax).

and then use the normal read/1,2,etc primitives with this
module context, e.g.

..., read(Stream, FlatZincItem)@flatzinc_syntax, ...

for example

fzn_echo(File) :-
	open(File, read, Stream),
	read(Stream, Term1)@flatzinc_syntax,
	( fromto(Term1, Term, Term2, end_of_file), param(Stream) do
	    writeln(Term),
	    read(Stream, Term2)@flatzinc_syntax
	),
	close(Stream).


Alternatively, the library exports read_item/2, which is defined as

read_item(Stream, Term) :-
	read(Stream, Term)@flatzinc_syntax,
	Term \== end_of_file.

and is call-compatible with the predicate of the same name
exported from lib(flatzinc_parser), but faster.  Since it
works simply by modifying syntax settings for the normal
ECLiPSe parser, it is less strict than the purpose
written library(flatzinc_parser), and will detect less
syntax errors. This should however not be an issue when
processing generated FlatZinc source.



