" also works.
- Fixed several bugs that occured when
reading lines longer than 8192 bytes long.
- New function "zpl_read_with_args" to allow
processing of command line defines, -s seed and
multi file input in embedded apllications.
- Funktions argmin/argmax implemented:
argmin(5) in { 1 .. 100 } : abs(50 - i)
will generate the set containing the indices of the
five smallest |50-i| evaluations. Be aware that the
the result is not neseccarily unambiguous since the index
set i snot ordered. For example
argmin in { 1 .. 10 } : 5.
In case of argmin(1) the "(1)" can be omitted.
argmax is the same the other way around.
- It is now possible to initialise parameters without giving the
index tuple explicitly. Writing
param a[{1..4}*{1..3}] := read "matrix.dat" as "n+" comment "#";
with for example a file like
1 2 3 4
5 6 7 8 # here is a comment
9 10 11 12
or with a file like this
1 2 3 4 5 6 7 8 9 10 11 12
will result in
a[1,1] = 1 ... a[4,3] = 12
Excess elements in the files are ignored.
If there are not enough elements in the file, the elements in the
parameter will be undefined, or set to default if present.
Use "s+" for strings.
- Check was missing if the parameter from a file is indeed a number.
Bug fixed regarding the field number given for tuple fields errors.
- Input from stringfiles is now possible. This
allows to embed Zimpl programs into other programs
without using any external files.
- Small bug in multi iterator validation fixed.
2.04 30. Jan 2006 Release
- Funktion random(minimum, maximum) implemented, which
generates (hopefully) uniformly distributed random values
between minimum and maximum. (not very well tested)
- A warning 203 is generated in many cases when the
indexing tuple is completely fixed.
- Objective function inversion warning for MPS files is
now only issued once.
- A constant value in the objective function is now translated
automatically into a variable __ObjOffset. This works on
all output formats.
- powerset() is now also generating the empty set.
- It is now possible to write:
UNION in I with i > 5 : A[i];
INTER in I with i > 5 : A[i];
to get the union or intersetection of all the involved sets.
- When initialising an indexed set with a list any "with" clause
on the set expresion was ignored.
- Error 195 was the same as 135. It is now all 135.
Error 195 has a new meaning.
- It is now possible to read a single value by
param n := read "huhu.dat" as "4n" skip 4 use 1
The above would read the fourth value in the fifth
line of the file huhu.dat.
- Fixed error in description of -n in -h output and some typos
in the documentation.
- Fixed problem when reading DOS format data files.
The CR at the end of the line is now removed instead of being
attached to the last field.
- Fixed bug with IN operator and Rangesets.
- It is now possible to build sets by indexing an
expression: { in I with i != 3 : p[i] }; or
{ in A with i != 3 : };
- Special Ordered Sets (SOS) implemented. Thanks Daniel.
- Changed a problem with the -n cf option due to a change in
the LP file format specification.
- Tabs are now allowed as separators after keywords (set, param, ...)
- Control characters (notably CR from DOS files) are now
ignored (treated as space) on input.
- Zimpl is now build as a library to simplify incorporation
into other programs.
2.03 2. Mar 2005 Release
- If -v=0 ist set, most warnings are now suppressed.
- Documentation improved.
- Applying union, minus, intersection, or symmetric
difference to two sets with tuples that have different component
types will now result in a useful error message.
- Fixed a bug that let unknown names evaluate to a member of a set.
Example: subto c1: forall in I do w[k] <= 1;
did not result in an error.
- Fixed a bug that made it possible to put an undefined name in a set.
- There is now a difference between "to" and "..".
"to" tries to do exactly what is requested possibly resulting in
an empty set. ".." does as before its best to produce a range.
- Fixed Bug in print command appearing in connection with default clause.
- Fixed Bug in handling of set products.
- Decreased memory consumption of hash tables.
- Slightly faster string hashing.
- Improved error handling for wrong components in sets.
2.02 15. May 2004 Release
- New function ordinal ord(s,t,c) implemented.
While there is no specific order, all sets have one.
That is ord will evaluate to the c-th component of the t-th
tuple in set s. ord({1..10}*{"a","b"}, 3, 1) is something
between 1 and 10, possibly 3. But doing
do forall in {1..card(I)} do print ord(E,i,1);
will print every element in I if it is one dimensional.
- Improved detection of incorrect initialization of sets and params.
- Bug in mod function fixed. Before mod gave the wrong result,
if the two numbers had factors in common.
- New -m switch that will write a CPLEX MST file with MIP starting values.
- Complete new Set implementation.
- If verbose is >= 3, the local variable
stack is printed if an error occurs.
- Makefile changed to support Mac OS-X.
- New -V flag to show the version number.
-h now also prints the banner text.
- man page created
2.01 29. Oct 2003 Release
- min/max over a indexed set of numbers, will now issue a warning,
if the index set is empty.
- Preprocessing is now switched on with the -O (optimize) switch.
- Fixed a major bug that occured, if two number
were subtracted from a constraint like in x - 5 + 3 >= 1
- Documentation update. Many spelling errors removed.
do print and do check statements documented.
- vif and vabs implemented. See documentation for details.
- set implementation changed. Generated powersets
and subsets do not use a hash table anymore.
This should reduce memory consumption, but
might slow things down a little bit.
- xor implemented.
- Fixed bug in presolve that resulted in fixed
variables not removed.
- Missing linefeed in hum format fixed.
- Implemented "check" statement.
- Implemented the "do" statement. This changes the
syntax for print. It is now "do print".
Now "do forall in I do print i; " is possible.
- Error 163 now shows the location of the error.
(Always start of the line ;-)
- It is now possible to define non indexed parameters
on the command line. -Dpeng=12 is equivalent to
param peng := 12; in the Zimpl file.
- <,<=,>=,> for strings implemented.
- Function sqrt() implemented.
- Functions log(), ln(), exp() reactivated.
- Some error cases of parameter input
were not handled correctly.
- Table input for parameter implemented.
- if for contstraints and summands implemented.
- if for set expressions implemented.
- Self defined functions implemented.
2.00 17. Sep 2003 Release
- Function sgn(expr) implemented.
- Fixed a bug in the set range routine. Now ranges with
negative numbers are allowed.
- Fixed bugs with MPS format.
- New output format "hum" for -t parameter generates unmangled human readable,
maschine unreadble LP format output. This replaces the -m switch.
- Changed -v switch to -v0..3 and also the outputs that appear by default.
- It is now possible to omit the .zpl extension on the input files.
- Changed output routine, so that it should work
even with with braindead OS like Windoof.
Also allowed to use a different directory separator.
- Trailing text on the last line should now draw a message.
- Bug fixed, that resulted in an unreadable LP file
if the index set of the variable has negative numbers.
- Fixed bug, that cut extensions from basenames given by -o .
- Fixed internal bug with bool not function.
- We now get an error message instead of an abort()
if the initialisation list of an parameter is empty.
- New functions min/max that take a list of expression,
like min(2, 5, a[4], b[7] / 2); (a and b are parameters)
- Included zlib. It is now possible to read in .gz transparantly.
- New function exists() that looks if a set has
at least one member, e.g. exists( in I with i > 5 )
should be equivatent to card( { in I with i > 5 }) > 0
- Better diagnosis if a variable/parameter/set name is used a second time.
- It is now possible to have contraint/obective names
that are identical to variable/parameter/set names.
- Changed gererated numbers for long names to hex. This needs less space.
- Names are now 8 characters long for MPS output,
but 16 for LPF. This is accroding to the CPLEX 7.0
specification. Starting at 8.0 it is possible to
have 255 character long names, we want to stay
compatible with the older versions.
- Changed the syntax for set initialisation.
if an indexset is assigned it has to be included in
braces like set A := { in I with i > 5 }
- It is now possible to write { in A with a > 5 }
whenever a set is needed. This means also it is now
possible to nest indexsets, like in
{ in { in C with k > 2 } with i mod 2 == 0 }
- Ranges are now possible: 7 <= 5x + 6 y <= 99
(MPS output not yet here)
- First presolve implemented.
-p now switches on presolve, -F does what -p did before.
- Fixed bug that empty constraints were ignored,
even with a non zero right hand side.
- Changed everything to rational numbers (GMP)
(Funktions exp, log, ln, rand are out of order)
- Fixed that variable which were not part of a constraint,
were omitted in the Bounds section of the LPF/MPS file.
- new -m switch to write unmangled lp file.
1.05 23. Mar 2003 Release
- make check now works.
- Removed senseless default in non indexed parameter.
- New Makefile that allows different architectures in parallel.
- Replaced rbt functions by a hash table. Mainly for portability.
- Fixed bug in print statement that accured when trying to
print a indexed set, without giving an index.
- It is now allowed to use a WITH clause in the initialisation
of parameters, variables and sets, like
param x[ in I with i > 5] := i * 4;
- Fixed bug that accured in the following case:
param x[<"1", i> in A] := i * 4;
- The number of elements in a set is now estimated and the
hash table is sized accordingly. This should same some
memory especially with the powerset function.
- Fixed bug in param initialisation which set the type
of the param always to NUMB.
- Changes param initialsation. STRG values are allowed
within indexed intialiszations.
- Changed IF command. It can now handle (in principle) all
types as return values, but only NUMB, STRG, NAME are
allowed by the parser.
- Change the implementation of SUM command. Major speedup.
- Implemented random(min, max) generates a random number between min and max.
At the moment rand() is used, but this will change.
- It is now possible to have a default value for a parameter.
param p[A] := <1> 1, <2> 2 default 99
will declare all p[i] with i in A and not 1 or 2 to return 99.
- Corrected a typo, that resulted in .orf files instead of .ord
- sym_lookup is now resolved in the scanner (speedup).
- Added new flag -p "filter" which pipes the output
through the filter, enabling for example compression.
(Daniels idea)
- The output files will be created in the current directory,
if no -o flag is given. If it is present the name and path
given will be used.
- New possible value infinit/-infinity for upper/lower bounds.
- We might display a warning if writing to a file fails somewhere in the middle.
- When writing MPS there is a warning if the problem was inverted.
- Warning about different dimension tuples prints tuples.
- Tabs are now allowed at the start of a statement.
- Non integral variable bounds for integral Variables are
Warned about and fixed.
- Bug fixed, that would not only set one variable from integer
to binary, but all that would follow in the set also.
- New function powerset(N) implemented. This generates all subsets
of N. Example: set S[] = powerset(N);
- New statement print started.
- Function subsets(N, k) implemented. This generates all
subsets of N with k elements. It is now possible to leave out
the indexing subset in a set declaration. So
set S[] := subsets(N, 3);
is valid. Additional the new function indexset(S) returns the
index set of S.
- Indexed Sets implemented.
- added "!" factorial function.
- log, ln, exp where missing in the parser and the documentation.
1.04 20. Oct 2002 Release
- Bug fixed in storage of variable and constraint names.
- Grammar fixed, since trailing '*' expr of vexpr where not parsed.
- Only variables that are written to the LP are written to the
".tbl" file.
- Fixed a bug that would discard free variables with non zero costs.
- Changed the output of the ".tbl" file. Now also the long constraint
names are enclosed in doublequotes.
- New options -n cm|cn|cf that control how the constraints in the
LPF/MPS file are named. "cm" will number them 1..n with a "c"
in front. "cn" will use the name supplied in the subto statement
and number them 1..n within the statement. "cf" will use the
name of the subto, then a 1..n number like in "cm" and then append
all the local variables from the forall statements.
(It is open if the "f" in "cf" stands for "full" or for "fuegenschuh".)
- Grammar changed again, to allow x/3 as shorthand for x * 1/3
- Changed grammar again, to get rid of conflicts.
- A union B does no longer warn about dublicate elements.
This should also speed up oder set operations a bit.
- The read template syntax is checked more precice.
- Integer variables with bounds [0,1] are automatically changed
to binary variables.
- New function proj(set,tuple) wich projects a set to the elements
of the tuple given. Example:
set A := { 1 to 9 } * { 10 to 19 } * { "A","B" };
set B := proj(A, <3,1>)
will give: <"A",1>, <"A",2"> ... <"B",9>
- Bug fixed, dublicate constraint names now give an error message.
- New functions log(x), ln(x) and exp(x), meaning
logarithm to base 10, natural logarithm and e^x.
- It is now possible to have variables on both sides of an
inequality. "x[1] <= y[1]" is now supported.
- Changed the parser to (hopefully) correct parse inequalites in
all possible varietes. This includes nested sums and coefficents
at all places.
1.03 31. Jul 2002 Release
- A division by Zero now gives an error message
(instead of an exception or whatever)
- It is now possible to assign a qualified set expression
to a set, like
set C := in A * B with i < j;
- It is now possible to nest "forall" statements. This
can vastly reduce the memory needed, because it is no
longer neccessary to build big cross products to loop
over them.
So instead of
forall in I * J with i < j do
it is possible to write
forall in I do forall in J with i < j do
- elems where now reused, this reduces the memory needed.
- changed to not copy in principle const objects, this should
have improved speed.
1.02 05. Jul 2002 Release
- new functions FLOOR(expr) and CEIL(expr) which find the
next integer down and up.
- Bug fixed in MPS output that lets zimpl write BOUND lines
for variables that are not used.
- new flag -r that write a CPLEX branching order file (.ord).
Two new attributes for variables:
"priority expr" sets the branching priority for the variable.
"startval expr" sets the start values for the variable
- new function ABS(expr) that returns the absolut value of expr.
- new function CARD(set) that computes the cardinality of a set.
- memory leak pugged, that occured when summing over a restricted set.
- added possiblility to initialise parameter per set element,
the same way as variables.
- the row scaling factor is now also printed in the .tbl file.
- Added "attributes" to the constraints. At the moment the following
are understood:
scale : scales the constraint before writing the LP file.
After scaling the absolut larges coefficient will be one.
separate : Means "this constraint should be separated".
At the moment, such constraints are written in an "User constraint"
section in the LP-File. But CPlex does not recognise this.
- "sum" is now also valid for expressions without variables.
- Fixed error in LPF Writing Routine, that would write "Inf"
instead of "+Inf".
- Wrong template in read now gives an error message instead of
an segment violation.
1.01 30. Oct 2001 Bug fix release
- Added several missing const's to the code.
- Unterminated string constants where not reported as errors.
This led to very irritating behavior. Fixed.
- Since it is possible that string type set members include spaces,
the "real" name in the .tbl file is now surrounded by doublequotes.
(I am not totally sure this is a good idea. Maybe I should just,
change all spaces to underscores.)
- It is now possible to write -x[3] in a constraint. Before
it was neccessary to write -1*x[3].
- Changed the field splitting for the read statement. The FS
keyword is gone. Read now tries to do the "right" thing.
Look at the documentation for details.
- When writing LP-format files, one's as coefficents are
no longer written. This makes the files somewhat shorter.
- -d (Debug) Option is no longer be ignored.
- Default field separators for the read statement are
now , <;> and ( is new).
- Fixed one minor malloc error with the include statement.
- Removed all uses of alloca() for better AIX compatibility.
- String valued parameters now work.
1.00 09. Oct 2001 Initial release
zimpl-3.3.4/Makefile 0000640 0012352 0006025 00000020142 13057565712 014176 0 ustar bzfgamra optimi #* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
#* *
#* File....: Makefile *
#* Name....: Zimpl Makefile *
#* Author..: Thorsten Koch *
#* Copyright by Author, All rights reserved *
#* *
#* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
#*
#* Copyright (C) 2005-2017 by Thorsten Koch
#*
#* This program is free software; you can redistribute it and/or
#* modify it under the terms of the GNU General Public License
#* as published by the Free Software Foundation; either version 2
#* of the License, or (at your option) any later version.
#*
#* This program is distributed in the hope that it will be useful,
#* but WITHOUT ANY WARRANTY; without even the implied warranty of
#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#* GNU General Public License for more details.
#*
#* You should have received a copy of the GNU General Public License
#* along with this program; if not, write to the Free Software
#* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#*
#
.PHONY: all depend clean lint doc doxygen check valgrind libdbl coverage
ARCH := $(shell uname -m | \
sed \
-e s/sun../sparc/ \
-e s/i.86/x86/ \
-e s/i86pc/x86/ \
-e s/amd64/x86_64/ \
-e s/IP../mips/ \
-e s/9000..../hppa/ \
-e s/Power\ Macintosh/ppc/ \
-e s/00........../pwr4/)
OSTYPE := $(shell uname -s | \
tr '[:upper:]' '[:lower:]' | \
tr '/' '_' | \
sed \
-e s/cygwin.*/cygwin/ \
-e s/irix../irix/ \
-e s/windows.*/windows/ \
-e s/mingw.*/mingw/)
HOSTNAME := $(shell uname -n | tr '[:upper:]' '[:lower:]')
VERSION = 3.3.4
VERBOSE = false
SHARED = false
STATIC = false
ZLIB = true
LINK = static
OPT = opt
COMP = gnu
CC = gcc
CC_o = -o
LINKCC = gcc
LINKCC_o = -o #the white space is important
LIBEXT = .a
YACC = bison
LEX = flex
DCC = gcc
LINT = flexelint
CPPCHECK = cppcheck
AR = ar cr
AR_o =
RANLIB = ranlib
DOXY = doxygen
VALGRIND = valgrind --tool=memcheck --leak-check=full \
--leak-resolution=high --show-reachable=yes
SRCDIR = src
BINDIR = bin
LIBDIR = lib
CPPFLAGS = -I$(SRCDIR) -DVERSION='"$(VERSION)"'
CFLAGS = -O
LDFLAGS = -lgmp -lm
YFLAGS = -d -t -v
LFLAGS = -d
ARFLAGS =
DFLAGS = -MM
GCCWARN = -Wall -W -Wpointer-arith -Wcast-align -Wwrite-strings \
-Wstrict-prototypes -Wmissing-prototypes -Winline \
-Wmissing-declarations -Wshadow -Waggregate-return \
-Wno-unused -Wno-unknown-pragmas
ifeq ($(ZLIB),true)
LDFLAGS += -lz
else
CPPFLAGS += -DWITHOUT_ZLIB
endif
ifeq ($(SHARED),true)
LINK = shared
endif
ifeq ($(STATIC),true)
LINK = static
endif
BASE = $(OSTYPE).$(ARCH).$(COMP).$(OPT)
OBJDIR = obj/O.$(OSTYPE).$(ARCH).$(COMP).$(LINK).$(OPT)
NAME = zimpl
BINNAME = $(NAME)-$(VERSION).$(OSTYPE).$(ARCH).$(COMP).$(LINK).$(OPT)
LIBNAME = $(NAME)-$(VERSION).$(BASE)
LIBRARY = $(LIBDIR)/lib$(LIBNAME)$(LIBEXT)
LIBRARYDBL = $(LIBDIR)/lib$(LIBNAME).dbl$(LIBEXT)
LIBLINK = $(LIBDIR)/lib$(NAME).$(BASE)$(LIBEXT)
LIBDBLLINK = $(LIBDIR)/lib$(NAME).$(BASE).dbl$(LIBEXT)
BINARY = $(BINDIR)/$(BINNAME)
BINARYDBL = $(BINDIR)/$(BINNAME).dbl
BINLINK = $(BINDIR)/$(NAME).$(BASE)
BINSHORTLINK = $(BINDIR)/$(NAME)
DEPEND = $(SRCDIR)/depend
#-----------------------------------------------------------------------------
OBJECT = zimpl.o xlpglue.o zlpglue.o \
ratlpstore.o ratlpfwrite.o ratmpswrite.o ratmstwrite.o \
ratordwrite.o ratpresolve.o
LIBBASE = blkmem.o bound.o code.o conname.o define.o elem.o entry.o \
hash.o heap.o idxset.o inst.o iread.o list.o \
load.o local.o metaio.o mmlparse2.o mmlscan.o mono.o \
mshell.o prog.o random.o rdefpar.o source.o \
setempty.o setpseudo.o setlist.o setrange.o setprod.o \
setmulti.o set4.o stmt.o stkchk.o strstore2.o symbol.o \
term2.o tuple.o vinst.o zimpllib.o
LIBOBJ = $(LIBBASE) gmpmisc.o numbgmp.o
LIBDBLOBJ = $(LIBBASE) numbdbl.o
OBJXXX = $(addprefix $(OBJDIR)/,$(OBJECT))
LIBXXX = $(addprefix $(OBJDIR)/,$(LIBOBJ))
LIBDBLXXX = $(addprefix $(OBJDIR)/,$(LIBDBLOBJ))
OBJSRC = $(addprefix $(SRCDIR)/,$(OBJECT:.o=.c))
LIBSRC = $(addprefix $(SRCDIR)/,$(LIBOBJ:.o=.c)) #(SRCDIR)/numbdbl.c
#-----------------------------------------------------------------------------
include make/make.$(OSTYPE).$(ARCH).$(COMP).$(OPT)
-include make/local/make.$(HOSTNAME)
-include make/local/make.$(HOSTNAME).$(COMP)
-include make/local/make.$(HOSTNAME).$(COMP).$(OPT)
#-----------------------------------------------------------------------------
FLAGS += $(USRFLAGS)
OFLAGS += $(USROFLAGS)
CFLAGS += $(USRCFLAGS) $(USROFLAGS)
LDFLAGS += $(USRLDFLAGS)
ARFLAGS += $(USRARFLAGS)
DFLAGS += $(USRDFLAGS)
ifeq ($(VERBOSE),false)
.SILENT: $(LIBRARY) $(LIBLINK) $(BINARY) $(BINLINK) $(BINSHORTLINK) \
$(SRCDIR)/mmlparse2.c $(SRCDIR)/mmlscan.c $(OBJXXX) $(LIBXXX) $(LIBDBLXXX)
endif
all: $(LIBRARY) $(LIBLINK) $(BINARY) $(BINLINK) $(BINSHORTLINK)
$(LIBLINK): $(LIBRARY)
@rm -f $@
cd $(dir $@) && ln -s $(notdir $(LIBRARY)) $(notdir $@)
$(LIBDBLLINK): $(LIBRARYDBL)
@rm -f $@
cd $(dir $@) && ln -s $(notdir $(LIBRARYDBL)) $(notdir $@)
$(BINLINK) $(BINSHORTLINK): $(BINARY)
@rm -f $@
cd $(dir $@) && ln -s $(notdir $(BINARY)) $(notdir $@)
$(BINARY): $(OBJDIR) $(BINDIR) $(OBJXXX) $(LIBRARY)
@echo "-> linking $@"
ifeq ($(COMP), msvc)
$(LINKCC) $(CFLAGS) $(OBJXXX) $(LIBRARY) $(LDFLAGS) $(LINKCC_o)$@
else
$(LINKCC) $(CFLAGS) $(OBJXXX) -L$(LIBDIR) -l$(LIBNAME) $(LDFLAGS) $(LINKCC_o)$@
endif
$(BINARYDBL): $(OBJDIR) $(BINDIR) $(OBJXXX) $(LIBRARYDBL)
@echo "-> linking $@"
$(LINKCC) $(CFLAGS) $(OBJXXX) -L$(LIBDIR) -l$(LIBNAME).dbl $(LDFLAGS) $(CC_o)$@
$(LIBRARY): $(OBJDIR) $(LIBDIR) $(LIBXXX)
@echo "-> generating library $@"
-rm -f $(LIBRARY)
$(AR) $(AR_o)$@ $(LIBXXX) $(ARFLAGS)
ifneq ($(RANLIB),)
$(RANLIB) $@
endif
libdbl: $(LIBRARYDBL) $(LIBDBLLINK)
$(LIBRARYDBL): $(OBJDIR) $(LIBDIR) $(LIBDBLXXX)
@echo "-> generating library $@"
-rm -f $(LIBRARYDBL)
$(AR) $@ $(LIBDBLXXX) $(ARFLAGS)
$(RANLIB) $@
$(SRCDIR)/mmlparse2.c: $(SRCDIR)/mmlparse2.y $(SRCDIR)/mme.h
@echo "-> generating yacc parser $@"
$(YACC) $(YFLAGS) -o $@ $<
$(SRCDIR)/mmlscan.c: $(SRCDIR)/mmlscan.l $(SRCDIR)/mme.h
@echo "-> generating lex scanner $@"
$(LEX) $(LFLAGS) -o$@ $<
lint: $(OBJSRC) $(LIBSRC)
$(LINT) $(SRCDIR)/project.lnt \
$(CPPFLAGS) -UNDEBUG -Dinline= -DNO_MSHELL $^
cppcheck: $(OBJSRC) $(LIBSRC)
$(CPPCHECK) $(CPPFLAGS) --inline-suppr --enable=warning,style,performance,portability,information $^
doc:
cd doc; make -f Makefile
doxygen:
cd doc; $(DOXY) $(NAME).dxy
check:
cd check; \
/bin/sh ./check.sh ../$(BINARY)
valgrind:
cd check; \
/bin/sh ./check.sh "$(VALGRIND) ../$(BINARY)"
coverage:
-ln -s ../../src $(OBJDIR)
-mkdir -p gcov
lcov -d $(OBJDIR) -z
make OPT=gcov check
lcov -d $(OBJDIR) -c >gcov/z.capture
lcov -d $(OBJDIR) -r gcov/z.capture "*mmlscan.c" "*mmlparse2.c" >gcov/zimpl.capture
genhtml -o gcov gcov/zimpl.capture
-rm gcov/z.capture
$(OBJDIR):
@echo "** creating directory \"$@\""
@-mkdir -p $(OBJDIR)
$(LIBDIR):
@echo "** creating directory \"$@\""
@-mkdir -p $(LIBDIR)
$(BINDIR):
@echo "** creating directory \"$@\""
@-mkdir -p $(BINDIR)
clean:
-rm -rf $(OBJDIR)/* $(BINARY) $(LIBRARY) $(LIBRARYDBL) $(LIBLINK) $(BINLINK) $(BINSHORTLINK)
depend:
$(SHELL) -ec '$(DCC) $(DFLAGS) $(CPPFLAGS) $(OBJSRC) $(LIBSRC) \
| sed '\''s|^\([0-9A-Za-z\_]\{1,\}\)\.o|$$\(OBJDIR\)/\1.o|g'\'' \
>$(DEPEND)'
-include $(DEPEND)
$(OBJDIR)/%.o: $(SRCDIR)/%.c
@echo "-> compiling $@"
$(CC) $(CPPFLAGS) $(CFLAGS) -c $< $(CC_o)$@
# --- EOF ---------------------------------------------------------------------
zimpl-3.3.4/Makefile.nmake 0000640 0012352 0006025 00000011570 13057565712 015275 0 ustar bzfgamra optimi # $Id: Makefile,v 1.82 2011/10/31 08:48:56 bzfkocht Exp $
#* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
#* *
#* File....: Makefile *
#* Name....: Zimpl Makefile *
#* Author..: Thorsten Koch *
#* Copyright by Author, All rights reserved *
#* *
#* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
#*
#* Copyright (C) 2005-2017 by Thorsten Koch
#*
#* This program is free software; you can redistribute it and/or
#* modify it under the terms of the GNU General Public License
#* as published by the Free Software Foundation; either version 2
#* of the License, or (at your option) any later version.
#*
#* This program is distributed in the hope that it will be useful,
#* but WITHOUT ANY WARRANTY; without even the implied warranty of
#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#* GNU General Public License for more details.
#*
#* You should have received a copy of the GNU General Public License
#* along with this program; if not, write to the Free Software
#* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#*
#
#.PHONY: all clean
ARCH = x86
OSTYPE = win
VERSION = 3.3.3
VERBOSE = 0
LINK = normal
OPT = opt
COMP = msvc
CC = cl
AR = lib
LD = link
SRCDIR = src
BINDIR = bin
LIBDIR = lib
CPPFLAGS = /DVERSION=\"$(VERSION)\" \
/I$(SRCDIR) /I$(SRCDIR)\WIN \
/Dpopen=_popen /Dpclose=_pclose /DWITH_PCRE=1 \
/Ilib\zlib \
/Ilib\pcre \
/Ilib\mpir.$(ARCH) \
/D_CRT_SECURE_NO_WARNINGS
CFLAGS =
ARFLAGS = /nologo
LIBS = lib\libz.$(ARCH).lib \
lib\libpcre.$(ARCH).lib \
lib\libmpir.$(ARCH).lib
LDFLAGS = /NODEFAULTLIB:LIBCMT /NODEFAULTLIB:LIBCMTD /STACK:67108864 /OPT:REF /OPT:ICF /NOLOGO
BASE = $(OSTYPE).$(ARCH).$(COMP).$(OPT)
OBJDIR = obj\O.$(OSTYPE).$(ARCH).$(COMP).$(LINK).$(OPT)
NAME = zimpl
BINNAME = $(NAME)-$(VERSION).$(OSTYPE).$(ARCH).$(COMP).$(LINK).$(OPT)
LIBNAME = $(NAME)-$(VERSION).$(BASE)
LIBRARY = $(LIBDIR)\lib$(LIBNAME).lib
BINARY = $(BINDIR)\$(BINNAME).exe
DEPEND = $(SRCDIR)\depend
#-----------------------------------------------------------------------------
OBJECT = $(OBJDIR)\zimpl.obj $(OBJDIR)\xlpglue.obj $(OBJDIR)\zlpglue.obj \
$(OBJDIR)\ratlpstore.obj $(OBJDIR)\ratlpfwrite.obj $(OBJDIR)\ratmpswrite.obj $(OBJDIR)\ratmstwrite.obj \
$(OBJDIR)\ratordwrite.obj $(OBJDIR)\ratpresolve.obj
LIBBASE = $(OBJDIR)\getopt.obj $(OBJDIR)\blkmem.obj $(OBJDIR)\bound.obj $(OBJDIR)\code.obj $(OBJDIR)\conname.obj \
$(OBJDIR)\define.obj $(OBJDIR)\elem.obj $(OBJDIR)\entry.obj \
$(OBJDIR)\hash.obj $(OBJDIR)\heap.obj $(OBJDIR)\idxset.obj $(OBJDIR)\inst.obj $(OBJDIR)\iread.obj $(OBJDIR)\list.obj \
$(OBJDIR)\load.obj $(OBJDIR)\local.obj $(OBJDIR)\metaio.obj $(OBJDIR)\mmlparse2.obj $(OBJDIR)\mmlscan.obj $(OBJDIR)\mono.obj \
$(OBJDIR)\mshell.obj $(OBJDIR)\prog.obj $(OBJDIR)\random.obj $(OBJDIR)\rdefpar.obj $(OBJDIR)\source.obj \
$(OBJDIR)\setempty.obj $(OBJDIR)\setpseudo.obj $(OBJDIR)\setlist.obj $(OBJDIR)\setrange.obj $(OBJDIR)\setprod.obj \
$(OBJDIR)\setmulti.obj $(OBJDIR)\set4.obj $(OBJDIR)\stmt.obj $(OBJDIR)\stkchk.obj $(OBJDIR)\strstore2.obj $(OBJDIR)/symbol.obj \
$(OBJDIR)\term2.obj $(OBJDIR)\tuple.obj $(OBJDIR)\vinst.obj $(OBJDIR)\zimpllib.obj
LIBOBJ = $(LIBBASE) $(OBJDIR)\gmpmisc.obj $(OBJDIR)\numbgmp.obj
#-----------------------------------------------------------------------------
!include make/nmake.$(OSTYPE).$(ARCH).$(COMP).$(OPT)
#-----------------------------------------------------------------------------
!if $(VERBOSE) == 0
!CMDSWITCHES +S
!endif
all: $(LIBRARY) $(BINARY)
$(BINARY): $(OBJDIR) $(BINDIR) $(OBJECT) $(LIBRARY)
@echo "-> linking $@"
$(LD) $(LDFLAGS) /OUT:$@ $(OBJECT) $(LIBRARY) $(LIBS)
$(LIBRARY): $(OBJDIR) $(LIBDIR) $(LIBOBJ)
@echo "-> generating library $@"
@del $(LIBRARY)
$(AR) $(ARFLAGS) /OUT:$@ $(LIBOBJ)
$(OBJDIR):
@echo "** creating directory \"$@\""
@mkdir $(OBJDIR)
$(LIBDIR):
@echo "** creating directory \"$@\""
@mkdir $(LIBDIR)
$(BINDIR):
@echo "** creating directory \"$@\""
@mkdir $(BINDIR)
clean:
del /Q $(OBJDIR)\*.* $(BINARY) $(LIBRARY)
!include $(DEPEND)
{$(SRCDIR)}.c{$(OBJDIR)}.obj:
@echo "-> compiling $@"
$(CC) $(CPPFLAGS) $(CFLAGS) /c $< /Fo$@
$(OBJDIR)\getopt.obj: $(SRCDIR)\WIN\getopt.c $(SRCDIR)\WIN\getopt.h
$(CC) $(CPPFLAGS) $(CFLAGS) /c $(SRCDIR)\WIN\getopt.c /Fo$@
# --- EOF ---------------------------------------------------------------------
zimpl-3.3.4/make/ 0000750 0012352 0006025 00000000000 13057565713 013454 5 ustar bzfgamra optimi zimpl-3.3.4/make/nmake.win.x86.msvc.opt 0000640 0012352 0006025 00000000207 13057565713 017462 0 ustar bzfgamra optimi CPPFLAGS = $(CPPFLAGS) /Dinline=_inline /DWIN32 /DNDEBUG
CFLAGS = $(CFLAGS) /W2 /wd4274 /Ox /nologo
LDFLAGS = $(LDFLAGS) /LTCG
zimpl-3.3.4/make/make.darwin.x86_64.gnu.opt 0000640 0012352 0006025 00000001033 13057565713 020123 0 ustar bzfgamra optimi #--- $Id: make.darwin.x86_64.gnu.opt,v 1.8 2014/03/03 08:36:28 bzfkocht Exp $
CPPFLAGS += -DNDEBUG -DNO_MSHELL -D__NO_MATH_INLINES
CFLAGS += -O3 -m64
LDFLAGS = -lgmp -lm
ifeq ($(LINK),shared)
#LIBRARY = $(LIBDIR)/lib$(LIBNAME).so
#LIBLINK = $(LIBDIR)/lib$(NAME).$(BASE).so
CFLAGS += -fPIC
#AR = gcc -m64 -shared -o # the trailing space is important
#ARFLAGS = $(LDFLAGS)
#RANLIB = true
endif
#ifeq ($(LINK),static)
LDFLAGS = -Bstatic -lgmp -lm
#endif
ifeq ($(ZLIB),true)
LDFLAGS += -lz
endif
zimpl-3.3.4/make/make.sunos.x86.gnu.dbg 0000640 0012352 0006025 00000000763 13057565713 017440 0 ustar bzfgamra optimi #--- $Id: make.sunos.x86.gnu.dbg,v 1.7 2014/01/12 11:07:04 bzfkocht Exp $
CPPFLAGS += -DFREEMEM -D__NO_MATH_INLINES
CFLAGS = -O0 -g -fident $(GCCWARN)
LDFLAGS = -lgmp -lm
ifeq ($(ZLIB),true)
LDFLAGS += -lz
endif
ifeq ($(LINK),shared)
#LIBRARY = $(LIBDIR)/lib$(LIBNAME).so
#LIBLINK = $(LIBDIR)/lib$(NAME).$(BASE).so
CFLAGS += -fPIC
#AR = gcc -shared -o # the trailing space is important
#ARFLAGS = $(LDFLAGS)
#RANLIB = true
endif
#ifeq ($(LINK),static)
LDFLAGS += -Bstatic
#endif
zimpl-3.3.4/make/make.linux.x86.gnu.opt-gccold 0000640 0012352 0006025 00000001004 13057565713 020714 0 ustar bzfgamra optimi #--- $Id: make.linux.x86.gnu.opt-gccold,v 1.3 2014/01/12 11:07:04 bzfkocht Exp $
CPPFLAGS += -DNDEBUG -DNO_MSHELL -D__NO_MATH_INLINES
CFLAGS = -O3 -m32
LDFLAGS = -lgmp -lm
ifeq ($(LINK),shared)
#LIBRARY = $(LIBDIR)/lib$(LIBNAME).so
#LIBLINK = $(LIBDIR)/lib$(NAME).$(BASE).so
CFLAGS += -fPIC
#AR = gcc -m32 -shared -o # the trailing space is important
#ARFLAGS = $(LDFLAGS)
#RANLIB = true
endif
#ifeq ($(LINK),static)
LDFLAGS += -static
#endif
ifeq ($(ZLIB),true)
LDFLAGS += -lz
endif
zimpl-3.3.4/make/make.cygwin.x86_64.gnu.opt 0000640 0012352 0006025 00000000376 13057565713 020150 0 ustar bzfgamra optimi #--- $Id: make.cygwin.x86.gnu.opt,v 1.9 2014/01/12 11:07:04 bzfkocht Exp $
CPPFLAGS += -DWINDOWS -DNDEBUG -DNO_MSHELL -D__NO_MATH_INLINES
CFLAGS = -O3 -march=pentiumpro $(GCCWARN)
LDFLAGS = -lgmp -lm -static
ifeq ($(ZLIB),true)
LDFLAGS += -lz
endif
zimpl-3.3.4/make/make.mingw.x86.gnu.dbg 0000640 0012352 0006025 00000000366 13057565713 017411 0 ustar bzfgamra optimi #--- $Id: make.mingw.x86.gnu.dbg,v 1.2 2014/01/12 11:07:04 bzfkocht Exp $
CPPFLAGS += -DWINDOWS -DFREEMEM -D__NO_MATH_INLINES
CFLAGS = -O -g $(GCCWARN)
LDFLAGS = -lgmp -lpcreposix -lpcre -lm -static
ifeq ($(ZLIB),true)
LDFLAGS += -lz
endif
zimpl-3.3.4/make/make.sunos.sparc.gnu.dbg 0000640 0012352 0006025 00000000345 13057565713 020117 0 ustar bzfgamra optimi #--- $Id: make.sunos.sparc.gnu.dbg,v 1.6 2014/01/12 11:07:04 bzfkocht Exp $
CPPFLAGS += -DFREEMEM -D__NO_MATH_INLINES
CFLAGS = -O0 -g -fident $(GCCWARN)
LDFLAGS = -Bstatic -lgmp -lm
ifeq ($(ZLIB),true)
LDFLAGS += -lz
endif
zimpl-3.3.4/make/make.win.x86.mingw-cross.opt 0000640 0012352 0006025 00000000500 13057565713 020600 0 ustar bzfgamra optimi #--- $Id: make.win.x86.mingw-cross.opt,v 1.8 2014/03/03 08:36:28 bzfkocht Exp $
CPPFLAGS += -DNDEBUG -DNO_MSHELL -D__NO_MATH_INLINES -DWITH_PCRE -DPCRE_STATIC
CFLAGS = -O3 -march=pentiumpro -g
LDFLAGS = -lpcreposix -lpcre -lgmp -lm -static
BINARY = $(BINDIR)/$(TARGET).exe
ifeq ($(ZLIB),true)
LDFLAGS += -lz
endif
zimpl-3.3.4/make/local/ 0000750 0012352 0006025 00000000000 13057565713 014546 5 ustar bzfgamra optimi zimpl-3.3.4/make/make.sunos.x86_64.gnu.opt 0000640 0012352 0006025 00000000356 13057565713 020015 0 ustar bzfgamra optimi #--- $Id: make.sunos.x86_64.gnu.opt,v 1.3 2014/01/12 11:07:04 bzfkocht Exp $
CPPFLAGS += -DNDEBUG -DNO_MSHELL -D__NO_MATH_INLINES
CFLAGS = -O3 -m64 -mtune=native
LDFLAGS = -Bstatic -lgmp -lm
ifeq ($(ZLIB),true)
LDFLAGS += -lz
endif
zimpl-3.3.4/make/make.freebsd.x86_64.gnu.dbg 0000640 0012352 0006025 00000000425 13057565713 020207 0 ustar bzfgamra optimi #--- $Id: make.freebsd.x86_64.gnu.dbg,v 1.2 2014/01/12 11:07:04 bzfkocht Exp $
CPPFLAGS += -I/usr/local/include -DFREEMEM -D__NO_MATH_INLINES
CFLAGS = -O0 -g -fident -ftrapv $(GCCWARN)
LDFLAGS = -L/usr/local/lib -lgmp -lm -static
ifeq ($(ZLIB),true)
LDFLAGS += -lz
endif
zimpl-3.3.4/make/make.sunos.sparc.sun.opt 0000640 0012352 0006025 00000000366 13057565713 020204 0 ustar bzfgamra optimi #--- $Id: make.sunos.sparc.sun.opt,v 1.12 2014/01/12 11:07:04 bzfkocht Exp $
CC = cc
CPPFLAGS += -DNDEBUG -DNO_MSHELL -Dinline=""
CFLAGS = -fast -xprefetch=auto -xipo=2
LDFLAGS = -Bstatic -lgmp -lm
ifeq ($(ZLIB),true)
LDFLAGS += -lz
endif
zimpl-3.3.4/make/make.cygwin.x86_64.gnu.dbg 0000640 0012352 0006025 00000000343 13057565713 020074 0 ustar bzfgamra optimi #--- $Id: make.cygwin.x86.gnu.dbg,v 1.9 2014/01/12 11:07:04 bzfkocht Exp $
CPPFLAGS += -DWINDOWS -DFREEMEM -D__NO_MATH_INLINES
CFLAGS = -O -g $(GCCWARN)
LDFLAGS = -lgmp -lm -static
ifeq ($(ZLIB),true)
LDFLAGS += -lz
endif
zimpl-3.3.4/make/make.sunos.x86_64.gnu.dbg 0000640 0012352 0006025 00000000353 13057565713 017744 0 ustar bzfgamra optimi #--- $Id: make.sunos.x86_64.gnu.dbg,v 1.2 2014/01/12 11:07:04 bzfkocht Exp $
CPPFLAGS += -DFREEMEM -D__NO_MATH_INLINES
CFLAGS = -O0 -m64 -g -fident $(GCCWARN)
LDFLAGS = -Bstatic -lgmp -lm
ifeq ($(ZLIB),true)
LDFLAGS += -lz
endif
zimpl-3.3.4/make/make.darwin.x86.gnu.dbg 0000640 0012352 0006025 00000000675 13057565713 017557 0 ustar bzfgamra optimi CPPFLAGS += -DFREEMEM -D__NO_MATH_INLINES
CFLAGS = -O0 -m32 -g -fident $(GCCWARN)
LDFLAGS = -lgmp -lm
ifeq ($(LINK),shared)
#LIBRARY = $(LIBDIR)/lib$(LIBNAME).so
#LIBLINK = $(LIBDIR)/lib$(NAME).$(BASE).so
CFLAGS += -fPIC
#AR = gcc -m32 -shared -o # the trailing space is important
#ARFLAGS = $(LDFLAGS)
#RANLIB = true
endif
#ifeq ($(LINK),static)
LDFLAGS = -Bstatic -lgmp -lm
#endif
ifeq ($(ZLIB),true)
LDFLAGS += -lz
endif
zimpl-3.3.4/make/make.linux.x86.gnu.prf 0000640 0012352 0006025 00000001037 13057565713 017456 0 ustar bzfgamra optimi #--- $Id: make.linux.x86.gnu.prf,v 1.11 2014/01/12 11:07:04 bzfkocht Exp $
CPPFLAGS += -DNDEBUG -DNO_MSHELL -D__NO_MATH_INLINES
CFLAGS = -march=pentiumpro -m32 -g -pg $(GCCWARN)
LDFLAGS = -lgmp -lm
ifeq ($(LINK),shared)
#LIBRARY = $(LIBDIR)/lib$(LIBNAME).so
#LIBLINK = $(LIBDIR)/lib$(NAME).$(BASE).so
CFLAGS += -fPIC
#AR = gcc -m32 -shared -o # the trailing space is important
#ARFLAGS = $(LDFLAGS)
#RANLIB = true
endif
#ifeq ($(LINK),static)
LDFLAGS += -static
#endif
ifeq ($(ZLIB),true)
LDFLAGS += -lz
endif
zimpl-3.3.4/make/make.darwin.x86.gnu.opt 0000640 0012352 0006025 00000000656 13057565713 017624 0 ustar bzfgamra optimi CPPFLAGS += -DNDEBUG -DNO_MSHELL -D__NO_MATH_INLINES
CFLAGS = -O3
LDFLAGS = -lgmp -lm
ifeq ($(LINK),shared)
#LIBRARY = $(LIBDIR)/lib$(LIBNAME).so
#LIBLINK = $(LIBDIR)/lib$(NAME).$(BASE).so
CFLAGS += -fPIC
#AR = gcc -m32 -shared -o # the trailing space is important
#ARFLAGS = $(LDFLAGS)
#RANLIB = true
endif
#ifeq ($(LINK),static)
LDFLAGS = -Bstatic -lgmp -lm
#endif
ifeq ($(ZLIB),true)
LDFLAGS += -lz
endif
zimpl-3.3.4/make/make.darwin.ppc.gnu.opt 0000640 0012352 0006025 00000000332 13057565713 017750 0 ustar bzfgamra optimi #--- $Id: make.darwin.ppc.gnu.opt,v 1.7 2014/03/03 08:36:28 bzfkocht Exp $
CPPFLAGS += -DNDEBUG -DNO_MSHELL -D__NO_MATH_INLINES
CFLAGS = -O3
LDFLAGS = -Bstatic -lgmp -lm
ifeq ($(ZLIB),true)
LDFLAGS += -lz
endif
zimpl-3.3.4/make/make.cygwin.x86.gnu.opt 0000640 0012352 0006025 00000000402 13057565713 017625 0 ustar bzfgamra optimi #--- $Id: make.cygwin.x86.gnu.opt,v 1.9 2014/01/12 11:07:04 bzfkocht Exp $
CPPFLAGS += -DWINDOWS -DNDEBUG -DNO_MSHELL -D__NO_MATH_INLINES
CFLAGS = -O3 -march=pentiumpro -g $(GCCWARN)
LDFLAGS = -lgmp -lm -static
ifeq ($(ZLIB),true)
LDFLAGS += -lz
endif
zimpl-3.3.4/make/make.linux.x86_64.eko.opt 0000640 0012352 0006025 00000000417 13057565713 017770 0 ustar bzfgamra optimi #--- $Id: make.linux.x86_64.eko.opt,v 1.6 2014/01/12 11:07:04 bzfkocht Exp $
CC = pathcc
CPPFLAGS += -DFREEMEM -D__NO_MATH_INLINES
CFLAGS = -std=c99 -D_POSIX_C_SOURCE=2 -march=auto -m64 -O3 -ipa
LDFLAGS = -lgmp -lm -static
ifeq ($(ZLIB),true)
LDFLAGS += -lz
endif
zimpl-3.3.4/make/make.win.x86.mingw-cross.dbg 0000640 0012352 0006025 00000000456 13057565713 020544 0 ustar bzfgamra optimi #--- $Id: make.win.x86.mingw-cross.dbg,v 1.6 2014/01/12 11:07:04 bzfkocht Exp $
CPPFLAGS += -DFREEMEM -D__NO_MATH_INLINES -DWITH_PCRE -DPCRE_STATIC
CFLAGS = -O -g $(GCCWARN)
LDFLAGS = -lpcreposix -lpcre -lgmp -lm -static
BINARY = $(BINDIR)/$(BINNAME).exe
ifeq ($(ZLIB),true)
LDFLAGS += -lz
endif
zimpl-3.3.4/make/make.darwin.x86.intel.dbg 0000640 0012352 0006025 00000000507 13057565713 020073 0 ustar bzfgamra optimi #--- $Id: make.darwin.x86.intel.dbg,v 1.3 2014/01/12 11:07:04 bzfkocht Exp $
CC = icc
CPPFLAGS += -DFREEMEM
CFLAGS = -g -fp-model precise -w2 -Wcheck \
-par_report0 -vec_report0 \
-wd111,171,279,981,1173,1419,1684
LDFLAGS = -lgmp -lm -Bstatic
# -wd383,444,810
ifeq ($(ZLIB),true)
LDFLAGS += -lz
endif
zimpl-3.3.4/make/nmake.win.x86_64.msvc.dbg 0000640 0012352 0006025 00000000201 13057565713 017717 0 ustar bzfgamra optimi CPPFLAGS = $(CPPFLAGS) /Dinline= /DWIN64
CFLAGS = $(CFLAGS) /W4 /Zi /wd4001 /wd4127 /wd4206 /wd4701 /wd4702 /wd4274 /nologo
zimpl-3.3.4/make/make.linux.x86_64.gnu.opt 0000640 0012352 0006025 00000001002 13057565713 017772 0 ustar bzfgamra optimi #--- $Id: make.linux.x86_64.gnu.opt,v 1.9 2014/01/12 11:07:04 bzfkocht Exp $
CPPFLAGS += -DNDEBUG -DNO_MSHELL -D__NO_MATH_INLINES
CFLAGS = -O3 -m64 -mtune=native
LDFLAGS = -lgmp -lm
ifeq ($(ZLIB),true)
LDFLAGS += -lz
endif
ifeq ($(LINK),shared)
#LIBRARY = $(LIBDIR)/lib$(LIBNAME).so
#LIBLINK = $(LIBDIR)/lib$(NAME).$(BASE).so
CFLAGS += -fPIC
#AR = gcc -m64 -shared -o # the trailing space is important
#ARFLAGS = $(LDFLAGS)
#RANLIB = true
endif
#ifeq ($(LINK),static)
LDFLAGS += -static
#endif
zimpl-3.3.4/make/make.sunos.x86.opt 0000640 0012352 0006025 00000000357 13057565713 016715 0 ustar bzfgamra optimi #--- $Id: make.sunos.x86.opt,v 1.3 2014/01/12 11:07:04 bzfkocht Exp $
CC = cc
CPPFLAGS += -DNDEBUG -DNO_MSHELL -Dinline=""
CFLAGS = -fast -xprefetch=auto -xipo=2
LDFLAGS = -Bstatic -lgmp -lm
ifeq ($(ZLIB),true)
LDFLAGS += -lz
endif
zimpl-3.3.4/make/make.osf1.alpha.compaq.dbg 0000640 0012352 0006025 00000000401 13057565713 020255 0 ustar bzfgamra optimi #--- $Id: make.osf1.alpha.compaq.dbg,v 1.9 2010/06/10 19:42:42 bzfkocht Exp $
CC = cc
CPPFLAGS += -DFREEMEM -Dinline=""
CFLAGS = -std1 -w0 -gall -check \
-msg_disable strctpadding,nestincl,ignorecallval,unusedincl,unnecincl,hexoctunsign,questcompare2
zimpl-3.3.4/make/make.linux.x86_64.intel.dbg 0000640 0012352 0006025 00000000642 13057565713 020257 0 ustar bzfgamra optimi #--- $Id: make.linux.x86_64.intel.dbg,v 1.4 2014/01/12 11:07:04 bzfkocht Exp $
CC = icc
CPPFLAGS += -DFREEMEM
CFLAGS = -g -fp-model precise -w2 -Wcheck \
-par_report0 -vec_report0 \
-wd111,171,279,981,1173,1419,1684
LDFLAGS = -lgmp -lm
ifeq ($(ZLIB),true)
LDFLAGS += -lz
endif
# -wd383,444,810
#ifeq ($(LINK),shared)
#LINK = normal
#endif
#ifeq ($(LINK),static)
LDFLAGS += -static
#endif
zimpl-3.3.4/make/make.darwin.ppc.gnu.dbg 0000640 0012352 0006025 00000000323 13057565713 017702 0 ustar bzfgamra optimi #--- $Id: make.darwin.ppc.gnu.dbg,v 1.3 2014/01/12 11:07:04 bzfkocht Exp $
CPPFLAGS += -DFREEMEM -D__NO_MATH_INLINES
CFLAGS = -O -g $(GCCWARN)
LDFLAGS = -lgmp -lm
ifeq ($(ZLIB),true)
LDFLAGS += -lz
endif
zimpl-3.3.4/make/nmake.win.x86.msvc.dbg 0000640 0012352 0006025 00000000201 13057565713 017406 0 ustar bzfgamra optimi CPPFLAGS = $(CPPFLAGS) /Dinline= /DWIN32
CFLAGS = $(CFLAGS) /W4 /Zi /wd4001 /wd4127 /wd4206 /wd4701 /wd4702 /wd4274 /nologo
zimpl-3.3.4/make/make.freebsd.x86.gnu.dbg 0000640 0012352 0006025 00000000422 13057565713 017673 0 ustar bzfgamra optimi #--- $Id: make.freebsd.x86.gnu.dbg,v 1.2 2014/01/12 11:07:04 bzfkocht Exp $
CPPFLAGS += -I/usr/local/include -DFREEMEM -D__NO_MATH_INLINES
CFLAGS = -O0 -g -fident -ftrapv $(GCCWARN)
LDFLAGS = -L/usr/local/lib -lgmp -lm -static
ifeq ($(ZLIB),true)
LDFLAGS += -lz
endif
zimpl-3.3.4/make/make.linux.x86.gnu.valgrind 0000640 0012352 0006025 00000001042 13057565713 020471 0 ustar bzfgamra optimi #--- $Id: make.linux.x86.gnu.valgrind,v 1.12 2014/03/03 08:36:28 bzfkocht Exp $
CPPFLAGS += -DNDEBUG -DNO_MSHELL -DFREEMEM -D__NO_MATH_INLINES
CFLAGS = -O3 -m32 -march=pentiumpro -g
LDFLAGS = -lgmp -lm
ifeq ($(LINK),shared)
#LIBRARY = $(LIBDIR)/lib$(LIBNAME).so
#LIBLINK = $(LIBDIR)/lib$(NAME).$(BASE).so
CFLAGS += -fPIC
#AR = gcc -m32 -shared -o # the trailing space is important
#ARFLAGS = $(LDFLAGS)
#RANLIB = true
endif
#ifeq ($(LINK),static)
LDFLAGS += -static
#endif
ifeq ($(ZLIB),true)
LDFLAGS += -lz
endif
zimpl-3.3.4/make/make.mingw.x86.msvc.dbg 0000640 0012352 0006025 00000001263 13057565713 017565 0 ustar bzfgamra optimi CPPFLAGS += -DNO_MSHELL -D__NO_MATH_INLINES -D_DLL
CFLAGS =
LDFLAGS = -NODEFAULTLIB:LIBCMT -NODEFAULTLIB:LIBCMTD -STACK:67108864 -OPT:REF -OPT:ICF -NOLOGO -LTCG
CC = cl
CC_o = -Fo
CFLAGS =
LINKCC = link
LINKCC_o = -OUT:
AR = lib -nologo
AR_o = /OUT:
RANLIB =
LIBEXT = .lib
CPPFLAGS += -Dpopen=_popen -Dpclose=_pclose -Dinline=_inline -DNDEBUG -DWITH_PCRE=1 -D_WIN32 -W2 -wd4272 -Ox -nologo
CPPFLAGS += -I$(SRCDIR)/WIN -Ilib/pcre -Ilib/zlib -Ilib/pcre -Ilib/mpir.$(ARCH)
LDFLAGS += lib/libz.$(ARCH).$(OPT).lib \
lib/libpcre.$(ARCH).$(OPT).lib \
lib/libmpir.$(ARCH).$(OPT).lib
LIBBASE += getopt.o
zimpl-3.3.4/make/make.linux.x86.intel.opt 0000640 0012352 0006025 00000000577 13057565713 020023 0 ustar bzfgamra optimi #--- $Id: make.linux.x86.intel.opt,v 1.14 2014/01/12 11:07:04 bzfkocht Exp $
CC = icc
CPPFLAGS += -DNDEBUG -DNO_MSHELL
CFLAGS = -O3 -ip -fp-model precise -w1 -par_report0 -vec_report0 \
-wd1173
LDFLAGS = -lgmp -lm -static
#ifeq ($(LINK),shared)
#LINK = normal
#endif
#ifeq ($(LINK),static)
LDFLAGS += -static
#endif
ifeq ($(ZLIB),true)
LDFLAGS += -lz
endif
zimpl-3.3.4/make/make.sunos.x86.sun.dbg 0000640 0012352 0006025 00000000333 13057565713 017445 0 ustar bzfgamra optimi #--- $Id: make.sunos.x86.sun.dbg,v 1.6 2014/01/12 11:07:04 bzfkocht Exp $
CC = cc
CPPFLAGS += -DFREEMEM -Dinline=""
CFLAGS = -g -xcheck=stkovf
LDFLAGS = -Bstatic -lgmp -lm
ifeq ($(ZLIB),true)
LDFLAGS += -lz
endif
zimpl-3.3.4/make/make.linux.x86.gnu.opt 0000640 0012352 0006025 00000001001 13057565713 017460 0 ustar bzfgamra optimi #--- $Id: make.linux.x86.gnu.opt,v 1.15 2014/01/12 11:07:04 bzfkocht Exp $
CPPFLAGS += -DNDEBUG -DNO_MSHELL -D__NO_MATH_INLINES
CFLAGS = -O3 -m32 -mtune=native
LDFLAGS = -lgmp -lm
ifeq ($(ZLIB),true)
LDFLAGS += -lz
endif
ifeq ($(LINK),shared)
#LIBRARY = $(LIBDIR)/lib$(LIBNAME).so
#LIBLINK = $(LIBDIR)/lib$(NAME).$(BASE).so
CFLAGS += -fPIC
#AR = gcc -m32 -shared -o # the trailing space is important
#ARFLAGS = $(LDFLAGS)
#RANLIB = true
endif
#ifeq ($(LINK),static)
LDFLAGS += -static
#endif
zimpl-3.3.4/make/make.linux.x86_64.gnu.opt-gccold 0000640 0012352 0006025 00000001017 13057565713 021231 0 ustar bzfgamra optimi #--- $Id: make.linux.x86_64.gnu.opt-gccold,v 1.3 2014/01/12 11:07:04 bzfkocht Exp $
CPPFLAGS += -DNDEBUG -DNO_MSHELL -D__NO_MATH_INLINES
CFLAGS = -O3 -m64
LDFLAGS = -lgmp -lm -static
ifeq ($(ZLIB),true)
LDFLAGS += -lz
endif
ifeq ($(LINK),shared)
#LIBRARY = $(LIBDIR)/lib$(LIBNAME).so
#LIBLINK = $(LIBDIR)/lib$(NAME).$(BASE).so
CFLAGS += -fPIC
#AR = gcc -m64 -shared -o # the trailing space is important
#ARFLAGS = $(LDFLAGS)
#RANLIB = true
endif
#ifeq ($(LINK),static)
LDFLAGS += -static
#endif
zimpl-3.3.4/make/make.irix.mips.sgi.dbg 0000640 0012352 0006025 00000000327 13057565713 017554 0 ustar bzfgamra optimi #--- $Id: make.irix.mips.sgi.dbg,v 1.6 2014/01/12 11:07:04 bzfkocht Exp $
CC = cc
CPPFLAGS += -DFREEMEM -Dinline=""
CFLAGS = -fullwarn -g
LDFLAGS = -Bstatic -lgmp -lm
ifeq ($(ZLIB),true)
LDFLAGS += -lz
endif
zimpl-3.3.4/make/nmake.win.x86_64.msvc.opt 0000640 0012352 0006025 00000000207 13057565713 017773 0 ustar bzfgamra optimi CPPFLAGS = $(CPPFLAGS) /Dinline=_inline /DWIN64 /DNDEBUG
CFLAGS = $(CFLAGS) /W2 /wd4274 /Ox /nologo
LDFLAGS = $(LDFLAGS) /LTCG
zimpl-3.3.4/make/make.linux.x86_64.intel.opt 0000640 0012352 0006025 00000000570 13057565713 020325 0 ustar bzfgamra optimi #--- $Id: make.linux.x86_64.intel.opt,v 1.4 2014/01/12 11:07:04 bzfkocht Exp $
CC = icc
CPPFLAGS += -DNDEBUG -DNO_MSHELL
CFLAGS = -O3 -ip -fp-model precise -w1 -par_report0 -vec_report0 \
-wd1173
LDFLAGS = -lgmp -lm
ifeq ($(ZLIB),true)
LDFLAGS += -lz
endif
#ifeq ($(LINK),shared)
#LINK = normal
#endif
#ifeq ($(LINK),static)
LDFLAGS += -static
#endif
zimpl-3.3.4/make/make.mingw.x86.gnu.opt 0000640 0012352 0006025 00000000352 13057565713 017452 0 ustar bzfgamra optimi #--- $Id: make.mingw.x86.gnu.opt,v 1.3 2014/03/03 08:36:28 bzfkocht Exp $
CPPFLAGS += -DNDEBUG -DNO_MSHELL -D__NO_MATH_INLINES
CFLAGS = -O3
LDFLAGS = -lgmp -lpcreposix -lpcre -lm -static
ifeq ($(ZLIB),true)
LDFLAGS += -lz
endif
zimpl-3.3.4/make/make.sunos.sparc.sun.dbg 0000640 0012352 0006025 00000000336 13057565713 020133 0 ustar bzfgamra optimi #--- $Id: make.sunos.sparc.sun.dbg,v 1.11 2014/01/12 11:07:04 bzfkocht Exp $
CC = cc
CPPFLAGS += -DFREEMEM -Dinline=""
CFLAGS = -g -xcheck=stkovf
LDFLAGS = -Bstatic -lgmp -lm
ifeq ($(ZLIB),true)
LDFLAGS += -lz
endif
zimpl-3.3.4/make/make.hp-ux.hppa.hp.dbg 0000640 0012352 0006025 00000000367 13057565713 017453 0 ustar bzfgamra optimi #--- $Id: make.hp-ux.hppa.hp.dbg,v 1.7 2014/01/12 11:07:04 bzfkocht Exp $
CC = cc
CPPFLAGS += -DFREEMEM -Dinline="" -Dfinite=isfinite
CFLAGS = -z -g +DD64 +W21,486,474
LDFLAGS = -noshared -lgmp -lm
ifeq ($(ZLIB),true)
LDFLAGS += -lz
endif
zimpl-3.3.4/make/make.sunos.x86.sun.opt 0000640 0012352 0006025 00000000363 13057565713 017516 0 ustar bzfgamra optimi #--- $Id: make.sunos.x86.sun.opt,v 1.6 2014/01/12 11:07:04 bzfkocht Exp $
CC = cc
CPPFLAGS += -DNDEBUG -DNO_MSHELL -Dinline=""
CFLAGS = -fast -xprefetch=auto -xipo=2
LDFLAGS = -Bstatic -lgmp -lm
ifeq ($(ZLIB),true)
LDFLAGS += -lz
endif
zimpl-3.3.4/make/make.linux.x86.intel.dbg 0000640 0012352 0006025 00000000637 13057565713 017752 0 ustar bzfgamra optimi #--- $Id: make.linux.x86.intel.dbg,v 1.14 2014/01/12 11:07:04 bzfkocht Exp $
CC = icc
CPPFLAGS += -DFREEMEM
CFLAGS = -g -fp-model precise -w2 -Wcheck \
-par_report0 -vec_report0 \
-wd111,171,279,981,1173,1419,1684
LDFLAGS = -lgmp -lm
# -wd383,444,810
ifeq ($(ZLIB),true)
LDFLAGS += -lz
endif
#ifeq ($(LINK),shared)
#LINK = normal
#endif
#ifeq ($(LINK),static)
LDFLAGS += -static
#endif
zimpl-3.3.4/make/make.sunos.sparc.gnu.opt 0000640 0012352 0006025 00000000332 13057565713 020161 0 ustar bzfgamra optimi #--- $Id: make.sunos.sparc.gnu.opt,v 1.8 2014/03/03 08:36:28 bzfkocht Exp $
CPPFLAGS += -DNDEBUG -DNO_MSHELL -D__NO_MATH_INLINES
CFLAGS = -O3
LDFLAGS = -Bstatic -lgmp -lm
ifeq ($(ZLIB),true)
LDFLAGS += -lz
endif
zimpl-3.3.4/make/make.aix.pwr4.ibm.dbg 0000640 0012352 0006025 00000000345 13057565713 017273 0 ustar bzfgamra optimi #--- $Id: make.aix.pwr4.ibm.dbg,v 1.9 2010/06/10 19:42:42 bzfkocht Exp $
CC = xlc
CPPFLAGS += -DFREEMEM -Dinline="" -DUSE_FSYNC
CFLAGS = -g -q64 -qmaxmem=-1 -bnoquiet -qsuppress=1506-732 \
-qflttrap -qcheck=all
#-qwarn64
zimpl-3.3.4/make/make.linux.x86_64.clang.dbg 0000640 0012352 0006025 00000001254 13057565713 020230 0 ustar bzfgamra optimi #--- $Id: make.linux.x86_64.gnu.dbg,v 1.7 2014/01/12 11:07:04 bzfkocht Exp $
CC = clang
CPPFLAGS += -DFREEMEM #-D__NO_MATH_INLINES
CFLAGS = -O0 -m64 -g -Weverything -Wno-padded -Wno-switch-enum -Wno-covered-switch-default -Wno-static-in-inline -Wno-pedantic -Wno-format-nonliteral -Wno-shorten-64-to-32 -Wno-disable-macro-expansion
LDFLAGS = -lgmp -lm
ifeq ($(ZLIB),true)
LDFLAGS += -lz
endif
ifeq ($(LINK),shared)
LIBRARY = $(LIBDIR)/lib$(LIBNAME).so
LIBLINK = $(LIBDIR)/lib$(NAME).$(BASE).so
CFLAGS += -fPIC
AR = gcc -m64 -shared -o # the trailing space is important
ARFLAGS = $(LDFLAGS)
RANLIB = true
endif
ifeq ($(LINK),static)
LDFLAGS += -static
endif
zimpl-3.3.4/make/make.mingw.x86_64.msvc.dbg 0000640 0012352 0006025 00000001263 13057565713 020076 0 ustar bzfgamra optimi CPPFLAGS += -DNO_MSHELL -D__NO_MATH_INLINES -D_DLL
CFLAGS =
LDFLAGS = -NODEFAULTLIB:LIBCMT -NODEFAULTLIB:LIBCMTD -STACK:67108864 -OPT:REF -OPT:ICF -NOLOGO -LTCG
CC = cl
CC_o = -Fo
CFLAGS =
LINKCC = link
LINKCC_o = -OUT:
AR = lib -nologo
AR_o = /OUT:
RANLIB =
LIBEXT = .lib
CPPFLAGS += -Dpopen=_popen -Dpclose=_pclose -Dinline=_inline -DNDEBUG -DWITH_PCRE=1 -D_WIN64 -W2 -wd4272 -Ox -nologo
CPPFLAGS += -I$(SRCDIR)/WIN -Ilib/pcre -Ilib/zlib -Ilib/pcre -Ilib/mpir.$(ARCH)
LDFLAGS += lib/libz.$(ARCH).$(OPT).lib \
lib/libpcre.$(ARCH).$(OPT).lib \
lib/libmpir.$(ARCH).$(OPT).lib
LIBBASE += getopt.o
zimpl-3.3.4/make/make.linux.x86_64.gnu.dbg 0000640 0012352 0006025 00000000767 13057565713 017745 0 ustar bzfgamra optimi #--- $Id: make.linux.x86_64.gnu.dbg,v 1.7 2014/01/12 11:07:04 bzfkocht Exp $
CPPFLAGS += -DFREEMEM -D__NO_MATH_INLINES
CFLAGS = -O0 -m64 -g $(GCCWARN)
LDFLAGS = -lgmp -lm
ifeq ($(ZLIB),true)
LDFLAGS += -lz
endif
ifeq ($(LINK),shared)
#LIBRARY = $(LIBDIR)/lib$(LIBNAME).so
#LIBLINK = $(LIBDIR)/lib$(NAME).$(BASE).so
CFLAGS += -fPIC
#AR = gcc -m64 -shared -o # the trailing space is important
#ARFLAGS = $(LDFLAGS)
#RANLIB = true
endif
#ifeq ($(LINK),static)
LDFLAGS += -static
#endif
zimpl-3.3.4/make/make.linux.x86.gnu.dbg 0000640 0012352 0006025 00000001017 13057565713 017421 0 ustar bzfgamra optimi #--- $Id: make.linux.x86.gnu.dbg,v 1.14 2014/01/12 11:07:04 bzfkocht Exp $
CPPFLAGS += -DFREEMEM -D__NO_MATH_INLINES -Dinline=
CFLAGS = -O0 -m32 -g -fident -ftrapv $(GCCWARN)
LDFLAGS = -lgmp -lm
ifeq ($(ZLIB),true)
LDFLAGS += -lz
endif
ifeq ($(LINK),shared)
#LIBRARY = $(LIBDIR)/lib$(LIBNAME).so
#LIBLINK = $(LIBDIR)/lib$(NAME).$(BASE).so
CFLAGS += -fPIC
#AR = gcc -m32 -shared -o # the trailing space is important
#ARFLAGS = $(LDFLAGS)
#RANLIB = true
endif
#ifeq ($(LINK),static)
LDFLAGS += -static
#endif
zimpl-3.3.4/make/make.sunos.x86.gnu.opt 0000640 0012352 0006025 00000000751 13057565713 017503 0 ustar bzfgamra optimi #--- $Id: make.sunos.x86.gnu.opt,v 1.8 2014/03/03 08:36:28 bzfkocht Exp $
CPPFLAGS += -DNDEBUG -DNO_MSHELL -D__NO_MATH_INLINES
CFLAGS = -O3
LDFLAGS = -lgmp -lm
ifeq ($(LINK),shared)
#LIBRARY = $(LIBDIR)/lib$(LIBNAME).so
#LIBLINK = $(LIBDIR)/lib$(NAME).$(BASE).so
CFLAGS += -fPIC
#AR = gcc -shared -o # the trailing space is important
#ARFLAGS = $(LDFLAGS)
#RANLIB = true
endif
#ifeq ($(LINK),static)
LDFLAGS += -Bstatic
#endif
ifeq ($(ZLIB),true)
LDFLAGS += -lz
endif
zimpl-3.3.4/make/make.freebsd.x86_64.gnu.opt 0000640 0012352 0006025 00000000402 13057565713 020250 0 ustar bzfgamra optimi #--- $Id: make.freebsd.x86_64.gnu.opt,v 1.2 2014/01/12 11:07:04 bzfkocht Exp $
CPPFLAGS += -I/usr/local/include -DNDEBUG -DNO_MSHELL -D__NO_MATH_INLINES
CFLAGS = -O3
LDFLAGS = -L/usr/local/lib -lgmp -lm -static
ifeq ($(ZLIB),true)
LDFLAGS += -lz
endif
zimpl-3.3.4/make/make.osf1.alpha.compaq.opt 0000640 0012352 0006025 00000000347 13057565713 020334 0 ustar bzfgamra optimi #--- $Id: make.osf1.alpha.compaq.opt,v 1.10 2014/01/12 11:07:04 bzfkocht Exp $
CC = cc
CPPFLAGS += -DNDEBUG -DNO_MSHELL -Dinline=""
CFLAGS = -O4 -fast
LDFLAGS = -non_shared -lgmp -lm
ifeq ($(ZLIB),true)
LDFLAGS += -lz
endif
zimpl-3.3.4/make/make.aix.pwr4.ibm.opt 0000640 0012352 0006025 00000000414 13057565713 017336 0 ustar bzfgamra optimi #--- $Id: make.aix.pwr4.ibm.opt,v 1.9 2010/06/10 19:42:42 bzfkocht Exp $
CC = xlc
CPPFLAGS += -DNDEBUG -DNO_MSHELL -Dinline="" \
-DLHT_BUCKETS=50000017U -DUSE_FSYNC
CFLAGS = -O3 -q64 -qmaxmem=-1 \
-qarch=auto -qtune=auto -qcache=auto \
-qsuppress=1506-732
zimpl-3.3.4/make/make.mingw.x86.msvc.opt 0000640 0012352 0006025 00000001277 13057565713 017640 0 ustar bzfgamra optimi CPPFLAGS += -DNDEBUG -DNO_MSHELL -D__NO_MATH_INLINES -D_DLL
CFLAGS = -O3
LDFLAGS = -NODEFAULTLIB:LIBCMT -NODEFAULTLIB:LIBCMTD -STACK:67108864 -OPT:REF -OPT:ICF -NOLOGO -LTCG
CC = cl
CC_o = -Fo
CFLAGS =
LINKCC = link
LINKCC_o = -OUT:
AR = lib -nologo
AR_o = /OUT:
RANLIB =
LIBEXT = .lib
CPPFLAGS += -Dpopen=_popen -Dpclose=_pclose -Dinline=_inline -DNDEBUG -DWITH_PCRE=1 -D_WIN32 -W2 -wd4272 -Ox -nologo
CPPFLAGS += -I$(SRCDIR)/WIN -Ilib/pcre -Ilib/zlib -Ilib/pcre -Ilib/mpir.$(ARCH)
LDFLAGS += lib/libz.$(ARCH).$(OPT).lib \
lib/libpcre.$(ARCH).$(OPT).lib \
lib/libmpir.$(ARCH).$(OPT).lib
LIBBASE += getopt.o zimpl-3.3.4/make/make.linux.x86_64.gnu.prf 0000640 0012352 0006025 00000001040 13057565713 017761 0 ustar bzfgamra optimi #--- $Id: make.linux.x86_64.gnu.prf,v 1.2 2014/01/12 11:07:04 bzfkocht Exp $
CPPFLAGS += -DNDEBUG -DNO_MSHELL -D__NO_MATH_INLINES
CFLAGS = -O -m64 -mtune=native -g -pg $(GCCWARN)
LDFLAGS = -lgmp -lm
ifeq ($(ZLIB),true)
LDFLAGS += -lz
endif
ifeq ($(LINK),shared)
#LIBRARY = $(LIBDIR)/lib$(LIBNAME).so
#LIBLINK = $(LIBDIR)/lib$(NAME).$(BASE).so
CFLAGS += -fPIC
#AR = gcc -m64 -shared -o # the trailing space is important
#ARFLAGS = $(LDFLAGS)
#RANLIB = true
endif
#ifeq ($(LINK),static)
LDFLAGS += -static
#endif
zimpl-3.3.4/make/make.cygwin.x86.gnu.dbg 0000640 0012352 0006025 00000000344 13057565713 017564 0 ustar bzfgamra optimi #--- $Id: make.cygwin.x86.gnu.dbg,v 1.9 2014/01/12 11:07:04 bzfkocht Exp $
CPPFLAGS += -DWINDOWS -DFREEMEM -D__NO_MATH_INLINES
CFLAGS = -O -g $(GCCWARN)
LDFLAGS = -lgmp -lm -static
ifeq ($(ZLIB),true)
LDFLAGS += -lz
endif
zimpl-3.3.4/make/make.freebsd.x86.gnu.opt 0000640 0012352 0006025 00000000377 13057565713 017752 0 ustar bzfgamra optimi #--- $Id: make.freebsd.x86.gnu.opt,v 1.3 2014/01/12 11:07:04 bzfkocht Exp $
CPPFLAGS += -I/usr/local/include -DNDEBUG -DNO_MSHELL -D__NO_MATH_INLINES
CFLAGS = -O3
LDFLAGS = -L/usr/local/lib -lgmp -lm -static
ifeq ($(ZLIB),true)
LDFLAGS += -lz
endif
zimpl-3.3.4/make/make.sunos.x86.dbg 0000640 0012352 0006025 00000000327 13057565713 016644 0 ustar bzfgamra optimi #--- $Id: make.sunos.x86.dbg,v 1.3 2014/01/12 11:07:04 bzfkocht Exp $
CC = cc
CPPFLAGS += -DFREEMEM -Dinline=""
CFLAGS = -g -xcheck=stkovf
LDFLAGS = -Bstatic -lgmp -lm
ifeq ($(ZLIB),true)
LDFLAGS += -lz
endif
zimpl-3.3.4/make/make.darwin.x86.intel.opt 0000640 0012352 0006025 00000000425 13057565713 020140 0 ustar bzfgamra optimi #--- $Id: make.darwin.x86.intel.opt,v 1.3 2014/01/12 11:07:04 bzfkocht Exp $
CC = icc
CPPFLAGS += -DNDEBUG -DNO_MSHELL
CFLAGS = -O3 -ip -fp-model precise -w1 -par_report0 -vec_report0 \
-wd1173
LDFLAGS = -lgmp -lm
ifeq ($(ZLIB),true)
LDFLAGS += -lz
endif
zimpl-3.3.4/make/make.linux.x86_64.eko.dbg 0000640 0012352 0006025 00000000443 13057565713 017721 0 ustar bzfgamra optimi #--- $Id: make.linux.x86_64.eko.dbg,v 1.6 2014/01/12 11:07:04 bzfkocht Exp $
CC = pathcc
CPPFLAGS += -DFREEMEM -D__NO_MATH_INLINES
CFLAGS = -std=c89 -Dinline= -D_POSIX_C_SOURCE=2 -march=em64t -m64 -O0 -g $(GCCWARN)
LDFLAGS = -lgmp -lm -static
ifeq ($(ZLIB),true)
LDFLAGS += -lz
endif
zimpl-3.3.4/make/make.linux.x86.gnu.gcov 0000640 0012352 0006025 00000001042 13057565713 017621 0 ustar bzfgamra optimi #--- $Id: make.linux.x86.gnu.gcov,v 1.10 2014/01/12 11:07:04 bzfkocht Exp $
CPPFLAGS += -DCOVERAGE -DFREEMEM -D__NO_MATH_INLINES
CFLAGS = -O0 -m32 -g -fprofile-arcs -ftest-coverage
LDFLAGS = -lgmp -lm
ifeq ($(LINK),shared)
#LIBRARY = $(LIBDIR)/lib$(LIBNAME).so
#LIBLINK = $(LIBDIR)/lib$(NAME).$(BASE).so
CFLAGS += -fPIC
#AR = gcc -m32 -shared -o # the trailing space is important
#ARFLAGS = $(LDFLAGS)
#RANLIB = true
endif
#ifeq ($(LINK),static)
LDFLAGS += -static
#endif
ifeq ($(ZLIB),true)
LDFLAGS += -lz
endif
zimpl-3.3.4/make/make.hp-ux.hppa.hp.opt 0000640 0012352 0006025 00000000400 13057565713 017505 0 ustar bzfgamra optimi #--- $Id: make.hp-ux.hppa.hp.opt,v 1.8 2014/01/12 11:07:04 bzfkocht Exp $
CC = cc
CPPFLAGS += -DNDEBUG -DNO_MSHELL -Dinline="" -Dfinite=isfinite
CFLAGS = +O3 +DD64 +W21,486,474
LDFLAGS = -noshared -lgmp -lm
ifeq ($(ZLIB),true)
LDFLAGS += -lz
endif
zimpl-3.3.4/make/make.darwin.x86_64.gnu.dbg 0000640 0012352 0006025 00000001062 13057565713 020057 0 ustar bzfgamra optimi #--- $Id: make.darwin.x86_64.gnu.dbg,v 1.7 2014/01/12 11:07:04 bzfkocht Exp $
CPPFLAGS += -DFREEMEM -D__NO_MATH_INLINES
CFLAGS = -O0 -m64 -g -fident $(GCCWARN)
LDFLAGS = -lgmp -lm
ifeq ($(LINK),shared)
#LIBRARY = $(LIBDIR)/lib$(LIBNAME).so
#LIBLINK = $(LIBDIR)/lib$(NAME).$(BASE).so
CFLAGS += -fPIC
#AR = gcc -m64 -shared -o # the trailing space is important
#ARFLAGS = $(LDFLAGS)
#RANLIB = true
endif
#ifeq ($(LINK),static)
LDFLAGS = -Bstatic -lgmp -lm
#endif
ifeq ($(ZLIB),true)
LDFLAGS += -lz
endif
zimpl-3.3.4/make/make.mingw.x86_64.msvc.opt 0000640 0012352 0006025 00000001277 13057565713 020151 0 ustar bzfgamra optimi CPPFLAGS += -DNDEBUG -DNO_MSHELL -D__NO_MATH_INLINES -D_DLL
CFLAGS = -O3
LDFLAGS = -NODEFAULTLIB:LIBCMT -NODEFAULTLIB:LIBCMTD -STACK:67108864 -OPT:REF -OPT:ICF -NOLOGO -LTCG
CC = cl
CC_o = -Fo
CFLAGS =
LINKCC = link
LINKCC_o = -OUT:
AR = lib -nologo
AR_o = /OUT:
RANLIB =
LIBEXT = .lib
CPPFLAGS += -Dpopen=_popen -Dpclose=_pclose -Dinline=_inline -DNDEBUG -DWITH_PCRE=1 -D_WIN64 -W2 -wd4272 -Ox -nologo
CPPFLAGS += -I$(SRCDIR)/WIN -Ilib/pcre -Ilib/zlib -Ilib/pcre -Ilib/mpir.$(ARCH)
LDFLAGS += lib/libz.$(ARCH).$(OPT).lib \
lib/libpcre.$(ARCH).$(OPT).lib \
lib/libmpir.$(ARCH).$(OPT).lib
LIBBASE += getopt.o zimpl-3.3.4/make/make.irix.mips.sgi.opt 0000640 0012352 0006025 00000000330 13057565713 017614 0 ustar bzfgamra optimi #--- $Id: make.irix.mips.sgi.opt,v 1.7 2014/01/12 11:07:04 bzfkocht Exp $
CC = cc
CPPFLAGS += -DNDEBUG -Dinline=""
CFLAGS = -O2 -mips4 -IPA
LDFLAGS = -Bstatic -lgmp -lm
ifeq ($(ZLIB),true)
LDFLAGS += -lz
endif
zimpl-3.3.4/src/ 0000750 0012352 0006025 00000000000 13057771122 013317 5 ustar bzfgamra optimi zimpl-3.3.4/src/metaio.c 0000640 0012352 0006025 00000025374 13057565713 014764 0 ustar bzfgamra optimi /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* File....: metaio.c */
/* Name....: Meta Input/Output */
/* Author..: Thorsten Koch */
/* Copyright by Author, All rights reserved */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Copyright (C) 2006-2017 by Thorsten Koch
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include
#include
#include
#include
#include
#include
#include
#include
#ifndef _lint
#ifndef WITHOUT_ZLIB
#include
#endif
#else
#include "lint.h"
#endif /* _lint */
#include "bool.h"
#include "mshell.h"
#include "mme.h"
#include "metaio.h"
enum file_type {
MFP_ERR,
MFP_STRG,
MFP_FILE,
MFP_PIPE
#ifndef WITHOUT_ZLIB
, MFP_ZLIB
#endif /* ! WITHOUT_ZLIB */
};
typedef struct strg_file StrgFile;
typedef enum file_type FileType;
#define STRGFILE_SID 0x53544649
#define MFP_SID 0x4d46505f
#define BUF_SIZE_INC 4096
struct strg_file
{
SID
const char* name;
const char* content;
int length;
int offset;
Bool use_copy;
StrgFile* next;
};
struct meta_file_ptr
{
SID
FileType type;
union
{
StrgFile* strg;
FILE* file;
#ifndef WITHOUT_ZLIB
gzFile zlib;
#endif /* ! WITHOUT_ZLIB */
} fp;
};
static StrgFile* strg_file_root = NULL;
static Bool strgfile_is_valid(const StrgFile* sf)
{
return (sf != NULL)
&& SID_ok(sf, STRGFILE_SID)
&& (sf->name != NULL)
&& (sf->content != NULL)
&& (sf->length >= 0)
&& (sf->offset >= 0)
&& (sf->offset <= sf->length);
}
void mio_add_strg_file(const char* name, const char* content, Bool use_copy)
{
StrgFile* sf = calloc(1, sizeof(*sf));
assert(name != NULL);
assert(content != NULL);
assert(sf != NULL);
sf->name = strdup(name);
sf->content = use_copy ? strdup(content) : content;
sf->length = (int)strlen(content); /* the final '\0' is not part of the file */
sf->offset = 0;
sf->use_copy = use_copy;
sf->next = strg_file_root;
SID_set(sf, STRGFILE_SID);
assert(strgfile_is_valid(sf));
strg_file_root = sf;
}
static int strgfile_getc(StrgFile* sf)
{
int c;
assert(strgfile_is_valid(sf));
if (sf->offset == sf->length)
c = EOF;
else
{
assert(sf->offset < sf->length);
c = sf->content[sf->offset];
sf->offset++;
}
return c;
}
static char* strgfile_gets(StrgFile* sf, char* buf, int size)
{
char* s = NULL;
assert(strgfile_is_valid(sf));
assert(buf != NULL);
assert(size > 0);
if (sf->offset < sf->length)
{
int i = 0;
while(sf->offset < sf->length && i < size - 1)
{
assert(sf->content[sf->offset] != '\0');
buf[i] = sf->content[sf->offset];
sf->offset++;
i++;
if (buf[i - 1] == '\n')
break;
}
buf[i] = '\0';
s = buf;
}
return s;
}
static Bool mfp_is_valid(const MFP* mfp)
{
return mfp != NULL && SID_ok(mfp, MFP_SID) && mfp->type != MFP_ERR;
}
MFP* mio_open(const char* name, const char* ext)
{
MFP* mfp = calloc(1, sizeof(*mfp));
char* filename;
StrgFile* sf;
assert(name != NULL);
assert(ext != NULL);
assert(mfp != NULL);
filename = malloc(strlen(name) + strlen(ext) + 1);
assert(filename != NULL);
strcpy(filename, name);
/* Check if a String File is openend
*/
for(sf = strg_file_root; sf != NULL; sf = sf->next)
if (!strcmp(name, sf->name))
break;
/* Did we find something ?
*/
if (sf != NULL)
{
mfp->type = MFP_STRG;
mfp->fp.strg = sf;
mfp->fp.strg->offset = 0;
SID_set(mfp, MFP_SID);
assert(mfp_is_valid(mfp));
}
else
{
/* Do we have a pipe?
*/
if (*filename == '#')
{
mfp->type = MFP_PIPE;
if (NULL == (mfp->fp.file = popen(&filename[1], "r")))
{
perror(filename);
free(mfp);
mfp = NULL;
}
else
{
SID_set(mfp, MFP_SID);
assert(mfp_is_valid(mfp));
}
}
else
{
int len;
/* This seems to be a real file, is it available ?
*/
if (access(filename, R_OK) != 0)
{
strcat(filename, ext);
/* If .gz/.zpl also does not work, revert to the old name
* to get a better error message.
*/
if (access(filename, R_OK) != 0)
strcpy(filename, name);
}
#ifndef WITHOUT_ZLIB
len = (int)strlen(filename);
if (len > 3 && !strcmp(&filename[len - 3], ".gz"))
{
mfp->type = MFP_ZLIB;
if (NULL == (mfp->fp.zlib = gzopen(filename, "r")))
{
perror(filename);
free(mfp);
mfp = NULL;
}
else
{
SID_set(mfp, MFP_SID);
assert(mfp_is_valid(mfp));
}
}
else
#endif /* !WITHOUT_ZLIB */
{
mfp->type = MFP_FILE;
if (NULL == (mfp->fp.file = fopen(filename, "r")))
{
perror(filename);
free(mfp);
mfp = NULL;
}
else
{
SID_set(mfp, MFP_SID);
assert(mfp_is_valid(mfp));
}
}
}
}
free(filename);
return mfp;
}
void mio_close(MFP* mfp)
{
assert(mfp_is_valid(mfp));
switch(mfp->type)
{
case MFP_STRG :
break;
case MFP_FILE :
fclose(mfp->fp.file);
break;
case MFP_PIPE :
pclose(mfp->fp.file);
break;
#ifndef WITHOUT_ZLIB
case MFP_ZLIB :
gzclose(mfp->fp.zlib);
break;
#endif /* ! WITHOUT_ZLIB */
default :
abort();
}
SID_del(mfp);
free(mfp);
}
int mio_getc(const MFP* mfp)
{
int c;
assert(mfp_is_valid(mfp));
switch(mfp->type)
{
case MFP_STRG :
c = strgfile_getc(mfp->fp.strg);
break;
case MFP_FILE :
case MFP_PIPE :
c = fgetc(mfp->fp.file);
break;
#ifndef WITHOUT_ZLIB
case MFP_ZLIB :
c = gzgetc(mfp->fp.zlib);
break;
#endif /* ! WITHOUT_ZLIB */
default :
abort();
}
return c;
}
char* mio_gets(const MFP* mfp, char* buf, int len)
{
char* s = NULL;
assert(mfp_is_valid(mfp));
switch(mfp->type)
{
case MFP_STRG :
s = strgfile_gets(mfp->fp.strg, buf, len);
break;
case MFP_FILE :
case MFP_PIPE :
s = fgets(buf, len, mfp->fp.file);
break;
#ifndef WITHOUT_ZLIB
case MFP_ZLIB :
s = gzgets(mfp->fp.zlib, buf, len);
break;
#endif /* ! WITHOUT_ZLIB */
default :
abort();
}
return s;
}
char* mio_get_line(const MFP* mfp)
{
int size = 1;
char* buf = NULL;
char* s;
assert(mfp_is_valid(mfp));
do
{
char* t;
int pos = size - 1;
size += BUF_SIZE_INC - 1;
buf = (buf == NULL) ? malloc((size_t)size) : realloc(buf, (size_t)size);
t = &buf[pos];
buf[size - 1] = '@';
s = mio_gets(mfp, t, BUF_SIZE_INC);
}
while(s != NULL && buf[size - 1] == '\0' && buf[size - 2] != '\n');
/* nothing read at all ?
*/
if (s == NULL && size == BUF_SIZE_INC)
{
free(buf);
buf = NULL;
}
return buf;
}
void mio_init()
{
/* Setup for internal test
*/
static const char* const progstrg =
"# $Id: metaio.c,v 1.21 2014/03/03 16:44:14 bzfkocht Exp $\n"
"#\n"
"# Generic formulation of the Travelling Salesmen Problem\n"
"#\n"
"set V := { read \"@selftest_cities.dat\" as \"<1s>\" comment \"#\" use cities };\n"
"set E := { in V * V with i < j };\n"
"set P[] := powerset(V);\n"
"set K := indexset(P) \\ { 0 };\n"
"\n"
"do print cities;\n"
"do print V;\n"
"do print E;\n"
"param px[V] := read \"@selftest_cities.dat\" as \"<1s> 2n\" comment \"#\" use cities;\n"
"param py[V] := read \"@selftest_cities.dat\" as \"<1s> 3n\" comment \"#\" use cities;\n"
"\n"
"defnumb dist(a,b) := sqrt((px[a] - px[b])^2 + (py[a] - py[b])^2);\n"
"\n"
"var x[E] binary;\n"
"\n"
"minimize cost: sum in E : dist(i,j) * x[i, j];\n"
"\n"
"subto two_connected:\n"
" forall in V do\n"
" (sum in E : x[v,j]) + (sum in E : x[i,v]) == 2;\n"
"\n"
"subto no_subtour:\n"
" forall in K with card(P[k]) > 2 and card(P[k]) < card(V) - 2 do\n"
" sum in E with in P[k] and in P[k] : x[i,j] \n"
" <= card(P[k]) - 1;\n";
static const char* const datastrg =
"Berlin 5251 1340\n"
"Frankfurt 5011 864\n"
"Leipzig 5133 1237\n"
"Heidelberg 4941 867\n"
"Karlsruhe 4901 840\n"
"Hamburg 5356 998\n"
"Bayreuth 4993 1159\n"
"Trier 4974 668\n"
"Hannover 5237 972\n"
"Stuttgart 4874 909\n"
"Passau 4856 1344\n"
"Augsburg 4833 1089\n"
"Koblenz 5033 759\n"
"Dortmund 5148 741\n";
mio_add_strg_file("@selftest_tspste.zpl", progstrg, FALSE);
mio_add_strg_file("@selftest_cities.dat", datastrg, FALSE);
}
void mio_exit()
{
StrgFile* p;
StrgFile* q;
for(p = strg_file_root; p != NULL; p = q)
{
q = p->next;
assert(strgfile_is_valid(p));
free((void*)p->name);
if (p->use_copy)
free((void*)p->content);
SID_del(p);
free(p);
}
strg_file_root = NULL;
}
zimpl-3.3.4/src/hash.c 0000640 0012352 0006025 00000022504 13057565713 014421 0 ustar bzfgamra optimi /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* File....: hash.c */
/* Name....: Hash Functions */
/* Author..: Thorsten Koch */
/* Copyright by Author, All rights reserved */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Copyright (C) 2001-2017 by Thorsten Koch
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include
#include
#include
#include
#include "bool.h"
#include "mshell.h"
#include "blkmem.h"
#include "ratlptypes.h"
#include "numb.h"
#include "elem.h"
#include "tuple.h"
#include "mme.h"
#include "set.h"
#include "symbol.h"
#include "entry.h"
#include "mono.h"
#include "hash.h"
#define HASH_SID 0x48617368
typedef struct hash_element HElem;
typedef struct set_elem_idx SetElemIdx;
struct set_elem_idx
{
const Elem* elem;
int idx;
};
struct hash_element
{
union
{
const Tuple* tuple;
const Entry* entry;
SetElemIdx elem_idx;
const Numb* numb;
const Mono* mono;
} value;
HElem* next;
};
struct hash
{
SID
unsigned int size;
int elems;
HashType type;
HElem** bucket;
};
static void hash_statist(FILE* fp, const Hash* hash);
Hash* hash_new(HashType type, int size)
{
static const unsigned int bucket_size[] =
{
53U, 103U, 503U, 1009U, 5003U, 10007U, 50021U, 100003U, 500009U, 1000003U,
5000011U, 10000019U, 50000017U, 0U
};
Hash* hash = calloc(1, sizeof(*hash));
int i;
assert(hash != NULL);
assert(size >= 0);
/* This is a linear search, but if the number of elements is large,
* it will hardly matter ;-)
*/
for(i = 0; bucket_size[i] < (unsigned int)size && bucket_size[i + 1] != 0; i++)
;
hash->size = bucket_size[i];
assert(hash->size > 11);
hash->elems = 0;
hash->type = type;
hash->bucket = calloc(hash->size, sizeof(*hash->bucket));
assert(hash->bucket != NULL);
SID_set(hash, HASH_SID);
assert(hash_is_valid(hash));
return hash;
}
void hash_free(Hash* hash)
{
HElem* he;
HElem* hq;
unsigned int i;
assert(hash_is_valid(hash));
if (verbose >= VERB_CHATTER)
hash_statist(stderr, hash);
SID_del(hash);
for(i = 0; i < hash->size; i++)
{
for(he = hash->bucket[i]; he != NULL; he = hq)
{
hq = he->next;
blk_free(he, sizeof(*he));
}
}
free(hash->bucket);
free(hash);
}
Bool hash_is_valid(const Hash* hash)
{
return ((hash != NULL)
&& (hash->type == HASH_TUPLE || hash->type == HASH_ENTRY
|| hash->type == HASH_ELEM_IDX || hash->type == HASH_NUMB
|| hash->type == HASH_MONO)
&& SID_ok(hash, HASH_SID));
}
void hash_add_tuple(Hash* hash, const Tuple* tuple)
{
HElem* he = blk_alloc(sizeof(*he));
unsigned int hcode;
assert(hash_is_valid(hash));
assert(tuple_is_valid(tuple));
assert(hash->type == HASH_TUPLE);
assert(he != NULL);
hcode = tuple_hash(tuple) % hash->size;
he->value.tuple = tuple;
he->next = hash->bucket[hcode];
hash->bucket[hcode] = he;
hash->elems++;
}
void hash_add_entry(Hash* hash, const Entry* entry)
{
HElem* he = blk_alloc(sizeof(*he));
const Tuple* tuple;
unsigned int hcode;
assert(hash_is_valid(hash));
assert(entry_is_valid(entry));
assert(hash->type == HASH_ENTRY);
assert(he != NULL);
tuple = entry_get_tuple(entry);
hcode = tuple_hash(tuple) % hash->size;
he->value.entry = entry;
he->next = hash->bucket[hcode];
hash->bucket[hcode] = he;
hash->elems++;
}
void hash_add_numb(Hash* hash, const Numb* numb)
{
HElem* he = blk_alloc(sizeof(*he));
unsigned int hcode;
assert(hash_is_valid(hash));
assert(numb_is_valid(numb));
assert(hash->type == HASH_NUMB);
assert(he != NULL);
hcode = numb_hash(numb) % hash->size;
he->value.numb = numb;
he->next = hash->bucket[hcode];
hash->bucket[hcode] = he;
hash->elems++;
}
void hash_add_mono(Hash* hash, const Mono* mono)
{
HElem* he = blk_alloc(sizeof(*he));
unsigned int hcode;
assert(hash_is_valid(hash));
assert(mono_is_valid(mono));
assert(hash->type == HASH_MONO);
assert(he != NULL);
hcode = mono_hash(mono) % hash->size;
he->value.mono = mono;
he->next = hash->bucket[hcode];
hash->bucket[hcode] = he;
hash->elems++;
}
Bool hash_has_tuple(const Hash* hash, const Tuple* tuple)
{
unsigned int hcode = tuple_hash(tuple) % hash->size;
HElem* he;
assert(hash_is_valid(hash));
assert(tuple_is_valid(tuple));
for(he = hash->bucket[hcode]; he != NULL; he = he->next)
if (!tuple_cmp(he->value.tuple, tuple))
break;
return he != NULL;
}
Bool hash_has_entry(const Hash* hash, const Tuple* tuple)
{
unsigned int hcode = tuple_hash(tuple) % hash->size;
HElem* he;
assert(hash_is_valid(hash));
assert(tuple_is_valid(tuple));
for(he = hash->bucket[hcode]; he != NULL; he = he->next)
if (!entry_cmp(he->value.entry, tuple))
break;
return he != NULL;
}
Bool hash_has_numb(const Hash* hash, const Numb* numb)
{
unsigned int hcode = numb_hash(numb) % hash->size;
HElem* he;
assert(hash_is_valid(hash));
assert(numb_is_valid(numb));
for(he = hash->bucket[hcode]; he != NULL; he = he->next)
if (numb_equal(he->value.numb, numb))
break;
return he != NULL;
}
/* Liefert NULL wenn nicht gefunden.
*/
const Entry* hash_lookup_entry(const Hash* hash, const Tuple* tuple)
{
unsigned int hcode = tuple_hash(tuple) % hash->size;
HElem* he;
assert(hash_is_valid(hash));
assert(tuple_is_valid(tuple));
for(he = hash->bucket[hcode]; he != NULL; he = he->next)
if (!entry_cmp(he->value.entry, tuple))
break;
if (he == NULL)
return NULL;
assert(he != NULL);
assert(entry_is_valid(he->value.entry));
return he->value.entry;
}
/* Liefert NULL wenn nicht gefunden.
*/
const Mono* hash_lookup_mono(const Hash* hash, const Mono* mono)
{
unsigned int hcode = mono_hash(mono) % hash->size;
HElem* he;
assert(hash_is_valid(hash));
assert(mono_is_valid(mono));
for(he = hash->bucket[hcode]; he != NULL; he = he->next)
if (mono_equal(he->value.mono, mono))
break;
if (he == NULL)
return NULL;
assert(he != NULL);
assert(mono_is_valid(he->value.mono));
return he->value.mono;
}
void hash_add_elem_idx(Hash* hash, const Elem* elem, int idx)
{
HElem* he = blk_alloc(sizeof(*he));
unsigned int hcode;
assert(hash_is_valid(hash));
assert(elem_is_valid(elem));
assert(he != NULL);
hcode = elem_hash(elem) % hash->size;
he->value.elem_idx.elem = elem;
he->value.elem_idx.idx = idx;
he->next = hash->bucket[hcode];
hash->bucket[hcode] = he;
hash->elems++;
}
/* Liefert -1 wenn nicht gefunden.
*/
int hash_lookup_elem_idx(const Hash* hash, const Elem* elem)
{
unsigned int hcode = elem_hash(elem) % hash->size;
HElem* he;
assert(hash_is_valid(hash));
assert(elem_is_valid(elem));
for(he = hash->bucket[hcode]; he != NULL; he = he->next)
if (!elem_cmp(he->value.elem_idx.elem, elem))
break;
if (he == NULL)
return -1;
assert(he != NULL);
return he->value.elem_idx.idx;
}
static void hash_statist(FILE* fp, const Hash* hash)
{
HElem* he;
int min = (int)hash->size;
int max = 0;
int sum = 0;
int zeros = 0;
int filled = 0;
double avg = 0.0;
unsigned int i;
assert(fp != NULL);
assert(hash_is_valid(hash));
for(i = 0; i < hash->size; i++)
{
int count = 0;
for(he = hash->bucket[i]; he != NULL; he = he->next)
count++;
if (count == 0)
zeros++;
else
filled++;
if (count < min)
min = count;
if (count > max)
max = count;
sum += count;
}
assert(sum == hash->elems);
if (filled > 0)
avg = (double)sum / (double)filled;
fprintf(fp,
"HashStat: size=%8u sum=%6d min=%3d max=%3d avg=%4.1f zero=%6d filled=%6d\n",
hash->size, sum, min, max, avg, zeros, filled);
}
zimpl-3.3.4/src/list.h 0000640 0012352 0006025 00000010525 13057565713 014456 0 ustar bzfgamra optimi /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* File....: list.h */
/* Name....: List Functions */
/* Author..: Thorsten Koch */
/* Copyright by Author, All rights reserved */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Copyright (C) 2001-2017 by Thorsten Koch
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _LIST_H_
#define _LIST_H_
#ifndef _BOOL_H_
#error "Need to include bool.h before list.h"
#endif
#ifndef _MME_H_
#error "Need to include mme.h before list.h"
#endif
#ifdef __cplusplus
extern "C" {
#endif
#define LIST_NULL ((List*)0)
/*lint -sem( list_new_elem, 1p == 1, @p == 1) */
extern List* list_new_elem(const Elem* elem);
/*lint -sem( list_new_tuple, 1p == 1, @p == 1) */
extern List* list_new_tuple(const Tuple* tuple);
/*lint -sem( list_new_entry, 1p == 1, @p == 1) */
extern List* list_new_entry(const Entry* entry);
/*lint -sem( list_new_list, 1p == 1, @p == 1) */
extern List* list_new_list(const List* list);
/*lint -sem( list_free, custodial(1), 1p == 1) */
extern void list_free(List* list);
/*lint -sem( list_is_valid, 1p == 1) */
extern Bool list_is_valid(const List* list);
/*lint -sem( list_is_elemlist, 1p == 1) */
extern Bool list_is_elemlist(const List* list);
/*lint -sem( list_is_entrylist, 1p == 1) */
extern Bool list_is_entrylist(const List* list);
/*lint -sem( list_is_tuplelist, 1p == 1) */
extern Bool list_is_tuplelist(const List* list);
/*lint -sem( list_copy, 1p == 1, @p == 1) */
extern List* list_copy(const List* list);
/*lint -sem( list_add_list, 1p == 1 && 2p == 1) */
extern void list_add_list(List* list, const List* ll);
/*lint -sem( list_add_elem, 1p == 1 && 2p == 1) */
extern void list_add_elem(List* list, const Elem* elem);
/*lint -sem( list_add_tuple, 1p == 1 && 2p == 1) */
extern void list_add_tuple(List* list, const Tuple* tuple);
/*lint -sem( list_add_entry, 1p == 1 && 2p == 1) */
extern void list_add_entry(List* list, const Entry* entry);
/*lint -sem( list_insert_elem, 1p == 1 && 2p == 1) */
extern void list_insert_elem(List* list, const Elem* elem);
/*lint -sem( list_insert_tuple, 1p == 1 && 2p == 1) */
extern void list_insert_tuple(List* list, const Tuple* tuple);
/*lint -sem( list_insert_entry, 1p == 1 && 2p == 1) */
extern void list_insert_entry(List* list, const Entry* entry);
/*lint -sem( list_get_elems, 1p == 1, @n >= 0) */
extern int list_get_elems(const List* list);
/*lint -sem( list_get_elem, 1p == 1, @p == 1) */
extern const Elem* list_get_elem(const List* list, ListElem** idxp);
/*lint -sem( list_get_tuple, 1p == 1, @p == 1) */
extern const Tuple* list_get_tuple(const List* list, ListElem** idxp);
/*lint -sem( list_get_entry, 1p == 1, @p == 1) */
extern const Entry* list_get_entry(const List* list, ListElem** idxp);
/*lint -sem( list_get_list, 1p == 1, @p == 1) */
extern const List* list_get_list(const List* list, ListElem** idxp);
/*lint -sem( list_print, 1p == 1 && 2p == 1) */
extern void list_print(FILE* fp, const List* list);
#ifdef __cplusplus
}
#endif
#endif /* _LIST_H_ */
zimpl-3.3.4/src/hash.h 0000640 0012352 0006025 00000007443 13057565713 014433 0 ustar bzfgamra optimi /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* File....: hash.h */
/* Name....: Hash Functions */
/* Author..: Thorsten Koch */
/* Copyright by Author, All rights reserved */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Copyright (C) 2001-2017 by Thorsten Koch
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _HASH_H_
#define _HASH_H_
#ifndef _BOOL_H_
#error "Need to include bool.h before hash.h"
#endif
#ifndef _NUMB_H_
#error "Need to include numb.h before hash.h"
#endif
#ifndef _ELEM_H_
#error "Need to include elem.h before hash.h"
#endif
#ifndef _TUPLE_H_
#error "Need to include tuple.h before hash.h"
#endif
#ifndef _MME_H_
#error "Need to include mme.h before hash.h (Entry,Mono)"
#endif
#ifdef __cplusplus
extern "C" {
#endif
enum hash_type { HASH_ERR = 0, HASH_TUPLE, HASH_ENTRY, HASH_ELEM_IDX, HASH_NUMB, HASH_MONO };
typedef enum hash_type HashType;
typedef struct hash Hash;
/*lint -sem( hash_new, 2n >= 0, @p == 1) */
extern Hash* hash_new(HashType type, int size);
/*lint -sem( hash_free, 1p == 1) */
extern void hash_free(Hash* hash);
/*lint -sem( hash_is_valid, 1p == 1) */
extern Bool hash_is_valid(const Hash* hash);
/*lint -sem( hash_add_tuple, 1p == 1 && 2p == 1) */
extern void hash_add_tuple(Hash* hash, const Tuple* tuple);
/*lint -sem( hash_add_entry, 1p == 1 && 2p == 1) */
extern void hash_add_entry(Hash* hash, const Entry* entry);
/*lint -sem( hash_add_mono, 1p == 1 && 2p == 1) */
extern void hash_add_mono(Hash* hash, const Mono* mono);
/*lint -sem( hash_add_elem_idx, 1p == 1 && 2p == 1 && 3n >= 0) */
extern void hash_add_elem_idx(Hash* hash, const Elem* elem, int idx);
/*lint -sem( hash_add_numb, 1p == 1 && 2p == 1) */
extern void hash_add_numb(Hash* hash, const Numb* numb);
/*lint -sem( hash_has_tuple, 1p == 1 && 2p == 1) */
extern Bool hash_has_tuple(const Hash* hash, const Tuple* tuple);
/*lint -sem( hash_has_entry, 1p == 1 && 2p == 1) */
extern Bool hash_has_entry(const Hash* hash, const Tuple* tuple);
/*lint -sem( hash_has_numb, 1p == 1 && 2p == 1) */
extern Bool hash_has_numb(const Hash* hash, const Numb* numb);
/*lint -sem( hash_lookup_entry, 1p == 1 && 2p == 1) */
extern const Entry* hash_lookup_entry(const Hash* hash, const Tuple* tuple);
/*lint -sem( hash_lookup_mono, 1p == 1 && 2p == 1) */
extern const Mono* hash_lookup_mono(const Hash* hash, const Mono* mono);
/*lint -sem( hash_lookup_elem_idx, 1p == 1 && 2p == 1) */
extern int hash_lookup_elem_idx(const Hash* hash, const Elem* elem);
#ifdef __cplusplus
}
#endif
#endif /* _HASH_H_ */
zimpl-3.3.4/src/setprod.c 0000640 0012352 0006025 00000025353 13057565713 015163 0 ustar bzfgamra optimi /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* File....: setprod.c */
/* Name....: Set Product Functions */
/* Author..: Thorsten Koch */
/* Copyright by Author, All rights reserved */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Copyright (C) 2001-2017 by Thorsten Koch
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include
#include
#include
#include
#include "bool.h"
#include "mshell.h"
#include "numb.h"
#include "elem.h"
#include "tuple.h"
#include "mme.h"
#include "hash.h"
#include "set.h"
#include "set4.h"
#define SET_PROD_SID 0x53455450
#define SET_PROD_ITER_SID 0x53455049
/* -------------------------------------------------------------------------
* --- valid
* -------------------------------------------------------------------------
*/
static Bool set_prod_is_valid(const Set* set)
{
return set != NULL
&& SID_ok2(set->prod, SET_PROD_SID)
&& set->head.refc > 0
&& set->head.dim > 1
&& set_is_valid(set->prod.set_a)
&& set_is_valid(set->prod.set_b);
}
static Bool set_prod_iter_is_valid(const SetIter* iter)
{
return iter != NULL
&& SID_ok2(iter->prod, SET_PROD_ITER_SID)
&& iter->prod.iter_a != NULL
&& iter->prod.iter_b != NULL;
}
/* -------------------------------------------------------------------------
* --- set_new
* -------------------------------------------------------------------------
*/
Set* set_prod_new(const Set* a, const Set* b)
{
Set* set;
assert(set_is_valid(a));
assert(set_is_valid(b));
assert(a->head.type != SET_PSEUDO);
assert(b->head.type != SET_PSEUDO);
if (a->head.type == SET_EMPTY || b->head.type == SET_EMPTY)
return set_empty_new(a->head.dim + b->head.dim);
set = calloc(1, sizeof(*set));
assert(set != NULL);
set->head.refc = 1;
set->head.dim = a->head.dim + b->head.dim;
set->head.members = a->head.members * b->head.members;
set->head.type = SET_PROD;
set->prod.set_a = set_copy(a);
set->prod.set_b = set_copy(b);
SID_set2(set->prod, SET_PROD_SID);
assert(set_prod_is_valid(set));
return set;
}
/* -------------------------------------------------------------------------
* --- copy
* -------------------------------------------------------------------------
*/
static Set* set_prod_copy(const Set* source)
{
Set* set = (Set*)source;
set->head.refc++;
(void)set_copy(set->prod.set_a);
(void)set_copy(set->prod.set_b);
return set;
}
/* -------------------------------------------------------------------------
* --- set_free
* -------------------------------------------------------------------------
*/
static void set_prod_free(Set* set)
{
assert(set_prod_is_valid(set));
set_free(set->prod.set_a);
set_free(set->prod.set_b);
set->head.refc--;
if (set->head.refc == 0)
{
SID_del2(set->prod);
free(set);
}
}
/* -------------------------------------------------------------------------
* --- lookup
* -------------------------------------------------------------------------
*/
/* Return index number of element. -1 if not present
*/
static int set_prod_lookup_idx(const Set* set, const Tuple* tuple, int offset)
{
int idx_a;
int idx_b;
assert(set_prod_is_valid(set));
assert(tuple_is_valid(tuple));
assert(offset >= 0);
assert(offset < tuple_get_dim(tuple));
idx_a = set_lookup_idx(set->prod.set_a, tuple, offset);
if (idx_a < 0)
return -1;
offset += set->prod.set_a->head.dim;
idx_b = set_lookup_idx(set->prod.set_b, tuple, offset);
if (idx_b < 0)
return -1;
return idx_a * set->prod.set_b->head.members + idx_b;
}
/* -------------------------------------------------------------------------
* --- get_tuple
* -------------------------------------------------------------------------
*/
static void set_prod_get_tuple(
const Set* set,
int idx,
Tuple* tuple,
int offset)
{
const Set* a;
const Set* b;
int offset2;
assert(set_prod_is_valid(set));
assert(idx >= 0);
assert(idx <= set->head.members);
assert(tuple_is_valid(tuple));
assert(offset >= 0);
assert(offset + set->head.dim <= tuple_get_dim(tuple));
a = set->prod.set_a;
b = set->prod.set_b;
offset2 = offset + a->head.dim;
set_get_tuple_intern(a, idx / b->head.members, tuple, offset);
set_get_tuple_intern(b, idx % b->head.members, tuple, offset2);
}
/* -------------------------------------------------------------------------
* --- iter_init
* -------------------------------------------------------------------------
*/
/* Initialise Iterator. Write into iter
*/
static SetIter* set_prod_iter_init(
const Set* set,
const Tuple* pattern,
int offset)
{
SetIter* iter;
assert(set_prod_is_valid(set));
assert(pattern == NULL || tuple_is_valid(pattern));
assert(offset >= 0);
assert(pattern == NULL || offset < tuple_get_dim(pattern));
iter = calloc(1, sizeof(*iter));
assert(iter != NULL);
iter->prod.elem = calloc(set->head.dim, sizeof(*iter->prod.elem));
assert(iter->prod.elem != NULL);
iter->prod.first = TRUE;
iter->prod.iter_a = set_iter_init_intern(set->prod.set_a, pattern, offset);
iter->prod.iter_b = set_iter_init_intern(set->prod.set_b, pattern,
offset + set->prod.set_a->head.dim);
SID_set2(iter->prod, SET_PROD_ITER_SID);
assert(set_prod_iter_is_valid(iter));
return iter;
}
/* -------------------------------------------------------------------------
* --- iter_next
* -------------------------------------------------------------------------
*/
/* This gets the fore part of the product and saves it and
* also gets the back part
*/
static Bool get_both_parts(
const Set* a,
const Set* b,
SetIter* iter,
SetIter* iter_a,
SetIter* iter_b,
Tuple* tuple,
int offset,
int offset2)
{
int i;
if (!set_iter_next_intern(iter_a, a, tuple, offset))
return FALSE;
for(i = 0; i < a->head.dim; i++)
{
assert(iter->prod.elem[i] == NULL);
iter->prod.elem[i] = elem_copy(tuple_get_elem(tuple, i + offset));
assert(elem_is_valid(iter->prod.elem[i]));
}
if (!set_iter_next_intern(iter_b, b, tuple, offset2))
return FALSE;
return TRUE;
}
/* FALSE means, there is no further element
*/
/*ARGSUSED*/
static Bool set_prod_iter_next(
SetIter* iter,
const Set* set,
Tuple* tuple,
int offset)
{
Set* a;
Set* b;
SetIter* iter_a;
SetIter* iter_b;
int offset2;
int i;
assert(set_prod_iter_is_valid(iter));
assert(set_prod_is_valid(set));
assert(tuple_is_valid(tuple));
assert(offset >= 0);
assert(offset + set->head.dim <= tuple_get_dim(tuple));
a = set->prod.set_a;
b = set->prod.set_b;
iter_a = iter->prod.iter_a;
iter_b = iter->prod.iter_b;
offset2 = offset + a->head.dim;
if (iter->prod.first)
{
iter->prod.first = FALSE;
return get_both_parts(a, b, iter, iter_a, iter_b, tuple, offset, offset2);
}
assert(!iter->prod.first);
/* Get back part
*/
if (set_iter_next_intern(iter_b, b, tuple, offset2))
{
/* copy fore part
*/
for(i = 0; i < a->head.dim; i++)
tuple_set_elem(tuple, i + offset, elem_copy(iter->prod.elem[i]));
return TRUE;
}
/* No back part, so reset it
*/
set_iter_reset_intern(iter_b, b);
/* Clear elem cache
*/
for(i = 0; i < set->head.dim; i++)
{
if (iter->prod.elem[i] != NULL)
{
elem_free(iter->prod.elem[i]);
iter->prod.elem[i] = NULL;
}
}
return get_both_parts(a, b, iter, iter_a, iter_b, tuple, offset, offset2);
}
/* -------------------------------------------------------------------------
* --- iter_exit
* -------------------------------------------------------------------------
*/
/*ARGSUSED*/
static void set_prod_iter_exit(SetIter* iter, const Set* set)
{
int i;
assert(set_prod_iter_is_valid(iter));
assert(set_prod_is_valid(set));
SID_del2(iter->prod);
set_iter_exit_intern(iter->prod.iter_a, set->prod.set_a);
set_iter_exit_intern(iter->prod.iter_b, set->prod.set_b);
for(i = 0; i < set->head.dim; i++)
if (iter->prod.elem[i] != NULL)
elem_free(iter->prod.elem[i]);
free(iter->prod.elem);
free(iter);
}
/* -------------------------------------------------------------------------
* --- iter_reset
* -------------------------------------------------------------------------
*/
/*ARGSUSED*/
static void set_prod_iter_reset(SetIter* iter, const Set* set)
{
assert(set_prod_iter_is_valid(iter));
assert(set_prod_is_valid(set));
iter->prod.first = TRUE;
set_iter_reset_intern(iter->prod.iter_a, set->prod.set_a);
set_iter_reset_intern(iter->prod.iter_b, set->prod.set_b);
}
/* -------------------------------------------------------------------------
* --- vtab_init
* -------------------------------------------------------------------------
*/
void set_prod_init(SetVTab* vtab)
{
vtab[SET_PROD].set_copy = set_prod_copy;
vtab[SET_PROD].set_free = set_prod_free;
vtab[SET_PROD].set_lookup_idx = set_prod_lookup_idx;
vtab[SET_PROD].set_get_tuple = set_prod_get_tuple;
vtab[SET_PROD].iter_init = set_prod_iter_init;
vtab[SET_PROD].iter_next = set_prod_iter_next;
vtab[SET_PROD].iter_exit = set_prod_iter_exit;
vtab[SET_PROD].iter_reset = set_prod_iter_reset;
vtab[SET_PROD].set_is_valid = set_prod_is_valid;
}
zimpl-3.3.4/src/load.c 0000640 0012352 0006025 00000016023 13057565713 014414 0 ustar bzfgamra optimi /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* File....: load.c */
/* Name....: Modell Loading Routines */
/* Author..: Thorsten Koch */
/* Copyright by Author, All rights reserved */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Copyright (C) 2001-2017 by Thorsten Koch
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include
#include
#include
#include
#include
#include "lint.h"
#include "bool.h"
#include "mshell.h"
#include "mme.h"
#include "stmt.h"
#include "prog.h"
#include "metaio.h"
#define BUF_EXT 65536
/* cpp leaves comments like
# 1 "test1.zpl"
# 1 ""
# 1 ""
# 1 "test1.zpl"
the routine tries to grap the linenumber.
*/
static void skip_comment(const MFP* fp, int* lineno)
{
int k = 0;
int c;
(*lineno)++;
do { c = mio_getc(fp); } while(!isdigit(c) && c != EOF && c != '\n');
while(isdigit(c))
{
k = 10 * k + c - '0';
c = mio_getc(fp);
}
if (c == ' ')
{
c = mio_getc(fp);
if (c == '\"')
{
c = mio_getc(fp);
if (c == '<')
{
*lineno = k - 1;
}
}
}
while(c != EOF && c != '\n')
c = mio_getc(fp);
}
static char* get_line(char** buf, int* size, const MFP* fp, int* lineno)
{
Bool in_string = FALSE;
int cnt = 0;
for(;;)
{
int c;
assert(cnt <= *size);
if (cnt == *size - 1)
{
*size += BUF_EXT;
*buf = realloc(*buf, (size_t)*size);
}
assert(*buf != NULL);
c = mio_getc(fp);
if (in_string && ((c == EOF) || c == '\n'))
{
fprintf(stderr, "*** Error 161: Line %d: Unterminated string\n", *lineno);
zpl_exit(EXIT_FAILURE);
}
if (c == EOF)
{
if (cnt > 0)
{
(*buf)[cnt] = '\0';
if (stmt_trigger_warning(162))
fprintf(stderr, "--- Warning 162: Line %d: Trailing \"%.20s\" ignored\n",
*lineno, *buf);
}
return NULL;
}
if (c == '\n')
{
c = ' ';
(*lineno)++;
}
if (iscntrl(c))
c = ' ';
/* Skip leading white space
*/
if (cnt == 0 && isspace(c))
continue;
if (c == '"')
in_string = !in_string;
/* Remove comments
*/
if (!in_string && (c == '#'))
{
skip_comment(fp, lineno);
/* do { c = mio_getc(fp); } while((c != EOF) && (c != '\n'));
(*lineno)++;
*/
continue;
}
(*buf)[cnt++] = (char)c;
if (!in_string && (c == ';'))
break;
}
(*buf)[cnt] = '\0';
return *buf;
}
static const char* make_pathname(
char* target,
const char* pathname,
const char* filename)
{
assert(target != NULL);
assert(pathname != NULL);
assert(filename != NULL);
/* Absolute Name ? */
if (*filename == DIRSEP)
strcpy(target, filename);
else
{
char* s;
strcpy(target, pathname);
if (NULL == (s = strrchr(target, DIRSEP)))
strcpy(target, filename);
else
strcpy(s + 1, filename);
}
return target;
}
static void add_stmt(
Prog* prog,
const char* filename,
const int lineno,
const char* text)
{
StmtType type = STMT_ERR;
assert(prog != NULL);
assert(filename != NULL);
assert(text != NULL);
if (!strncmp(text, "set", 3) && isspace(text[3]))
type = STMT_SET;
else if (!strncmp(text, "param", 5) && isspace(text[5]))
type = STMT_PARAM;
else if (!strncmp(text, "var", 3) && isspace(text[3]))
type = STMT_VAR;
else if (!strncmp(text, "minimize", 8) && isspace(text[8]))
type = STMT_MIN;
else if (!strncmp(text, "maximize", 8) && isspace(text[8]))
type = STMT_MAX;
else if (!strncmp(text, "subto", 5) && isspace(text[5]))
type = STMT_CONS;
else if (!strncmp(text, "defnumb", 7) && isspace(text[7]))
type = STMT_DEF;
else if (!strncmp(text, "defstrg", 7) && isspace(text[7]))
type = STMT_DEF;
else if (!strncmp(text, "defbool", 7) && isspace(text[7]))
type = STMT_DEF;
else if (!strncmp(text, "defset", 6) && isspace(text[6]))
type = STMT_DEF;
else if (!strncmp(text, "do", 2) && isspace(text[2]))
type = STMT_DO;
else if (!strncmp(text, "sos", 3) && isspace(text[3]))
type = STMT_SOS;
else
{
fprintf(stderr, "*** Error 163: Line %d: Syntax Error\n", lineno);
show_source(stderr, text, 1);
zpl_exit(EXIT_FAILURE);
}
prog_add_stmt(prog, stmt_new(type, filename, lineno, text));
}
void prog_load(Prog* prog, const char* cmdpipe, const char* filename)
{
int bufsize = BUF_EXT;
char* buf = malloc((size_t)bufsize);
MFP* fp;
char* s;
int lineno = 1;
char newname [1024];
char* temp;
char* myfilename;
assert(prog != NULL);
assert(filename != NULL);
assert(buf != NULL);
assert(filename != NULL);
if (cmdpipe == NULL)
myfilename = strdup(filename);
else
{
myfilename = malloc(strlen(filename) + strlen(cmdpipe) + 1024);
sprintf(&myfilename[1], cmdpipe, filename);
myfilename[0] = '#';
}
if (NULL == (fp = mio_open(myfilename, ".zpl")))
zpl_exit(EXIT_FAILURE);
if (verbose)
printf("Reading %s\n", myfilename);
while((s = get_line(&buf, &bufsize, fp, &lineno)) != NULL)
{
assert(!isspace(*s));
/* This could happen if we have a ;; somewhere.
*/
if (*s == '\0')
continue;
if (1 == sscanf(s, "include \"%1023[^\"]\"", newname))
{
temp = malloc(strlen(filename) + strlen(newname) + 2);
prog_load(prog, cmdpipe, make_pathname(temp, filename, newname));
free(temp);
}
else
{
add_stmt(prog, filename, lineno, s);
}
}
mio_close(fp);
free(myfilename);
free(buf);
}
zimpl-3.3.4/src/list.c 0000640 0012352 0006025 00000022206 13057565713 014450 0 ustar bzfgamra optimi /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* File....: list.c */
/* Name....: List Functions */
/* Author..: Thorsten Koch */
/* Copyright by Author, All rights reserved */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Copyright (C) 2001-2017 by Thorsten Koch
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include
#include
#include
#include
#include "bool.h"
#include "mshell.h"
#include "blkmem.h"
#include "ratlptypes.h"
#include "numb.h"
#include "elem.h"
#include "tuple.h"
#include "mme.h"
#include "entry.h"
#include "list.h"
#define LIST_SID 0x4c697374
enum list_type
{
LIST_ERR = 0, LIST_ELEM, LIST_TUPLE, LIST_ENTRY, LIST_IDXELEM, LIST_LIST
};
typedef enum list_type ListType;
typedef union list_data ListData;
union list_data
{
Entry* entry;
Tuple* tuple;
Elem* elem;
List* list;
};
struct list_element
{
ListData data;
ListElem* prev;
ListElem* next;
};
struct list
{
SID
int refc;
int elems;
ListType type;
ListElem anchor;
};
static void list_add_data(List* list, const ListData* data)
{
ListElem* elem = blk_alloc(sizeof(*elem));
assert(list_is_valid(list));
assert(elem != NULL);
assert(data != NULL);
elem->data = *data;
elem->next = &list->anchor;
elem->prev = list->anchor.prev;
list->anchor.prev->next = elem;
list->anchor.prev = elem;
list->elems++;
}
static void list_insert_data(List* list, const ListData* data)
{
ListElem* elem = blk_alloc(sizeof(*elem));
assert(list_is_valid(list));
assert(elem != NULL);
assert(data != NULL);
elem->data = *data;
elem->next = list->anchor.next;
elem->prev = &list->anchor;
list->anchor.next->prev = elem;
list->anchor.next = elem;
list->elems++;
}
static List* list_new(ListType type, const ListData* data)
{
List* list = calloc(1, sizeof(*list));
assert(list != NULL);
assert(data != NULL);
list->refc = 1;
list->elems = 0;
list->type = type;
list->anchor.prev = &list->anchor;
list->anchor.next = &list->anchor;
SID_set(list, LIST_SID);
assert(list_is_valid(list));
list_add_data(list, data);
return list;
}
List* list_new_elem(const Elem* elem)
{
ListData data;
assert(elem_is_valid(elem));
data.elem = elem_copy(elem);
return list_new(LIST_ELEM, &data);
}
List* list_new_tuple(const Tuple* tuple)
{
ListData data;
assert(tuple_is_valid(tuple));
data.tuple = tuple_copy(tuple);
return list_new(LIST_TUPLE, &data);
}
List* list_new_entry(const Entry* entry)
{
ListData data;
assert(entry_is_valid(entry));
data.entry = entry_copy(entry);
return list_new(LIST_ENTRY, &data);
}
List* list_new_list(const List* list)
{
ListData data;
assert(list_is_valid(list));
data.list = list_copy(list);
return list_new(LIST_LIST, &data);
}
void list_free(List* list)
{
ListElem* p;
ListElem* q;
assert(list_is_valid(list));
list->refc--;
if (list->refc == 0)
{
SID_del(list);
for(p = list->anchor.next; p != &list->anchor; p = q)
{
q = p->next;
switch(list->type)
{
case LIST_ELEM :
elem_free(p->data.elem);
break;
case LIST_TUPLE :
tuple_free(p->data.tuple);
break;
case LIST_ENTRY :
entry_free(p->data.entry);
break;
case LIST_IDXELEM :
break;
case LIST_LIST :
list_free(p->data.list);
break;
default :
abort();
}
blk_free(p, sizeof(*p));
}
free(list);
}
}
Bool list_is_valid(const List* list)
{
return ((list != NULL) && SID_ok(list, LIST_SID) && (list->refc > 0));
}
Bool list_is_elemlist(const List* list)
{
assert(list_is_valid(list));
return list->type == LIST_ELEM;
}
Bool list_is_entrylist(const List* list)
{
assert(list_is_valid(list));
return list->type == LIST_ENTRY;
}
Bool list_is_tuplelist(const List* list)
{
assert(list_is_valid(list));
return list->type == LIST_TUPLE;
}
List* list_copy(const List* source)
{
List* list = (List*)source;
assert(list_is_valid(list));
list->refc++;
return list;
}
void list_add_elem(List* list, const Elem* elem)
{
ListData data;
assert(list_is_valid(list));
assert(elem_is_valid(elem));
assert(list->type == LIST_ELEM);
data.elem = elem_copy(elem);
list_add_data(list, &data);
}
void list_insert_elem(List* list, const Elem* elem)
{
ListData data;
assert(list_is_valid(list));
assert(elem_is_valid(elem));
assert(list->type == LIST_ELEM);
data.elem = elem_copy(elem);
list_insert_data(list, &data);
}
void list_add_tuple(List* list, const Tuple* tuple)
{
ListData data;
assert(list_is_valid(list));
assert(tuple_is_valid(tuple));
assert(list->type == LIST_TUPLE);
data.tuple = tuple_copy(tuple);
list_add_data(list, &data);
}
void list_insert_tuple(List* list, const Tuple* tuple)
{
ListData data;
assert(list_is_valid(list));
assert(tuple_is_valid(tuple));
assert(list->type == LIST_TUPLE);
data.tuple = tuple_copy(tuple);
list_insert_data(list, &data);
}
void list_add_entry(List* list, const Entry* entry)
{
ListData data;
assert(list_is_valid(list));
assert(entry_is_valid(entry));
assert(list->type == LIST_ENTRY);
data.entry = entry_copy(entry);
list_add_data(list, &data);
}
void list_insert_entry(List* list, const Entry* entry)
{
ListData data;
assert(list_is_valid(list));
assert(entry_is_valid(entry));
assert(list->type == LIST_ENTRY);
data.entry = entry_copy(entry);
list_insert_data(list, &data);
}
void list_add_list(List* list, const List* ll)
{
ListData data;
assert(list_is_valid(list));
assert(list_is_valid(ll));
assert(list->type == LIST_LIST);
data.list = list_copy(ll);
list_add_data(list, &data);
}
int list_get_elems(const List* list)
{
assert(list_is_valid(list));
return list->elems;
}
static ListData* list_get_data(const List* list, ListElem** idxp)
{
assert(list_is_valid(list));
assert(idxp != NULL);
if (*idxp == NULL)
*idxp = list->anchor.next;
if (*idxp == &list->anchor)
return NULL;
*idxp = (*idxp)->next;
return &((*idxp)->prev->data);
}
const Elem* list_get_elem(const List* list, ListElem** idxp)
{
ListData* data;
assert(list_is_valid(list));
assert(list->type == LIST_ELEM);
assert(idxp != NULL);
data = list_get_data(list, idxp);
return (data == NULL) ? ELEM_NULL : data->elem;
}
const Tuple* list_get_tuple(const List* list, ListElem** idxp)
{
ListData* data;
assert(list_is_valid(list));
assert(list->type == LIST_TUPLE);
assert(idxp != NULL);
data = list_get_data(list, idxp);
return (data == NULL) ? TUPLE_NULL : data->tuple;
}
const Entry* list_get_entry(const List* list, ListElem** idxp)
{
ListData* data;
assert(list_is_valid(list));
assert(list->type == LIST_ENTRY);
assert(idxp != NULL);
data = list_get_data(list, idxp);
return (data == NULL) ? ENTRY_NULL : data->entry;
}
const List* list_get_list(const List* list, ListElem** idxp)
{
ListData* data;
assert(list_is_valid(list));
assert(list->type == LIST_LIST);
assert(idxp != NULL);
data = list_get_data(list, idxp);
return (data == NULL) ? LIST_NULL : data->list;
}
void list_print(FILE* fp, const List* list)
{
ListElem* le;
for(le = list->anchor.next; le != &list->anchor; le = le->next)
{
switch(list->type)
{
case LIST_ELEM :
elem_print(fp, le->data.elem, TRUE);
break;
case LIST_TUPLE :
tuple_print(fp, le->data.tuple);
break;
case LIST_ENTRY :
entry_print(fp, le->data.entry);
break;
case LIST_LIST :
list_print(fp, le->data.list);
break;
default :
abort();
}
fprintf(fp, "\n");
}
}
zimpl-3.3.4/src/mmlparse2.c 0000640 0012352 0006025 00000605342 13060001515 015362 0 ustar bzfgamra optimi /* A Bison parser, made by GNU Bison 3.0.4. */
/* Bison implementation for Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see . */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
under terms of your choice, so long as that work isn't itself a
parser generator using the skeleton or a modified version thereof
as a parser skeleton. Alternatively, if you modify or redistribute
the parser skeleton itself, you may (at your option) remove this
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
/* C LALR(1) parser skeleton written by Richard Stallman, by
simplifying the original so-called "semantic" parser. */
/* All symbols defined below should begin with yy or YY, to avoid
infringing on user name space. This should be done even for local
variables, as they might otherwise be expanded by user macros.
There are some unavoidable exceptions within include files to
define necessary library symbols; they are noted "INFRINGES ON
USER NAME SPACE" below. */
/* Identify Bison output. */
#define YYBISON 1
/* Bison version. */
#define YYBISON_VERSION "3.0.4"
/* Skeleton name. */
#define YYSKELETON_NAME "yacc.c"
/* Pure parsers. */
#define YYPURE 1
/* Push parsers. */
#define YYPUSH 0
/* Pull parsers. */
#define YYPULL 1
/* Copy the first part of user declarations. */
#line 1 "src/mmlparse2.y" /* yacc.c:339 */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* File....: mmlparse2.y */
/* Name....: MML Parser */
/* Author..: Thorsten Koch */
/* Copyright by Author, All rights reserved */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Copyright (C) 2001-2017 by Thorsten Koch
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/*lint -e428 -e433 -e506 -e514 -e525 -e527 -e537 -e568 -e574 */
/*lint -e639 -e659 -e661 -e662 -e676 -e685 */
/*lint -e713 -e717 -e732 -e734 -e737 -e744 -e750 -e751 -e753 -e762 -e764 -e774 -e778 */
/*lint -e810 -e818 -e825 -e830 */
/*lint -esym(530,yylen) */
/*lint -esym(563,yyerrorlab) */
/*lint -esym(746,__yy_memcpy) -esym(516,__yy_memcpy) */
/*lint -esym(718,yylex) -esym(746,yylex) */
/*lint -esym(644,yyval,yylval) -esym(645,yylval) -esym(550,yynerrs) */
/*lint -esym(553,__GNUC__) -esym(578,yylen) */
/*lint -esym(768,bits) -esym(553,YYSTACK_USE_ALLOCA) */
/*lint -esym(593,yymsg) Custodial pointer possibly not freed */
/*lint -esym(426,mem_malloc) call violates semantics */
#pragma clang diagnostic ignored "-Wdisabled-macro-expansion"
#pragma clang diagnostic ignored "-Wconversion"
#pragma clang diagnostic ignored "-Wsign-conversion"
#pragma clang diagnostic ignored "-Wunused-macros"
#pragma clang diagnostic ignored "-Wimplicit-function-declaration"
#pragma clang diagnostic ignored "-Wunreachable-code"
#include
#include
#include
#include
#include "bool.h"
#include "mshell.h"
#include "ratlptypes.h"
#include "numb.h"
#include "elem.h"
#include "tuple.h"
#include "mme.h"
#include "set.h"
#include "symbol.h"
#include "entry.h"
#include "idxset.h"
#include "rdefpar.h"
#include "bound.h"
#include "define.h"
#include "mono.h"
#include "term.h"
#include "list.h"
#include "stmt.h"
#include "local.h"
#include "code.h"
#include "inst.h"
#define YYERROR_VERBOSE 1
/* the function is actually getting a YYSTYPE* as argument, but the
* type isn't available here, so it is decalred to accept any number of
* arguments, i.e. yylex() and not yylex(void).
*/
extern int yylex();
/*lint -sem(yyerror, 1p && nulterm(1), r_no) */
extern void yyerror(const char* s);
#line 153 "src/mmlparse2.c" /* yacc.c:339 */
# ifndef YY_NULLPTR
# if defined __cplusplus && 201103L <= __cplusplus
# define YY_NULLPTR nullptr
# else
# define YY_NULLPTR 0
# endif
# endif
/* Enabling verbose error messages. */
#ifdef YYERROR_VERBOSE
# undef YYERROR_VERBOSE
# define YYERROR_VERBOSE 1
#else
# define YYERROR_VERBOSE 0
#endif
/* In a future release of Bison, this section will be replaced
by #include "mmlparse2.h". */
#ifndef YY_YY_SRC_MMLPARSE2_H_INCLUDED
# define YY_YY_SRC_MMLPARSE2_H_INCLUDED
/* Debug traces. */
#ifndef YYDEBUG
# define YYDEBUG 1
#endif
#if YYDEBUG
extern int yydebug;
#endif
/* Token type. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
enum yytokentype
{
DECLSET = 258,
DECLPAR = 259,
DECLVAR = 260,
DECLMIN = 261,
DECLMAX = 262,
DECLSUB = 263,
DECLSOS = 264,
DEFNUMB = 265,
DEFSTRG = 266,
DEFBOOL = 267,
DEFSET = 268,
PRINT = 269,
CHECK = 270,
BINARY = 271,
INTEGER = 272,
REAL = 273,
IMPLICIT = 274,
ASGN = 275,
DO = 276,
WITH = 277,
IN = 278,
TO = 279,
UNTIL = 280,
BY = 281,
FORALL = 282,
EXISTS = 283,
PRIORITY = 284,
STARTVAL = 285,
DEFAULT = 286,
CMP_LE = 287,
CMP_GE = 288,
CMP_EQ = 289,
CMP_LT = 290,
CMP_GT = 291,
CMP_NE = 292,
INFTY = 293,
AND = 294,
OR = 295,
XOR = 296,
NOT = 297,
SUM = 298,
MIN = 299,
MAX = 300,
ARGMIN = 301,
ARGMAX = 302,
PROD = 303,
IF = 304,
THEN = 305,
ELSE = 306,
END = 307,
INTER = 308,
UNION = 309,
CROSS = 310,
SYMDIFF = 311,
WITHOUT = 312,
PROJ = 313,
MOD = 314,
DIV = 315,
POW = 316,
FAC = 317,
CARD = 318,
ROUND = 319,
FLOOR = 320,
CEIL = 321,
RANDOM = 322,
ORD = 323,
ABS = 324,
SGN = 325,
LOG = 326,
LN = 327,
EXP = 328,
SQRT = 329,
SIN = 330,
COS = 331,
TAN = 332,
ASIN = 333,
ACOS = 334,
ATAN = 335,
POWER = 336,
SGNPOW = 337,
READ = 338,
AS = 339,
SKIP = 340,
USE = 341,
COMMENT = 342,
MATCH = 343,
SUBSETS = 344,
INDEXSET = 345,
POWERSET = 346,
VIF = 347,
VABS = 348,
TYPE1 = 349,
TYPE2 = 350,
LENGTH = 351,
SUBSTR = 352,
NUMBSYM = 353,
STRGSYM = 354,
VARSYM = 355,
SETSYM = 356,
NUMBDEF = 357,
STRGDEF = 358,
BOOLDEF = 359,
SETDEF = 360,
DEFNAME = 361,
NAME = 362,
STRG = 363,
NUMB = 364,
SCALE = 365,
SEPARATE = 366,
CHECKONLY = 367,
INDICATOR = 368
};
#endif
/* Value type. */
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
union YYSTYPE
{
#line 91 "src/mmlparse2.y" /* yacc.c:355 */
unsigned int bits;
Numb* numb;
const char* strg;
const char* name;
Symbol* sym;
Define* def;
CodeNode* code;
#line 317 "src/mmlparse2.c" /* yacc.c:355 */
};
typedef union YYSTYPE YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define YYSTYPE_IS_DECLARED 1
#endif
int yyparse (void);
#endif /* !YY_YY_SRC_MMLPARSE2_H_INCLUDED */
/* Copy the second part of user declarations. */
#line 333 "src/mmlparse2.c" /* yacc.c:358 */
#ifdef short
# undef short
#endif
#ifdef YYTYPE_UINT8
typedef YYTYPE_UINT8 yytype_uint8;
#else
typedef unsigned char yytype_uint8;
#endif
#ifdef YYTYPE_INT8
typedef YYTYPE_INT8 yytype_int8;
#else
typedef signed char yytype_int8;
#endif
#ifdef YYTYPE_UINT16
typedef YYTYPE_UINT16 yytype_uint16;
#else
typedef unsigned short int yytype_uint16;
#endif
#ifdef YYTYPE_INT16
typedef YYTYPE_INT16 yytype_int16;
#else
typedef short int yytype_int16;
#endif
#ifndef YYSIZE_T
# ifdef __SIZE_TYPE__
# define YYSIZE_T __SIZE_TYPE__
# elif defined size_t
# define YYSIZE_T size_t
# elif ! defined YYSIZE_T
# include /* INFRINGES ON USER NAME SPACE */
# define YYSIZE_T size_t
# else
# define YYSIZE_T unsigned int
# endif
#endif
#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
#ifndef YY_
# if defined YYENABLE_NLS && YYENABLE_NLS
# if ENABLE_NLS
# include /* INFRINGES ON USER NAME SPACE */
# define YY_(Msgid) dgettext ("bison-runtime", Msgid)
# endif
# endif
# ifndef YY_
# define YY_(Msgid) Msgid
# endif
#endif
#ifndef YY_ATTRIBUTE
# if (defined __GNUC__ \
&& (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \
|| defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
# define YY_ATTRIBUTE(Spec) __attribute__(Spec)
# else
# define YY_ATTRIBUTE(Spec) /* empty */
# endif
#endif
#ifndef YY_ATTRIBUTE_PURE
# define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__))
#endif
#ifndef YY_ATTRIBUTE_UNUSED
# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
#endif
#if !defined _Noreturn \
&& (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
# if defined _MSC_VER && 1200 <= _MSC_VER
# define _Noreturn __declspec (noreturn)
# else
# define _Noreturn YY_ATTRIBUTE ((__noreturn__))
# endif
#endif
/* Suppress unused-variable warnings by "using" E. */
#if ! defined lint || defined __GNUC__
# define YYUSE(E) ((void) (E))
#else
# define YYUSE(E) /* empty */
#endif
#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
/* Suppress an incorrect diagnostic about yylval being uninitialized. */
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
_Pragma ("GCC diagnostic push") \
_Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
_Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
_Pragma ("GCC diagnostic pop")
#else
# define YY_INITIAL_VALUE(Value) Value
#endif
#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
# define YY_IGNORE_MAYBE_UNINITIALIZED_END
#endif
#ifndef YY_INITIAL_VALUE
# define YY_INITIAL_VALUE(Value) /* Nothing. */
#endif
#if ! defined yyoverflow || YYERROR_VERBOSE
/* The parser invokes alloca or malloc; define the necessary symbols. */
# ifdef YYSTACK_USE_ALLOCA
# if YYSTACK_USE_ALLOCA
# ifdef __GNUC__
# define YYSTACK_ALLOC __builtin_alloca
# elif defined __BUILTIN_VA_ARG_INCR
# include /* INFRINGES ON USER NAME SPACE */
# elif defined _AIX
# define YYSTACK_ALLOC __alloca
# elif defined _MSC_VER
# include /* INFRINGES ON USER NAME SPACE */
# define alloca _alloca
# else
# define YYSTACK_ALLOC alloca
# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
# include /* INFRINGES ON USER NAME SPACE */
/* Use EXIT_SUCCESS as a witness for stdlib.h. */
# ifndef EXIT_SUCCESS
# define EXIT_SUCCESS 0
# endif
# endif
# endif
# endif
# endif
# ifdef YYSTACK_ALLOC
/* Pacify GCC's 'empty if-body' warning. */
# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
# ifndef YYSTACK_ALLOC_MAXIMUM
/* The OS might guarantee only one guard page at the bottom of the stack,
and a page size can be as small as 4096 bytes. So we cannot safely
invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
to allow for a few compiler-allocated temporary stack slots. */
# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
# endif
# else
# define YYSTACK_ALLOC YYMALLOC
# define YYSTACK_FREE YYFREE
# ifndef YYSTACK_ALLOC_MAXIMUM
# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
# endif
# if (defined __cplusplus && ! defined EXIT_SUCCESS \
&& ! ((defined YYMALLOC || defined malloc) \
&& (defined YYFREE || defined free)))
# include /* INFRINGES ON USER NAME SPACE */
# ifndef EXIT_SUCCESS
# define EXIT_SUCCESS 0
# endif
# endif
# ifndef YYMALLOC
# define YYMALLOC malloc
# if ! defined malloc && ! defined EXIT_SUCCESS
void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
# endif
# endif
# ifndef YYFREE
# define YYFREE free
# if ! defined free && ! defined EXIT_SUCCESS
void free (void *); /* INFRINGES ON USER NAME SPACE */
# endif
# endif
# endif
#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
#if (! defined yyoverflow \
&& (! defined __cplusplus \
|| (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
/* A type that is properly aligned for any stack member. */
union yyalloc
{
yytype_int16 yyss_alloc;
YYSTYPE yyvs_alloc;
};
/* The size of the maximum gap between one aligned stack and the next. */
# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
/* The size of an array large to enough to hold all stacks, each with
N elements. */
# define YYSTACK_BYTES(N) \
((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
+ YYSTACK_GAP_MAXIMUM)
# define YYCOPY_NEEDED 1
/* Relocate STACK from its old location to the new one. The
local variables YYSIZE and YYSTACKSIZE give the old and new number of
elements in the stack, and YYPTR gives the new location of the
stack. Advance YYPTR to a properly aligned location for the next
stack. */
# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
do \
{ \
YYSIZE_T yynewbytes; \
YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
Stack = &yyptr->Stack_alloc; \
yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
yyptr += yynewbytes / sizeof (*yyptr); \
} \
while (0)
#endif
#if defined YYCOPY_NEEDED && YYCOPY_NEEDED
/* Copy COUNT objects from SRC to DST. The source and destination do
not overlap. */
# ifndef YYCOPY
# if defined __GNUC__ && 1 < __GNUC__
# define YYCOPY(Dst, Src, Count) \
__builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
# else
# define YYCOPY(Dst, Src, Count) \
do \
{ \
YYSIZE_T yyi; \
for (yyi = 0; yyi < (Count); yyi++) \
(Dst)[yyi] = (Src)[yyi]; \
} \
while (0)
# endif
# endif
#endif /* !YYCOPY_NEEDED */
/* YYFINAL -- State number of the termination state. */
#define YYFINAL 40
/* YYLAST -- Last index in YYTABLE. */
#define YYLAST 3245
/* YYNTOKENS -- Number of terminals. */
#define YYNTOKENS 126
/* YYNNTS -- Number of nonterminals. */
#define YYNNTS 59
/* YYNRULES -- Number of rules. */
#define YYNRULES 307
/* YYNSTATES -- Number of states. */
#define YYNSTATES 920
/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
by yylex, with out-of-bounds checking. */
#define YYUNDEFTOK 2
#define YYMAXUTOK 368
#define YYTRANSLATE(YYX) \
((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
as returned by yylex, without out-of-bounds checking. */
static const yytype_uint8 yytranslate[] =
{
0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
121, 122, 116, 114, 120, 115, 2, 123, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 117,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 118, 2, 119, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 124, 2, 125, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
105, 106, 107, 108, 109, 110, 111, 112, 113
};
#if YYDEBUG
/* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
static const yytype_uint16 yyrline[] =
{
0, 160, 160, 161, 162, 163, 164, 165, 166, 167,
168, 169, 170, 178, 185, 191, 197, 207, 208, 211,
214, 217, 223, 232, 241, 250, 259, 268, 271, 281,
284, 287, 294, 297, 298, 305, 306, 314, 321, 330,
340, 351, 360, 370, 374, 384, 385, 386, 390, 393,
394, 395, 400, 408, 409, 410, 411, 416, 424, 425,
429, 430, 438, 439, 442, 443, 447, 451, 455, 458,
470, 473, 483, 489, 492, 495, 500, 505, 513, 516,
521, 526, 533, 537, 542, 546, 552, 555, 560, 565,
570, 574, 581, 588, 594, 600, 606, 611, 619, 628,
637, 645, 656, 659, 663, 668, 676, 677, 680, 683,
684, 687, 690, 691, 694, 697, 698, 701, 704, 705,
708, 711, 712, 715, 718, 719, 720, 721, 722, 726,
727, 731, 732, 733, 734, 738, 739, 740, 744, 745,
746, 747, 748, 751, 752, 760, 761, 762, 766, 767,
771, 772, 773, 779, 780, 783, 789, 792, 793, 794,
795, 796, 797, 798, 799, 800, 801, 802, 805, 808,
811, 819, 825, 828, 834, 835, 836, 844, 848, 849,
850, 851, 852, 853, 863, 864, 871, 874, 880, 881,
882, 885, 886, 889, 890, 893, 894, 898, 899, 900,
903, 907, 910, 915, 916, 919, 922, 925, 928, 931,
934, 937, 940, 941, 942, 943, 944, 945, 946, 949,
952, 958, 959, 963, 964, 965, 966, 970, 973, 976,
980, 981, 982, 983, 984, 985, 986, 987, 988, 989,
990, 991, 992, 993, 994, 995, 996, 997, 998, 999,
1004, 1010, 1011, 1015, 1018, 1024, 1027, 1033, 1034, 1035,
1039, 1040, 1041, 1042, 1043, 1044, 1050, 1051, 1052, 1056,
1057, 1058, 1061, 1064, 1067, 1070, 1076, 1077, 1078, 1081,
1084, 1087, 1092, 1097, 1098, 1099, 1100, 1101, 1102, 1103,
1104, 1105, 1106, 1107, 1108, 1109, 1110, 1111, 1112, 1113,
1115, 1116, 1117, 1120, 1123, 1126, 1129, 1132
};
#endif
#if YYDEBUG || YYERROR_VERBOSE || 0
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
First, the terminals, then, starting at YYNTOKENS, nonterminals. */
static const char *const yytname[] =
{
"$end", "error", "$undefined", "DECLSET", "DECLPAR", "DECLVAR",
"DECLMIN", "DECLMAX", "DECLSUB", "DECLSOS", "DEFNUMB", "DEFSTRG",
"DEFBOOL", "DEFSET", "PRINT", "CHECK", "BINARY", "INTEGER", "REAL",
"IMPLICIT", "ASGN", "DO", "WITH", "IN", "TO", "UNTIL", "BY", "FORALL",
"EXISTS", "PRIORITY", "STARTVAL", "DEFAULT", "CMP_LE", "CMP_GE",
"CMP_EQ", "CMP_LT", "CMP_GT", "CMP_NE", "INFTY", "AND", "OR", "XOR",
"NOT", "SUM", "MIN", "MAX", "ARGMIN", "ARGMAX", "PROD", "IF", "THEN",
"ELSE", "END", "INTER", "UNION", "CROSS", "SYMDIFF", "WITHOUT", "PROJ",
"MOD", "DIV", "POW", "FAC", "CARD", "ROUND", "FLOOR", "CEIL", "RANDOM",
"ORD", "ABS", "SGN", "LOG", "LN", "EXP", "SQRT", "SIN", "COS", "TAN",
"ASIN", "ACOS", "ATAN", "POWER", "SGNPOW", "READ", "AS", "SKIP", "USE",
"COMMENT", "MATCH", "SUBSETS", "INDEXSET", "POWERSET", "VIF", "VABS",
"TYPE1", "TYPE2", "LENGTH", "SUBSTR", "NUMBSYM", "STRGSYM", "VARSYM",
"SETSYM", "NUMBDEF", "STRGDEF", "BOOLDEF", "SETDEF", "DEFNAME", "NAME",
"STRG", "NUMB", "SCALE", "SEPARATE", "CHECKONLY", "INDICATOR", "'+'",
"'-'", "'*'", "';'", "'['", "']'", "','", "'('", "')'", "'/'", "'{'",
"'}'", "$accept", "stmt", "decl_set", "set_entry_list", "set_entry",
"def_numb", "def_strg", "def_bool", "def_set", "name_list", "decl_par",
"par_singleton", "par_default", "decl_var", "var_type", "lower", "upper",
"priority", "startval", "cexpr_entry_list", "cexpr_entry", "matrix_head",
"matrix_body", "decl_obj", "decl_sub", "constraint_list", "constraint",
"vbool", "con_attr_list", "con_attr", "con_type", "vexpr", "vproduct",
"vfactor", "vexpo", "vval", "decl_sos", "soset", "sos_type", "exec_do",
"command", "idxset", "pure_idxset", "sexpr", "sunion", "sproduct",
"sval", "read", "read_par", "tuple_list", "lexpr", "tuple", "symidx",
"cexpr_list", "cexpr", "cproduct", "cfactor", "cexpo", "cval", YY_NULLPTR
};
#endif
# ifdef YYPRINT
/* YYTOKNUM[NUM] -- (External) token number corresponding to the
(internal) symbol number NUM (which must be that of a token). */
static const yytype_uint16 yytoknum[] =
{
0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
365, 366, 367, 368, 43, 45, 42, 59, 91, 93,
44, 40, 41, 47, 123, 125
};
# endif
#define YYPACT_NINF -522
#define yypact_value_is_default(Yystate) \
(!!((Yystate) == (-522)))
#define YYTABLE_NINF -1
#define yytable_value_is_error(Yytable_value) \
0
/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
STATE-NUM. */
static const yytype_int16 yypact[] =
{
1403, -85, -38, -32, -24, -9, -1, 37, -16, 56,
62, 77, 65, 154, -522, -522, -522, -522, -522, -522,
-522, -522, -522, -522, -522, 4, 11, 27, 181, 185,
215, 219, 136, 182, 190, 222, 1765, 1518, 865, 208,
-522, 1281, 522, 1413, 865, 307, 316, -522, 587, 865,
316, 2608, 2608, 1601, 32, 250, 250, 250, 250, 1997,
865, 30, 39, 918, 1052, 865, 1518, 865, 865, 239,
263, 267, 281, 297, 301, 309, 315, 334, 352, 363,
391, 393, 446, 458, 469, 513, 521, 554, 561, 564,
575, 332, 332, -522, 332, 583, 592, 601, -522, -522,
-522, 3124, 3124, 2404, 1682, 1111, -522, 15, -522, -522,
537, 556, 333, -522, -522, 745, 607, 1518, 1518, 611,
1518, 630, 958, 712, 364, 1518, 1281, 728, -522, 1111,
740, -522, 708, 753, 649, 2798, 1518, 2798, 2798, 661,
680, -522, 759, 992, 2798, 556, 697, 2798, 789, 2866,
792, 736, -522, 739, 792, 865, 1518, 754, 758, 760,
783, 787, 831, 837, 839, 852, 861, 862, 870, 332,
2669, 2669, 2608, 668, 0, -522, -522, 893, 624, 344,
817, 865, 1518, 2472, 8, -522, 144, 268, 865, -522,
-522, 796, 307, -522, 106, 233, 251, 339, -522, -17,
972, 1847, 995, 1847, 997, 2404, 1000, 2404, 1005, 1011,
639, 1012, 1017, 1281, 1281, 2798, 2798, 2798, 2798, 1281,
2798, 2798, 2798, 2798, 2798, 2798, 2798, 2798, 2798, 2798,
2798, 2798, 943, 2798, 2798, 2798, -522, -522, -522, 2798,
2798, 2798, -522, -522, 579, 326, -522, -11, 992, 90,
740, 149, 25, 1281, 1281, 1281, 1281, 1281, 1281, 1042,
1042, 2798, 2798, 2798, 3063, 3063, 3063, 3063, 3063, -522,
865, -522, 833, 2798, 305, 21, 20, 1281, 1281, 1281,
1281, 1281, 1281, 1518, 1518, 1518, 1281, 2798, 2798, 2798,
2798, 2798, 2798, 866, 65, 1281, -522, 386, 1030, 13,
940, -21, -522, 1022, 2798, 759, 2798, 2798, 2798, 2798,
-522, 556, 1039, 556, 2798, 965, 1518, 1179, 556, 2065,
307, -522, 1401, 967, 1069, 955, 2608, 2608, 2608, 2608,
2608, 2608, 2608, 2608, 2608, 2608, 2608, 2608, -522, 1236,
1236, -522, -522, 737, 811, 2608, 2608, -522, 2730, 3063,
3063, 2608, 2608, 2730, -522, 1071, 962, 2472, 2472, 1008,
496, 502, 2540, -522, -522, -522, -522, 2608, 2608, 1075,
-522, 1091, 1007, 1087, 1095, 1096, 1110, -522, 2798, 1009,
346, 3063, 1018, 381, 3063, 813, 2798, 847, 2798, 3063,
2404, 1042, 910, 748, 652, 895, 915, 989, 97, 921,
1055, 1086, 1089, 1105, 1150, 1169, 1175, 1180, 1200, 1211,
1231, 1233, 1019, 1244, 213, 750, 467, 532, 578, -522,
-522, 1929, -522, 1022, -522, -522, 2798, 2798, -522, -522,
-522, -522, -522, -522, -522, -522, 556, 333, 333, -522,
-522, -522, -522, -522, 1034, 1518, 676, -522, 1111, 1111,
1111, 1111, 1111, 1111, -522, 1100, 1100, 1111, 556, 556,
556, 556, 556, 556, 1281, -522, 99, 1023, 1037, 162,
-522, 1281, 548, -522, 2798, 2798, -522, 18, 2798, 556,
556, 556, 556, 1413, 556, -522, 1121, -522, -522, 1518,
556, 789, 307, 316, 848, 316, -522, 2608, 2608, 1246,
1248, 1266, 1270, 1319, 1322, 1324, 1328, 1337, 1349, 1353,
1380, 1385, 1391, 1404, 1409, 1415, 1418, 485, 511, 1421,
865, 1518, 1051, 1053, 1054, 1057, 1073, 1076, 1084, 1093,
1108, 2608, -522, 0, 344, 0, 344, -522, -522, -522,
-522, 0, 344, 0, 344, -522, 1601, 1601, -522, 324,
252, 343, 2472, 2472, 2472, 2608, 2608, 2608, 2608, 2608,
2608, 2608, 2608, 2608, 2608, 2608, 2608, 2608, -522, 771,
624, 86, 384, 32, 2608, -522, 2798, 2798, 1518, 1281,
333, -522, -522, -522, -522, -522, -522, 865, 556, 865,
556, -522, 971, 199, -522, 15, 1022, -522, -522, -522,
-522, 2798, 2798, -522, -522, -522, -522, -522, -522, -522,
-522, -522, -522, -522, -522, -522, -522, 2798, -522, -522,
-522, -522, 1085, 105, -522, -18, -10, -522, 378, 533,
209, -522, 1518, 1281, 1281, -522, 1022, 1111, 192, 1081,
556, -522, 29, 17, 1101, 2934, 1149, 1104, 789, 792,
1113, 792, 0, 344, 357, 382, -522, -522, -522, -522,
-522, -522, -522, -522, -522, 2798, 2798, -522, 1210, 1152,
2608, 2608, 2608, 2608, 2608, 2608, 2608, 2608, 2608, 1202,
295, 44, 230, -522, -522, 1230, 1230, 144, 268, 771,
624, 771, 624, 771, 624, 771, 624, 771, 624, 771,
624, 771, 771, 771, 771, 771, 771, 1153, 1153, 2798,
2798, 1153, 2798, 2798, 1153, -522, 771, 1184, 1250, 47,
1092, 1271, 1275, 1281, 2798, 1181, 1427, 655, 706, -522,
-522, 2798, -522, 2798, -522, 1518, 958, 931, 662, -522,
-522, -522, -522, 2798, 1187, -522, 2268, 394, 2133, -522,
1214, 307, -522, 1215, 2608, 1430, 1436, 2608, 2608, 1601,
-522, 2608, 2608, 1524, 556, 556, 556, 556, -522, -522,
-522, -522, 2798, 2798, 1098, 376, -522, -522, 2798, 2798,
204, 380, 329, 2798, -522, 556, -522, 1268, 3002, 1286,
429, -522, 789, -522, 463, -522, -522, 344, 157, 355,
372, 392, 412, -522, -522, -522, -522, -522, 1153, 1153,
1153, 1153, 556, 556, -522, -522, 1455, 1485, -522, -522,
-522, 795, 2798, 2335, 2798, 2201, 1224, -522, -522, 2608,
-522, 2608, -522, 2608, -522, 2608, -522, -522, -522, 2798,
-522, 493, 1291, 507, 1297, -522, 144, 268, 1153, 144,
268, 1153, 144, 268, 1153, 144, 268, 1153, 1488, -522,
-522, -522, -522, 2608, 2608, 2608, 2608, 2608, 2608, 2608,
2608, -522, 530, 536, 541, 546, 576, 588, 596, 606,
616, 665, 677, 694, 696, 703, 735, 742, -522, -522,
-522, -522, -522, -522, -522, -522, -522, -522, -522, -522,
-522, -522, -522, -522, 1153, 1153, 1153, 1153, 1153, 1153,
1153, 1153, 1153, 1153, 1153, 1153, 1153, 1153, 1153, 1153
};
/* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
Performed when YYTABLE does not specify something else to do. Zero
means the default is an error. */
static const yytype_uint16 yydefact[] =
{
0, 0, 32, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 2, 8, 9, 10, 11, 3,
4, 5, 6, 7, 12, 0, 0, 45, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1, 0, 0, 0, 0, 58, 48, 46, 0, 0,
48, 0, 0, 0, 174, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 253, 253, 181, 253, 0, 0, 0, 278, 277,
276, 0, 0, 0, 0, 180, 188, 195, 197, 179,
178, 255, 257, 260, 266, 269, 0, 0, 0, 0,
0, 0, 182, 0, 0, 0, 0, 0, 184, 185,
0, 177, 0, 0, 0, 0, 0, 0, 0, 0,
33, 62, 0, 64, 0, 34, 0, 0, 60, 0,
53, 0, 47, 0, 53, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 253,
0, 0, 0, 0, 138, 145, 150, 153, 0, 257,
0, 0, 0, 0, 0, 73, 0, 0, 0, 175,
176, 0, 58, 27, 0, 0, 0, 0, 251, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 279, 280, 201, 0,
0, 0, 267, 268, 0, 0, 203, 0, 229, 0,
227, 0, 255, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 283,
0, 245, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 13, 0, 0, 0,
0, 0, 31, 0, 0, 65, 0, 0, 0, 0,
222, 66, 0, 59, 0, 0, 0, 0, 49, 0,
58, 40, 45, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 156, 0,
0, 151, 152, 0, 0, 0, 0, 70, 0, 0,
0, 0, 0, 0, 71, 0, 0, 0, 0, 0,
0, 0, 0, 72, 135, 136, 137, 0, 0, 0,
171, 0, 0, 0, 0, 0, 0, 252, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 212,
300, 0, 215, 0, 213, 214, 0, 0, 194, 189,
191, 193, 190, 192, 198, 199, 256, 258, 259, 263,
264, 261, 262, 270, 0, 0, 0, 246, 241, 239,
236, 240, 238, 237, 242, 243, 244, 247, 235, 233,
230, 234, 232, 231, 0, 183, 187, 0, 0, 0,
17, 0, 0, 67, 0, 0, 63, 0, 0, 223,
224, 225, 226, 0, 61, 42, 0, 50, 55, 0,
54, 60, 58, 48, 0, 48, 38, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 170, 139, 141, 140, 142, 149, 146, 147,
154, 143, 258, 144, 259, 148, 0, 0, 127, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 74, 129,
129, 129, 129, 174, 0, 28, 0, 0, 0, 0,
271, 274, 306, 272, 275, 307, 273, 0, 208, 0,
210, 265, 0, 0, 200, 196, 0, 284, 287, 288,
289, 0, 0, 285, 286, 290, 291, 292, 293, 294,
295, 296, 297, 298, 299, 219, 301, 0, 254, 281,
282, 202, 0, 0, 228, 0, 0, 248, 0, 0,
0, 249, 0, 0, 0, 16, 0, 22, 0, 0,
221, 68, 0, 35, 0, 0, 0, 0, 60, 53,
0, 53, 155, 271, 0, 0, 165, 166, 159, 161,
160, 158, 162, 163, 164, 0, 0, 157, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 75,
0, 0, 0, 128, 124, 125, 126, 0, 0, 112,
114, 115, 117, 109, 111, 118, 120, 121, 123, 106,
108, 113, 116, 110, 119, 122, 107, 78, 79, 0,
0, 80, 0, 0, 81, 173, 172, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 217,
216, 0, 205, 0, 207, 0, 186, 0, 0, 18,
15, 14, 69, 0, 0, 30, 0, 0, 0, 44,
0, 58, 39, 0, 0, 0, 0, 0, 0, 0,
76, 0, 0, 0, 129, 129, 129, 129, 23, 24,
25, 26, 0, 0, 0, 0, 218, 303, 0, 0,
0, 0, 0, 0, 21, 36, 29, 0, 0, 0,
0, 41, 60, 37, 0, 167, 168, 0, 0, 0,
0, 0, 0, 131, 132, 133, 134, 130, 82, 84,
83, 85, 209, 211, 220, 304, 0, 0, 204, 206,
250, 0, 0, 0, 0, 0, 0, 169, 77, 0,
129, 0, 129, 0, 129, 0, 129, 305, 302, 0,
19, 0, 0, 0, 0, 43, 0, 0, 102, 0,
0, 104, 0, 0, 103, 0, 0, 105, 0, 52,
51, 57, 56, 0, 0, 0, 0, 0, 0, 0,
0, 20, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 129, 129,
129, 129, 129, 129, 129, 129, 129, 129, 129, 129,
129, 129, 129, 129, 86, 90, 89, 96, 88, 95,
94, 100, 87, 93, 92, 99, 91, 98, 97, 101
};
/* YYPGOTO[NTERM-NUM]. */
static const yytype_int16 yypgoto[] =
{
-522, -522, -522, 880, 718, -522, -522, -522, -522, 996,
-522, -522, -522, -522, 1047, -41, -149, -188, -485, 873,
1080, -130, -522, -522, -522, -521, 1025, -330, 48, -522,
-96, 562, -331, -132, -522, -522, -522, 816, -522, -522,
1102, -31, 860, 269, 1398, 998, -218, 1290, -522, -522,
-8, 977, -28, 26, -36, 509, -33, -99, -522
};
/* YYDEFGOTO[NTERM-NUM]. */
static const yytype_int16 yydefgoto[] =
{
-1, 13, 14, 469, 470, 15, 16, 17, 18, 194,
19, 139, 744, 20, 50, 150, 320, 148, 315, 140,
141, 142, 305, 21, 22, 184, 185, 359, 707, 807,
367, 360, 174, 175, 176, 177, 23, 191, 192, 24,
39, 127, 128, 129, 106, 107, 108, 143, 310, 249,
122, 130, 236, 110, 178, 112, 113, 114, 115
};
/* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
positive, shift that token. If negative, reduce the rule whose
number is the opposite. If YYTABLE_NINF, syntax error. */
static const yytype_uint16 yytable[] =
{
111, 124, 242, 243, 371, 323, 647, 145, 731, 154,
421, 134, 304, 146, 533, 535, 733, 187, 153, 377,
541, 543, 25, 111, 41, 679, 680, 548, 549, 200,
124, 43, 206, 208, 209, 473, 211, 212, 341, 342,
641, 434, 435, 45, 46, 47, 48, 362, 743, 426,
427, 742, 287, 288, 289, 290, 291, 292, 210, 188,
283, 284, 285, 475, 237, 59, 238, 245, 252, 26,
259, 242, 243, 247, 59, 27, 364, 365, 366, 36,
37, 124, 124, 28, 276, 199, 283, 284, 285, 124,
32, 368, 38, 262, 263, 754, 262, 263, 29, 111,
124, 301, 245, 261, 262, 263, 30, 732, 311, 271,
272, 313, 275, 318, 422, 734, 348, 293, 709, 710,
124, 632, 42, 349, 324, 363, 189, 190, 300, 44,
251, 260, 491, 261, 262, 263, 344, 303, 261, 262,
263, 338, 420, 447, 31, 49, 124, 361, 325, 261,
355, 201, 253, 254, 40, 255, 256, 369, 345, 346,
203, 299, 33, 750, 770, 111, 652, 111, 34, 385,
379, 387, 382, 594, 356, 478, 364, 365, 366, 395,
396, 397, 398, 35, 400, 401, 402, 403, 404, 405,
406, 407, 408, 409, 410, 411, 362, 413, 414, 111,
345, 346, 51, 111, 111, 111, 52, 341, 342, 828,
423, 262, 263, 257, 258, 424, 537, 601, 243, 262,
263, 545, 684, 685, 686, 436, 372, 380, 373, 383,
730, 439, 440, 441, 442, 443, 53, 111, 798, 444,
54, 287, 288, 289, 290, 291, 292, 124, 124, 124,
724, 458, 459, 460, 461, 462, 463, 55, 345, 346,
724, 415, 364, 365, 366, 416, 417, 418, 111, 261,
479, 480, 481, 482, 425, 454, 455, 456, 484, 635,
124, 724, 636, 490, 556, 557, 558, 559, 560, 561,
500, 502, 504, 506, 508, 510, 512, 514, 516, 446,
364, 365, 366, 56, 648, 105, 121, 826, 486, 740,
132, 57, 636, 262, 263, 538, 539, 540, 262, 263,
441, 361, 551, 262, 263, 131, 187, 262, 263, 818,
477, 570, 572, 617, 362, 121, 147, 277, 278, 279,
280, 281, 282, 58, 351, 352, 759, 760, 583, 149,
588, 586, 590, 372, 593, 374, 591, 193, 253, 254,
213, 255, 256, 552, 553, 554, 345, 346, 283, 284,
285, 372, 244, 375, 532, 562, 563, 564, 565, 566,
567, 820, 351, 352, 214, 623, 121, 121, 215, 274,
625, 626, 264, 265, 121, 244, 287, 288, 289, 290,
291, 292, 216, 264, 265, 121, 829, 830, 754, 630,
277, 278, 279, 280, 281, 282, 712, 713, 217, 257,
258, 59, 218, 831, 832, 121, 652, 419, 815, 723,
219, 253, 254, 724, 255, 256, 220, 629, 593, 640,
262, 263, 111, 833, 834, 788, 683, 644, 420, 266,
235, 121, 649, 124, 651, 221, 267, 351, 352, 372,
353, 376, 655, 835, 836, 420, 261, 267, 582, 345,
346, 345, 346, 222, 244, 467, 244, 468, 262, 263,
825, 646, 393, 394, 223, 124, 351, 352, 399, 668,
262, 263, 257, 258, 262, 263, 351, 352, 351, 352,
751, 261, 753, 585, 642, 819, 345, 346, 262, 263,
187, 682, 224, 669, 225, 827, 361, 361, 361, 688,
690, 692, 694, 696, 698, 700, 351, 352, 556, 557,
558, 559, 560, 561, 562, 563, 564, 565, 566, 567,
717, 718, 124, 262, 263, 859, 448, 449, 450, 451,
452, 453, 121, 121, 121, 457, 721, 59, 722, 861,
179, 179, 179, 792, 466, 726, 727, 226, 63, 64,
719, 125, 283, 284, 285, 67, 68, 345, 346, 227,
69, 728, 888, 59, 735, 121, 368, 261, 889, 619,
228, 761, 762, 890, 63, 64, 124, 125, 891, 345,
346, 67, 68, 151, 152, 665, 69, 262, 263, 747,
345, 346, 88, 173, 180, 186, 351, 352, 708, 711,
714, 262, 263, 94, 736, 345, 346, 97, 892, 755,
756, 666, 253, 254, 229, 255, 256, 467, 88, 468,
893, 133, 230, 126, 345, 346, 104, 243, 894, 94,
351, 352, 261, 97, 620, 345, 346, 261, 895, 592,
351, 352, 277, 278, 279, 280, 281, 282, 896, 126,
262, 263, 104, 764, 765, 231, 766, 767, 283, 284,
285, 179, 232, 253, 254, 233, 255, 256, 775, 390,
345, 346, 179, 257, 258, 780, 234, 781, 261, 124,
621, 419, 351, 352, 239, 253, 254, 785, 255, 256,
345, 346, 790, 240, 628, 253, 254, 897, 255, 256,
351, 352, 241, 187, 243, 800, 802, 782, 270, 898,
345, 346, 273, 592, 343, 286, 812, 813, 351, 352,
637, 639, 816, 817, 257, 258, 899, 821, 900, 294,
863, 864, 775, 865, 866, 901, 867, 868, 121, 869,
870, 253, 254, 295, 255, 256, 257, 258, 298, 262,
263, 437, 438, 297, 597, 778, 257, 258, 302, 351,
352, 135, 345, 346, 784, 347, 841, 902, 843, 775,
121, 345, 346, 847, 903, 850, 261, 853, 631, 856,
303, 253, 254, 858, 255, 256, 268, 269, 351, 352,
345, 346, 808, 809, 810, 811, 312, 351, 352, 314,
262, 263, 257, 258, 319, 296, 779, 873, 875, 877,
879, 881, 883, 885, 887, 179, 179, 179, 179, 179,
179, 179, 179, 179, 179, 179, 179, 121, 720, 345,
346, 345, 346, 321, 534, 536, 351, 352, 322, 532,
542, 544, 257, 258, 650, 152, 179, 179, 596, 618,
261, 179, 283, 284, 285, 326, 179, 179, 848, 327,
851, 328, 854, 445, 857, 345, 346, 580, 499, 501,
503, 505, 507, 509, 511, 513, 515, 517, 518, 519,
59, 121, 737, 738, 329, 283, 284, 285, 330, 262,
263, 63, 64, 370, 125, 839, 464, 840, 67, 68,
550, 202, 204, 69, 186, 351, 352, 262, 263, 569,
571, 345, 346, 420, 354, 587, 904, 905, 906, 907,
908, 909, 910, 911, 912, 913, 914, 915, 916, 917,
918, 919, 331, 59, 350, 88, 63, 64, 332, 125,
333, 262, 263, 67, 63, 64, 94, 125, 69, 589,
97, 67, 68, 334, 253, 254, 69, 255, 256, 283,
284, 285, 335, 336, 253, 254, 126, 255, 256, 104,
474, 337, 774, 378, 283, 284, 285, 283, 284, 285,
88, 283, 284, 285, 121, 498, 653, 179, 88, 262,
263, 94, 547, 109, 123, 97, 381, 598, 384, 94,
144, 386, 723, 97, 253, 254, 388, 255, 256, 262,
263, 126, 389, 391, 104, 257, 258, 599, 392, 205,
179, 602, 104, 123, 412, 257, 258, 552, 553, 554,
472, 783, 195, 196, 197, 179, 179, 59, 555, 483,
654, 179, 179, 179, 179, 179, 179, 179, 179, 179,
179, 179, 179, 179, 179, 179, 179, 306, 307, 308,
309, 250, 485, 179, 496, 257, 258, 59, 63, 64,
497, 125, 546, 343, 123, 123, 573, 123, 63, 64,
69, 125, 123, 262, 263, 67, 68, 576, 186, 681,
69, 600, 574, 123, 575, 577, 578, 687, 689, 691,
693, 695, 697, 699, 701, 702, 703, 704, 705, 706,
579, 581, 88, 123, 253, 254, 716, 255, 256, 283,
584, 615, 88, 94, 633, 253, 254, 97, 255, 256,
814, 253, 254, 94, 255, 256, 627, 97, 634, 123,
283, 284, 285, 126, 253, 254, 104, 255, 256, 262,
263, 645, 670, 207, 671, 672, 104, 603, 673, 179,
179, 179, 179, 179, 179, 179, 179, 179, 283, 284,
285, 283, 284, 285, 674, 257, 258, 675, 741, 748,
262, 263, 758, 262, 263, 676, 257, 258, 604, 771,
729, 605, 257, 258, 677, 262, 263, 487, 745, 262,
263, 749, 60, 61, 62, 257, 258, 606, 136, 678,
752, 757, 499, 501, 503, 505, 507, 509, 511, 513,
515, 362, 70, 71, 72, 73, 74, 75, 76, 77,
78, 79, 80, 81, 82, 83, 84, 85, 86, 87,
123, 123, 123, 179, 262, 263, 797, 179, 179, 552,
179, 179, 607, 763, 471, 89, 90, 91, 92, 520,
144, 95, 96, 262, 263, 521, 98, 99, 100, 262,
263, 608, 772, 123, 262, 263, 773, 609, 262, 263,
138, 768, 610, 776, 786, 522, 523, 524, 525, 526,
527, 528, 529, 530, 262, 263, 794, 166, 167, 822,
654, 186, 611, 799, 801, 262, 263, 63, 64, 168,
125, 791, 793, 612, 67, 68, 169, 824, 179, 69,
179, 845, 179, 860, 179, 262, 263, 262, 263, 862,
339, 340, 638, 613, 739, 614, 643, 531, 262, 263,
345, 346, 351, 352, 262, 263, 616, 769, 656, 495,
603, 88, 179, 179, 179, 179, 179, 179, 179, 179,
345, 346, 94, 476, 351, 352, 97, 568, 657, 715,
595, 846, 604, 849, 248, 852, 465, 855, 622, 0,
624, 0, 126, 0, 0, 104, 1, 2, 3, 4,
5, 6, 7, 8, 9, 10, 11, 492, 493, 47,
494, 0, 123, 0, 12, 872, 874, 876, 878, 880,
882, 884, 886, 345, 346, 135, 351, 352, 345, 346,
0, 658, 351, 352, 605, 0, 659, 0, 59, 471,
606, 345, 346, 0, 0, 0, 60, 61, 62, 660,
144, 65, 136, 351, 352, 0, 123, 345, 346, 0,
0, 607, 0, 0, 0, 661, 70, 71, 72, 73,
74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
84, 85, 86, 87, 351, 352, 137, 0, 123, 345,
346, 0, 608, 0, 0, 351, 352, 662, 0, 89,
90, 91, 92, 609, 0, 95, 96, 0, 345, 346,
98, 99, 100, 351, 352, 0, 663, 101, 102, 345,
346, 610, 351, 352, 138, 345, 346, 664, 0, 0,
611, 262, 263, 667, 262, 263, 116, 0, 0, 777,
262, 263, 795, 59, 0, 123, 0, 0, 796, 0,
117, 60, 61, 62, 63, 64, 65, 118, 0, 262,
263, 67, 68, 725, 0, 0, 69, 837, 0, 0,
0, 70, 71, 72, 73, 74, 75, 76, 77, 78,
79, 80, 81, 82, 83, 84, 85, 86, 87, 262,
263, 0, 262, 263, 0, 0, 0, 838, 88, 123,
871, 0, 0, 471, 89, 90, 91, 92, 0, 94,
95, 96, 119, 97, 0, 98, 99, 100, 181, 0,
0, 0, 101, 102, 803, 804, 805, 806, 0, 120,
0, 0, 104, 0, 155, 61, 62, 0, 0, 65,
182, 428, 429, 430, 431, 432, 433, 0, 0, 0,
0, 0, 0, 0, 70, 71, 72, 73, 74, 75,
157, 158, 159, 160, 161, 162, 163, 164, 165, 85,
86, 87, 166, 167, 0, 0, 0, 0, 0, 0,
0, 0, 0, 183, 168, 0, 0, 89, 90, 91,
92, 169, 0, 95, 96, 0, 0, 0, 98, 99,
100, 0, 123, 0, 0, 170, 171, 59, 0, 0,
0, 0, 172, 0, 0, 60, 61, 62, 63, 64,
65, 66, 0, 0, 0, 67, 68, 0, 0, 0,
69, 0, 0, 0, 0, 70, 71, 72, 73, 74,
75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
85, 86, 87, 0, 0, 137, 0, 0, 0, 0,
0, 0, 88, 0, 0, 0, 0, 0, 89, 90,
91, 92, 0, 94, 95, 96, 0, 97, 0, 98,
99, 100, 0, 0, 0, 0, 101, 102, 0, 0,
59, 0, 0, 103, 0, 0, 104, 246, 60, 61,
62, 63, 64, 65, 66, 0, 0, 0, 67, 68,
0, 0, 0, 69, 0, 0, 0, 0, 70, 71,
72, 73, 74, 75, 76, 77, 78, 79, 80, 81,
82, 83, 84, 85, 86, 87, 0, 0, 0, 0,
0, 0, 0, 0, 0, 88, 0, 0, 0, 0,
0, 89, 90, 91, 92, 93, 94, 95, 96, 0,
97, 0, 98, 99, 100, 0, 0, 0, 0, 101,
102, 0, 59, 0, 0, 0, 103, 0, 0, 104,
60, 61, 62, 63, 64, 65, 66, 0, 0, 0,
67, 68, 0, 0, 0, 69, 0, 0, 0, 0,
70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
80, 81, 82, 83, 84, 85, 86, 87, 0, 0,
0, 0, 0, 0, 0, 0, 0, 88, 0, 0,
0, 0, 0, 89, 90, 91, 92, 0, 94, 95,
96, 0, 97, 0, 98, 99, 100, 0, 0, 0,
0, 101, 102, 0, 59, 0, 0, 0, 103, 0,
0, 104, 60, 61, 62, 0, 0, 65, 136, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 70, 71, 72, 73, 74, 75, 76, 77,
78, 79, 80, 81, 82, 83, 84, 85, 86, 87,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 89, 90, 91, 92, 0,
0, 95, 96, 198, 0, 0, 98, 99, 100, 0,
60, 61, 62, 101, 102, 65, 136, 0, 0, 0,
138, 0, 0, 0, 0, 0, 0, 0, 0, 0,
70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
80, 81, 82, 83, 84, 85, 86, 87, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 89, 90, 91, 92, 0, 0, 95,
96, 0, 0, 488, 98, 99, 100, 0, 60, 61,
62, 101, 102, 65, 489, 0, 0, 0, 138, 0,
0, 0, 0, 0, 0, 0, 0, 0, 70, 71,
72, 73, 74, 75, 76, 77, 78, 79, 80, 81,
82, 83, 84, 85, 86, 87, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 89, 90, 91, 92, 0, 0, 95, 96, 0,
0, 789, 98, 99, 100, 0, 60, 61, 62, 101,
102, 65, 136, 0, 0, 0, 138, 0, 0, 0,
0, 0, 0, 0, 0, 0, 70, 71, 72, 73,
74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
84, 85, 86, 87, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 89,
90, 91, 92, 0, 0, 95, 96, 0, 0, 844,
98, 99, 100, 0, 60, 61, 62, 101, 102, 65,
136, 0, 0, 0, 138, 0, 0, 0, 0, 0,
0, 0, 0, 0, 70, 71, 72, 73, 74, 75,
76, 77, 78, 79, 80, 81, 82, 83, 84, 85,
86, 87, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 89, 90, 91,
92, 0, 0, 95, 96, 0, 787, 0, 98, 99,
100, 60, 61, 62, 0, 101, 102, 136, 0, 0,
0, 0, 138, 0, 0, 0, 0, 0, 0, 0,
0, 70, 71, 72, 73, 74, 75, 76, 77, 78,
79, 80, 81, 82, 83, 84, 85, 86, 87, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 89, 90, 91, 92, 0, 0,
95, 96, 0, 842, 0, 98, 99, 100, 60, 61,
62, 0, 0, 0, 136, 0, 0, 0, 0, 138,
0, 0, 0, 0, 0, 0, 0, 0, 70, 71,
72, 73, 74, 75, 76, 77, 78, 79, 80, 81,
82, 83, 84, 85, 86, 87, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 89, 90, 91, 92, 0, 0, 95, 96, 0,
0, 0, 98, 99, 100, 0, 0, 60, 61, 62,
63, 64, 65, 66, 0, 0, 138, 67, 68, 0,
0, 0, 69, 0, 0, 0, 0, 70, 71, 72,
73, 74, 75, 76, 77, 78, 79, 80, 81, 82,
83, 84, 85, 86, 87, 0, 0, 0, 0, 0,
0, 0, 0, 0, 88, 0, 0, 0, 0, 0,
89, 90, 91, 92, 0, 94, 95, 96, 0, 97,
0, 98, 99, 100, 357, 155, 61, 62, 101, 102,
65, 156, 0, 0, 0, 103, 0, 0, 104, 0,
0, 0, 0, 0, 0, 70, 71, 72, 73, 74,
75, 157, 158, 159, 160, 161, 162, 163, 164, 165,
85, 86, 87, 166, 167, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 168, 0, 0, 89, 90,
91, 92, 169, 0, 95, 96, 0, 0, 0, 98,
99, 100, 0, 155, 61, 62, 170, 171, 65, 156,
0, 0, 0, 358, 0, 0, 0, 0, 0, 0,
0, 0, 0, 70, 71, 72, 73, 74, 75, 157,
158, 159, 160, 161, 162, 163, 164, 165, 85, 86,
87, 166, 167, 0, 0, 0, 0, 0, 0, 0,
0, 0, 183, 168, 0, 0, 89, 90, 91, 92,
169, 0, 95, 96, 0, 0, 0, 98, 99, 100,
0, 155, 61, 62, 170, 171, 65, 156, 0, 0,
0, 172, 0, 0, 0, 0, 0, 0, 0, 0,
0, 70, 71, 72, 73, 74, 75, 157, 158, 159,
160, 161, 162, 163, 164, 165, 85, 86, 87, 166,
167, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 168, 0, 0, 89, 90, 91, 92, 169, 0,
95, 96, 155, 61, 62, 98, 99, 100, 156, 0,
0, 0, 170, 171, 0, 0, 0, 0, 0, 172,
0, 0, 70, 71, 72, 73, 74, 75, 157, 158,
159, 160, 161, 162, 163, 164, 165, 85, 86, 87,
166, 167, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 168, 0, 0, 89, 90, 91, 92, 169,
0, 95, 96, 155, 61, 62, 98, 99, 100, 156,
0, 0, 0, 339, 340, 0, 0, 0, 0, 0,
172, 0, 0, 70, 71, 72, 73, 74, 75, 157,
158, 159, 160, 161, 162, 163, 164, 165, 85, 86,
87, 166, 167, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 168, 0, 0, 89, 90, 91, 92,
169, 0, 95, 96, 0, 0, 0, 98, 99, 100,
0, 60, 61, 62, 170, 171, 65, 136, 0, 0,
0, 172, 0, 0, 0, 0, 0, 0, 0, 0,
0, 70, 71, 72, 73, 74, 75, 76, 77, 78,
79, 80, 81, 82, 83, 84, 85, 86, 87, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 89, 90, 91, 92, 0, 0,
95, 96, 0, 0, 0, 98, 99, 100, 0, 60,
61, 62, 101, 102, 65, 316, 0, 0, 0, 138,
0, 0, 0, 0, 0, 0, 0, 0, 0, 70,
71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
81, 82, 83, 84, 85, 86, 87, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 89, 90, 91, 92, 0, 0, 95, 96,
0, 0, 0, 98, 99, 100, 0, 60, 61, 62,
101, 317, 65, 136, 0, 0, 0, 138, 0, 0,
0, 0, 0, 0, 0, 0, 0, 70, 71, 72,
73, 74, 75, 76, 77, 78, 79, 80, 81, 82,
83, 84, 85, 86, 87, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
89, 90, 91, 92, 0, 0, 95, 96, 0, 0,
0, 98, 99, 100, 0, 60, 61, 62, 101, 746,
65, 136, 0, 0, 0, 138, 0, 0, 0, 0,
0, 0, 0, 0, 0, 70, 71, 72, 73, 74,
75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
85, 86, 87, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 89, 90,
91, 92, 0, 0, 95, 96, 60, 61, 62, 98,
99, 100, 136, 0, 0, 0, 101, 823, 0, 0,
0, 0, 0, 138, 0, 0, 70, 71, 72, 73,
74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
84, 85, 86, 87, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 89,
90, 91, 92, 0, 0, 95, 96, 60, 61, 62,
98, 99, 100, 136, 0, 0, 0, 101, 102, 0,
0, 0, 0, 0, 138, 0, 0, 70, 71, 72,
73, 74, 75, 76, 77, 78, 79, 80, 81, 82,
83, 84, 85, 86, 87, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
89, 90, 91, 92, 0, 0, 95, 96, 0, 0,
0, 98, 99, 100, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 138
};
static const yytype_int16 yycheck[] =
{
36, 37, 101, 102, 192, 154, 491, 43, 26, 50,
21, 42, 142, 44, 345, 346, 26, 53, 49, 36,
351, 352, 107, 59, 20, 546, 547, 357, 358, 60,
66, 20, 63, 64, 65, 22, 67, 68, 170, 171,
22, 259, 260, 16, 17, 18, 19, 39, 31, 24,
25, 22, 32, 33, 34, 35, 36, 37, 66, 27,
39, 40, 41, 84, 92, 35, 94, 103, 104, 107,
55, 170, 171, 104, 35, 107, 32, 33, 34, 14,
15, 117, 118, 107, 120, 59, 39, 40, 41, 125,
106, 187, 27, 114, 115, 51, 114, 115, 107, 135,
136, 137, 138, 120, 114, 115, 107, 125, 144, 117,
118, 147, 120, 149, 125, 125, 116, 125, 32, 33,
156, 22, 118, 123, 155, 117, 94, 95, 136, 118,
104, 116, 320, 120, 114, 115, 172, 120, 120, 114,
115, 169, 122, 122, 107, 118, 182, 183, 156, 120,
181, 121, 53, 54, 0, 56, 57, 188, 114, 115,
121, 135, 106, 648, 117, 201, 497, 203, 106, 205,
201, 207, 203, 391, 182, 305, 32, 33, 34, 215,
216, 217, 218, 106, 220, 221, 222, 223, 224, 225,
226, 227, 228, 229, 230, 231, 39, 233, 234, 235,
114, 115, 21, 239, 240, 241, 21, 339, 340, 52,
120, 114, 115, 114, 115, 125, 348, 120, 317, 114,
115, 353, 552, 553, 554, 261, 120, 201, 122, 203,
125, 264, 265, 266, 267, 268, 21, 273, 759, 270,
21, 32, 33, 34, 35, 36, 37, 283, 284, 285,
51, 287, 288, 289, 290, 291, 292, 121, 114, 115,
51, 235, 32, 33, 34, 239, 240, 241, 304, 120,
306, 307, 308, 309, 125, 283, 284, 285, 314, 117,
316, 51, 120, 319, 32, 33, 34, 35, 36, 37,
326, 327, 328, 329, 330, 331, 332, 333, 334, 273,
32, 33, 34, 121, 492, 36, 37, 792, 316, 117,
41, 121, 120, 114, 115, 348, 349, 350, 114, 115,
353, 357, 358, 114, 115, 117, 362, 114, 115, 125,
304, 367, 368, 120, 39, 66, 29, 32, 33, 34,
35, 36, 37, 121, 114, 115, 51, 52, 381, 33,
386, 384, 388, 120, 390, 122, 389, 107, 53, 54,
121, 56, 57, 39, 40, 41, 114, 115, 39, 40,
41, 120, 103, 122, 122, 32, 33, 34, 35, 36,
37, 52, 114, 115, 121, 421, 117, 118, 121, 120,
426, 427, 59, 60, 125, 126, 32, 33, 34, 35,
36, 37, 121, 59, 60, 136, 51, 52, 51, 445,
32, 33, 34, 35, 36, 37, 32, 33, 121, 114,
115, 35, 121, 51, 52, 156, 757, 122, 52, 51,
121, 53, 54, 51, 56, 57, 121, 445, 474, 475,
114, 115, 478, 51, 52, 51, 122, 483, 122, 116,
118, 182, 493, 489, 495, 121, 123, 114, 115, 120,
116, 122, 498, 51, 52, 122, 120, 123, 122, 114,
115, 114, 115, 121, 205, 89, 207, 91, 114, 115,
51, 489, 213, 214, 121, 521, 114, 115, 219, 520,
114, 115, 114, 115, 114, 115, 114, 115, 114, 115,
649, 120, 651, 122, 478, 125, 114, 115, 114, 115,
546, 547, 121, 521, 121, 52, 552, 553, 554, 555,
556, 557, 558, 559, 560, 561, 114, 115, 32, 33,
34, 35, 36, 37, 32, 33, 34, 35, 36, 37,
576, 577, 578, 114, 115, 52, 277, 278, 279, 280,
281, 282, 283, 284, 285, 286, 587, 35, 589, 52,
51, 52, 53, 751, 295, 601, 602, 121, 46, 47,
578, 49, 39, 40, 41, 53, 54, 114, 115, 121,
58, 617, 52, 35, 51, 316, 682, 120, 52, 122,
121, 687, 688, 52, 46, 47, 632, 49, 52, 114,
115, 53, 54, 16, 17, 120, 58, 114, 115, 645,
114, 115, 90, 51, 52, 53, 114, 115, 570, 571,
572, 114, 115, 101, 632, 114, 115, 105, 52, 665,
666, 120, 53, 54, 121, 56, 57, 89, 90, 91,
52, 119, 121, 121, 114, 115, 124, 746, 52, 101,
114, 115, 120, 105, 122, 114, 115, 120, 52, 390,
114, 115, 32, 33, 34, 35, 36, 37, 52, 121,
114, 115, 124, 709, 710, 121, 712, 713, 39, 40,
41, 172, 121, 53, 54, 121, 56, 57, 724, 50,
114, 115, 183, 114, 115, 731, 121, 733, 120, 735,
122, 122, 114, 115, 121, 53, 54, 743, 56, 57,
114, 115, 748, 121, 445, 53, 54, 52, 56, 57,
114, 115, 121, 759, 823, 761, 762, 735, 121, 52,
114, 115, 121, 464, 172, 23, 772, 773, 114, 115,
471, 472, 778, 779, 114, 115, 52, 783, 52, 21,
846, 847, 788, 849, 850, 52, 852, 853, 489, 855,
856, 53, 54, 23, 56, 57, 114, 115, 119, 114,
115, 262, 263, 20, 122, 120, 114, 115, 117, 114,
115, 22, 114, 115, 122, 117, 822, 52, 824, 825,
521, 114, 115, 829, 52, 831, 120, 833, 122, 835,
120, 53, 54, 839, 56, 57, 61, 62, 114, 115,
114, 115, 764, 765, 766, 767, 119, 114, 115, 30,
114, 115, 114, 115, 32, 117, 120, 863, 864, 865,
866, 867, 868, 869, 870, 326, 327, 328, 329, 330,
331, 332, 333, 334, 335, 336, 337, 578, 579, 114,
115, 114, 115, 117, 345, 346, 114, 115, 119, 122,
351, 352, 114, 115, 16, 17, 357, 358, 120, 119,
120, 362, 39, 40, 41, 121, 367, 368, 830, 121,
832, 121, 834, 50, 836, 114, 115, 378, 326, 327,
328, 329, 330, 331, 332, 333, 334, 335, 336, 337,
35, 632, 633, 634, 121, 39, 40, 41, 121, 114,
115, 46, 47, 117, 49, 120, 50, 122, 53, 54,
358, 61, 62, 58, 362, 114, 115, 114, 115, 367,
368, 114, 115, 122, 117, 122, 888, 889, 890, 891,
892, 893, 894, 895, 896, 897, 898, 899, 900, 901,
902, 903, 121, 35, 61, 90, 46, 47, 121, 49,
121, 114, 115, 53, 46, 47, 101, 49, 58, 122,
105, 53, 54, 121, 53, 54, 58, 56, 57, 39,
40, 41, 121, 121, 53, 54, 121, 56, 57, 124,
50, 121, 723, 21, 39, 40, 41, 39, 40, 41,
90, 39, 40, 41, 735, 50, 497, 498, 90, 114,
115, 101, 50, 36, 37, 105, 21, 122, 21, 101,
43, 21, 51, 105, 53, 54, 21, 56, 57, 114,
115, 121, 21, 21, 124, 114, 115, 122, 21, 121,
531, 120, 124, 66, 101, 114, 115, 39, 40, 41,
20, 120, 56, 57, 58, 546, 547, 35, 50, 20,
498, 552, 553, 554, 555, 556, 557, 558, 559, 560,
561, 562, 563, 564, 565, 566, 567, 85, 86, 87,
88, 104, 117, 574, 117, 114, 115, 35, 46, 47,
21, 49, 21, 531, 117, 118, 21, 120, 46, 47,
58, 49, 125, 114, 115, 53, 54, 20, 546, 547,
58, 122, 21, 136, 107, 20, 20, 555, 556, 557,
558, 559, 560, 561, 562, 563, 564, 565, 566, 567,
20, 122, 90, 156, 53, 54, 574, 56, 57, 39,
122, 122, 90, 101, 121, 53, 54, 105, 56, 57,
52, 53, 54, 101, 56, 57, 122, 105, 121, 182,
39, 40, 41, 121, 53, 54, 124, 56, 57, 114,
115, 50, 121, 121, 121, 121, 124, 122, 121, 670,
671, 672, 673, 674, 675, 676, 677, 678, 39, 40,
41, 39, 40, 41, 121, 114, 115, 121, 117, 50,
114, 115, 50, 114, 115, 121, 114, 115, 122, 117,
125, 122, 114, 115, 121, 114, 115, 38, 117, 114,
115, 117, 43, 44, 45, 114, 115, 122, 49, 121,
117, 21, 670, 671, 672, 673, 674, 675, 676, 677,
678, 39, 63, 64, 65, 66, 67, 68, 69, 70,
71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
283, 284, 285, 754, 114, 115, 757, 758, 759, 39,
761, 762, 122, 120, 297, 96, 97, 98, 99, 43,
303, 102, 103, 114, 115, 49, 107, 108, 109, 114,
115, 122, 21, 316, 114, 115, 21, 122, 114, 115,
121, 117, 122, 122, 117, 69, 70, 71, 72, 73,
74, 75, 76, 77, 114, 115, 754, 81, 82, 51,
758, 759, 122, 761, 762, 114, 115, 46, 47, 93,
49, 117, 117, 122, 53, 54, 100, 51, 829, 58,
831, 117, 833, 52, 835, 114, 115, 114, 115, 52,
114, 115, 472, 122, 636, 122, 483, 121, 114, 115,
114, 115, 114, 115, 114, 115, 122, 117, 122, 322,
122, 90, 863, 864, 865, 866, 867, 868, 869, 870,
114, 115, 101, 303, 114, 115, 105, 362, 122, 573,
392, 829, 122, 831, 104, 833, 294, 835, 421, -1,
423, -1, 121, -1, -1, 124, 3, 4, 5, 6,
7, 8, 9, 10, 11, 12, 13, 16, 17, 18,
19, -1, 445, -1, 21, 863, 864, 865, 866, 867,
868, 869, 870, 114, 115, 22, 114, 115, 114, 115,
-1, 122, 114, 115, 122, -1, 122, -1, 35, 472,
122, 114, 115, -1, -1, -1, 43, 44, 45, 122,
483, 48, 49, 114, 115, -1, 489, 114, 115, -1,
-1, 122, -1, -1, -1, 122, 63, 64, 65, 66,
67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
77, 78, 79, 80, 114, 115, 83, -1, 521, 114,
115, -1, 122, -1, -1, 114, 115, 122, -1, 96,
97, 98, 99, 122, -1, 102, 103, -1, 114, 115,
107, 108, 109, 114, 115, -1, 122, 114, 115, 114,
115, 122, 114, 115, 121, 114, 115, 122, -1, -1,
122, 114, 115, 122, 114, 115, 28, -1, -1, 122,
114, 115, 122, 35, -1, 578, -1, -1, 122, -1,
42, 43, 44, 45, 46, 47, 48, 49, -1, 114,
115, 53, 54, 596, -1, -1, 58, 122, -1, -1,
-1, 63, 64, 65, 66, 67, 68, 69, 70, 71,
72, 73, 74, 75, 76, 77, 78, 79, 80, 114,
115, -1, 114, 115, -1, -1, -1, 122, 90, 632,
122, -1, -1, 636, 96, 97, 98, 99, -1, 101,
102, 103, 104, 105, -1, 107, 108, 109, 27, -1,
-1, -1, 114, 115, 110, 111, 112, 113, -1, 121,
-1, -1, 124, -1, 43, 44, 45, -1, -1, 48,
49, 253, 254, 255, 256, 257, 258, -1, -1, -1,
-1, -1, -1, -1, 63, 64, 65, 66, 67, 68,
69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
79, 80, 81, 82, -1, -1, -1, -1, -1, -1,
-1, -1, -1, 92, 93, -1, -1, 96, 97, 98,
99, 100, -1, 102, 103, -1, -1, -1, 107, 108,
109, -1, 735, -1, -1, 114, 115, 35, -1, -1,
-1, -1, 121, -1, -1, 43, 44, 45, 46, 47,
48, 49, -1, -1, -1, 53, 54, -1, -1, -1,
58, -1, -1, -1, -1, 63, 64, 65, 66, 67,
68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
78, 79, 80, -1, -1, 83, -1, -1, -1, -1,
-1, -1, 90, -1, -1, -1, -1, -1, 96, 97,
98, 99, -1, 101, 102, 103, -1, 105, -1, 107,
108, 109, -1, -1, -1, -1, 114, 115, -1, -1,
35, -1, -1, 121, -1, -1, 124, 125, 43, 44,
45, 46, 47, 48, 49, -1, -1, -1, 53, 54,
-1, -1, -1, 58, -1, -1, -1, -1, 63, 64,
65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
75, 76, 77, 78, 79, 80, -1, -1, -1, -1,
-1, -1, -1, -1, -1, 90, -1, -1, -1, -1,
-1, 96, 97, 98, 99, 100, 101, 102, 103, -1,
105, -1, 107, 108, 109, -1, -1, -1, -1, 114,
115, -1, 35, -1, -1, -1, 121, -1, -1, 124,
43, 44, 45, 46, 47, 48, 49, -1, -1, -1,
53, 54, -1, -1, -1, 58, -1, -1, -1, -1,
63, 64, 65, 66, 67, 68, 69, 70, 71, 72,
73, 74, 75, 76, 77, 78, 79, 80, -1, -1,
-1, -1, -1, -1, -1, -1, -1, 90, -1, -1,
-1, -1, -1, 96, 97, 98, 99, -1, 101, 102,
103, -1, 105, -1, 107, 108, 109, -1, -1, -1,
-1, 114, 115, -1, 35, -1, -1, -1, 121, -1,
-1, 124, 43, 44, 45, -1, -1, 48, 49, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, 63, 64, 65, 66, 67, 68, 69, 70,
71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, 96, 97, 98, 99, -1,
-1, 102, 103, 36, -1, -1, 107, 108, 109, -1,
43, 44, 45, 114, 115, 48, 49, -1, -1, -1,
121, -1, -1, -1, -1, -1, -1, -1, -1, -1,
63, 64, 65, 66, 67, 68, 69, 70, 71, 72,
73, 74, 75, 76, 77, 78, 79, 80, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, 96, 97, 98, 99, -1, -1, 102,
103, -1, -1, 38, 107, 108, 109, -1, 43, 44,
45, 114, 115, 48, 49, -1, -1, -1, 121, -1,
-1, -1, -1, -1, -1, -1, -1, -1, 63, 64,
65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
75, 76, 77, 78, 79, 80, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, 96, 97, 98, 99, -1, -1, 102, 103, -1,
-1, 38, 107, 108, 109, -1, 43, 44, 45, 114,
115, 48, 49, -1, -1, -1, 121, -1, -1, -1,
-1, -1, -1, -1, -1, -1, 63, 64, 65, 66,
67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
77, 78, 79, 80, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, 96,
97, 98, 99, -1, -1, 102, 103, -1, -1, 38,
107, 108, 109, -1, 43, 44, 45, 114, 115, 48,
49, -1, -1, -1, 121, -1, -1, -1, -1, -1,
-1, -1, -1, -1, 63, 64, 65, 66, 67, 68,
69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
79, 80, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, 96, 97, 98,
99, -1, -1, 102, 103, -1, 38, -1, 107, 108,
109, 43, 44, 45, -1, 114, 115, 49, -1, -1,
-1, -1, 121, -1, -1, -1, -1, -1, -1, -1,
-1, 63, 64, 65, 66, 67, 68, 69, 70, 71,
72, 73, 74, 75, 76, 77, 78, 79, 80, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, 96, 97, 98, 99, -1, -1,
102, 103, -1, 38, -1, 107, 108, 109, 43, 44,
45, -1, -1, -1, 49, -1, -1, -1, -1, 121,
-1, -1, -1, -1, -1, -1, -1, -1, 63, 64,
65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
75, 76, 77, 78, 79, 80, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, 96, 97, 98, 99, -1, -1, 102, 103, -1,
-1, -1, 107, 108, 109, -1, -1, 43, 44, 45,
46, 47, 48, 49, -1, -1, 121, 53, 54, -1,
-1, -1, 58, -1, -1, -1, -1, 63, 64, 65,
66, 67, 68, 69, 70, 71, 72, 73, 74, 75,
76, 77, 78, 79, 80, -1, -1, -1, -1, -1,
-1, -1, -1, -1, 90, -1, -1, -1, -1, -1,
96, 97, 98, 99, -1, 101, 102, 103, -1, 105,
-1, 107, 108, 109, 42, 43, 44, 45, 114, 115,
48, 49, -1, -1, -1, 121, -1, -1, 124, -1,
-1, -1, -1, -1, -1, 63, 64, 65, 66, 67,
68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
78, 79, 80, 81, 82, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, 93, -1, -1, 96, 97,
98, 99, 100, -1, 102, 103, -1, -1, -1, 107,
108, 109, -1, 43, 44, 45, 114, 115, 48, 49,
-1, -1, -1, 121, -1, -1, -1, -1, -1, -1,
-1, -1, -1, 63, 64, 65, 66, 67, 68, 69,
70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
80, 81, 82, -1, -1, -1, -1, -1, -1, -1,
-1, -1, 92, 93, -1, -1, 96, 97, 98, 99,
100, -1, 102, 103, -1, -1, -1, 107, 108, 109,
-1, 43, 44, 45, 114, 115, 48, 49, -1, -1,
-1, 121, -1, -1, -1, -1, -1, -1, -1, -1,
-1, 63, 64, 65, 66, 67, 68, 69, 70, 71,
72, 73, 74, 75, 76, 77, 78, 79, 80, 81,
82, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, 93, -1, -1, 96, 97, 98, 99, 100, -1,
102, 103, 43, 44, 45, 107, 108, 109, 49, -1,
-1, -1, 114, 115, -1, -1, -1, -1, -1, 121,
-1, -1, 63, 64, 65, 66, 67, 68, 69, 70,
71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
81, 82, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, 93, -1, -1, 96, 97, 98, 99, 100,
-1, 102, 103, 43, 44, 45, 107, 108, 109, 49,
-1, -1, -1, 114, 115, -1, -1, -1, -1, -1,
121, -1, -1, 63, 64, 65, 66, 67, 68, 69,
70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
80, 81, 82, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, 93, -1, -1, 96, 97, 98, 99,
100, -1, 102, 103, -1, -1, -1, 107, 108, 109,
-1, 43, 44, 45, 114, 115, 48, 49, -1, -1,
-1, 121, -1, -1, -1, -1, -1, -1, -1, -1,
-1, 63, 64, 65, 66, 67, 68, 69, 70, 71,
72, 73, 74, 75, 76, 77, 78, 79, 80, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, 96, 97, 98, 99, -1, -1,
102, 103, -1, -1, -1, 107, 108, 109, -1, 43,
44, 45, 114, 115, 48, 49, -1, -1, -1, 121,
-1, -1, -1, -1, -1, -1, -1, -1, -1, 63,
64, 65, 66, 67, 68, 69, 70, 71, 72, 73,
74, 75, 76, 77, 78, 79, 80, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, 96, 97, 98, 99, -1, -1, 102, 103,
-1, -1, -1, 107, 108, 109, -1, 43, 44, 45,
114, 115, 48, 49, -1, -1, -1, 121, -1, -1,
-1, -1, -1, -1, -1, -1, -1, 63, 64, 65,
66, 67, 68, 69, 70, 71, 72, 73, 74, 75,
76, 77, 78, 79, 80, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
96, 97, 98, 99, -1, -1, 102, 103, -1, -1,
-1, 107, 108, 109, -1, 43, 44, 45, 114, 115,
48, 49, -1, -1, -1, 121, -1, -1, -1, -1,
-1, -1, -1, -1, -1, 63, 64, 65, 66, 67,
68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
78, 79, 80, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, 96, 97,
98, 99, -1, -1, 102, 103, 43, 44, 45, 107,
108, 109, 49, -1, -1, -1, 114, 115, -1, -1,
-1, -1, -1, 121, -1, -1, 63, 64, 65, 66,
67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
77, 78, 79, 80, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, 96,
97, 98, 99, -1, -1, 102, 103, 43, 44, 45,
107, 108, 109, 49, -1, -1, -1, 114, 115, -1,
-1, -1, -1, -1, 121, -1, -1, 63, 64, 65,
66, 67, 68, 69, 70, 71, 72, 73, 74, 75,
76, 77, 78, 79, 80, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
96, 97, 98, 99, -1, -1, 102, 103, -1, -1,
-1, 107, 108, 109, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, 121
};
/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
symbol of state STATE-NUM. */
static const yytype_uint8 yystos[] =
{
0, 3, 4, 5, 6, 7, 8, 9, 10, 11,
12, 13, 21, 127, 128, 131, 132, 133, 134, 136,
139, 149, 150, 162, 165, 107, 107, 107, 107, 107,
107, 107, 106, 106, 106, 106, 14, 15, 27, 166,
0, 20, 118, 20, 118, 16, 17, 18, 19, 118,
140, 21, 21, 21, 21, 121, 121, 121, 121, 35,
43, 44, 45, 46, 47, 48, 49, 53, 54, 58,
63, 64, 65, 66, 67, 68, 69, 70, 71, 72,
73, 74, 75, 76, 77, 78, 79, 80, 90, 96,
97, 98, 99, 100, 101, 102, 103, 105, 107, 108,
109, 114, 115, 121, 124, 169, 170, 171, 172, 177,
179, 180, 181, 182, 183, 184, 28, 42, 49, 104,
121, 169, 176, 177, 180, 49, 121, 167, 168, 169,
177, 117, 169, 119, 167, 22, 49, 83, 121, 137,
145, 146, 147, 173, 177, 180, 167, 29, 143, 33,
141, 16, 17, 167, 141, 43, 49, 69, 70, 71,
72, 73, 74, 75, 76, 77, 81, 82, 93, 100,
114, 115, 121, 157, 158, 159, 160, 161, 180, 181,
157, 27, 49, 92, 151, 152, 157, 180, 27, 94,
95, 163, 164, 107, 135, 135, 135, 135, 36, 179,
167, 121, 168, 121, 168, 121, 167, 121, 167, 167,
176, 167, 167, 121, 121, 121, 121, 121, 121, 121,
121, 121, 121, 121, 121, 121, 121, 121, 121, 121,
121, 121, 121, 121, 121, 118, 178, 178, 178, 121,
121, 121, 183, 183, 169, 180, 125, 167, 173, 175,
177, 179, 180, 53, 54, 56, 57, 114, 115, 55,
116, 120, 114, 115, 59, 60, 116, 123, 61, 62,
121, 176, 176, 121, 169, 176, 180, 32, 33, 34,
35, 36, 37, 39, 40, 41, 23, 32, 33, 34,
35, 36, 37, 176, 21, 23, 117, 20, 119, 179,
176, 180, 117, 120, 147, 148, 85, 86, 87, 88,
174, 180, 119, 180, 30, 144, 49, 115, 180, 32,
142, 117, 119, 142, 167, 176, 121, 121, 121, 121,
121, 121, 121, 121, 121, 121, 121, 121, 178, 114,
115, 159, 159, 157, 180, 114, 115, 117, 116, 123,
61, 114, 115, 116, 117, 167, 176, 42, 121, 153,
157, 180, 39, 117, 32, 33, 34, 156, 156, 167,
117, 143, 120, 122, 122, 122, 122, 36, 21, 167,
179, 21, 167, 179, 21, 180, 21, 180, 21, 21,
50, 21, 21, 169, 169, 180, 180, 180, 180, 169,
180, 180, 180, 180, 180, 180, 180, 180, 180, 180,
180, 180, 101, 180, 180, 179, 179, 179, 179, 122,
122, 21, 125, 120, 125, 125, 24, 25, 170, 170,
170, 170, 170, 170, 172, 172, 180, 181, 181, 182,
182, 182, 182, 182, 167, 50, 179, 122, 169, 169,
169, 169, 169, 169, 176, 176, 176, 169, 180, 180,
180, 180, 180, 180, 50, 166, 169, 89, 91, 129,
130, 177, 20, 22, 50, 84, 146, 179, 147, 180,
180, 180, 180, 20, 180, 117, 176, 38, 38, 49,
180, 143, 16, 17, 19, 140, 117, 21, 50, 157,
180, 157, 180, 157, 180, 157, 180, 157, 180, 157,
180, 157, 180, 157, 180, 157, 180, 157, 157, 157,
43, 49, 69, 70, 71, 72, 73, 74, 75, 76,
77, 121, 122, 158, 181, 158, 181, 159, 182, 182,
182, 158, 181, 158, 181, 159, 21, 50, 153, 153,
157, 180, 39, 40, 41, 50, 32, 33, 34, 35,
36, 37, 32, 33, 34, 35, 36, 37, 152, 157,
180, 157, 180, 21, 21, 107, 20, 20, 20, 20,
181, 122, 122, 182, 122, 122, 182, 122, 180, 122,
180, 182, 169, 180, 172, 171, 120, 122, 122, 122,
122, 120, 120, 122, 122, 122, 122, 122, 122, 122,
122, 122, 122, 122, 122, 122, 122, 120, 119, 122,
122, 122, 177, 180, 177, 180, 180, 122, 169, 176,
180, 122, 22, 121, 121, 117, 120, 169, 129, 169,
180, 22, 179, 145, 180, 50, 176, 144, 143, 141,
16, 141, 158, 181, 157, 180, 122, 122, 122, 122,
122, 122, 122, 122, 122, 120, 120, 122, 167, 176,
121, 121, 121, 121, 121, 121, 121, 121, 121, 151,
151, 157, 180, 122, 153, 153, 153, 157, 180, 157,
180, 157, 180, 157, 180, 157, 180, 157, 180, 157,
180, 157, 157, 157, 157, 157, 157, 154, 154, 32,
33, 154, 32, 33, 154, 163, 157, 180, 180, 176,
169, 167, 167, 51, 51, 177, 180, 180, 180, 125,
125, 26, 125, 26, 125, 51, 176, 169, 169, 130,
117, 117, 22, 31, 138, 117, 115, 180, 50, 117,
144, 142, 117, 142, 51, 180, 180, 21, 50, 51,
52, 156, 156, 120, 180, 180, 180, 180, 117, 117,
117, 117, 21, 21, 169, 180, 122, 122, 120, 120,
180, 180, 176, 120, 122, 180, 117, 38, 51, 38,
180, 117, 143, 117, 157, 122, 122, 181, 151, 157,
180, 157, 180, 110, 111, 112, 113, 155, 154, 154,
154, 154, 180, 180, 52, 52, 180, 180, 125, 125,
52, 180, 51, 115, 51, 51, 144, 52, 52, 51,
52, 51, 52, 51, 52, 51, 52, 122, 122, 120,
122, 180, 38, 180, 38, 117, 157, 180, 154, 157,
180, 154, 157, 180, 154, 157, 180, 154, 180, 52,
52, 52, 52, 156, 156, 156, 156, 156, 156, 156,
156, 122, 157, 180, 157, 180, 157, 180, 157, 180,
157, 180, 157, 180, 157, 180, 157, 180, 52, 52,
52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
52, 52, 52, 52, 154, 154, 154, 154, 154, 154,
154, 154, 154, 154, 154, 154, 154, 154, 154, 154
};
/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
static const yytype_uint8 yyr1[] =
{
0, 126, 127, 127, 127, 127, 127, 127, 127, 127,
127, 127, 127, 128, 128, 128, 128, 129, 129, 129,
129, 129, 130, 131, 132, 133, 134, 135, 135, 136,
136, 136, 136, 137, 137, 138, 138, 139, 139, 139,
139, 139, 139, 139, 139, 140, 140, 140, 141, 141,
141, 141, 141, 142, 142, 142, 142, 142, 143, 143,
144, 144, 145, 145, 145, 145, 146, 147, 148, 148,
149, 149, 150, 151, 151, 151, 151, 151, 152, 152,
152, 152, 152, 152, 152, 152, 152, 152, 152, 152,
152, 152, 152, 152, 152, 152, 152, 152, 152, 152,
152, 152, 152, 152, 152, 152, 153, 153, 153, 153,
153, 153, 153, 153, 153, 153, 153, 153, 153, 153,
153, 153, 153, 153, 153, 153, 153, 153, 153, 154,
154, 155, 155, 155, 155, 156, 156, 156, 157, 157,
157, 157, 157, 157, 157, 158, 158, 158, 158, 158,
159, 159, 159, 160, 160, 160, 161, 161, 161, 161,
161, 161, 161, 161, 161, 161, 161, 161, 161, 161,
161, 162, 163, 163, 164, 164, 164, 165, 166, 166,
166, 166, 166, 166, 167, 167, 168, 168, 169, 169,
169, 169, 169, 169, 169, 170, 170, 171, 171, 171,
171, 172, 172, 172, 172, 172, 172, 172, 172, 172,
172, 172, 172, 172, 172, 172, 172, 172, 172, 172,
172, 173, 173, 174, 174, 174, 174, 175, 175, 175,
176, 176, 176, 176, 176, 176, 176, 176, 176, 176,
176, 176, 176, 176, 176, 176, 176, 176, 176, 176,
176, 177, 177, 178, 178, 179, 179, 180, 180, 180,
181, 181, 181, 181, 181, 181, 182, 182, 182, 183,
183, 183, 183, 183, 183, 183, 184, 184, 184, 184,
184, 184, 184, 184, 184, 184, 184, 184, 184, 184,
184, 184, 184, 184, 184, 184, 184, 184, 184, 184,
184, 184, 184, 184, 184, 184, 184, 184
};
/* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
static const yytype_uint8 yyr2[] =
{
0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 5, 8, 8, 7, 1, 3, 6,
8, 4, 2, 8, 8, 8, 8, 1, 3, 9,
8, 5, 1, 1, 1, 0, 2, 9, 6, 8,
5, 9, 6, 11, 8, 0, 1, 2, 0, 2,
3, 9, 9, 0, 2, 2, 8, 8, 0, 2,
0, 2, 1, 3, 1, 2, 2, 3, 3, 4,
5, 5, 5, 1, 3, 4, 5, 7, 4, 4,
4, 4, 6, 6, 6, 6, 12, 12, 12, 12,
12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
12, 12, 8, 8, 8, 8, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 2, 3, 0,
3, 1, 1, 1, 1, 1, 1, 1, 1, 3,
3, 3, 3, 3, 3, 1, 3, 3, 3, 3,
1, 2, 2, 1, 3, 4, 2, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 6, 6, 7,
3, 5, 4, 4, 0, 1, 1, 3, 2, 2,
2, 2, 2, 4, 1, 1, 5, 3, 1, 3,
3, 3, 3, 3, 3, 1, 4, 1, 3, 3,
4, 2, 4, 2, 7, 5, 7, 5, 4, 7,
4, 7, 3, 3, 3, 3, 5, 5, 6, 4,
7, 4, 2, 2, 2, 2, 2, 1, 3, 1,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 2, 3, 3, 4, 4,
7, 2, 3, 0, 3, 1, 3, 1, 3, 3,
1, 3, 3, 3, 3, 4, 1, 2, 2, 1,
3, 4, 4, 4, 4, 4, 1, 1, 1, 2,
2, 4, 4, 2, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
3, 4, 8, 6, 7, 8, 4, 4
};
#define yyerrok (yyerrstatus = 0)
#define yyclearin (yychar = YYEMPTY)
#define YYEMPTY (-2)
#define YYEOF 0
#define YYACCEPT goto yyacceptlab
#define YYABORT goto yyabortlab
#define YYERROR goto yyerrorlab
#define YYRECOVERING() (!!yyerrstatus)
#define YYBACKUP(Token, Value) \
do \
if (yychar == YYEMPTY) \
{ \
yychar = (Token); \
yylval = (Value); \
YYPOPSTACK (yylen); \
yystate = *yyssp; \
goto yybackup; \
} \
else \
{ \
yyerror (YY_("syntax error: cannot back up")); \
YYERROR; \
} \
while (0)
/* Error token number */
#define YYTERROR 1
#define YYERRCODE 256
/* Enable debugging if requested. */
#if YYDEBUG
# ifndef YYFPRINTF
# include /* INFRINGES ON USER NAME SPACE */
# define YYFPRINTF fprintf
# endif
# define YYDPRINTF(Args) \
do { \
if (yydebug) \
YYFPRINTF Args; \
} while (0)
/* This macro is provided for backward compatibility. */
#ifndef YY_LOCATION_PRINT
# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
#endif
# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
do { \
if (yydebug) \
{ \
YYFPRINTF (stderr, "%s ", Title); \
yy_symbol_print (stderr, \
Type, Value); \
YYFPRINTF (stderr, "\n"); \
} \
} while (0)
/*----------------------------------------.
| Print this symbol's value on YYOUTPUT. |
`----------------------------------------*/
static void
yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
{
FILE *yyo = yyoutput;
YYUSE (yyo);
if (!yyvaluep)
return;
# ifdef YYPRINT
if (yytype < YYNTOKENS)
YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
# endif
YYUSE (yytype);
}
/*--------------------------------.
| Print this symbol on YYOUTPUT. |
`--------------------------------*/
static void
yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
{
YYFPRINTF (yyoutput, "%s %s (",
yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
yy_symbol_value_print (yyoutput, yytype, yyvaluep);
YYFPRINTF (yyoutput, ")");
}
/*------------------------------------------------------------------.
| yy_stack_print -- Print the state stack from its BOTTOM up to its |
| TOP (included). |
`------------------------------------------------------------------*/
static void
yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
{
YYFPRINTF (stderr, "Stack now");
for (; yybottom <= yytop; yybottom++)
{
int yybot = *yybottom;
YYFPRINTF (stderr, " %d", yybot);
}
YYFPRINTF (stderr, "\n");
}
# define YY_STACK_PRINT(Bottom, Top) \
do { \
if (yydebug) \
yy_stack_print ((Bottom), (Top)); \
} while (0)
/*------------------------------------------------.
| Report that the YYRULE is going to be reduced. |
`------------------------------------------------*/
static void
yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule)
{
unsigned long int yylno = yyrline[yyrule];
int yynrhs = yyr2[yyrule];
int yyi;
YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
yyrule - 1, yylno);
/* The symbols being reduced. */
for (yyi = 0; yyi < yynrhs; yyi++)
{
YYFPRINTF (stderr, " $%d = ", yyi + 1);
yy_symbol_print (stderr,
yystos[yyssp[yyi + 1 - yynrhs]],
&(yyvsp[(yyi + 1) - (yynrhs)])
);
YYFPRINTF (stderr, "\n");
}
}
# define YY_REDUCE_PRINT(Rule) \
do { \
if (yydebug) \
yy_reduce_print (yyssp, yyvsp, Rule); \
} while (0)
/* Nonzero means print parse trace. It is left uninitialized so that
multiple parsers can coexist. */
int yydebug;
#else /* !YYDEBUG */
# define YYDPRINTF(Args)
# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
# define YY_STACK_PRINT(Bottom, Top)
# define YY_REDUCE_PRINT(Rule)
#endif /* !YYDEBUG */
/* YYINITDEPTH -- initial size of the parser's stacks. */
#ifndef YYINITDEPTH
# define YYINITDEPTH 200
#endif
/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
if the built-in stack extension method is used).
Do not make this value too large; the results are undefined if
YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
evaluated with infinite-precision integer arithmetic. */
#ifndef YYMAXDEPTH
# define YYMAXDEPTH 10000
#endif
#if YYERROR_VERBOSE
# ifndef yystrlen
# if defined __GLIBC__ && defined _STRING_H
# define yystrlen strlen
# else
/* Return the length of YYSTR. */
static YYSIZE_T
yystrlen (const char *yystr)
{
YYSIZE_T yylen;
for (yylen = 0; yystr[yylen]; yylen++)
continue;
return yylen;
}
# endif
# endif
# ifndef yystpcpy
# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
# define yystpcpy stpcpy
# else
/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
YYDEST. */
static char *
yystpcpy (char *yydest, const char *yysrc)
{
char *yyd = yydest;
const char *yys = yysrc;
while ((*yyd++ = *yys++) != '\0')
continue;
return yyd - 1;
}
# endif
# endif
# ifndef yytnamerr
/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
quotes and backslashes, so that it's suitable for yyerror. The
heuristic is that double-quoting is unnecessary unless the string
contains an apostrophe, a comma, or backslash (other than
backslash-backslash). YYSTR is taken from yytname. If YYRES is
null, do not copy; instead, return the length of what the result
would have been. */
static YYSIZE_T
yytnamerr (char *yyres, const char *yystr)
{
if (*yystr == '"')
{
YYSIZE_T yyn = 0;
char const *yyp = yystr;
for (;;)
switch (*++yyp)
{
case '\'':
case ',':
goto do_not_strip_quotes;
case '\\':
if (*++yyp != '\\')
goto do_not_strip_quotes;
/* Fall through. */
default:
if (yyres)
yyres[yyn] = *yyp;
yyn++;
break;
case '"':
if (yyres)
yyres[yyn] = '\0';
return yyn;
}
do_not_strip_quotes: ;
}
if (! yyres)
return yystrlen (yystr);
return yystpcpy (yyres, yystr) - yyres;
}
# endif
/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
about the unexpected token YYTOKEN for the state stack whose top is
YYSSP.
Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
not large enough to hold the message. In that case, also set
*YYMSG_ALLOC to the required number of bytes. Return 2 if the
required number of bytes is too large to store. */
static int
yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
yytype_int16 *yyssp, int yytoken)
{
YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]);
YYSIZE_T yysize = yysize0;
enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
/* Internationalized format string. */
const char *yyformat = YY_NULLPTR;
/* Arguments of yyformat. */
char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
/* Number of reported tokens (one for the "unexpected", one per
"expected"). */
int yycount = 0;
/* There are many possibilities here to consider:
- If this state is a consistent state with a default action, then
the only way this function was invoked is if the default action
is an error action. In that case, don't check for expected
tokens because there are none.
- The only way there can be no lookahead present (in yychar) is if
this state is a consistent state with a default action. Thus,
detecting the absence of a lookahead is sufficient to determine
that there is no unexpected or expected token to report. In that
case, just report a simple "syntax error".
- Don't assume there isn't a lookahead just because this state is a
consistent state with a default action. There might have been a
previous inconsistent state, consistent state with a non-default
action, or user semantic action that manipulated yychar.
- Of course, the expected token list depends on states to have
correct lookahead information, and it depends on the parser not
to perform extra reductions after fetching a lookahead from the
scanner and before detecting a syntax error. Thus, state merging
(from LALR or IELR) and default reductions corrupt the expected
token list. However, the list is correct for canonical LR with
one exception: it will still contain any token that will not be
accepted due to an error action in a later state.
*/
if (yytoken != YYEMPTY)
{
int yyn = yypact[*yyssp];
yyarg[yycount++] = yytname[yytoken];
if (!yypact_value_is_default (yyn))
{
/* Start YYX at -YYN if negative to avoid negative indexes in
YYCHECK. In other words, skip the first -YYN actions for
this state because they are default actions. */
int yyxbegin = yyn < 0 ? -yyn : 0;
/* Stay within bounds of both yycheck and yytname. */
int yychecklim = YYLAST - yyn + 1;
int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
int yyx;
for (yyx = yyxbegin; yyx < yyxend; ++yyx)
if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
&& !yytable_value_is_error (yytable[yyx + yyn]))
{
if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
{
yycount = 1;
yysize = yysize0;
break;
}
yyarg[yycount++] = yytname[yyx];
{
YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
if (! (yysize <= yysize1
&& yysize1 <= YYSTACK_ALLOC_MAXIMUM))
return 2;
yysize = yysize1;
}
}
}
}
switch (yycount)
{
# define YYCASE_(N, S) \
case N: \
yyformat = S; \
break
YYCASE_(0, YY_("syntax error"));
YYCASE_(1, YY_("syntax error, unexpected %s"));
YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
# undef YYCASE_
}
{
YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
return 2;
yysize = yysize1;
}
if (*yymsg_alloc < yysize)
{
*yymsg_alloc = 2 * yysize;
if (! (yysize <= *yymsg_alloc
&& *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
*yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
return 1;
}
/* Avoid sprintf, as that infringes on the user's name space.
Don't have undefined behavior even if the translation
produced a string with the wrong number of "%s"s. */
{
char *yyp = *yymsg;
int yyi = 0;
while ((*yyp = *yyformat) != '\0')
if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
{
yyp += yytnamerr (yyp, yyarg[yyi++]);
yyformat += 2;
}
else
{
yyp++;
yyformat++;
}
}
return 0;
}
#endif /* YYERROR_VERBOSE */
/*-----------------------------------------------.
| Release the memory associated to this symbol. |
`-----------------------------------------------*/
static void
yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
{
YYUSE (yyvaluep);
if (!yymsg)
yymsg = "Deleting";
YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
YYUSE (yytype);
YY_IGNORE_MAYBE_UNINITIALIZED_END
}
/*----------.
| yyparse. |
`----------*/
int
yyparse (void)
{
/* The lookahead symbol. */
int yychar;
/* The semantic value of the lookahead symbol. */
/* Default value used for initialization, for pacifying older GCCs
or non-GCC compilers. */
YY_INITIAL_VALUE (static YYSTYPE yyval_default;)
YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
/* Number of syntax errors so far. */
int yynerrs;
int yystate;
/* Number of tokens to shift before error messages enabled. */
int yyerrstatus;
/* The stacks and their tools:
'yyss': related to states.
'yyvs': related to semantic values.
Refer to the stacks through separate pointers, to allow yyoverflow
to reallocate them elsewhere. */
/* The state stack. */
yytype_int16 yyssa[YYINITDEPTH];
yytype_int16 *yyss;
yytype_int16 *yyssp;
/* The semantic value stack. */
YYSTYPE yyvsa[YYINITDEPTH];
YYSTYPE *yyvs;
YYSTYPE *yyvsp;
YYSIZE_T yystacksize;
int yyn;
int yyresult;
/* Lookahead token as an internal (translated) token number. */
int yytoken = 0;
/* The variables used to return semantic value and location from the
action routines. */
YYSTYPE yyval;
#if YYERROR_VERBOSE
/* Buffer for error messages, and its allocated size. */
char yymsgbuf[128];
char *yymsg = yymsgbuf;
YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
#endif
#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
/* The number of symbols on the RHS of the reduced rule.
Keep to zero when no symbol should be popped. */
int yylen = 0;
yyssp = yyss = yyssa;
yyvsp = yyvs = yyvsa;
yystacksize = YYINITDEPTH;
YYDPRINTF ((stderr, "Starting parse\n"));
yystate = 0;
yyerrstatus = 0;
yynerrs = 0;
yychar = YYEMPTY; /* Cause a token to be read. */
goto yysetstate;
/*------------------------------------------------------------.
| yynewstate -- Push a new state, which is found in yystate. |
`------------------------------------------------------------*/
yynewstate:
/* In all cases, when you get here, the value and location stacks
have just been pushed. So pushing a state here evens the stacks. */
yyssp++;
yysetstate:
*yyssp = yystate;
if (yyss + yystacksize - 1 <= yyssp)
{
/* Get the current used size of the three stacks, in elements. */
YYSIZE_T yysize = yyssp - yyss + 1;
#ifdef yyoverflow
{
/* Give user a chance to reallocate the stack. Use copies of
these so that the &'s don't force the real ones into
memory. */
YYSTYPE *yyvs1 = yyvs;
yytype_int16 *yyss1 = yyss;
/* Each stack pointer address is followed by the size of the
data in use in that stack, in bytes. This used to be a
conditional around just the two extra args, but that might
be undefined if yyoverflow is a macro. */
yyoverflow (YY_("memory exhausted"),
&yyss1, yysize * sizeof (*yyssp),
&yyvs1, yysize * sizeof (*yyvsp),
&yystacksize);
yyss = yyss1;
yyvs = yyvs1;
}
#else /* no yyoverflow */
# ifndef YYSTACK_RELOCATE
goto yyexhaustedlab;
# else
/* Extend the stack our own way. */
if (YYMAXDEPTH <= yystacksize)
goto yyexhaustedlab;
yystacksize *= 2;
if (YYMAXDEPTH < yystacksize)
yystacksize = YYMAXDEPTH;
{
yytype_int16 *yyss1 = yyss;
union yyalloc *yyptr =
(union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
if (! yyptr)
goto yyexhaustedlab;
YYSTACK_RELOCATE (yyss_alloc, yyss);
YYSTACK_RELOCATE (yyvs_alloc, yyvs);
# undef YYSTACK_RELOCATE
if (yyss1 != yyssa)
YYSTACK_FREE (yyss1);
}
# endif
#endif /* no yyoverflow */
yyssp = yyss + yysize - 1;
yyvsp = yyvs + yysize - 1;
YYDPRINTF ((stderr, "Stack size increased to %lu\n",
(unsigned long int) yystacksize));
if (yyss + yystacksize - 1 <= yyssp)
YYABORT;
}
YYDPRINTF ((stderr, "Entering state %d\n", yystate));
if (yystate == YYFINAL)
YYACCEPT;
goto yybackup;
/*-----------.
| yybackup. |
`-----------*/
yybackup:
/* Do appropriate processing given the current state. Read a
lookahead token if we need one and don't already have one. */
/* First try to decide what to do without reference to lookahead token. */
yyn = yypact[yystate];
if (yypact_value_is_default (yyn))
goto yydefault;
/* Not known => get a lookahead token if don't already have one. */
/* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
if (yychar == YYEMPTY)
{
YYDPRINTF ((stderr, "Reading a token: "));
yychar = yylex (&yylval);
}
if (yychar <= YYEOF)
{
yychar = yytoken = YYEOF;
YYDPRINTF ((stderr, "Now at end of input.\n"));
}
else
{
yytoken = YYTRANSLATE (yychar);
YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
}
/* If the proper action on seeing token YYTOKEN is to reduce or to
detect an error, take that action. */
yyn += yytoken;
if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
goto yydefault;
yyn = yytable[yyn];
if (yyn <= 0)
{
if (yytable_value_is_error (yyn))
goto yyerrlab;
yyn = -yyn;
goto yyreduce;
}
/* Count tokens shifted since error; after three, turn off error
status. */
if (yyerrstatus)
yyerrstatus--;
/* Shift the lookahead token. */
YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
/* Discard the shifted token. */
yychar = YYEMPTY;
yystate = yyn;
YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
*++yyvsp = yylval;
YY_IGNORE_MAYBE_UNINITIALIZED_END
goto yynewstate;
/*-----------------------------------------------------------.
| yydefault -- do the default action for the current state. |
`-----------------------------------------------------------*/
yydefault:
yyn = yydefact[yystate];
if (yyn == 0)
goto yyerrlab;
goto yyreduce;
/*-----------------------------.
| yyreduce -- Do a reduction. |
`-----------------------------*/
yyreduce:
/* yyn is the number of a rule to reduce with. */
yylen = yyr2[yyn];
/* If YYLEN is nonzero, implement the default value of the action:
'$$ = $1'.
Otherwise, the following line sets YYVAL to garbage.
This behavior is undocumented and Bison
users should not rely upon it. Assigning to YYVAL
unconditionally makes the parser a bit smaller, and it avoids a
GCC warning that YYVAL may be used uninitialized. */
yyval = yyvsp[1-yylen];
YY_REDUCE_PRINT (yyn);
switch (yyn)
{
case 2:
#line 160 "src/mmlparse2.y" /* yacc.c:1646 */
{ code_set_root((yyvsp[0].code)); }
#line 2470 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 3:
#line 161 "src/mmlparse2.y" /* yacc.c:1646 */
{ code_set_root((yyvsp[0].code)); }
#line 2476 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 4:
#line 162 "src/mmlparse2.y" /* yacc.c:1646 */
{ code_set_root((yyvsp[0].code)); }
#line 2482 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 5:
#line 163 "src/mmlparse2.y" /* yacc.c:1646 */
{ code_set_root((yyvsp[0].code)); }
#line 2488 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 6:
#line 164 "src/mmlparse2.y" /* yacc.c:1646 */
{ code_set_root((yyvsp[0].code)); }
#line 2494 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 7:
#line 165 "src/mmlparse2.y" /* yacc.c:1646 */
{ code_set_root((yyvsp[0].code)); }
#line 2500 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 8:
#line 166 "src/mmlparse2.y" /* yacc.c:1646 */
{ code_set_root((yyvsp[0].code)); }
#line 2506 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 9:
#line 167 "src/mmlparse2.y" /* yacc.c:1646 */
{ code_set_root((yyvsp[0].code)); }
#line 2512 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 10:
#line 168 "src/mmlparse2.y" /* yacc.c:1646 */
{ code_set_root((yyvsp[0].code)); }
#line 2518 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 11:
#line 169 "src/mmlparse2.y" /* yacc.c:1646 */
{ code_set_root((yyvsp[0].code)); }
#line 2524 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 12:
#line 170 "src/mmlparse2.y" /* yacc.c:1646 */
{ code_set_root((yyvsp[0].code)); }
#line 2530 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 13:
#line 178 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_newsym_set1, 3,
code_new_name((yyvsp[-3].name)), /* Name */
code_new_inst(i_idxset_pseudo_new, 1, /* index set */
code_new_inst(i_bool_true, 0)),
(yyvsp[-1].code)); /* initial set */
}
#line 2542 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 14:
#line 185 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_newsym_set1, 3,
code_new_name((yyvsp[-6].name)), /* Name */
(yyvsp[-4].code), /* index set */
(yyvsp[-1].code)); /* set */
}
#line 2553 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 15:
#line 191 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_newsym_set2, 3,
code_new_name((yyvsp[-6].name)), /* Name */
(yyvsp[-4].code), /* index set */
(yyvsp[-1].code)); /* initial set_entry_list */
}
#line 2564 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 16:
#line 197 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_newsym_set2, 3,
code_new_name((yyvsp[-5].name)), /* Name */
code_new_inst(i_idxset_pseudo_new, 1, /* index set */
code_new_inst(i_bool_true, 0)),
(yyvsp[-1].code)); /* initial set_entry_list */
}
#line 2576 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 17:
#line 207 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_entry_list_new, 1, (yyvsp[0].code)); }
#line 2582 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 18:
#line 208 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_entry_list_add, 2, (yyvsp[-2].code), (yyvsp[0].code));
}
#line 2590 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 19:
#line 211 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_entry_list_subsets, 3, (yyvsp[-3].code), (yyvsp[-1].code), code_new_numb(numb_new_integer(-1)));
}
#line 2598 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 20:
#line 214 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_entry_list_subsets, 3, (yyvsp[-5].code), (yyvsp[-3].code), (yyvsp[-1].code));
}
#line 2606 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 21:
#line 217 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_entry_list_powerset, 1, (yyvsp[-1].code));
}
#line 2614 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 22:
#line 223 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_entry, 2, (yyvsp[-1].code), (yyvsp[0].code)); }
#line 2620 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 23:
#line 232 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_newdef, 3,
code_new_define((yyvsp[-6].def)),
code_new_inst(i_tuple_new, 1, (yyvsp[-4].code)),
(yyvsp[-1].code));
}
#line 2631 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 24:
#line 241 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_newdef, 3,
code_new_define((yyvsp[-6].def)),
code_new_inst(i_tuple_new, 1, (yyvsp[-4].code)),
(yyvsp[-1].code));
}
#line 2642 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 25:
#line 250 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_newdef, 3,
code_new_define((yyvsp[-6].def)),
code_new_inst(i_tuple_new, 1, (yyvsp[-4].code)),
(yyvsp[-1].code));
}
#line 2653 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 26:
#line 259 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_newdef, 3,
code_new_define((yyvsp[-6].def)),
code_new_inst(i_tuple_new, 1, (yyvsp[-4].code)),
(yyvsp[-1].code));
}
#line 2664 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 27:
#line 268 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_elem_list_new, 1, code_new_name((yyvsp[0].name)));
}
#line 2672 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 28:
#line 271 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_elem_list_add, 2, (yyvsp[-2].code), code_new_name((yyvsp[0].name)));
}
#line 2680 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 29:
#line 281 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_newsym_para1, 4, code_new_name((yyvsp[-7].name)), (yyvsp[-5].code), (yyvsp[-2].code), (yyvsp[-1].code));
}
#line 2688 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 30:
#line 284 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_newsym_para2, 4, code_new_name((yyvsp[-6].name)), (yyvsp[-4].code), (yyvsp[-1].code), code_new_inst(i_nop, 0));
}
#line 2696 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 31:
#line 287 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_newsym_para1, 4,
code_new_name((yyvsp[-3].name)),
code_new_inst(i_idxset_pseudo_new, 1, code_new_inst(i_bool_true, 0)),
(yyvsp[-1].code),
code_new_inst(i_nop, 0));
}
#line 2708 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 32:
#line 294 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_nop, 0); }
#line 2714 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 33:
#line 297 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = (yyvsp[0].code); }
#line 2720 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 34:
#line 298 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_entry_list_new, 1,
code_new_inst(i_entry, 2, code_new_inst(i_tuple_empty, 0), (yyvsp[0].code)));
}
#line 2729 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 35:
#line 305 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_nop, 0); }
#line 2735 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 36:
#line 306 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_entry, 2, code_new_inst(i_tuple_empty, 0), (yyvsp[0].code)); }
#line 2741 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 37:
#line 314 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_newsym_var, 7,
code_new_name((yyvsp[-7].name)),
(yyvsp[-5].code), (yyvsp[-3].code), (yyvsp[-2].code), (yyvsp[-1].code),
code_new_numb(numb_copy(numb_unknown())),
code_new_numb(numb_copy(numb_unknown())));
}
#line 2753 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 38:
#line 321 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_newsym_var, 7,
code_new_name((yyvsp[-4].name)),
code_new_inst(i_idxset_pseudo_new, 1,
code_new_inst(i_bool_true, 0)),
(yyvsp[-3].code), (yyvsp[-2].code), (yyvsp[-1].code),
code_new_numb(numb_copy(numb_unknown())),
code_new_numb(numb_copy(numb_unknown())));
}
#line 2767 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 39:
#line 330 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_newsym_var, 7,
code_new_name((yyvsp[-6].name)),
(yyvsp[-4].code),
code_new_varclass(VAR_IMP),
code_new_inst(i_bound_new, 1, code_new_numb(numb_new_integer(0))),
code_new_inst(i_bound_new, 1, code_new_numb(numb_new_integer(1))),
code_new_numb(numb_copy(numb_unknown())),
code_new_numb(numb_copy(numb_unknown())));
}
#line 2782 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 40:
#line 340 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_newsym_var, 7,
code_new_name((yyvsp[-3].name)),
code_new_inst(i_idxset_pseudo_new, 1,
code_new_inst(i_bool_true, 0)),
code_new_varclass(VAR_IMP),
code_new_inst(i_bound_new, 1, code_new_numb(numb_new_integer(0))),
code_new_inst(i_bound_new, 1, code_new_numb(numb_new_integer(1))),
code_new_numb(numb_copy(numb_unknown())),
code_new_numb(numb_copy(numb_unknown())));
}
#line 2798 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 41:
#line 351 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_newsym_var, 7,
code_new_name((yyvsp[-7].name)),
(yyvsp[-5].code),
code_new_varclass(VAR_INT),
code_new_inst(i_bound_new, 1, code_new_numb(numb_new_integer(0))),
code_new_inst(i_bound_new, 1, code_new_numb(numb_new_integer(1))),
(yyvsp[-2].code), (yyvsp[-1].code));
}
#line 2812 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 42:
#line 360 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_newsym_var, 7,
code_new_name((yyvsp[-4].name)),
code_new_inst(i_idxset_pseudo_new, 1,
code_new_inst(i_bool_true, 0)),
code_new_varclass(VAR_INT),
code_new_inst(i_bound_new, 1, code_new_numb(numb_new_integer(0))),
code_new_inst(i_bound_new, 1, code_new_numb(numb_new_integer(1))),
(yyvsp[-2].code), (yyvsp[-1].code));
}
#line 2827 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 43:
#line 370 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_newsym_var, 7,
code_new_name((yyvsp[-9].name)), (yyvsp[-7].code), code_new_varclass(VAR_INT), (yyvsp[-4].code), (yyvsp[-3].code), (yyvsp[-2].code), (yyvsp[-1].code));
}
#line 2836 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 44:
#line 374 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_newsym_var, 7,
code_new_name((yyvsp[-6].name)),
code_new_inst(i_idxset_pseudo_new, 1,
code_new_inst(i_bool_true, 0)),
code_new_varclass(VAR_INT), (yyvsp[-4].code), (yyvsp[-3].code), (yyvsp[-2].code), (yyvsp[-1].code));
}
#line 2848 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 45:
#line 384 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_varclass(VAR_CON); }
#line 2854 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 46:
#line 385 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_varclass(VAR_CON); }
#line 2860 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 47:
#line 386 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_varclass(VAR_IMP); }
#line 2866 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 48:
#line 390 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_bound_new, 1, code_new_numb(numb_new_integer(0)));
}
#line 2874 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 49:
#line 393 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_bound_new, 1, (yyvsp[0].code)); }
#line 2880 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 50:
#line 394 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_bound(BOUND_MINUS_INFTY); }
#line 2886 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 51:
#line 395 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_expr_if_else, 3, (yyvsp[-6].code),
code_new_inst(i_bound_new, 1, (yyvsp[-4].code)),
code_new_bound(BOUND_MINUS_INFTY));
}
#line 2896 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 52:
#line 400 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_expr_if_else, 3, (yyvsp[-6].code),
code_new_bound(BOUND_MINUS_INFTY),
code_new_inst(i_bound_new, 1, (yyvsp[-1].code)));
}
#line 2906 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 53:
#line 408 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_bound(BOUND_INFTY); }
#line 2912 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 54:
#line 409 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_bound_new, 1, (yyvsp[0].code)); }
#line 2918 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 55:
#line 410 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_bound(BOUND_INFTY); }
#line 2924 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 56:
#line 411 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_expr_if_else, 3, (yyvsp[-5].code),
code_new_inst(i_bound_new, 1, (yyvsp[-3].code)),
code_new_bound(BOUND_INFTY));
}
#line 2934 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 57:
#line 416 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_expr_if_else, 3, (yyvsp[-5].code),
code_new_bound(BOUND_INFTY),
code_new_inst(i_bound_new, 1, (yyvsp[-1].code)));
}
#line 2944 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 58:
#line 424 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_numb(numb_new_integer(0)); }
#line 2950 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 59:
#line 425 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = (yyvsp[0].code); }
#line 2956 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 60:
#line 429 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_numb(numb_copy(numb_unknown())); }
#line 2962 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 61:
#line 430 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = (yyvsp[0].code); }
#line 2968 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 62:
#line 438 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_entry_list_new, 1, (yyvsp[0].code)); }
#line 2974 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 63:
#line 439 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_entry_list_add, 2, (yyvsp[-2].code), (yyvsp[0].code));
}
#line 2982 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 64:
#line 442 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_read, 1, (yyvsp[0].code)); }
#line 2988 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 65:
#line 443 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_list_matrix, 2, (yyvsp[-1].code), (yyvsp[0].code)); }
#line 2994 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 66:
#line 447 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_entry, 2, (yyvsp[-1].code), (yyvsp[0].code)); }
#line 3000 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 67:
#line 451 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = (yyvsp[-1].code); }
#line 3006 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 68:
#line 455 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_matrix_list_new, 2, (yyvsp[-2].code), (yyvsp[-1].code));
}
#line 3014 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 69:
#line 458 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_matrix_list_add, 3, (yyvsp[-3].code), (yyvsp[-2].code), (yyvsp[-1].code));
}
#line 3022 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 70:
#line 470 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_object_min, 2, code_new_name((yyvsp[-3].name)), (yyvsp[-1].code));
}
#line 3030 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 71:
#line 473 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_object_max, 2, code_new_name((yyvsp[-3].name)), (yyvsp[-1].code));
}
#line 3038 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 72:
#line 483 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_subto, 2, code_new_name((yyvsp[-3].name)), (yyvsp[-1].code));
}
#line 3046 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 73:
#line 489 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_constraint_list, 2, (yyvsp[0].code), code_new_inst(i_nop, 0));
}
#line 3054 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 74:
#line 492 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_constraint_list, 2, (yyvsp[-2].code), (yyvsp[0].code));
}
#line 3062 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 75:
#line 495 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_constraint_list, 2,
code_new_inst(i_forall, 2, (yyvsp[-2].code), (yyvsp[0].code)),
code_new_inst(i_nop, 0));
}
#line 3072 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 76:
#line 500 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_constraint_list, 2,
code_new_inst(i_expr_if_else, 3, (yyvsp[-3].code), (yyvsp[-1].code), code_new_inst(i_nop, 0)),
code_new_inst(i_nop, 0));
}
#line 3082 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 77:
#line 505 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_constraint_list, 2,
code_new_inst(i_expr_if_else, 3, (yyvsp[-5].code), (yyvsp[-3].code), (yyvsp[-1].code)),
code_new_inst(i_nop, 0));
}
#line 3092 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 78:
#line 513 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_constraint, 4, (yyvsp[-3].code), (yyvsp[-2].code), (yyvsp[-1].code), code_new_bits((yyvsp[0].bits)));
}
#line 3100 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 79:
#line 516 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_constraint, 4, (yyvsp[-3].code), (yyvsp[-2].code),
code_new_inst(i_term_expr, 1, (yyvsp[-1].code)),
code_new_bits((yyvsp[0].bits)));
}
#line 3110 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 80:
#line 521 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_constraint, 4,
code_new_inst(i_term_expr, 1, (yyvsp[-3].code)),
(yyvsp[-2].code), (yyvsp[-1].code), code_new_bits((yyvsp[0].bits)));
}
#line 3120 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 81:
#line 526 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_constraint, 4,
code_new_inst(i_term_expr, 1, (yyvsp[-3].code)),
(yyvsp[-2].code),
code_new_inst(i_term_expr, 1, (yyvsp[-1].code)),
code_new_bits((yyvsp[0].bits)));
}
#line 3132 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 82:
#line 533 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_rangeconst, 6, (yyvsp[-5].code), (yyvsp[-3].code), (yyvsp[-1].code), (yyvsp[-4].code),
code_new_contype(CON_RHS), code_new_bits((yyvsp[0].bits)));
}
#line 3141 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 83:
#line 537 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_rangeconst, 6, (yyvsp[-5].code),
code_new_inst(i_term_expr, 1, (yyvsp[-3].code)), (yyvsp[-1].code), (yyvsp[-4].code),
code_new_contype(CON_RHS), code_new_bits((yyvsp[0].bits)));
}
#line 3151 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 84:
#line 542 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_rangeconst, 6, (yyvsp[-1].code), (yyvsp[-3].code), (yyvsp[-5].code), (yyvsp[-4].code),
code_new_contype(CON_LHS), code_new_bits((yyvsp[0].bits)));
}
#line 3160 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 85:
#line 546 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_rangeconst, 6, (yyvsp[-1].code),
code_new_inst(i_term_expr, 1, (yyvsp[-3].code)),
(yyvsp[-5].code), (yyvsp[-4].code),
code_new_contype(CON_LHS), code_new_bits((yyvsp[0].bits)));
}
#line 3171 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 86:
#line 552 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_vif_else, 8, (yyvsp[-10].code), (yyvsp[-8].code), (yyvsp[-7].code), (yyvsp[-6].code), (yyvsp[-4].code), (yyvsp[-3].code), (yyvsp[-2].code), code_new_bits((yyvsp[0].bits)));
}
#line 3179 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 87:
#line 555 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_vif_else, 8, (yyvsp[-10].code),
code_new_inst(i_term_expr, 1, (yyvsp[-8].code)),
(yyvsp[-7].code), (yyvsp[-6].code), (yyvsp[-4].code), (yyvsp[-3].code), (yyvsp[-2].code), code_new_bits((yyvsp[0].bits)));
}
#line 3189 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 88:
#line 560 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_vif_else, 8, (yyvsp[-10].code), (yyvsp[-8].code), (yyvsp[-7].code),
code_new_inst(i_term_expr, 1, (yyvsp[-6].code)),
(yyvsp[-4].code), (yyvsp[-3].code), (yyvsp[-2].code), code_new_bits((yyvsp[0].bits)));
}
#line 3199 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 89:
#line 565 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_vif_else, 8, (yyvsp[-10].code), (yyvsp[-8].code), (yyvsp[-7].code), (yyvsp[-6].code),
code_new_inst(i_term_expr, 1, (yyvsp[-4].code)),
(yyvsp[-3].code), (yyvsp[-2].code), code_new_bits((yyvsp[0].bits)));
}
#line 3209 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 90:
#line 570 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_vif_else, 8, (yyvsp[-10].code), (yyvsp[-8].code), (yyvsp[-7].code), (yyvsp[-6].code), (yyvsp[-4].code), (yyvsp[-3].code),
code_new_inst(i_term_expr, 1, (yyvsp[-2].code)), code_new_bits((yyvsp[0].bits)));
}
#line 3218 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 91:
#line 574 "src/mmlparse2.y" /* yacc.c:1646 */
{ /* ??? This is an error */
(yyval.code) = code_new_inst(i_vif_else, 8, (yyvsp[-10].code),
code_new_inst(i_term_expr, 1, (yyvsp[-8].code)),
(yyvsp[-7].code),
code_new_inst(i_term_expr, 1, (yyvsp[-6].code)),
(yyvsp[-4].code), (yyvsp[-3].code), (yyvsp[-2].code), code_new_bits((yyvsp[0].bits)));
}
#line 3230 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 92:
#line 581 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_vif_else, 8, (yyvsp[-10].code),
code_new_inst(i_term_expr, 1, (yyvsp[-8].code)),
(yyvsp[-7].code), (yyvsp[-6].code),
code_new_inst(i_term_expr, 1, (yyvsp[-4].code)),
(yyvsp[-3].code), (yyvsp[-2].code), code_new_bits((yyvsp[0].bits)));
}
#line 3242 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 93:
#line 588 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_vif_else, 8, (yyvsp[-10].code),
code_new_inst(i_term_expr, 1, (yyvsp[-8].code)),
(yyvsp[-7].code), (yyvsp[-6].code), (yyvsp[-4].code), (yyvsp[-3].code),
code_new_inst(i_term_expr, 1, (yyvsp[-2].code)), code_new_bits((yyvsp[0].bits)));
}
#line 3253 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 94:
#line 594 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_vif_else, 8, (yyvsp[-10].code), (yyvsp[-8].code), (yyvsp[-7].code),
code_new_inst(i_term_expr, 1, (yyvsp[-6].code)),
code_new_inst(i_term_expr, 1, (yyvsp[-4].code)),
(yyvsp[-3].code), (yyvsp[-2].code), code_new_bits((yyvsp[0].bits)));
}
#line 3264 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 95:
#line 600 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_vif_else, 8, (yyvsp[-10].code), (yyvsp[-8].code), (yyvsp[-7].code),
code_new_inst(i_term_expr, 1, (yyvsp[-6].code)),
(yyvsp[-4].code), (yyvsp[-3].code),
code_new_inst(i_term_expr, 1, (yyvsp[-2].code)), code_new_bits((yyvsp[0].bits)));
}
#line 3275 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 96:
#line 606 "src/mmlparse2.y" /* yacc.c:1646 */
{ /* ??? This is an error */
(yyval.code) = code_new_inst(i_vif_else, 8, (yyvsp[-10].code), (yyvsp[-8].code), (yyvsp[-7].code), (yyvsp[-6].code),
code_new_inst(i_term_expr, 1, (yyvsp[-4].code)), (yyvsp[-3].code),
code_new_inst(i_term_expr, 1, (yyvsp[-2].code)), code_new_bits((yyvsp[0].bits)));
}
#line 3285 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 97:
#line 611 "src/mmlparse2.y" /* yacc.c:1646 */
{ /* ??? This is an error */
(yyval.code) = code_new_inst(i_vif_else, 8, (yyvsp[-10].code),
code_new_inst(i_term_expr, 1, (yyvsp[-8].code)),
(yyvsp[-7].code),
code_new_inst(i_term_expr, 1, (yyvsp[-6].code)),
code_new_inst(i_term_expr, 1, (yyvsp[-4].code)),
(yyvsp[-3].code), (yyvsp[-2].code), code_new_bits((yyvsp[0].bits)));
}
#line 3298 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 98:
#line 619 "src/mmlparse2.y" /* yacc.c:1646 */
{ /* ??? This is an error */
(yyval.code) = code_new_inst(i_vif_else, 8, (yyvsp[-10].code),
code_new_inst(i_term_expr, 1, (yyvsp[-8].code)),
(yyvsp[-7].code),
code_new_inst(i_term_expr, 1, (yyvsp[-6].code)),
(yyvsp[-4].code), (yyvsp[-3].code),
code_new_inst(i_term_expr, 1, (yyvsp[-2].code)),
code_new_bits((yyvsp[0].bits)));
}
#line 3312 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 99:
#line 628 "src/mmlparse2.y" /* yacc.c:1646 */
{ /* ??? This is an error */
(yyval.code) = code_new_inst(i_vif_else, 8, (yyvsp[-10].code),
code_new_inst(i_term_expr, 1, (yyvsp[-8].code)),
(yyvsp[-7].code), (yyvsp[-6].code),
code_new_inst(i_term_expr, 1, (yyvsp[-4].code)),
(yyvsp[-3].code),
code_new_inst(i_term_expr, 1, (yyvsp[-2].code)),
code_new_bits((yyvsp[0].bits)));
}
#line 3326 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 100:
#line 637 "src/mmlparse2.y" /* yacc.c:1646 */
{ /* ??? This is an error */
(yyval.code) = code_new_inst(i_vif_else, 8, (yyvsp[-10].code), (yyvsp[-8].code), (yyvsp[-7].code),
code_new_inst(i_term_expr, 1, (yyvsp[-6].code)),
code_new_inst(i_term_expr, 1, (yyvsp[-4].code)),
(yyvsp[-3].code),
code_new_inst(i_term_expr, 1, (yyvsp[-2].code)),
code_new_bits((yyvsp[0].bits)));
}
#line 3339 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 101:
#line 645 "src/mmlparse2.y" /* yacc.c:1646 */
{ /* ??? This is an error */
(yyval.code) = code_new_inst(i_vif_else, 8, (yyvsp[-10].code),
code_new_inst(i_term_expr, 1, (yyvsp[-8].code)),
(yyvsp[-7].code),
code_new_inst(i_term_expr, 1, (yyvsp[-6].code)),
code_new_inst(i_term_expr, 1, (yyvsp[-4].code)),
(yyvsp[-3].code),
code_new_inst(i_term_expr, 1, (yyvsp[-2].code)),
code_new_bits((yyvsp[0].bits)));
}
#line 3354 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 102:
#line 656 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_vif, 5, (yyvsp[-6].code), (yyvsp[-4].code), (yyvsp[-3].code), (yyvsp[-2].code), code_new_bits((yyvsp[0].bits)));
}
#line 3362 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 103:
#line 659 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_vif, 5, (yyvsp[-6].code),
code_new_inst(i_term_expr, 1, (yyvsp[-4].code)), (yyvsp[-3].code), (yyvsp[-2].code), code_new_bits((yyvsp[0].bits)));
}
#line 3371 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 104:
#line 663 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_vif, 5, (yyvsp[-6].code),
(yyvsp[-4].code), (yyvsp[-3].code), code_new_inst(i_term_expr, 1, (yyvsp[-2].code)),
code_new_bits((yyvsp[0].bits)));
}
#line 3381 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 105:
#line 668 "src/mmlparse2.y" /* yacc.c:1646 */
{ /* ??? This is an error */
(yyval.code) = code_new_inst(i_vif, 5, (yyvsp[-6].code),
code_new_inst(i_term_expr, 1, (yyvsp[-4].code)), (yyvsp[-3].code),
code_new_inst(i_term_expr, 1, (yyvsp[-2].code)), code_new_bits((yyvsp[0].bits)));
}
#line 3391 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 106:
#line 676 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_vbool_ne, 2, (yyvsp[-2].code), (yyvsp[0].code)); }
#line 3397 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 107:
#line 677 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_vbool_ne, 2, code_new_inst(i_term_expr, 1, (yyvsp[-2].code)), (yyvsp[0].code));
}
#line 3405 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 108:
#line 680 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_vbool_ne, 2, (yyvsp[-2].code), code_new_inst(i_term_expr, 1, (yyvsp[0].code)));
}
#line 3413 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 109:
#line 683 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_vbool_eq, 2, (yyvsp[-2].code), (yyvsp[0].code)); }
#line 3419 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 110:
#line 684 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_vbool_eq, 2, code_new_inst(i_term_expr, 1, (yyvsp[-2].code)), (yyvsp[0].code));
}
#line 3427 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 111:
#line 687 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_vbool_eq, 2, (yyvsp[-2].code), code_new_inst(i_term_expr, 1, (yyvsp[0].code)));
}
#line 3435 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 112:
#line 690 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_vbool_le, 2, (yyvsp[-2].code), (yyvsp[0].code)); }
#line 3441 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 113:
#line 691 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_vbool_le, 2, code_new_inst(i_term_expr, 1, (yyvsp[-2].code)), (yyvsp[0].code));
}
#line 3449 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 114:
#line 694 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_vbool_le, 2, (yyvsp[-2].code), code_new_inst(i_term_expr, 1, (yyvsp[0].code)));
}
#line 3457 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 115:
#line 697 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_vbool_ge, 2, (yyvsp[-2].code), (yyvsp[0].code)); }
#line 3463 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 116:
#line 698 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_vbool_ge, 2, code_new_inst(i_term_expr, 1, (yyvsp[-2].code)), (yyvsp[0].code));
}
#line 3471 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 117:
#line 701 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_vbool_ge, 2, (yyvsp[-2].code), code_new_inst(i_term_expr, 1, (yyvsp[0].code)));
}
#line 3479 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 118:
#line 704 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_vbool_lt, 2, (yyvsp[-2].code), (yyvsp[0].code)); }
#line 3485 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 119:
#line 705 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_vbool_lt, 2, code_new_inst(i_term_expr, 1, (yyvsp[-2].code)), (yyvsp[0].code));
}
#line 3493 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 120:
#line 708 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_vbool_lt, 2, (yyvsp[-2].code), code_new_inst(i_term_expr, 1, (yyvsp[0].code)));
}
#line 3501 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 121:
#line 711 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_vbool_gt, 2, (yyvsp[-2].code), (yyvsp[0].code)); }
#line 3507 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 122:
#line 712 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_vbool_gt, 2, code_new_inst(i_term_expr, 1, (yyvsp[-2].code)), (yyvsp[0].code));
}
#line 3515 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 123:
#line 715 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_vbool_gt, 2, (yyvsp[-2].code), code_new_inst(i_term_expr, 1, (yyvsp[0].code)));
}
#line 3523 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 124:
#line 718 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_vbool_and, 2, (yyvsp[-2].code), (yyvsp[0].code)); }
#line 3529 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 125:
#line 719 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_vbool_or, 2, (yyvsp[-2].code), (yyvsp[0].code)); }
#line 3535 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 126:
#line 720 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_vbool_xor, 2, (yyvsp[-2].code), (yyvsp[0].code)); }
#line 3541 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 127:
#line 721 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_vbool_not, 1, (yyvsp[0].code)); }
#line 3547 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 128:
#line 722 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = (yyvsp[-1].code); }
#line 3553 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 129:
#line 726 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.bits) = 0; }
#line 3559 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 130:
#line 727 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.bits) = (yyvsp[-2].bits) | (yyvsp[0].bits); }
#line 3565 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 131:
#line 731 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.bits) = LP_FLAG_CON_SCALE; }
#line 3571 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 132:
#line 732 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.bits) = LP_FLAG_CON_SEPAR; }
#line 3577 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 133:
#line 733 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.bits) = LP_FLAG_CON_CHECK; }
#line 3583 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 134:
#line 734 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.bits) = LP_FLAG_CON_INDIC; }
#line 3589 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 135:
#line 738 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_contype(CON_RHS); }
#line 3595 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 136:
#line 739 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_contype(CON_LHS); }
#line 3601 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 137:
#line 740 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_contype(CON_EQUAL); }
#line 3607 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 138:
#line 744 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = (yyvsp[0].code); }
#line 3613 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 139:
#line 745 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_term_add, 2, (yyvsp[-2].code), (yyvsp[0].code)); }
#line 3619 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 140:
#line 746 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_term_sub, 2, (yyvsp[-2].code), (yyvsp[0].code)); }
#line 3625 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 141:
#line 747 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_term_const, 2, (yyvsp[-2].code), (yyvsp[0].code)); }
#line 3631 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 142:
#line 748 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_term_sub, 2, (yyvsp[-2].code), code_new_inst(i_term_expr, 1, (yyvsp[0].code)));
}
#line 3639 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 143:
#line 751 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_term_const, 2, (yyvsp[0].code), (yyvsp[-2].code)); }
#line 3645 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 144:
#line 752 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_term_sub, 2,
code_new_inst(i_term_expr, 1, (yyvsp[-2].code)),
(yyvsp[0].code));
}
#line 3655 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 145:
#line 760 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = (yyvsp[0].code); }
#line 3661 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 146:
#line 761 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_term_coeff, 2, (yyvsp[-2].code), (yyvsp[0].code)); }
#line 3667 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 147:
#line 762 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_term_coeff, 2, (yyvsp[-2].code),
code_new_inst(i_expr_div, 2, code_new_numb(numb_new_integer(1)), (yyvsp[0].code)));
}
#line 3676 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 148:
#line 766 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_term_coeff, 2, (yyvsp[0].code), (yyvsp[-2].code)); }
#line 3682 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 149:
#line 767 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_term_mul, 2, (yyvsp[-2].code), (yyvsp[0].code)); }
#line 3688 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 151:
#line 772 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = (yyvsp[0].code); }
#line 3694 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 152:
#line 773 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_term_coeff, 2, (yyvsp[0].code), code_new_numb(numb_new_integer(-1)));
}
#line 3702 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 153:
#line 779 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = (yyvsp[0].code); }
#line 3708 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 154:
#line 780 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_term_power, 2, (yyvsp[-2].code), (yyvsp[0].code));
}
#line 3716 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 155:
#line 783 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_term_sum, 2, (yyvsp[-2].code), (yyvsp[0].code));
}
#line 3724 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 156:
#line 789 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_symbol_deref, 2, code_new_symbol((yyvsp[-1].sym)), (yyvsp[0].code));
}
#line 3732 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 157:
#line 792 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_vabs, 1, (yyvsp[-1].code)); }
#line 3738 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 158:
#line 793 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_vexpr_fun, 2, code_new_numb(numb_new_integer(-2)), (yyvsp[-1].code)); }
#line 3744 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 159:
#line 794 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_vexpr_fun, 2, code_new_numb(numb_new_integer(3)), (yyvsp[-1].code)); }
#line 3750 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 160:
#line 795 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_vexpr_fun, 2, code_new_numb(numb_new_integer(4)), (yyvsp[-1].code)); }
#line 3756 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 161:
#line 796 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_vexpr_fun, 2, code_new_numb(numb_new_integer(5)), (yyvsp[-1].code)); }
#line 3762 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 162:
#line 797 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_vexpr_fun, 2, code_new_numb(numb_new_integer(6)), (yyvsp[-1].code)); }
#line 3768 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 163:
#line 798 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_vexpr_fun, 2, code_new_numb(numb_new_integer(7)), (yyvsp[-1].code)); }
#line 3774 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 164:
#line 799 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_vexpr_fun, 2, code_new_numb(numb_new_integer(8)), (yyvsp[-1].code)); }
#line 3780 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 165:
#line 800 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_vexpr_fun, 2, code_new_numb(numb_new_integer(9)), (yyvsp[-1].code)); }
#line 3786 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 166:
#line 801 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_vexpr_fun, 2, code_new_numb(numb_new_integer(10)), (yyvsp[-1].code)); }
#line 3792 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 167:
#line 802 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_vexpr_fun, 3, code_new_numb(numb_new_integer(11)), (yyvsp[-3].code), (yyvsp[-1].code));
}
#line 3800 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 168:
#line 805 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_vexpr_fun, 3, code_new_numb(numb_new_integer(12)), (yyvsp[-3].code), (yyvsp[-1].code));
}
#line 3808 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 169:
#line 808 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_expr_if_else, 3, (yyvsp[-5].code), (yyvsp[-3].code), (yyvsp[-1].code));
}
#line 3816 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 170:
#line 811 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = (yyvsp[-1].code); }
#line 3822 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 171:
#line 819 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_sos, 2, code_new_name((yyvsp[-3].name)), (yyvsp[-1].code));
}
#line 3830 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 172:
#line 825 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_soset, 3, (yyvsp[0].code), (yyvsp[-3].code), (yyvsp[-2].code));
}
#line 3838 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 173:
#line 828 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_forall, 2, (yyvsp[-2].code), (yyvsp[0].code));
}
#line 3846 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 174:
#line 834 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_numb(numb_new_integer(1)); }
#line 3852 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 175:
#line 835 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_numb(numb_new_integer(1)); }
#line 3858 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 176:
#line 836 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_numb(numb_new_integer(2)); }
#line 3864 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 177:
#line 844 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = (yyvsp[-1].code); }
#line 3870 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 178:
#line 848 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_print, 1, (yyvsp[0].code)); }
#line 3876 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 179:
#line 849 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_print, 1, (yyvsp[0].code)); }
#line 3882 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 180:
#line 850 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_print, 1, (yyvsp[0].code)); }
#line 3888 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 181:
#line 851 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_print, 1, code_new_symbol((yyvsp[0].sym))); }
#line 3894 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 182:
#line 852 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_check, 1, (yyvsp[0].code)); }
#line 3900 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 183:
#line 853 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_forall, 2, (yyvsp[-2].code), (yyvsp[0].code));
}
#line 3908 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 184:
#line 863 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = (yyvsp[0].code); }
#line 3914 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 185:
#line 864 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_idxset_new, 3,
code_new_inst(i_tuple_empty, 0), (yyvsp[0].code), code_new_inst(i_bool_true, 0));
}
#line 3923 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 186:
#line 871 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_idxset_new, 3, (yyvsp[-4].code), (yyvsp[-2].code), (yyvsp[0].code));
}
#line 3931 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 187:
#line 874 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_idxset_new, 3, (yyvsp[-2].code), (yyvsp[0].code), code_new_inst(i_bool_true, 0));
}
#line 3939 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 189:
#line 881 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_set_union, 2, (yyvsp[-2].code), (yyvsp[0].code)); }
#line 3945 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 190:
#line 882 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_set_union, 2, (yyvsp[-2].code), (yyvsp[0].code));
}
#line 3953 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 191:
#line 885 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_set_sdiff, 2, (yyvsp[-2].code), (yyvsp[0].code)); }
#line 3959 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 192:
#line 886 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_set_minus, 2, (yyvsp[-2].code), (yyvsp[0].code));
}
#line 3967 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 193:
#line 889 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_set_minus, 2, (yyvsp[-2].code), (yyvsp[0].code)); }
#line 3973 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 194:
#line 890 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_set_inter, 2, (yyvsp[-2].code), (yyvsp[0].code)); }
#line 3979 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 196:
#line 894 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_set_union2, 2, (yyvsp[-2].code), (yyvsp[0].code)); }
#line 3985 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 198:
#line 899 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_set_cross, 2, (yyvsp[-2].code), (yyvsp[0].code)); }
#line 3991 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 199:
#line 900 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_set_cross, 2, (yyvsp[-2].code), (yyvsp[0].code));
}
#line 3999 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 200:
#line 903 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_set_inter2, 2, (yyvsp[-2].code), (yyvsp[0].code)); }
#line 4005 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 201:
#line 907 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_symbol_deref, 2, code_new_symbol((yyvsp[-1].sym)), (yyvsp[0].code));
}
#line 4013 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 202:
#line 910 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_define_deref, 2,
code_new_define((yyvsp[-3].def)),
code_new_inst(i_tuple_new, 1, (yyvsp[-1].code)));
}
#line 4023 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 203:
#line 915 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_set_empty, 1, code_new_size(0)); }
#line 4029 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 204:
#line 916 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_set_range2, 3, (yyvsp[-5].code), (yyvsp[-3].code), (yyvsp[-1].code));
}
#line 4037 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 205:
#line 919 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_set_range2, 3, (yyvsp[-3].code), (yyvsp[-1].code), code_new_numb(numb_new_integer(1)));
}
#line 4045 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 206:
#line 922 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_set_range, 3, (yyvsp[-5].code), (yyvsp[-3].code), (yyvsp[-1].code));
}
#line 4053 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 207:
#line 925 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_set_range, 3, (yyvsp[-3].code), (yyvsp[-1].code), code_new_numb(numb_new_integer(1)));
}
#line 4061 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 208:
#line 928 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_set_argmin, 3, code_new_numb(numb_new_integer(1)), (yyvsp[-2].code), (yyvsp[0].code));
}
#line 4069 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 209:
#line 931 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_set_argmin, 3, (yyvsp[-4].code), (yyvsp[-2].code), (yyvsp[0].code));
}
#line 4077 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 210:
#line 934 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_set_argmax, 3, code_new_numb(numb_new_integer(1)), (yyvsp[-2].code), (yyvsp[0].code));
}
#line 4085 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 211:
#line 937 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_set_argmax, 3, (yyvsp[-4].code), (yyvsp[-2].code), (yyvsp[0].code));
}
#line 4093 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 212:
#line 940 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = (yyvsp[-1].code); }
#line 4099 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 213:
#line 941 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_set_new_tuple, 1, (yyvsp[-1].code)); }
#line 4105 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 214:
#line 942 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_set_new_elem, 1, (yyvsp[-1].code)); }
#line 4111 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 215:
#line 943 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_set_idxset, 1, (yyvsp[-1].code)); }
#line 4117 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 216:
#line 944 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_set_expr, 2, (yyvsp[-3].code), (yyvsp[-1].code)); }
#line 4123 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 217:
#line 945 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_set_expr, 2, (yyvsp[-3].code), (yyvsp[-1].code)); }
#line 4129 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 218:
#line 946 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_set_proj, 2, (yyvsp[-3].code), (yyvsp[-1].code));
}
#line 4137 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 219:
#line 949 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_set_indexset, 1, code_new_symbol((yyvsp[-1].sym)));
}
#line 4145 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 220:
#line 952 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_expr_if_else, 3, (yyvsp[-5].code), (yyvsp[-3].code), (yyvsp[-1].code));
}
#line 4153 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 221:
#line 958 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_read_new, 2, (yyvsp[-2].code), (yyvsp[0].code)); }
#line 4159 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 222:
#line 959 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_read_param, 2, (yyvsp[-1].code), (yyvsp[0].code)); }
#line 4165 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 223:
#line 963 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_read_skip, 1, (yyvsp[0].code)); }
#line 4171 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 224:
#line 964 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_read_use, 1, (yyvsp[0].code)); }
#line 4177 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 225:
#line 965 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_read_comment, 1, (yyvsp[0].code)); }
#line 4183 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 226:
#line 966 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_read_match, 1, (yyvsp[0].code)); }
#line 4189 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 227:
#line 970 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_tuple_list_new, 1, (yyvsp[0].code));
}
#line 4197 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 228:
#line 973 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_tuple_list_add, 2, (yyvsp[-2].code), (yyvsp[0].code));
}
#line 4205 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 229:
#line 976 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_read, 1, (yyvsp[0].code)); }
#line 4211 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 230:
#line 980 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_bool_eq, 2, (yyvsp[-2].code), (yyvsp[0].code)); }
#line 4217 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 231:
#line 981 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_bool_ne, 2, (yyvsp[-2].code), (yyvsp[0].code)); }
#line 4223 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 232:
#line 982 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_bool_gt, 2, (yyvsp[-2].code), (yyvsp[0].code)); }
#line 4229 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 233:
#line 983 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_bool_ge, 2, (yyvsp[-2].code), (yyvsp[0].code)); }
#line 4235 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 234:
#line 984 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_bool_lt, 2, (yyvsp[-2].code), (yyvsp[0].code)); }
#line 4241 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 235:
#line 985 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_bool_le, 2, (yyvsp[-2].code), (yyvsp[0].code)); }
#line 4247 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 236:
#line 986 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_bool_seq, 2, (yyvsp[-2].code), (yyvsp[0].code)); }
#line 4253 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 237:
#line 987 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_bool_sneq, 2, (yyvsp[-2].code), (yyvsp[0].code)); }
#line 4259 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 238:
#line 988 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_bool_subs, 2, (yyvsp[0].code), (yyvsp[-2].code)); }
#line 4265 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 239:
#line 989 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_bool_sseq, 2, (yyvsp[0].code), (yyvsp[-2].code)); }
#line 4271 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 240:
#line 990 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_bool_subs, 2, (yyvsp[-2].code), (yyvsp[0].code)); }
#line 4277 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 241:
#line 991 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_bool_sseq, 2, (yyvsp[-2].code), (yyvsp[0].code)); }
#line 4283 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 242:
#line 992 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_bool_and, 2, (yyvsp[-2].code), (yyvsp[0].code)); }
#line 4289 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 243:
#line 993 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_bool_or, 2, (yyvsp[-2].code), (yyvsp[0].code)); }
#line 4295 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 244:
#line 994 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_bool_xor, 2, (yyvsp[-2].code), (yyvsp[0].code)); }
#line 4301 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 245:
#line 995 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_bool_not, 1, (yyvsp[0].code)); }
#line 4307 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 246:
#line 996 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = (yyvsp[-1].code); }
#line 4313 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 247:
#line 997 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_bool_is_elem, 2, (yyvsp[-2].code), (yyvsp[0].code)); }
#line 4319 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 248:
#line 998 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_bool_exists, 1, (yyvsp[-1].code)); }
#line 4325 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 249:
#line 999 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_define_deref, 2,
code_new_define((yyvsp[-3].def)),
code_new_inst(i_tuple_new, 1, (yyvsp[-1].code)));
}
#line 4335 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 250:
#line 1004 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_expr_if_else, 3, (yyvsp[-5].code), (yyvsp[-3].code), (yyvsp[-1].code));
}
#line 4343 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 251:
#line 1010 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_tuple_empty, 0); }
#line 4349 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 252:
#line 1011 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_tuple_new, 1, (yyvsp[-1].code)); }
#line 4355 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 253:
#line 1015 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_tuple_empty, 0);
}
#line 4363 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 254:
#line 1018 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_tuple_new, 1, (yyvsp[-1].code));
}
#line 4371 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 255:
#line 1024 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_elem_list_new, 1, (yyvsp[0].code));
}
#line 4379 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 256:
#line 1027 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_elem_list_add, 2, (yyvsp[-2].code), (yyvsp[0].code));
}
#line 4387 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 257:
#line 1033 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = (yyvsp[0].code); }
#line 4393 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 258:
#line 1034 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_expr_add, 2, (yyvsp[-2].code), (yyvsp[0].code)); }
#line 4399 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 259:
#line 1035 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_expr_sub, 2, (yyvsp[-2].code), (yyvsp[0].code)); }
#line 4405 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 260:
#line 1039 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = (yyvsp[0].code); }
#line 4411 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 261:
#line 1040 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_expr_mul, 2, (yyvsp[-2].code), (yyvsp[0].code)); }
#line 4417 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 262:
#line 1041 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_expr_div, 2, (yyvsp[-2].code), (yyvsp[0].code)); }
#line 4423 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 263:
#line 1042 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_expr_mod, 2, (yyvsp[-2].code), (yyvsp[0].code)); }
#line 4429 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 264:
#line 1043 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_expr_intdiv, 2, (yyvsp[-2].code), (yyvsp[0].code)); }
#line 4435 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 265:
#line 1044 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_expr_prod, 2, (yyvsp[-2].code), (yyvsp[0].code));
}
#line 4443 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 267:
#line 1051 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = (yyvsp[0].code); }
#line 4449 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 268:
#line 1052 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_expr_neg, 1, (yyvsp[0].code)); }
#line 4455 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 270:
#line 1057 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_expr_pow, 2, (yyvsp[-2].code), (yyvsp[0].code)); }
#line 4461 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 271:
#line 1058 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_expr_sum, 2, (yyvsp[-2].code), (yyvsp[0].code));
}
#line 4469 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 272:
#line 1061 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_expr_min, 2, (yyvsp[-2].code), (yyvsp[0].code));
}
#line 4477 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 273:
#line 1064 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_expr_max, 2, (yyvsp[-2].code), (yyvsp[0].code));
}
#line 4485 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 274:
#line 1067 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_expr_sglmin, 1, (yyvsp[-1].code));
}
#line 4493 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 275:
#line 1070 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_expr_sglmax, 1, (yyvsp[-1].code));
}
#line 4501 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 276:
#line 1076 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_numb((yyvsp[0].numb)); }
#line 4507 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 277:
#line 1077 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_strg((yyvsp[0].strg)); }
#line 4513 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 278:
#line 1078 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_local_deref, 1, code_new_name((yyvsp[0].name)));
}
#line 4521 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 279:
#line 1081 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_symbol_deref, 2, code_new_symbol((yyvsp[-1].sym)), (yyvsp[0].code));
}
#line 4529 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 280:
#line 1084 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_symbol_deref, 2, code_new_symbol((yyvsp[-1].sym)), (yyvsp[0].code));
}
#line 4537 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 281:
#line 1087 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_define_deref, 2,
code_new_define((yyvsp[-3].def)),
code_new_inst(i_tuple_new, 1, (yyvsp[-1].code)));
}
#line 4547 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 282:
#line 1092 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_define_deref, 2,
code_new_define((yyvsp[-3].def)),
code_new_inst(i_tuple_new, 1, (yyvsp[-1].code)));
}
#line 4557 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 283:
#line 1097 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_expr_fac, 1, (yyvsp[-1].code)); }
#line 4563 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 284:
#line 1098 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_expr_card, 1, (yyvsp[-1].code)); }
#line 4569 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 285:
#line 1099 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_expr_abs, 1, (yyvsp[-1].code)); }
#line 4575 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 286:
#line 1100 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_expr_sgn, 1, (yyvsp[-1].code)); }
#line 4581 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 287:
#line 1101 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_expr_round, 1, (yyvsp[-1].code)); }
#line 4587 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 288:
#line 1102 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_expr_floor, 1, (yyvsp[-1].code)); }
#line 4593 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 289:
#line 1103 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_expr_ceil, 1, (yyvsp[-1].code)); }
#line 4599 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 290:
#line 1104 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_expr_log, 1, (yyvsp[-1].code)); }
#line 4605 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 291:
#line 1105 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_expr_ln, 1, (yyvsp[-1].code)); }
#line 4611 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 292:
#line 1106 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_expr_exp, 1, (yyvsp[-1].code)); }
#line 4617 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 293:
#line 1107 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_expr_sqrt, 1, (yyvsp[-1].code)); }
#line 4623 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 294:
#line 1108 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_expr_sin, 1, (yyvsp[-1].code)); }
#line 4629 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 295:
#line 1109 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_expr_cos, 1, (yyvsp[-1].code)); }
#line 4635 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 296:
#line 1110 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_expr_tan, 1, (yyvsp[-1].code)); }
#line 4641 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 297:
#line 1111 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_expr_asin, 1, (yyvsp[-1].code)); }
#line 4647 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 298:
#line 1112 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_expr_acos, 1, (yyvsp[-1].code)); }
#line 4653 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 299:
#line 1113 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_expr_atan, 1, (yyvsp[-1].code)); }
#line 4659 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 300:
#line 1115 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = (yyvsp[-1].code); }
#line 4665 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 301:
#line 1116 "src/mmlparse2.y" /* yacc.c:1646 */
{ (yyval.code) = code_new_inst(i_expr_length, 1, (yyvsp[-1].code)); }
#line 4671 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 302:
#line 1117 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_expr_substr, 3, (yyvsp[-5].code), (yyvsp[-3].code), (yyvsp[-1].code));
}
#line 4679 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 303:
#line 1120 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_expr_rand, 2, (yyvsp[-3].code), (yyvsp[-1].code));
}
#line 4687 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 304:
#line 1123 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_expr_if_else, 3, (yyvsp[-5].code), (yyvsp[-3].code), (yyvsp[-1].code));
}
#line 4695 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 305:
#line 1126 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_expr_ord, 3, (yyvsp[-5].code), (yyvsp[-3].code), (yyvsp[-1].code));
}
#line 4703 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 306:
#line 1129 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_expr_min2, 1, (yyvsp[-1].code));
}
#line 4711 "src/mmlparse2.c" /* yacc.c:1646 */
break;
case 307:
#line 1132 "src/mmlparse2.y" /* yacc.c:1646 */
{
(yyval.code) = code_new_inst(i_expr_max2, 1, (yyvsp[-1].code));
}
#line 4719 "src/mmlparse2.c" /* yacc.c:1646 */
break;
#line 4723 "src/mmlparse2.c" /* yacc.c:1646 */
default: break;
}
/* User semantic actions sometimes alter yychar, and that requires
that yytoken be updated with the new translation. We take the
approach of translating immediately before every use of yytoken.
One alternative is translating here after every semantic action,
but that translation would be missed if the semantic action invokes
YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
incorrect destructor might then be invoked immediately. In the
case of YYERROR or YYBACKUP, subsequent parser actions might lead
to an incorrect destructor call or verbose syntax error message
before the lookahead is translated. */
YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
YYPOPSTACK (yylen);
yylen = 0;
YY_STACK_PRINT (yyss, yyssp);
*++yyvsp = yyval;
/* Now 'shift' the result of the reduction. Determine what state
that goes to, based on the state we popped back to and the rule
number reduced by. */
yyn = yyr1[yyn];
yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
yystate = yytable[yystate];
else
yystate = yydefgoto[yyn - YYNTOKENS];
goto yynewstate;
/*--------------------------------------.
| yyerrlab -- here on detecting error. |
`--------------------------------------*/
yyerrlab:
/* Make sure we have latest lookahead translation. See comments at
user semantic actions for why this is necessary. */
yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
/* If not already recovering from an error, report this error. */
if (!yyerrstatus)
{
++yynerrs;
#if ! YYERROR_VERBOSE
yyerror (YY_("syntax error"));
#else
# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
yyssp, yytoken)
{
char const *yymsgp = YY_("syntax error");
int yysyntax_error_status;
yysyntax_error_status = YYSYNTAX_ERROR;
if (yysyntax_error_status == 0)
yymsgp = yymsg;
else if (yysyntax_error_status == 1)
{
if (yymsg != yymsgbuf)
YYSTACK_FREE (yymsg);
yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
if (!yymsg)
{
yymsg = yymsgbuf;
yymsg_alloc = sizeof yymsgbuf;
yysyntax_error_status = 2;
}
else
{
yysyntax_error_status = YYSYNTAX_ERROR;
yymsgp = yymsg;
}
}
yyerror (yymsgp);
if (yysyntax_error_status == 2)
goto yyexhaustedlab;
}
# undef YYSYNTAX_ERROR
#endif
}
if (yyerrstatus == 3)
{
/* If just tried and failed to reuse lookahead token after an
error, discard it. */
if (yychar <= YYEOF)
{
/* Return failure if at end of input. */
if (yychar == YYEOF)
YYABORT;
}
else
{
yydestruct ("Error: discarding",
yytoken, &yylval);
yychar = YYEMPTY;
}
}
/* Else will try to reuse lookahead token after shifting the error
token. */
goto yyerrlab1;
/*---------------------------------------------------.
| yyerrorlab -- error raised explicitly by YYERROR. |
`---------------------------------------------------*/
yyerrorlab:
/* Pacify compilers like GCC when the user code never invokes
YYERROR and the label yyerrorlab therefore never appears in user
code. */
if (/*CONSTCOND*/ 0)
goto yyerrorlab;
/* Do not reclaim the symbols of the rule whose action triggered
this YYERROR. */
YYPOPSTACK (yylen);
yylen = 0;
YY_STACK_PRINT (yyss, yyssp);
yystate = *yyssp;
goto yyerrlab1;
/*-------------------------------------------------------------.
| yyerrlab1 -- common code for both syntax error and YYERROR. |
`-------------------------------------------------------------*/
yyerrlab1:
yyerrstatus = 3; /* Each real token shifted decrements this. */
for (;;)
{
yyn = yypact[yystate];
if (!yypact_value_is_default (yyn))
{
yyn += YYTERROR;
if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
{
yyn = yytable[yyn];
if (0 < yyn)
break;
}
}
/* Pop the current state because it cannot handle the error token. */
if (yyssp == yyss)
YYABORT;
yydestruct ("Error: popping",
yystos[yystate], yyvsp);
YYPOPSTACK (1);
yystate = *yyssp;
YY_STACK_PRINT (yyss, yyssp);
}
YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
*++yyvsp = yylval;
YY_IGNORE_MAYBE_UNINITIALIZED_END
/* Shift the error token. */
YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
yystate = yyn;
goto yynewstate;
/*-------------------------------------.
| yyacceptlab -- YYACCEPT comes here. |
`-------------------------------------*/
yyacceptlab:
yyresult = 0;
goto yyreturn;
/*-----------------------------------.
| yyabortlab -- YYABORT comes here. |
`-----------------------------------*/
yyabortlab:
yyresult = 1;
goto yyreturn;
#if !defined yyoverflow || YYERROR_VERBOSE
/*-------------------------------------------------.
| yyexhaustedlab -- memory exhaustion comes here. |
`-------------------------------------------------*/
yyexhaustedlab:
yyerror (YY_("memory exhausted"));
yyresult = 2;
/* Fall through. */
#endif
yyreturn:
if (yychar != YYEMPTY)
{
/* Make sure we have latest lookahead translation. See comments at
user semantic actions for why this is necessary. */
yytoken = YYTRANSLATE (yychar);
yydestruct ("Cleanup: discarding lookahead",
yytoken, &yylval);
}
/* Do not reclaim the symbols of the rule whose action triggered
this YYABORT or YYACCEPT. */
YYPOPSTACK (yylen);
YY_STACK_PRINT (yyss, yyssp);
while (yyssp != yyss)
{
yydestruct ("Cleanup: popping",
yystos[*yyssp], yyvsp);
YYPOPSTACK (1);
}
#ifndef yyoverflow
if (yyss != yyssa)
YYSTACK_FREE (yyss);
#endif
#if YYERROR_VERBOSE
if (yymsg != yymsgbuf)
YYSTACK_FREE (yymsg);
#endif
return yyresult;
}
zimpl-3.3.4/src/zimpllib.h 0000640 0012352 0006025 00000004364 13057565713 015331 0 ustar bzfgamra optimi /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* File....: zimpllib.h */
/* Name....: Zimpl library */
/* Author..: Thorsten Koch */
/* Copyright by Author, All rights reserved */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Copyright (C) 2005-2017 by Thorsten Koch
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _ZIMPLLIB_H_
#define _ZIMPLLIB_H_
#ifndef _BOOL_H_
#error "Need to include bool.h before zimpllib.h"
#endif
#ifdef __cplusplus
extern "C" {
#endif
/*lint -sem( zpl_add_parameter, 1p && nulterm(1)) */
extern void zpl_add_parameter(const char* def);
/*lint -sem( zpl_var_print, 1p == 1 && 2p == 1) */
extern void zpl_var_print(FILE* fp, const Var* var);
/*lint -sem( zpl_print_banner, 1p == 1) */
extern void zpl_print_banner(FILE* fp, Bool with_license);
/*lint -sem(zpl_read, nulterm(1)) */
extern Bool zpl_read(const char* filename, Bool with_management, void* user_data);
/*lint -sem(zpl_read_with_args, 1n > 0 && 2p) */
extern Bool zpl_read_with_args(char** argv, int argc, Bool with_management, void* user_data);
#ifdef __cplusplus
}
#endif
#endif /* _ZIMPLLIB_H_ */
zimpl-3.3.4/src/project.lnt 0000640 0012352 0006025 00000007471 13057565713 015525 0 ustar bzfgamra optimi -passes(3)
+fsc // strings are const
-ffc // Function takes Custody flag -> off
-A(C90)
-hFb^3
-width(132,4)
-"format=%f:%l: %t %n: %m"
-Ilint
-Ilint/posix
//-I/usr/include
+libh(lint.h)
-function(exit,_assert)
-function(exit,__assert)
-function(exit,__assertfail)
-function(exit,__assert_fail)
-function(exit,zimpl_exit)
-esym(534,close,creat,fclose,fprintf,fputc,fflush,fsync)
-esym(534,fputs,fscanf,fseek,fwrite,lseek,memcpy,memmove,memset)
-esym(534,printf,puts,scanf,sprintf,sscanf,strcat,strcpy)
-esym(534,strncat,strncpy,unlink,write,regerror)
//
-e592 // Non-literal format specifier used without arguments
-e749 // local enumeration constant not referenced
-e758 // Operator followed by operator is confusing
-e766 // Include of header file not used
-e788 // enum constant not used within defaulted switch
-e801 // Use of goto is deprecated
-e826 // Suspicious pointer-to-pointer conversion
-e834 // Operator followed by operator is confusing. Use parentheses
//
-efile(766,mshell.h)
-efile(537,stdarg.h,float.h,alloca.h,math.h,stdio.h)
-esym(666,assert)
-efile(525,mmlparse.y,mmlparse.c)
-esym(757,yylen)
-DYYMAXDEPTH=0
-esym(526,__builtin_next_arg)
-esym(628,__builtin_next_arg)
-esym(718,__builtin_next_arg)
-esym(746,__builtin_next_arg)
//-esym(749,list_type::LIST_ERR);
-esym(773,BEGIN)
-esym(760,FLEX_DEBUG)
-esym(765,yy_create_buffer,yy_scan_buffer,yy_scan_string,yy_scan_bytes)
-esym(765,yy_switch_to_buffer,yyout,yyin,yy_flush_buffer,yyrestart)
-esym(765,yy_init_buffer,yyleng)
-esym(768,code)
//-esym(123,malloc,calloc,realloc,free)
-strong(AzJzX,Tuple,Set,Str,VBCmpOp,VBFixed)
-strong(AzJzX,IdxSet,Term,TermElem,IneqType,Ineq,Local,ListElem,List)
-strong(AzJzX,ListElem,List,ListData,ListType)
-strong(AzJzX,StmtType,Stmt,Prog,CodeType,CodeNode)
-strong(AzJzX,RDef,RPar,MFP,RParType,RParVal)
-strong(AzJzX,Bound,BoundType)
-strong(AzJzX,Heap,HeapType,HeapData,heapCmp)
-strong(AzJzX,SetIter,SetCheckType,DefineType,Define)
-strong(AzJzX,Var,VarType,VarState,VarClass,Con,ConType,ConState,LpDirect,LpType,LpFormat)
-strong(AzJzX,LpsHElem,LpsHashType)
-strong(AzJzX,PSResult)
-strong(AzJzX,SetType,SetVTab,SetEmpty,SetPseudo,SetHead,SetList,SetRange,SetProd,SetMulti)
-strong(AzJzX,SetEmptyIter,SetPseudoIter,SetListIter,SetRangeIter,SetProdIter,SetMultiIter)
-strong(AzJzX,ElemType,Elem,ElemValue,ElemStore)
-strong(AzJzX,Entry,EntryValue,SymbolType,Symbol)
-strong(AzJzX,Pool,PoolElem)
-strong(AzJzX,Numb,NumbStore)
-strong(AzJzX,StrgFile,FileType)
-strong(AzJzX,HashType,Hash,HElem,SetElemIdx)
-strong(AzJzX,HeapData,heap_data)
-strong(AcJX,Inst)
-strong(AJXbl,Bool)
-e793 // ANSI limit of 1024 'macros in module' exceeded
/* ratlpstore.c */
-esym(528,hash_statist)
/* iread.c */
-esym(771,field) // Symbol 'field' (line 227) conceivably not initialized
/* gmpmisc.c */
-esym(754,pool_elem::pad)
//-e429
//--- Bison ---
-esym(424, yyss, yyvs) // klappt nicht
-esym(613, yyss, yyvs)
-esym(673, yyss, yyvs) // klappt nicht
-esym(553,YYENABLE_NLS,YYLTYPE_IS_TRIVIAL)
-efile(451,lint/posix/stdio.h) // repeated include file
//--- GMP ---
-esym(534,__gmpf_out_str,__gmpq_set_str,__gmpq_out_str)
-esym(849,GMP_RAND_ALG_LC,GMP_RAND_ALG_DEFAULT)
//--- ratlp
-esym(757,lps_readmps) // global not referenced
-efunc(662,code_new_inst)
-efunc(803,lps_makename)
//--- set4.h ---
-esym(768,set_empty::head,set_pseudo::head,set_range::head,set_prod::head,set_multi::head)
-esym(768,set_empty_iter::dummy)
//--- elem.c ---
-esym(522,elem_init)
//--- code.c ---
-esym(534,stkchk_used_x) // ignoring return value
//--- iread.c ---
-esym(645,regex) // regex may not have been initialized
//-------------- NOCH ZU TUN --------------------------------
-e714 // Symbol not referenced
-e765 // external could be made static
-e759 // header declaration for symbol could be moved from header to module
-e769 // global enumeration constant not referenced
-e755 // global macro not referenced
-e413
zimpl-3.3.4/src/define.c 0000640 0012352 0006025 00000007407 13057565713 014735 0 ustar bzfgamra optimi /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* File....: define.c */
/* Name....: Define Table Functions */
/* Author..: Thorsten Koch */
/* Copyright by Author, All rights reserved */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Copyright (C) 2001-2017 by Thorsten Koch
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include
#include
#include
#include
#include "bool.h"
#include "mshell.h"
#include "numb.h"
#include "elem.h"
#include "tuple.h"
#include "mme.h"
#include "define.h"
#define DEFINE_SID 0x44656669
struct define
{
SID
const char* name;
DefineType type;
Tuple* param;
CodeNode* code;
Define* next;
};
#ifndef NDEBUG
static Define anchor = { 0, "", DEF_ERR, NULL, NULL, NULL };
#else
static Define anchor = { "", DEF_ERR, NULL, NULL, NULL };
#endif
Define* define_new(
const char* name,
DefineType type)
{
Define* def;
assert(name != NULL);
assert(strlen(name) > 0);
assert(type != DEF_ERR);
def = calloc(1, sizeof(*def));
assert(def != NULL);
def->name = name;
def->type = type;
def->param = NULL;
def->code = NULL;
def->next = anchor.next;
anchor.next = def;
SID_set(def, DEFINE_SID);
assert(define_is_valid(def));
return def;
}
void define_set_param(
Define* def,
Tuple* param)
{
assert(define_is_valid(def));
assert(tuple_is_valid(param));
def->param = param;
}
void define_set_code(
Define* def,
CodeNode* code)
{
assert(define_is_valid(def));
assert(code != NULL);
def->code = code;
}
void define_exit(void)
{
Define* q;
Define* p;
for(p = anchor.next; p != NULL; p = q)
{
assert(define_is_valid(p));
SID_del(p);
tuple_free(p->param);
q = p->next;
free(p);
}
anchor.next = NULL;
}
Bool define_is_valid(const Define* def)
{
if (def == NULL || !SID_ok(def, DEFINE_SID))
return FALSE;
mem_check(def);
return TRUE;
}
Define* define_lookup(const char* name)
{
Define* def;
assert(name != NULL);
for(def = anchor.next; def != NULL; def = def->next)
if (!strcmp(def->name, name))
break;
return def;
}
const char* define_get_name(const Define* def)
{
assert(define_is_valid(def));
return def->name;
}
DefineType define_get_type(const Define* def)
{
assert(define_is_valid(def));
return def->type;
}
const Tuple* define_get_param(const Define* def)
{
assert(define_is_valid(def));
return def->param;
}
CodeNode* define_get_code(const Define* def)
{
assert(define_is_valid(def));
return def->code;
}
zimpl-3.3.4/src/symbol.c 0000640 0012352 0006025 00000017241 13057565713 015005 0 ustar bzfgamra optimi /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* File....: symbol.c */
/* Name....: Symbol Table Functions */
/* Author..: Thorsten Koch */
/* Copyright by Author, All rights reserved */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Copyright (C) 2001-2017 by Thorsten Koch
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include
#include
#include
#include
#include "bool.h"
#include "mshell.h"
#include "ratlptypes.h"
#include "numb.h"
#include "elem.h"
#include "tuple.h"
#include "mme.h"
#include "entry.h"
#include "set.h"
#include "hash.h"
#include "stmt.h"
#include "symbol.h"
#define TEST_DUBLICATE 0
#define SYMBOL_SID 0x53796d62
#define SYMBOL_EXTEND_SIZE 100
struct symbol
{
SID
const char* name;
int size;
int used;
int extend;
SymbolType type;
Set* set;
Hash* hash;
Entry** entry;
Entry* deflt;
Symbol* next;
};
static Symbol* anchor = NULL;
Symbol* symbol_new(
const char* name,
SymbolType type,
const Set* set,
int estimated_size,
const Entry* deflt)
{
Symbol* sym;
assert(name != NULL);
assert(strlen(name) > 0);
assert(set != NULL);
assert(estimated_size >= 0);
sym = calloc(1, sizeof(*sym));
assert(sym != NULL);
sym->name = name;
sym->type = type;
sym->size = 1;
sym->used = 0;
sym->extend = SYMBOL_EXTEND_SIZE;
sym->set = set_copy(set);
sym->hash = hash_new(HASH_ENTRY, estimated_size);
sym->entry = calloc(1, sizeof(*sym->entry));
sym->deflt = (deflt != ENTRY_NULL) ? entry_copy(deflt) : ENTRY_NULL;
sym->next = anchor;
anchor = sym;
assert(sym->entry != NULL);
SID_set(sym, SYMBOL_SID);
assert(symbol_is_valid(sym));
return sym;
}
void symbol_exit(void)
{
Symbol* q;
Symbol* p;
int i;
for(p = anchor; p != NULL; p = q)
{
assert(symbol_is_valid(p));
SID_del(p);
q = p->next;
for(i = 0; i < p->used; i++)
entry_free(p->entry[i]);
free(p->entry);
set_free(p->set);
hash_free(p->hash);
if (p->deflt != NULL)
entry_free(p->deflt);
free(p);
}
anchor = NULL;
}
Bool symbol_is_valid(const Symbol* sym)
{
if (sym == NULL || !SID_ok(sym, SYMBOL_SID))
return FALSE;
mem_check(sym);
mem_check(sym->entry);
return TRUE;
}
Symbol* symbol_lookup(const char* name)
{
Symbol* sym;
assert(name != NULL);
for(sym = anchor; sym != NULL; sym = sym->next)
if (!strcmp(sym->name, name))
break;
return sym;
}
Bool symbol_has_entry(const Symbol* sym, const Tuple* tuple)
{
assert(symbol_is_valid(sym));
assert(tuple_is_valid(tuple));
return hash_has_entry(sym->hash, tuple)
|| (sym->deflt != NULL && set_lookup(sym->set, tuple));
}
/* Liefert NULL wenn nicht gefunden.
* Falls ein default zurueckgegeben wird, stimmt "tuple" nicht mit
* entry->tuple ueberein.
*/
const Entry* symbol_lookup_entry(const Symbol* sym, const Tuple* tuple)
{
const Entry* entry;
assert(symbol_is_valid(sym));
assert(tuple_is_valid(tuple));
entry = hash_lookup_entry(sym->hash, tuple);
if (NULL == entry && sym->deflt != NULL && set_lookup(sym->set, tuple))
entry = sym->deflt;
return entry;
}
/* Entry is eaten.
* No check is done if entry->tuple is a member of sym->set !
* This has to be done before.
*/
void symbol_add_entry(Symbol* sym, Entry* entry)
{
const Tuple* tuple;
assert(symbol_is_valid(sym));
assert(entry_is_valid(entry));
assert(sym->used <= sym->size);
if (sym->used == sym->size)
{
sym->size += sym->extend;
sym->extend += sym->extend;
sym->entry = realloc(
sym->entry, (size_t)sym->size * sizeof(*sym->entry));
assert(sym->entry != NULL);
}
assert(sym->used < sym->size);
tuple = entry_get_tuple(entry);
/* There is no index set for the internal symbol.
*/
assert(!strcmp(sym->name, SYMBOL_NAME_INTERNAL) || set_lookup(sym->set, tuple));
if (hash_has_entry(sym->hash, tuple))
{
if (stmt_trigger_warning(166))
{
fprintf(stderr, "--- Warning 166: Duplicate element ");
tuple_print(stderr, tuple);
fprintf(stderr, " for symbol %s rejected\n", sym->name);
}
entry_free(entry);
}
else
{
/* Falls noch nicht geschehen, legen wir hier den Typ des
* Symbols fest.
*/
if ((sym->type == SYM_ERR) && (sym->used == 0))
sym->type = entry_get_type(entry);
assert(sym->type != SYM_ERR);
hash_add_entry(sym->hash, entry);
sym->entry[sym->used] = entry;
sym->used++;
}
}
int symbol_get_dim(const Symbol* sym)
{
assert(symbol_is_valid(sym));
return set_get_dim(sym->set);
}
const Set* symbol_get_iset(const Symbol* sym)
{
assert(symbol_is_valid(sym));
return sym->set;
}
const char* symbol_get_name(const Symbol* sym)
{
assert(symbol_is_valid(sym));
return sym->name;
}
SymbolType symbol_get_type(const Symbol* sym)
{
assert(symbol_is_valid(sym));
return sym->type;
}
const Numb* symbol_get_numb(const Symbol* sym, int idx)
{
assert(symbol_is_valid(sym));
assert(idx >= 0);
assert(idx < sym->used);
return entry_get_numb(sym->entry[idx]);
}
const char* symbol_get_strg(const Symbol* sym, int idx)
{
assert(symbol_is_valid(sym));
assert(idx >= 0);
assert(idx < sym->used);
return entry_get_strg(sym->entry[idx]);
}
const Set* symbol_get_set(const Symbol* sym, int idx)
{
assert(symbol_is_valid(sym));
assert(idx >= 0);
assert(idx < sym->used);
return entry_get_set(sym->entry[idx]);
}
Var* symbol_get_var(const Symbol* sym, int idx)
{
assert(symbol_is_valid(sym));
assert(idx >= 0);
assert(idx < sym->used);
return entry_get_var(sym->entry[idx]);
}
void symbol_print(FILE* fp, const Symbol* sym)
{
static const char* const type_name[] = { "Error", "Numb", "Strg", "Set", "Var" };
int i;
assert(symbol_is_valid(sym));
fprintf(fp, "Name : %s\n", sym->name);
fprintf(fp, "Type : %s\n", type_name[sym->type]);
fprintf(fp, "Index : ");
set_print(fp, sym->set);
fprintf(fp, "\nEntries:\n");
for(i = 0; i < sym->used; i++)
{
fprintf(fp, "\t%3d: ", i);
entry_print(fp, sym->entry[i]);
fprintf(fp, "\n");
}
fprintf(fp, "\n");
}
void symbol_print_all(FILE* fp)
{
Symbol* sym;
assert(fp != NULL);
for(sym = anchor; sym != NULL; sym = sym->next)
symbol_print(fp, sym);
}
zimpl-3.3.4/src/entry.h 0000640 0012352 0006025 00000006607 13057565713 014652 0 ustar bzfgamra optimi /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* File....: entry.h */
/* Name....: Symbol Table Entry Functions */
/* Author..: Thorsten Koch */
/* Copyright by Author, All rights reserved */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Copyright (C) 2001-2017 by Thorsten Koch
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _ENTRY_H_
#define _ENTRY_H_
#ifndef _BOOL_H_
#error "Need to include bool.h before entry.h"
#endif
#ifdef __cplusplus
extern "C" {
#endif
#define ENTRY_NULL ((Entry*)0)
/*lint -sem( entry_new_numb, 1p == 1, @p == 1) */
extern Entry* entry_new_numb(const Tuple* tuple, const Numb* numb);
/*lint -sem( entry_new_strg, nulterm(2), 1p == 1 && 2p, @p == 1) */
extern Entry* entry_new_strg(const Tuple* tuple, const char* strg);
/*lint -sem( entry_new_set, 1p == 1 && 2p == 1, @p == 1) */
extern Entry* entry_new_set(const Tuple* tuple, const Set* set);
/*lint -sem( entry_new_var, 1p == 1 && 2p == 1, @p == 1) */
extern Entry* entry_new_var(const Tuple* tuple, Var* var);
/*lint -sem( entry_free, custodial(1), 1p == 1) */
extern void entry_free(Entry* entry);
/*lint -sem( entry_is_valid, 1p == 1) */
extern Bool entry_is_valid(const Entry* entry);
/*lint -sem( entry_copy, 1p == 1, @p == 1) */
extern Entry* entry_copy(const Entry* entry);
/*lint -sem( entry_cmp, 1p == 1 && 2p == 1) */
extern Bool entry_cmp(const Entry* entry, const Tuple* tuple);
/*lint -sem( entry_get_type, 1p == 1, @n >= 0) */
extern SymbolType entry_get_type(const Entry* entry);
/*lint -sem( entry_get_tuple, 1p == 1, @p == 1) */
extern const Tuple* entry_get_tuple(const Entry* entry);
/*lint -sem( entry_get_numb, 1p == 1) */
extern const Numb* entry_get_numb(const Entry* entry);
/*lint -sem( entry_get_strg, 1p == 1, @p && nulterm(@)) */
extern const char* entry_get_strg(const Entry* entry);
/*lint -sem( entry_get_set, 1p == 1, @p == 1) */
extern const Set* entry_get_set(const Entry* entry);
/*lint -sem( entry_get_var, 1p == 1, @p == 1) */
extern Var* entry_get_var(const Entry* entry);
/*lint -sem( entry_print, 1p == 1 && 2p == 1) */
extern void entry_print(FILE* fp, const Entry* entry);
#ifdef __cplusplus
}
#endif
#endif /* _ENTRY_H_ */
zimpl-3.3.4/src/zlpglue.c 0000640 0012352 0006025 00000010614 13057565713 015157 0 ustar bzfgamra optimi /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* File....: zlpglue.c */
/* Name....: LP Storage Interface Zimpl commandline part */
/* Author..: Thorsten Koch */
/* Copyright by Author, All rights reserved */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Copyright (C) 2001-2017 by Thorsten Koch
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include
#include
#include
#include
#include
#include "bool.h"
#include "mshell.h"
#include "ratlptypes.h"
#include "numb.h"
#include "elem.h"
#include "tuple.h"
#include "mme.h"
#include "bound.h"
#include "mono.h"
#include "term.h"
#include "ratlp.h"
#include "zlpglue.h"
/*lint -esym(818, lp) 'lp' could be declared as pointing to const */
static const char* const title = "This file was automatically generated by Zimpl";
/** Print some statistics about the mathematical program stored.
*/
void zlp_stat(
Lps* lp) /**< Pointer to storage */
{
assert(lp != NULL);
lps_stat(lp);
}
/** Set the maximal length for generated variable and constraint names.
*/
void zlp_setnamelen(
Lps* lp, /**< Pointer to storage */
int name_len) /**< Maximal length for generated variable and constraint names */
{
assert(lp != NULL);
lps_setnamelen(lp, name_len);
}
#if 0 /* Not used anymore */
Bool zlp_presolve(Lps* lp)
{
PSResult res;
res = lps_presolve(lp, verbose);
switch(res)
{
case PRESOLVE_INFEASIBLE :
printf("Model is infeasible\n");
return FALSE;
case PRESOLVE_UNBOUNDED :
printf("Model is unbounded\n");
return FALSE;
case PRESOLVE_VANISHED :
printf("Presolve solved the problem -- see .tbl file for values\n");
break;
case PRESOLVE_OKAY :
break;
default :
abort();
}
return TRUE;
}
#endif
/** Write mathematical program to file.
*/
void zlp_write(
Lps* lp, /**< Pointer to storage */
FILE* fp, /**< File pointer to write to */
LpFormat format, /**< File format */
const char* text) /**< Comment to be written into the file */
{
assert(lp != NULL);
assert(fp != NULL);
lps_scale(lp);
lps_write(lp, fp, format, text);
}
/** Write variable and constraint translation table to file.
* Depending on the maximal allowed name length, variable and constraint
* names will be mangled to keep them unique. This table provied the
* necessary translation between the mangled and the original name.
*/
void zlp_transtable(
Lps* lp, /**< Pointer to storage */
FILE* fp, /**< File pointer to write to */
LpFormat format) /**< File format */
{
assert(lp != NULL);
assert(fp != NULL);
lps_transtable(lp, fp, format, "zimpl");
}
/** Write branching ordering information to file.
*/
void zlp_orderfile(
Lps* lp, /**< Pointer to storage */
FILE* fp, /**< File pointer to write to */
LpFormat format) /**< File format */
{
assert(lp != NULL);
assert(fp != NULL);
lps_orderfile(lp, fp, format, title);
}
/** Write Mip STart file.
*/
void zlp_mstfile(
Lps* lp, /**< Pointer to storage */
FILE* fp, /**< File pointer to write to */
LpFormat format) /**< File format */
{
assert(lp != NULL);
assert(fp != NULL);
lps_mstfile(lp, fp, format, title);
}
zimpl-3.3.4/src/lint.h 0000640 0012352 0006025 00000007222 13057565713 014451 0 ustar bzfgamra optimi /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* File....: lint.h */
/* Name....: Lint defines */
/* Author..: Thorsten Koch */
/* Copyright by Author, All rights reserved */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Copyright (C) 2001-2017 by Thorsten Koch
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _LINT_H_
#define _LINT_H_
/* Use this file only if we are linting
*/
#ifdef _lint
#ifdef __cplusplus
extern "C" {
#endif
/* Unfortunately strdup() is not a POSIX function.
*/
/*lint -sem(strdup, 1p && nulterm(1), @P == malloc(1P) && nulterm(@p)) */
extern char* strdup(const char* s);
/* It is not clear if isinf() and isnan() are already POSIX
* or only in the next Draft.
*/
extern int isinf(double);
extern int isnan(double);
extern int isfinite(double);
extern int finite(double); /* This is probably not POSIX */
/*lint -esym(757, optarg, optind, opterr, optopt) */
/*lint -sem(getopt, 1n > 0 && 2p && 3p) */
extern int getopt(int argc, char* const argv[], const char* optstring);
extern char* optarg;
extern int optind;
extern int opterr;
extern int optopt;
/*lint -function(fopen, popen) */
extern FILE* popen(const char *command, const char *type);
/*lint -function(fclose, pclose) */
/*lint -esym(534, pclose) */
extern int pclose(FILE *stream);
/*lint -sem(fsync, 1n >= 0, @n <= 0) */
extern int fsync(int fd);
/* zlib support
*/
/*lint -esym(534,gzclose) */
typedef void* gzFile;
/*lint -sem( gzopen, 1p && nulterm(1) && 2p && nulterm(2), r_null) */
extern gzFile gzopen(const char *path, const char *mode);
/*lint -sem( gzread, 1p == 1 && 2p) */
extern int gzread(gzFile file, void* buf, unsigned len);
/*lint -sem( gzwrite, 1p == 1 && 2p) */
extern int gzwrite(gzFile file, const void* buf, unsigned len);
/*lint -sem( gzputs, 1p == 1 && 2p && nulterm(2)) */
extern int gzputs(gzFile file, const char *s);
/*lintx -sem( gzgets, 1p == 1 && 2p > 0 && 2P <= 3n && 3n > 0, @P == 2P || @P == 0) */
/*lint -function(fgets(1), gzgets(2)) */
/*lint -function(fgets(2), gzgets(3)) */
/*lint -function(fgets(3), gzgets(1)) */
/*lint -function(fgets(r), gzgets(r)) */
extern char* gzgets(gzFile file, char *buf, int len);
/*lint -function(fgetc, gzgetc) */
extern int gzgetc(gzFile file);
/*lint -sem( gzclose, 1p == 1) */
extern int gzclose(gzFile file);
#ifdef __cplusplus
}
#endif
#endif /* _lint */
#if defined(__GNUC__) || defined(__CLANG__)
#define UNUSED __attribute__ ((unused))
#define NORETURN __attribute__ ((noreturn))
#else
#define UNUSED
#define NORETURN
#endif /* __GNUC__ || __CLANG__ */
#endif /* _LINT_H_ */
zimpl-3.3.4/src/setpseudo.c 0000640 0012352 0006025 00000016027 13057565713 015514 0 ustar bzfgamra optimi /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* File....: setpseudo.c */
/* Name....: Set Pseudo Functions */
/* Author..: Thorsten Koch */
/* Copyright by Author, All rights reserved */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Copyright (C) 2001-2017 by Thorsten Koch
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include
#include
#include
#include
#include "bool.h"
#include "lint.h"
#include "mshell.h"
#include "numb.h"
#include "elem.h"
#include "tuple.h"
#include "mme.h"
#include "hash.h"
#include "set.h"
#include "set4.h"
#define SET_PSEUDO_SID 0x53455452
#define SET_PSEUDO_ITER_SID 0x53455249
/* -------------------------------------------------------------------------
* --- valid
* -------------------------------------------------------------------------
*/
static Bool set_pseudo_is_valid(const Set* set)
{
return set != NULL
&& SID_ok2(set->pseudo, SET_PSEUDO_SID)
&& set->head.refc > 0
&& set->head.dim == 0
&& set->head.members == 1;
}
static Bool set_pseudo_iter_is_valid(const SetIter* iter)
{
return iter != NULL && SID_ok2(iter->pseudo, SET_PSEUDO_ITER_SID);
}
/* -------------------------------------------------------------------------
* --- set_new
* -------------------------------------------------------------------------
*/
Set* set_pseudo_new()
{
Set* set;
set = calloc(1, sizeof(*set));
assert(set != NULL);
set->head.refc = 1;
set->head.dim = 0;
set->head.members = 1;
set->head.type = SET_PSEUDO;
SID_set2(set->pseudo, SET_PSEUDO_SID);
assert(set_pseudo_is_valid(set));
return set;
}
/* -------------------------------------------------------------------------
* --- copy
* -------------------------------------------------------------------------
*/
static Set* set_pseudo_copy(const Set* source)
{
Set* set = (Set*)source;
set->head.refc++;
return set;
}
/* -------------------------------------------------------------------------
* --- set_free
* -------------------------------------------------------------------------
*/
static void set_pseudo_free(Set* set)
{
assert(set_pseudo_is_valid(set));
set->head.refc--;
if (set->head.refc == 0)
{
SID_del2(set->pseudo);
free(set);
}
}
/* -------------------------------------------------------------------------
* --- lookup
* -------------------------------------------------------------------------
*/
/* Return index number of element. -1 if not present
*/
/*ARGSUSED*/
static int set_pseudo_lookup_idx(const Set* set, const Tuple* tuple, int offset)
{
assert(set_pseudo_is_valid(set));
assert(tuple_is_valid(tuple));
assert(offset == 0);
assert(tuple_get_dim(tuple) == 0);
return 0;
}
/* -------------------------------------------------------------------------
* --- get_tuple
* -------------------------------------------------------------------------
*/
/*ARGSUSED*/
static void set_pseudo_get_tuple(
const Set* set,
int idx,
Tuple* tuple,
int offset)
{
assert(set_pseudo_is_valid(set));
assert(idx == 0);
assert(tuple_is_valid(tuple));
assert(offset == 0);
assert(tuple_get_dim(tuple) == 0);
}
/* -------------------------------------------------------------------------
* --- iter_init
* -------------------------------------------------------------------------
*/
/* Initialise Iterator. Write into iter
*/
/*ARGSUSED*/
static SetIter* iter_init(
const Set* set,
const Tuple* pattern,
int offset)
{
SetIter* iter;
assert(set_pseudo_is_valid(set));
assert(pattern == NULL || tuple_is_valid(pattern));
assert(pattern == NULL || tuple_get_dim(pattern) == 0);
assert(offset == 0);
iter = calloc(1, sizeof(*iter));
assert(iter != NULL);
iter->pseudo.first = TRUE;
SID_set2(iter->pseudo, SET_PSEUDO_ITER_SID);
assert(set_pseudo_iter_is_valid(iter));
return iter;
}
/* -------------------------------------------------------------------------
* --- iter_next
* -------------------------------------------------------------------------
*/
/* FALSE means, there is no further element
*/
/*ARGSUSED*/
static Bool iter_next(
SetIter* iter,
UNUSED const Set* set,
UNUSED Tuple* tuple,
UNUSED int offset)
{
assert(set_pseudo_iter_is_valid(iter));
assert(set_pseudo_is_valid(set));
if (!iter->pseudo.first)
return FALSE;
iter->pseudo.first = FALSE;
return TRUE;
}
/* -------------------------------------------------------------------------
* --- iter_exit
* -------------------------------------------------------------------------
*/
/*ARGSUSED*/
static void iter_exit(SetIter* iter, UNUSED const Set* set)
{
assert(set_pseudo_iter_is_valid(iter));
SID_del2(iter->pseudo);
free(iter);
}
/* -------------------------------------------------------------------------
* --- iter_reset
* -------------------------------------------------------------------------
*/
/*ARGSUSED*/
static void iter_reset(SetIter* iter, UNUSED const Set* set)
{
assert(set_pseudo_iter_is_valid(iter));
iter->pseudo.first = TRUE;
}
/* -------------------------------------------------------------------------
* --- vtab_init
* -------------------------------------------------------------------------
*/
void set_pseudo_init(SetVTab* vtab)
{
vtab[SET_PSEUDO].set_copy = set_pseudo_copy;
vtab[SET_PSEUDO].set_free = set_pseudo_free;
vtab[SET_PSEUDO].set_lookup_idx = set_pseudo_lookup_idx;
vtab[SET_PSEUDO].set_get_tuple = set_pseudo_get_tuple;
vtab[SET_PSEUDO].iter_init = iter_init;
vtab[SET_PSEUDO].iter_next = iter_next;
vtab[SET_PSEUDO].iter_exit = iter_exit;
vtab[SET_PSEUDO].iter_reset = iter_reset;
vtab[SET_PSEUDO].set_is_valid = set_pseudo_is_valid;
}
zimpl-3.3.4/src/iread.c 0000640 0012352 0006025 00000051672 13057565713 014572 0 ustar bzfgamra optimi /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* File....: iread.c */
/* Name....: Read Instruction */
/* Author..: Thorsten Koch */
/* Copyright by Author, All rights reserved */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Copyright (C) 2001-2017 by Thorsten Koch
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include
#include
#include
#include
#include
#include
#ifdef WITH_PCRE
#include
#else
#include
#endif
#ifndef _lint
#include
#else
#include "lint.h"
#endif /* _lint */
#include "bool.h"
#include "mshell.h"
#include "ratlptypes.h"
#include "numb.h"
#include "elem.h"
#include "tuple.h"
#include "mme.h"
#include "set.h"
#include "symbol.h"
#include "define.h"
#include "bound.h"
#include "idxset.h"
#include "mono.h"
#include "term.h"
#include "rdefpar.h"
#include "conname.h"
#include "stmt.h"
#include "local.h"
#include "list.h"
#include "entry.h"
#include "heap.h"
#include "code.h"
#include "inst.h"
#include "xlpglue.h"
#include "metaio.h"
#include "strstore.h"
/* read "datei" as "<1n,3s,12s,4n> %6s" skip 17 use 2000 fs " ;"
*/
#define MAX_FIELDS 65536
CodeNode* i_read_new(CodeNode* self)
{
const char* filename;
const char* pattern;
Trace("i_read_new");
assert(code_is_valid(self));
filename = code_eval_child_strg(self, 0);
pattern = code_eval_child_strg(self, 1);
code_value_rdef(self, rdef_new(filename, pattern));
return self;
}
CodeNode* i_read_param(CodeNode* self)
{
RDef* rdef;
const RPar* rpar;
Trace("i_read_param");
assert(code_is_valid(self));
rdef = rdef_copy(code_eval_child_rdef(self, 0));
rpar = code_eval_child_rpar(self, 1);
rdef_set_param(rdef, rpar);
code_value_rdef(self, rdef);
return self;
}
CodeNode* i_read_comment(CodeNode* self)
{
const char* comment;
Trace("i_read_comment");
assert(code_is_valid(self));
comment = code_eval_child_strg(self, 0);
code_value_rpar(self, rpar_new_comment(comment));
return self;
}
CodeNode* i_read_match(CodeNode* self)
{
const char* match;
Trace("i_read_match");
assert(code_is_valid(self));
match = code_eval_child_strg(self, 0);
code_value_rpar(self, rpar_new_match(match));
return self;
}
CodeNode* i_read_use(CodeNode* self)
{
const Numb* use;
int int_use;
Trace("i_read_use");
assert(code_is_valid(self));
use = code_eval_child_numb(self, 0);
if (!numb_is_int(use))
{
fprintf(stderr, "*** Error 147: use value ");
numb_print(stderr, use);
fprintf(stderr, " is too big or not an integer\n");
code_errmsg(self);
zpl_exit(EXIT_FAILURE);
}
int_use = numb_toint(use);
if (int_use <= 0)
{
fprintf(stderr, "*** Error 148: use value %d is not positive\n", int_use);
code_errmsg(self);
zpl_exit(EXIT_FAILURE);
}
code_value_rpar(self, rpar_new_use(int_use));
return self;
}
CodeNode* i_read_skip(CodeNode* self)
{
const Numb* skip;
int int_skip;
Trace("i_read_skip");
assert(code_is_valid(self));
skip = code_eval_child_numb(self, 0);
if (!numb_is_int(skip))
{
fprintf(stderr, "*** Error 149: skip value ");
numb_print(stderr, skip);
fprintf(stderr, " is too big or not an integer\n");
code_errmsg(self);
zpl_exit(EXIT_FAILURE);
}
int_skip = numb_toint(skip);
if (int_skip < 0)
{
fprintf(stderr, "*** Error 150: skip value %d is negative\n", int_skip);
code_errmsg(self);
zpl_exit(EXIT_FAILURE);
}
code_value_rpar(self, rpar_new_skip(int_skip));
return self;
}
static int parse_pattern(
const CodeNode* self,
const char* pattern,
int* param_field,
int* param_type,
Bool* is_tuple_list,
Bool* is_streaming,
int* hi_field_no)
{
const char* sep = " ,<>";
char* temp = strdup(pattern);
char* s;
char* t;
int field;
char type;
int params = 0;
Bool is_single_value = FALSE;
assert(self != NULL);
assert(pattern != NULL);
assert(param_field != NULL);
assert(param_type != NULL);
assert(is_tuple_list != NULL);
assert(hi_field_no != NULL);
*is_streaming = FALSE;
*is_tuple_list = FALSE;
*hi_field_no = 0;
/* Is this a tuple_list "<1n,2s>" or
* an entry_list "<1n,2n> 3s" pattern
* or a single value "2n"
* or a stream "s+" or "n+"
* or a stream tuple list "" or ""
*/
/*lint -e{731} supress "Boolean argument to equal/not equal"
*/
if (( (NULL == strchr(temp, '>')) != (NULL == strchr(temp, '<')))
|| (strrchr(temp, '>') != strchr(temp, '>'))
|| (strrchr(temp, '<') != strchr(temp, '<')))
{
fprintf(stderr, "*** Error 151: Not a valid read template\n");
code_errmsg(self);
zpl_exit(EXIT_FAILURE);
}
/* Is there an + involved ? Than it is a stream.
*/
if (NULL != strchr(temp, '+'))
{
t = temp;
/* We have a stream template
*/
if (t[0] == '<')
{
if (strlen(t) != 4 || (t[1] != 'n' && t[1] != 's') || t[2] != '+' || t[3] != '>')
{
fprintf(stderr, "*** Error 151: Not a valid read template\n");
code_errmsg(self);
zpl_exit(EXIT_FAILURE);
}
*is_tuple_list = TRUE;
t++;
t[2] = '\0';
}
if (strlen(t) != 2 || (t[0] != 'n' && t[0] != 's') || t[1] != '+')
{
fprintf(stderr, "*** Error 151: Not a valid read template\n");
code_errmsg(self);
zpl_exit(EXIT_FAILURE);
}
*is_streaming = TRUE;
param_field[0] = 0;
param_type [0] = t[0];
*hi_field_no = MAX_FIELDS - 1;
free(temp);
return 1;
}
/* Single value or tuple list or entry list ?
*/
s = strchr(temp, '>');
if (NULL == s)
{
/* Single value */
is_single_value = TRUE;
}
else
{
for(++s; isspace(*s); s++)
;
*is_tuple_list = (*s == '\0');
}
/* Here we start to rip the template apart
*/
for(s = strtok(temp, sep);
(s != NULL) && (params < MAX_FIELDS);
s = strtok(NULL, sep))
{
if (2 != sscanf(s, "%d%c", &field, &type))
{
fprintf(stderr, "*** Error 152: Invalid read template syntax\n");
code_errmsg(self);
zpl_exit(EXIT_FAILURE);
}
field--;
if ((field < 0) || (field >= MAX_FIELDS))
{
fprintf(stderr, "*** Error 153: Invalid field number [%d]\n", field + 1);
code_errmsg(self);
zpl_exit(EXIT_FAILURE);
}
if ((type != 'n') && (type != 's'))
{
fprintf(stderr, "*** Error 154: Invalid field type [%c]\n", type);
code_errmsg(self);
zpl_exit(EXIT_FAILURE);
}
if (field > *hi_field_no)
*hi_field_no = field;
param_field[params] = field;
param_type [params] = type;
params++;
}
free(temp);
if (is_single_value)
{
if (params != 1)
{
fprintf(stderr, "*** Error 201: Invalid read template, only one field allowed\n");
code_errmsg(self);
zpl_exit(EXIT_FAILURE);
}
}
else if (params - (*is_tuple_list ? 0 : 1) < 1)
{
fprintf(stderr, "*** Error 155: Invalid read template, not enough fields\n");
code_errmsg(self);
zpl_exit(EXIT_FAILURE);
}
return params;
}
/*lint -sem(split_fields, nulterm(1), 1p && 2n >= 0 && 2n < MAX_FIELDS && 3p, @n >= 0) */
static int split_fields(char* s, int hi_field_no, char* field[])
{
char* t = s;
int fields = 0;
assert(s != NULL);
assert(hi_field_no >= 0);
assert(hi_field_no < MAX_FIELDS);
assert(field != NULL);
for(;;)
{
Bool new_field = FALSE;
switch(*s)
{
case '\"' :
s++;
t = s;
while((*s != '\0') && (*s != '\"'))
s++;
new_field = TRUE;
break;
case '\0' :
case '\t' :
case ' ' :
case ',' :
case ';' :
case ':' :
new_field = TRUE;
break;
default :
s++;
break;
}
if (new_field)
{
assert(fields <= hi_field_no);
assert(fields < MAX_FIELDS);
/*xint --e{661} Possible access of out-of-bounds pointer */
char* u = s;
field[fields] = t;
fields++;
if (*s == '\"')
s++;
while(isspace(*s))
s++;
if (*s == ',' || *s == ';' || *s == ':')
s++;
while(isspace(*s))
s++;
*u = '\0';
if (*s == '\0')
break;
/* Have we collected all fields we are interested in?
*/
if (fields - 1 == hi_field_no)
break;
t = s;
}
}
return fields;
}
static List* process_entry_stream(
const CodeNode* self,
List* list,
const RDef* rdef,
int line,
int fields,
char** field,
int param_type) /* param_type[0] */
{
Tuple* tuple;
Entry* entry;
Numb* numb;
int i;
assert(rdef != NULL);
assert(line >= 1);
assert(fields >= 1);
assert(field != NULL);
assert(param_type == 'n' || param_type == 's');
tuple = tuple_new(0);
for(i = 0; i < fields; i++)
{
if (param_type == 'n')
{
if (!numb_is_number(field[i]))
{
fprintf(stderr, "*** Error 174: Numeric field");
fprintf(stderr, " read as \"%s\". This is not a number.\n", field[i]);
fprintf(stderr, "*** File: %s line %d\n",
rdef_get_filename(rdef), line);
code_errmsg(self);
zpl_exit(EXIT_FAILURE);
}
numb = numb_new_ascii(field[i]);
entry = entry_new_numb(tuple, numb);
numb_free(numb);
}
else
{
entry = entry_new_strg(tuple, str_new(field[i]));
}
if (list == NULL)
list = list_new_entry(entry);
else
list_add_entry(list, entry);
entry_free(entry);
}
tuple_free(tuple);
return list;
}
static List* process_tuple_stream(
const CodeNode* self,
List* list,
const RDef* rdef,
int line,
int fields,
char** field,
int param_type) /* param_type[0] */
{
Elem* elem;
Numb* numb;
int i;
assert(rdef != NULL);
assert(line >= 1);
assert(fields >= 1);
assert(field != NULL);
assert(param_type == 'n' || param_type == 's');
for(i = 0; i < fields; i++)
{
Tuple* tuple = tuple_new(1);
if (param_type == 'n')
{
if (!numb_is_number(field[i]))
{
fprintf(stderr, "*** Error 174: Numeric field");
fprintf(stderr, " read as \"%s\". This is not a number.\n", field[i]);
fprintf(stderr, "*** File: %s line %d\n",
rdef_get_filename(rdef), line);
code_errmsg(self);
zpl_exit(EXIT_FAILURE);
}
numb = numb_new_ascii(field[i]);
elem = elem_new_numb(numb);
numb_free(numb);
}
else
{
elem = elem_new_strg(str_new(field[i]));
}
tuple_set_elem(tuple, 0, elem);
if (list == NULL)
list = list_new_tuple(tuple);
else
list_add_tuple(list, tuple);
tuple_free(tuple);
}
return list;
}
static List* process_line(
const CodeNode* self,
List* list,
const RDef* rdef,
int line,
Bool is_tuple_list,
int dim,
int fields,
char** field,
const int* param_field,
const int* param_type)
{
Tuple* tuple;
Elem* elem;
Numb* numb;
char* t;
int i;
assert(rdef != NULL);
assert(line >= 1);
assert(dim >= 0);
assert(fields >= 1);
assert(field != NULL);
assert(param_type != NULL);
assert(param_field != NULL);
tuple = tuple_new(dim);
for(i = 0; i < dim; i++)
{
if (param_field[i] >= fields)
{
fprintf(stderr, "*** Error 156: Not enough fields in data\n");
fprintf(stderr, "*** File: %s line %d\n",
rdef_get_filename(rdef), line);
code_errmsg(self);
zpl_exit(EXIT_FAILURE);
}
t = field[param_field[i]];
if (param_type[i] == 'n')
{
if (!numb_is_number(t))
{
fprintf(stderr, "*** Error 174: Numeric field %d", param_field[i] + 1);
fprintf(stderr, " read as \"%s\". This is not a number.\n", t);
fprintf(stderr, "*** File: %s line %d\n",
rdef_get_filename(rdef), line);
code_errmsg(self);
zpl_exit(EXIT_FAILURE);
}
numb = numb_new_ascii(t);
elem = elem_new_numb(numb);
numb_free(numb);
}
else
{
elem = elem_new_strg(str_new(t));
}
tuple_set_elem(tuple, i, elem);
}
if (is_tuple_list)
{
if (list == NULL)
list = list_new_tuple(tuple);
else
list_add_tuple(list, tuple);
}
else
{
Entry* entry;
if (param_field[i] >= fields)
{
fprintf(stderr, "*** Error 157: Not enough fields in data (value)\n");
fprintf(stderr, "*** File: %s line %d\n",
rdef_get_filename(rdef), line);
code_errmsg(self);
zpl_exit(EXIT_FAILURE);
}
t = field[param_field[i]];
if (param_type[i] == 'n')
{
if (!numb_is_number(t))
{
fprintf(stderr, "*** Error 174: Numeric field %d", param_field[i] + 1);
fprintf(stderr, " read as \"%s\". This is not a number.\n", t);
fprintf(stderr, "*** File: %s line %d\n",
rdef_get_filename(rdef), line);
code_errmsg(self);
zpl_exit(EXIT_FAILURE);
}
numb = numb_new_ascii(t);
entry = entry_new_numb(tuple, numb);
numb_free(numb);
}
else
{
entry = entry_new_strg(tuple, str_new(t));
}
if (list == NULL)
list = list_new_entry(entry);
else
list_add_entry(list, entry);
entry_free(entry);
}
tuple_free(tuple);
return list;
}
/* The result of this function is either a tuple_list "<1n,2s>" or
* an entry_list "<2n,3s> 1s" or an elem_list "n+".
* The single value "1s" generates an entry_list.
*/
CodeNode* i_read(CodeNode* self)
{
MFP* fp;
char* buf;
char** field;
int fields;
int* param_field; /* template parameter field number */
int* param_type; /* template parameter field type */
Bool is_tuple_list;
Bool is_streaming;
int hi_field_no;
int dim;
const RDef* rdef;
List* list = NULL;
char* filename;
char* comment;
const char* match;
int skip;
int use;
regex_t regex;
Trace("i_read");
assert(code_is_valid(self));
field = malloc(MAX_FIELDS * sizeof(*field));
param_field = malloc(MAX_FIELDS * sizeof(*param_field));
param_type = malloc(MAX_FIELDS * sizeof(*param_type));
assert(field != NULL);
assert(param_field != NULL);
assert(param_type != NULL);
rdef = code_eval_child_rdef(self, 0);
use = rdef_get_use(rdef);
skip = rdef_get_skip(rdef);
dim = parse_pattern(self,
rdef_get_pattern(rdef), param_field, param_type,
&is_tuple_list, &is_streaming, &hi_field_no);
filename = malloc(strlen(rdef_get_filename(rdef)) + 4);
assert(filename != NULL);
strcpy(filename, rdef_get_filename(rdef));
comment = malloc(strlen(rdef_get_comment(rdef)) + 3);
assert(comment != NULL);
comment[0] = '\n';
comment[1] = '\r';
strcpy(&comment[2], rdef_get_comment(rdef));
if (NULL != (match = rdef_get_match(rdef)))
{
int err = regcomp(®ex, match, REG_EXTENDED | REG_NOSUB);
if (err != 0)
{
char errmsg[1024];
regerror(err, ®ex, errmsg, sizeof(errmsg));
fprintf(stderr, "Error 802: %s\n", errmsg);
code_errmsg(self);
zpl_exit(EXIT_FAILURE);
}
}
/* The last template parameter is the value for the entry_list.
*/
if (!is_tuple_list)
dim--;
if (NULL == (fp = mio_open(filename, ".gz")))
{
code_errmsg(self);
zpl_exit(EXIT_FAILURE);
}
else
{
int line = 0;
if (verbose >= VERB_NORMAL)
printf("Reading %s\n", filename);
while(NULL != (buf = mio_get_line(fp)))
{
char* s;
/* Count the line
*/
line++;
/* Is this a comment line or is there a comment on the line,
* then remove it.
*/
if (NULL != (s = strpbrk(buf, comment)))
*s = '\0';
/* If this is an empty line...
*/
for(s = buf; (*s != '\0') && isspace(*s); s++)
;
/* ... we skip it.
*/
if (*s == '\0')
{
free(buf);
continue;
}
/* do we have regex and if yes it is matched ?
* if not, skip the line.
*/
if (match != NULL && regexec(®ex, s, 0, NULL, 0))
{
free(buf);
continue;
}
/* Should we skip this line ?
*/
if (skip-- > 0)
{
free(buf);
continue;
}
/* Now we break the line in fields.
*/
fields = split_fields(s, hi_field_no, field);
#if 0
{
int i;
fprintf(stdout, "Fields=%d\n", fields);
for(i = 0; i < fields; i++)
fprintf(stdout, "Field[%d]=[%s]\n", i, field[i]);
}
#endif
if (is_streaming)
{
if (fields == MAX_FIELDS)
{
if (stmt_trigger_warning(213))
{
fprintf(stderr, "--- Warning 213: More than %d input fields in line %d of %s\n",
fields, line, filename);
code_errmsg(self);
}
}
if (is_tuple_list)
list = process_tuple_stream(self, list, rdef, line,
fields, field, param_type[0]);
else
list = process_entry_stream(self, list, rdef, line,
fields, field, param_type[0]);
}
else
{
list = process_line(self, list, rdef, line, is_tuple_list, dim,
fields, field, param_field, param_type);
}
free(buf);
if (--use == 0)
break;
}
mio_close(fp);
}
/* If we found nothing to put into the list, we add a dummy entry
*/
if (list == NULL)
{
Tuple* tuple = tuple_new(0);
if (is_tuple_list)
list = list_new_tuple(tuple);
else
{
Set* set = set_pseudo_new();
Entry* entry = entry_new_set(tuple, set);
list = list_new_entry(entry);
entry_free(entry);
set_free(set);
}
tuple_free(tuple);
/*
fprintf(stderr, "*** Error 158: Read from file found no data\n");
code_errmsg(self);
zpl_exit(EXIT_FAILURE);
*/
}
code_value_list(self, list);
if (match != NULL)
regfree(®ex);
free(comment);
free(filename);
free(param_type);
free(param_field);
free(field);
return self;
}
zimpl-3.3.4/src/ratlp.h 0000640 0012352 0006025 00000022505 13057565713 014626 0 ustar bzfgamra optimi /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* File....: ratlp.h */
/* Name....: Rational Number LP Storage Library */
/* Author..: Thorsten Koch */
/* Copyright by Author, All rights reserved */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Copyright (C) 2003-2017 by Thorsten Koch
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _RATLP_H_
#define _RATLP_H_
#ifndef __GMP_H__
#error "Need to include gmp.h before ratlp.h"
#endif
#ifndef _BOOL_H_
#error "Need to include bool.h before ratlp.h"
#endif
#ifndef _RATLPTYPES_H_
#error "Need to include ratlptypes.h before ratlp.h"
#endif
#ifndef _MME_H_
#error "Need to include mme.h before ratlp.h"
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* lpstore.c
*/
/*lint -sem( lps_alloc, nulterm(1), 1p, @p == 1) */
extern Lps* lps_alloc(const char* name);
/*lint -sem( lps_free, custodial(1), 1p) */
extern void lps_free(Lps* lp);
/*lint -sem( lps_number, 1p == 1) */
extern void lps_number(const Lps* lp);
/*lint -sem( lps_getsos, nulterm(2), 1p && 2p) */
extern Sos* lps_getsos(const Lps* lp, const char* name);
/*lint -sem( lps_getvar, nulterm(2), 1p && 2p) */
extern Var* lps_getvar(const Lps* lp, const char* name);
/*lint -sem( lps_getcon, nulterm(2), 1p && 2p) */
extern Con* lps_getcon(const Lps* lp, const char* name);
/*lint -sem( lps_getnzo, 1p == 1 && 2p == 1 && 3p == 1) */
extern Nzo* lps_getnzo(const Lps* lp, const Con* con, const Var* var);
/*lint -sem( lps_addsos, nulterm(2), 1p == 1 && 2p && 4n >= 0, @p == 1) */
extern Sos* lps_addsos(Lps* lp, const char* name, SosType type, int priority);
/*lint -sem( lps_addsse, 1p == 1 && 2p == 1 && 3p == 1) */
extern void lps_addsse(Sos* sos, Var* var, const mpq_t weight);
/*lint -sem( lps_addvar, nulterm(2), 1p == 1 && 2p, @p == 1) */
extern Var* lps_addvar(Lps* lp, const char* name);
/*lint -sem( lps_delvar, 1p == 1 && 2p == 1) */
extern void lps_delvar(Lps* lp, Var* var);
/*lint -sem( lps_addcon, nulterm(2), 1p == 1 && 2p, @p == 1) */
extern Con* lps_addcon(Lps* lp, const char* name);
/*lint -sem( lps_delcon, 1p == 1 && 2p == 1) */
extern void lps_delcon(Lps* lp, Con* con);
/*lint -sem( lps_addnzo, 1p == 1 && 2p == 1 && 3p == 1) */
extern void lps_addnzo(Lps* lp, Con* con, Var* var, const mpq_t value);
/*lint -sem( lps_delnzo, 1p == 1 && 2p == 2) */
extern void lps_delnzo(Lps* lp, Nzo* nzo);
/*lint -sem( lps_addqme, 1p == 1 && 2p == 1 && 3p == 1 && 4p == 1) */
extern void lps_addqme(Lps* lp, Con* con, Var* var1, Var* var2, const mpq_t value);
/*lint -sem( lps_addterm, 1p == 1 && 2p == 1 && 3p == 1) */
extern void lps_addterm(Lps* lp, Con* con, const Term* term);
/*lint -sem( lps_stat, 1p == 1) */
extern void lps_stat(const Lps* lp);
/*lint -sem( lps_setval, 1p == 1) */
extern void lps_setval(Nzo* nzo, const mpq_t value);
/*lint -sem( lps_getval, 1p == 1) */
extern void lps_getval(const Nzo* nzo, mpq_t value);
/*lint -sem( lps_stat, 1p == 1) */
extern void lps_setdir(Lps* lp, LpDirect direct);
/*lint -sem( lps_setprobname, nulterm(2), 1p && 2p) */
extern void lps_setprobname(Lps* lp, const char* name);
/*lint -sem( lps_setobjname, nulterm(2), 1p && 2p) */
extern void lps_setobjname(Lps* lp, const char* name);
/*lint -sem( lps_setrhsname, nulterm(2), 1p && 2p) */
extern void lps_setrhsname(Lps* lp, const char* name);
/*lint -sem( lps_setbndname, nulterm(2), 1p && 2p) */
extern void lps_setbndname(Lps* lp, const char* name);
/*lint -sem( lps_setrngname, nulterm(2), 1p && 2p) */
extern void lps_setrngname(Lps* lp, const char* name);
/*lint -sem( lps_getcost, 1p == 1) */
extern void lps_getcost(const Var* var, mpq_t cost);
/*lint -sem( lps_setcost, 1p == 1) */
extern void lps_setcost(Var* var, const mpq_t cost);
/*lint -sem( lps_haslower, 1p == 1) */
extern Bool lps_haslower(const Var* var);
/*lint -sem( lps_getlower, 1p == 1) */
extern void lps_getlower(const Var* var, mpq_t lower);
/*lint -sem( lps_setlower, 1p == 1) */
extern void lps_setlower(Var* var, const mpq_t lower);
/*lint -sem( lps_hasupper, 1p == 1) */
extern Bool lps_hasupper(const Var* var);
/*lint -sem( lps_getupper, 1p == 1) */
extern void lps_getupper(const Var* var, mpq_t upper);
/*lint -sem( lps_setupper, 1p == 1) */
extern void lps_setupper(Var* var, const mpq_t upper);
/*lint -sem( lps_getclass, 1p == 1) */
extern VarClass lps_getclass(const Var* var);
/*lint -sem( lps_setclass, 1p == 1) */
extern void lps_setclass(Var* var, VarClass vclass);
/*lint -sem( lps_setlhs, 1p == 1) */
extern void lps_setlhs(Con* con, const mpq_t lhs);
/*lint -sem( lps_setrhs, 1p == 1) */
extern void lps_setrhs(Con* con, const mpq_t rhs);
/*lint -sem( lps_setcontype, 1p == 1) */
extern void lps_setcontype(Con* con, ConType type);
/*lint -sem( lps_contype, 1p == 1) */
extern ConType lps_contype(const Con* con);
/*lint -sem( lps_vartype, 1p == 1) */
extern VarType lps_vartype(const Var* var);
/*lint -sem( lps_getlhs, 1p == 1) */
extern void lps_getlhs(const Con* con, mpq_t lhs);
/*lint -sem( lps_getrhs, 1p == 1) */
extern void lps_getrhs(const Con* con, mpq_t rhs);
/*lint -sem( lps_varname, 1p == 1, nulterm(@) */
extern const char* lps_varname(const Var* var);
/*lint -sem( lps_setvartype, 1p == 1) */
extern void lps_setvartype(Var* con, VarType type);
/*lint -sem( lps_flags, 1p == 1) */
extern unsigned int lps_flags(const Con* con);
/*lint -sem( lps_addflags, 1p == 1) */
extern void lps_addflags(Con* con, unsigned int flags);
/*lint -sem( lps_setscale, 1p == 1) */
extern void lps_setscale(Con* con, const mpq_t scale);
/*lint -sem( lps_setpriority, 1p == 1) */
extern void lps_setpriority(Var* var, int priority);
/*lint -sem( lps_setvalue, 1p == 1) */
extern void lps_setvalue(Var* var, const mpq_t value);
/*lint -sem( lps_setstartval, 1p == 1) */
extern void lps_setstartval(Var* var, const mpq_t startval);
/*lint -sem( lps_setnamelen, 1p == 1) */
extern void lps_setnamelen(Lps* lp, int name_len);
/*lint -sem( lps_setindictaor, 1p == 1 && 2p == 1) */
extern void lps_setindicator(Con* con, Var* var, Bool on_true);
/*lint -sem( lps_write, nulterm(4), 1p == 1 && 2p == 1) */
extern void lps_write(const Lps* lp, FILE* fp, LpFormat format, const char* text);
/*lint -sem( lps_transtable, nulterm(4), 1p == 1 && 2p == 1 && 4p) */
extern void lps_transtable(const Lps* lp, FILE* fp, LpFormat format, const char* head);
/*lint -sem( lps_scale, 1p == 1) */
extern void lps_scale(const Lps* lp);
/*lint -sem( lps_scale, 1p == 1) */
extern Bool lps_has_sos(const Lps* lp);
/*lint -sem( lps_con_sumup, 1p == 1) */
extern Bool lps_con_sumup(const Con* con, mpq_t sum);
/* ratmpsread.c
*/
/*lint -sem( lps_readmps, nulterm(1), 1p) */
extern Lps* lps_readmps(const char* filename);
/* ratlpfwrite.c
*/
/*lint -sem( lpf_write, nulterm(3), 1p == 1 && 2p == 1) */
extern void lpf_write(const Lps* lp, FILE* fp, LpFormat format, const char* text);
/* ratmpswrite.c
*/
/*lint -sem( lpf_write, nulterm(3), 1p == 1 && 2p == 1) */
extern void mps_write(const Lps* lp, FILE* fp, const char* text);
/* ratordwrite.c
*/
/*lint -sem( lps_ordwrite, nulterm(4), 1p == 1 && 2p == 1) */
extern void lps_orderfile(const Lps* lp, FILE* fp, LpFormat format, const char* text);
/* ratmstwrite.c
*/
/*lint -sem( lps_mstwrite, nulterm(4), 1p == 1 && 2p == 1) */
extern void lps_mstfile(const Lps* lp, FILE* fp, LpFormat format, const char* text);
#if 0 /* Not used anymore ??? */
/* ratpresolve.c
*/
/*lint -sem( lps_presolve, 1p == 1 && 2n >= 0) */
extern PSResult lps_presolve(Lps* lp, int verbose_level);
#endif
#ifdef __cplusplus
}
#endif
#endif /* _RATLP_H_ */
zimpl-3.3.4/src/gmpmisc.c 0000640 0012352 0006025 00000013276 13057565713 015143 0 ustar bzfgamra optimi /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* File....: ratmisc.c */
/* Name....: miscellenious rational arithmetic functions */
/* Author..: Thorsten Koch */
/* Copyright by Author, All rights reserved */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Copyright (C) 2003-2017 by Thorsten Koch
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include
#include
#include
#include
#include
#include
#include "bool.h"
#include "mshell.h"
#include "gmpmisc.h"
mpq_t const_zero;
mpq_t const_one;
mpq_t const_minus_one;
#define POOL_SIZE 10000
#define POOL_ELEM_SIZE 16
typedef union pool_elem PoolElem;
typedef struct pool Pool;
union pool_elem
{
char pad[POOL_ELEM_SIZE];
PoolElem* next;
};
struct pool
{
PoolElem elem[POOL_SIZE];
Pool* next;
};
static Pool* pool_root = NULL;
static PoolElem* pool_next = NULL;
static void* pool_alloc(void)
{
Pool* pool;
PoolElem* elem;
int i;
if (pool_next == NULL)
{
pool = malloc(sizeof(*pool));
pool->next = pool_root;
pool_root = pool;
for(i = 0; i < POOL_SIZE - 1; i++)
pool->elem[i].next = &pool->elem[i + 1];
pool->elem[i].next = NULL;
pool_next = &pool->elem[0];
}
assert(pool_next != NULL);
elem = pool_next;
pool_next = elem->next;
return elem;
}
static void pool_free(void* pv)
{
PoolElem* elem = pv;
elem->next = pool_next;
pool_next = elem;
}
static void pool_exit(void)
{
Pool* p;
Pool* q;
for(p = pool_root; p != NULL; p = q)
{
q = p->next;
free(p);
}
pool_root = NULL;
pool_next = NULL;
}
/* [+|-]?[0-9]*.[0-9]+[[e|E][+|-][0-9]+]? */
/* if it does not fit here, it doesn't fit in a double either */
void gmp_str2mpq(mpq_t value, const char* num)
{
char tmp[1024];
int i;
int k = 0;
int exponent = 0;
int fraction = 0;
assert(num != NULL);
assert(strlen(num) < 32);
/* printf("%s ", num); */
/* Skip initial whitespace
*/
while(isspace(*num))
num++;
/* Skip initial +/-
*/
if (*num == '+')
num++;
else if (*num == '-')
tmp[k++] = *num++;
for(i = 0; num[i] != '\0'; i++)
{
if (isdigit(num[i]))
{
tmp[k++] = num[i];
exponent -= fraction;
}
else if (num[i] == '.')
fraction = 1;
else if (tolower(num[i]) == 'e')
{
exponent += atoi(&num[i + 1]);
break;
}
}
while(exponent > 0)
{
tmp[k++] = '0';
exponent--;
}
tmp[k++] = '/';
tmp[k++] = '1';
while(exponent < 0)
{
tmp[k++] = '0';
exponent++;
}
tmp[k] = '\0';
/* printf("%s\n", tmp);*/
mpq_set_str(value, tmp, 10);
mpq_canonicalize(value);
}
void gmp_print_mpq(FILE* fp, const mpq_t qval)
{
mpf_t fval;
mpf_init(fval);
mpf_set_q(fval, qval);
mpf_out_str(fp, 10, 32, fval);
fprintf(fp, " = ");
mpq_out_str(fp, 10, qval);
fputc('\n', fp);
mpf_clear(fval);
}
/*ARGSUSED*/
static void* gmp_alloc(size_t size)
{
if (size <= POOL_ELEM_SIZE)
return pool_alloc();
return malloc(size);
}
/*ARGSUSED*/
static void* gmp_realloc(void* ptr, size_t old_size, size_t new_size)
{
void* p;
if (old_size <= POOL_ELEM_SIZE && new_size <= POOL_ELEM_SIZE)
return ptr;
if (old_size <= POOL_ELEM_SIZE)
{
assert(new_size > POOL_ELEM_SIZE);
assert(new_size > old_size);
p = malloc(new_size);
memcpy(p, ptr, old_size);
pool_free(ptr);
return p;
}
if (new_size <= POOL_ELEM_SIZE)
{
assert(old_size > POOL_ELEM_SIZE);
assert(old_size > new_size);
p = pool_alloc();
memcpy(p, ptr, new_size);
free(ptr);
return p;
}
return realloc(ptr, new_size);
}
/*ARGSUSED*/
static void gmp_free(void* ptr, size_t size)
{
if (size <= POOL_ELEM_SIZE)
pool_free(ptr);
else
free(ptr);
}
void gmp_init(Bool verbose, Bool with_management)
{
if (with_management)
mp_set_memory_functions(gmp_alloc, gmp_realloc, gmp_free);
mpq_init(const_zero);
mpq_init(const_one);
mpq_init(const_minus_one);
mpq_set_ui(const_one, 1, 1); /* = 1 */
mpq_set_si(const_minus_one, -1, 1); /* = -1 */
if (verbose)
printf("Using GMP Version %s %s\n",
gmp_version, with_management ? "[memory management redirected]" : "[memory management unchanged]");
}
void gmp_exit()
{
mpq_clear(const_zero);
mpq_clear(const_one);
mpq_clear(const_minus_one);
pool_exit();
}
zimpl-3.3.4/src/mmlscan.c 0000640 0012352 0006025 00000235607 13057566041 015135 0 ustar bzfgamra optimi #line 2 "src/mmlscan.c"
#line 4 "src/mmlscan.c"
#define YY_INT_ALIGNED short int
/* A lexical scanner generated by flex */
/* %not-for-header */
/* %if-c-only */
/* %if-not-reentrant */
/* %endif */
/* %endif */
/* %ok-for-header */
#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 6
#define YY_FLEX_SUBMINOR_VERSION 0
#if YY_FLEX_SUBMINOR_VERSION > 0
#define FLEX_BETA
#endif
/* %if-c++-only */
/* %endif */
/* %if-c-only */
/* %endif */
/* %if-c-only */
/* %endif */
/* First, we deal with platform-specific or compiler-specific issues. */
/* begin standard C headers. */
/* %if-c-only */
#include
#include
#include
#include
/* %endif */
/* %if-tables-serialization */
/* %endif */
/* end standard C headers. */
/* %if-c-or-c++ */
/* flex integer type definitions */
#ifndef FLEXINT_H
#define FLEXINT_H
/* C99 systems have . Non-C99 systems may or may not. */
#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
* if you want the limit (max/min) macros for int types.
*/
#ifndef __STDC_LIMIT_MACROS
#define __STDC_LIMIT_MACROS 1
#endif
#include
typedef int8_t flex_int8_t;
typedef uint8_t flex_uint8_t;
typedef int16_t flex_int16_t;
typedef uint16_t flex_uint16_t;
typedef int32_t flex_int32_t;
typedef uint32_t flex_uint32_t;
#else
typedef signed char flex_int8_t;
typedef short int flex_int16_t;
typedef int flex_int32_t;
typedef unsigned char flex_uint8_t;
typedef unsigned short int flex_uint16_t;
typedef unsigned int flex_uint32_t;
/* Limits of integral types. */
#ifndef INT8_MIN
#define INT8_MIN (-128)
#endif
#ifndef INT16_MIN
#define INT16_MIN (-32767-1)
#endif
#ifndef INT32_MIN
#define INT32_MIN (-2147483647-1)
#endif
#ifndef INT8_MAX
#define INT8_MAX (127)
#endif
#ifndef INT16_MAX
#define INT16_MAX (32767)
#endif
#ifndef INT32_MAX
#define INT32_MAX (2147483647)
#endif
#ifndef UINT8_MAX
#define UINT8_MAX (255U)
#endif
#ifndef UINT16_MAX
#define UINT16_MAX (65535U)
#endif
#ifndef UINT32_MAX
#define UINT32_MAX (4294967295U)
#endif
#endif /* ! C99 */
#endif /* ! FLEXINT_H */
/* %endif */
/* %if-c++-only */
/* %endif */
#ifdef __cplusplus
/* The "const" storage-class-modifier is valid. */
#define YY_USE_CONST
#else /* ! __cplusplus */
/* C99 requires __STDC__ to be defined as 1. */
#if defined (__STDC__)
#define YY_USE_CONST
#endif /* defined (__STDC__) */
#endif /* ! __cplusplus */
#ifdef YY_USE_CONST
#define yyconst const
#else
#define yyconst
#endif
/* %not-for-header */
/* Returned upon end-of-file. */
#define YY_NULL 0
/* %ok-for-header */
/* %not-for-header */
/* Promotes a possibly negative, possibly signed char to an unsigned
* integer for use as an array index. If the signed char is negative,
* we want to instead treat it as an 8-bit unsigned char, hence the
* double cast.
*/
#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
/* %ok-for-header */
/* %if-reentrant */
/* %endif */
/* %if-not-reentrant */
/* %endif */
/* Enter a start condition. This macro really ought to take a parameter,
* but we do it the disgusting crufty way forced on us by the ()-less
* definition of BEGIN.
*/
#define BEGIN (yy_start) = 1 + 2 *
/* Translate the current start state into a value that can be later handed
* to BEGIN to return to the state. The YYSTATE alias is for lex
* compatibility.
*/
#define YY_START (((yy_start) - 1) / 2)
#define YYSTATE YY_START
/* Action number for EOF rule of a given start state. */
#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
/* Special action meaning "start processing a new file". */
#define YY_NEW_FILE yyrestart(yyin )
#define YY_END_OF_BUFFER_CHAR 0
/* Size of default input buffer. */
#ifndef YY_BUF_SIZE
#ifdef __ia64__
/* On IA-64, the buffer size is 16k, not 8k.
* Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
* Ditto for the __ia64__ case accordingly.
*/
#define YY_BUF_SIZE 32768
#else
#define YY_BUF_SIZE 16384
#endif /* __ia64__ */
#endif
/* The state buf must be large enough to hold one state per character in the main buffer.
*/
#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
#ifndef YY_TYPEDEF_YY_BUFFER_STATE
#define YY_TYPEDEF_YY_BUFFER_STATE
typedef struct yy_buffer_state *YY_BUFFER_STATE;
#endif
#ifndef YY_TYPEDEF_YY_SIZE_T
#define YY_TYPEDEF_YY_SIZE_T
typedef size_t yy_size_t;
#endif
/* %if-not-reentrant */
extern yy_size_t yyleng;
/* %endif */
/* %if-c-only */
/* %if-not-reentrant */
extern FILE *yyin, *yyout;
/* %endif */
/* %endif */
#define EOB_ACT_CONTINUE_SCAN 0
#define EOB_ACT_END_OF_FILE 1
#define EOB_ACT_LAST_MATCH 2
#define YY_LESS_LINENO(n)
#define YY_LINENO_REWIND_TO(ptr)
/* Return all but the first "n" matched characters back to the input stream. */
#define yyless(n) \
do \
{ \
/* Undo effects of setting up yytext. */ \
int yyless_macro_arg = (n); \
YY_LESS_LINENO(yyless_macro_arg);\
*yy_cp = (yy_hold_char); \
YY_RESTORE_YY_MORE_OFFSET \
(yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
YY_DO_BEFORE_ACTION; /* set up yytext again */ \
} \
while ( 0 )
#define unput(c) yyunput( c, (yytext_ptr) )
#ifndef YY_STRUCT_YY_BUFFER_STATE
#define YY_STRUCT_YY_BUFFER_STATE
struct yy_buffer_state
{
/* %if-c-only */
FILE *yy_input_file;
/* %endif */
/* %if-c++-only */
/* %endif */
char *yy_ch_buf; /* input buffer */
char *yy_buf_pos; /* current position in input buffer */
/* Size of input buffer in bytes, not including room for EOB
* characters.
*/
yy_size_t yy_buf_size;
/* Number of characters read into yy_ch_buf, not including EOB
* characters.
*/
int yy_n_chars;
/* Whether we "own" the buffer - i.e., we know we created it,
* and can realloc() it to grow it, and should free() it to
* delete it.
*/
int yy_is_our_buffer;
/* Whether this is an "interactive" input source; if so, and
* if we're using stdio for input, then we want to use getc()
* instead of fread(), to make sure we stop fetching input after
* each newline.
*/
int yy_is_interactive;
/* Whether we're considered to be at the beginning of a line.
* If so, '^' rules will be active on the next match, otherwise
* not.
*/
int yy_at_bol;
int yy_bs_lineno; /**< The line count. */
int yy_bs_column; /**< The column count. */
/* Whether to try to fill the input buffer when we reach the
* end of it.
*/
int yy_fill_buffer;
int yy_buffer_status;
#define YY_BUFFER_NEW 0
#define YY_BUFFER_NORMAL 1
/* When an EOF's been seen but there's still some text to process
* then we mark the buffer as YY_EOF_PENDING, to indicate that we
* shouldn't try reading from the input source any more. We might
* still have a bunch of tokens to match, though, because of
* possible backing-up.
*
* When we actually see the EOF, we change the status to "new"
* (via yyrestart()), so that the user can continue scanning by
* just pointing yyin at a new input file.
*/
#define YY_BUFFER_EOF_PENDING 2
};
#endif /* !YY_STRUCT_YY_BUFFER_STATE */
/* %if-c-only Standard (non-C++) definition */
/* %not-for-header */
/* %if-not-reentrant */
/* Stack of input buffers. */
static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
/* %endif */
/* %ok-for-header */
/* %endif */
/* We provide macros for accessing buffer states in case in the
* future we want to put the buffer states in a more general
* "scanner state".
*
* Returns the top of the stack, or NULL.
*/
#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
? (yy_buffer_stack)[(yy_buffer_stack_top)] \
: NULL)
/* Same as previous macro, but useful when we know that the buffer stack is not
* NULL or when we need an lvalue. For internal use only.
*/
#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
/* %if-c-only Standard (non-C++) definition */
/* %if-not-reentrant */
/* %not-for-header */
/* yy_hold_char holds the character lost when yytext is formed. */
static char yy_hold_char;
static int yy_n_chars; /* number of characters read into yy_ch_buf */
yy_size_t yyleng;
/* Points to current character in buffer. */
static char *yy_c_buf_p = (char *) 0;
static int yy_init = 0; /* whether we need to initialize */
static int yy_start = 0; /* start state number */
/* Flag which is used to allow yywrap()'s to do buffer switches
* instead of setting up a fresh yyin. A bit of a hack ...
*/
static int yy_did_buffer_switch_on_eof;
/* %ok-for-header */
/* %endif */
void yyrestart (FILE *input_file );
void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer );
YY_BUFFER_STATE yy_create_buffer (FILE *file,int size );
void yy_delete_buffer (YY_BUFFER_STATE b );
void yy_flush_buffer (YY_BUFFER_STATE b );
void yypush_buffer_state (YY_BUFFER_STATE new_buffer );
void yypop_buffer_state (void );
static void yyensure_buffer_stack (void );
static void yy_load_buffer_state (void );
static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file );
#define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER )
YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size );
YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str );
YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,yy_size_t len );
/* %endif */
void *yyalloc (yy_size_t );
void *yyrealloc (void *,yy_size_t );
void yyfree (void * );
#define yy_new_buffer yy_create_buffer
#define yy_set_interactive(is_interactive) \
{ \
if ( ! YY_CURRENT_BUFFER ){ \
yyensure_buffer_stack (); \
YY_CURRENT_BUFFER_LVALUE = \
yy_create_buffer(yyin,YY_BUF_SIZE ); \
} \
YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
}
#define yy_set_bol(at_bol) \
{ \
if ( ! YY_CURRENT_BUFFER ){\
yyensure_buffer_stack (); \
YY_CURRENT_BUFFER_LVALUE = \
yy_create_buffer(yyin,YY_BUF_SIZE ); \
} \
YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
}
#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
/* %% [1.0] yytext/yyin/yyout/yy_state_type/yylineno etc. def's & init go here */
/* Begin user sect3 */
#define yywrap() (/*CONSTCOND*/1)
#define YY_SKIP_YYWRAP
#define FLEX_DEBUG
typedef unsigned char YY_CHAR;
FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
typedef int yy_state_type;
extern int yylineno;
int yylineno = 1;
extern char *yytext;
#ifdef yytext_ptr
#undef yytext_ptr
#endif
#define yytext_ptr yytext
/* %% [1.5] DFA */
/* %if-c-only Standard (non-C++) definition */
static yy_state_type yy_get_previous_state (void );
static yy_state_type yy_try_NUL_trans (yy_state_type current_state );
static int yy_get_next_buffer (void );
#if defined(__GNUC__) && __GNUC__ >= 3
__attribute__((__noreturn__))
#endif
static void yy_fatal_error (yyconst char msg[] );
/* %endif */
/* Done after the current pattern has been matched and before the
* corresponding action - sets up yytext.
*/
#define YY_DO_BEFORE_ACTION \
(yytext_ptr) = yy_bp; \
/* %% [2.0] code to fiddle yytext and yyleng for yymore() goes here \ */\
yyleng = (size_t) (yy_cp - yy_bp); \
(yy_hold_char) = *yy_cp; \
*yy_cp = '\0'; \
/* %% [3.0] code to copy yytext_ptr to yytext[] goes here, if %array \ */\
(yy_c_buf_p) = yy_cp;
/* %% [4.0] data tables for the DFA and the user's section 1 definitions go here */
#define YY_NUM_RULES 107
#define YY_END_OF_BUFFER 108
/* This struct is not used in this scanner,
but its presence is necessary. */
struct yy_trans_info
{
flex_int32_t yy_verify;
flex_int32_t yy_nxt;
};
static yyconst flex_int16_t yy_accept[344] =
{ 0,
0, 0, 108, 106, 105, 105, 9, 106, 106, 106,
106, 100, 27, 6, 106, 7, 102, 48, 1, 102,
102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
102, 102, 102, 102, 102, 102, 102, 102, 26, 105,
8, 0, 103, 0, 104, 1, 41, 101, 0, 100,
0, 2, 4, 3, 5, 102, 102, 102, 102, 102,
56, 102, 102, 42, 102, 102, 102, 102, 102, 102,
102, 27, 102, 102, 102, 102, 102, 36, 102, 25,
102, 72, 102, 102, 102, 102, 102, 12, 102, 102,
102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
102, 102, 102, 102, 102, 102, 40, 102, 102, 102,
102, 102, 102, 102, 0, 100, 0, 100, 65, 102,
11, 102, 102, 102, 102, 102, 102, 102, 102, 76,
102, 102, 50, 102, 39, 102, 73, 102, 102, 102,
102, 102, 102, 102, 71, 102, 52, 51, 49, 10,
93, 102, 81, 102, 102, 102, 102, 102, 102, 102,
14, 67, 75, 102, 20, 102, 102, 102, 31, 102,
77, 102, 102, 102, 58, 102, 16, 35, 102, 13,
0, 79, 102, 78, 80, 102, 64, 70, 102, 102,
102, 102, 102, 102, 102, 38, 102, 102, 102, 102,
102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
102, 102, 102, 32, 47, 102, 55, 30, 102, 102,
102, 102, 57, 74, 102, 102, 102, 102, 37, 102,
102, 66, 26, 0, 101, 102, 102, 102, 90, 102,
46, 102, 102, 102, 102, 102, 102, 69, 102, 102,
102, 102, 102, 102, 44, 102, 99, 102, 102, 102,
15, 102, 89, 102, 102, 68, 60, 102, 102, 102,
102, 102, 19, 102, 94, 95, 43, 102, 54, 53,
28, 102, 102, 102, 102, 102, 24, 102, 34, 33,
102, 102, 102, 102, 102, 97, 102, 102, 49, 102,
102, 92, 102, 82, 102, 102, 98, 102, 102, 102,
59, 85, 23, 21, 22, 102, 102, 102, 102, 29,
102, 102, 102, 102, 102, 102, 86, 45, 48, 102,
96, 88, 102, 91, 17, 18, 87, 83, 61, 84,
62, 63, 0
} ;
static yyconst YY_CHAR yy_ec[256] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
2, 2, 2, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 2, 4, 5, 1, 1, 1, 1, 6, 1,
1, 7, 8, 1, 9, 10, 1, 11, 12, 13,
11, 11, 11, 11, 11, 11, 11, 14, 1, 15,
16, 17, 1, 1, 18, 18, 18, 19, 19, 18,
18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
1, 20, 1, 21, 18, 1, 22, 23, 24, 25,
26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
36, 37, 38, 39, 40, 41, 42, 43, 44, 45,
46, 47, 1, 48, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1
} ;
static yyconst YY_CHAR yy_meta[49] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2, 2, 2, 1, 1, 1, 1, 2, 2, 1,
1, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 1
} ;
static yyconst flex_uint16_t yy_base[347] =
{ 0,
0, 0, 405, 406, 47, 49, 388, 398, 396, 394,
43, 47, 384, 383, 382, 381, 0, 406, 406, 39,
31, 59, 39, 49, 31, 56, 61, 70, 360, 356,
71, 77, 90, 79, 36, 82, 364, 357, 406, 121,
406, 387, 406, 385, 406, 406, 406, 122, 126, 132,
141, 406, 406, 406, 406, 0, 350, 353, 363, 359,
356, 363, 349, 0, 344, 352, 355, 71, 344, 352,
335, 0, 337, 351, 72, 339, 335, 0, 336, 134,
337, 0, 343, 76, 335, 344, 327, 342, 327, 321,
110, 329, 341, 320, 339, 119, 325, 324, 328, 317,
317, 333, 96, 320, 318, 326, 0, 314, 320, 323,
47, 321, 306, 307, 154, 153, 156, 169, 0, 305,
0, 310, 308, 307, 319, 315, 306, 314, 303, 0,
296, 148, 0, 309, 0, 294, 0, 297, 310, 298,
147, 300, 303, 300, 0, 303, 296, 295, 282, 0,
0, 301, 296, 149, 161, 296, 162, 285, 286, 296,
0, 280, 0, 279, 0, 274, 275, 149, 0, 288,
0, 277, 285, 274, 0, 269, 0, 0, 279, 0,
185, 0, 169, 0, 0, 268, 0, 0, 274, 279,
264, 261, 266, 259, 167, 0, 259, 260, 265, 267,
251, 271, 259, 172, 252, 263, 257, 256, 256, 254,
248, 245, 246, 0, 0, 248, 0, 0, 258, 256,
242, 244, 0, 0, 238, 175, 242, 247, 0, 190,
241, 0, 239, 193, 201, 229, 238, 226, 235, 235,
0, 236, 232, 233, 225, 226, 224, 0, 230, 238,
221, 238, 229, 232, 0, 228, 0, 226, 225, 218,
0, 213, 0, 222, 217, 0, 0, 228, 205, 205,
206, 207, 0, 218, 0, 0, 0, 202, 0, 0,
0, 208, 201, 200, 207, 216, 0, 210, 0, 0,
207, 210, 194, 193, 194, 0, 185, 184, 0, 204,
188, 0, 187, 0, 205, 186, 0, 198, 183, 190,
0, 0, 0, 0, 0, 181, 180, 179, 164, 0,
183, 181, 135, 128, 129, 96, 0, 0, 0, 81,
0, 0, 50, 0, 0, 0, 0, 0, 0, 0,
0, 0, 406, 216, 218, 66
} ;
static yyconst flex_int16_t yy_def[347] =
{ 0,
343, 1, 343, 343, 343, 343, 343, 344, 345, 343,
343, 343, 343, 343, 343, 343, 346, 343, 343, 346,
346, 346, 346, 346, 346, 346, 346, 346, 346, 346,
346, 346, 346, 346, 346, 346, 346, 346, 343, 343,
343, 344, 343, 345, 343, 343, 343, 343, 343, 343,
343, 343, 343, 343, 343, 346, 346, 346, 346, 346,
346, 346, 346, 346, 346, 346, 346, 346, 346, 346,
346, 346, 346, 346, 346, 346, 346, 346, 346, 346,
346, 346, 346, 346, 346, 346, 346, 346, 346, 346,
346, 346, 346, 346, 346, 346, 346, 346, 346, 346,
346, 346, 346, 346, 346, 346, 346, 346, 346, 346,
346, 346, 346, 346, 343, 343, 343, 343, 346, 346,
346, 346, 346, 346, 346, 346, 346, 346, 346, 346,
346, 346, 346, 346, 346, 346, 346, 346, 346, 346,
346, 346, 346, 346, 346, 346, 346, 346, 346, 346,
346, 346, 346, 346, 346, 346, 346, 346, 346, 346,
346, 346, 346, 346, 346, 346, 346, 346, 346, 346,
346, 346, 346, 346, 346, 346, 346, 346, 346, 346,
343, 346, 346, 346, 346, 346, 346, 346, 346, 346,
346, 346, 346, 346, 346, 346, 346, 346, 346, 346,
346, 346, 346, 346, 346, 346, 346, 346, 346, 346,
346, 346, 346, 346, 346, 346, 346, 346, 346, 346,
346, 346, 346, 346, 346, 346, 346, 346, 346, 346,
346, 346, 346, 343, 343, 346, 346, 346, 346, 346,
346, 346, 346, 346, 346, 346, 346, 346, 346, 346,
346, 346, 346, 346, 346, 346, 346, 346, 346, 346,
346, 346, 346, 346, 346, 346, 346, 346, 346, 346,
346, 346, 346, 346, 346, 346, 346, 346, 346, 346,
346, 346, 346, 346, 346, 346, 346, 346, 346, 346,
346, 346, 346, 346, 346, 346, 346, 346, 346, 346,
346, 346, 346, 346, 346, 346, 346, 346, 346, 346,
346, 346, 346, 346, 346, 346, 346, 346, 346, 346,
346, 346, 346, 346, 346, 346, 346, 346, 346, 346,
346, 346, 346, 346, 346, 346, 346, 346, 346, 346,
346, 346, 0, 343, 343, 343
} ;
static yyconst flex_uint16_t yy_nxt[455] =
{ 0,
4, 5, 6, 7, 8, 9, 10, 4, 4, 11,
12, 12, 12, 13, 14, 15, 16, 17, 17, 18,
19, 20, 21, 22, 23, 24, 25, 17, 17, 26,
17, 17, 27, 28, 29, 30, 31, 17, 32, 33,
34, 35, 36, 37, 38, 17, 17, 39, 40, 40,
40, 40, 47, 48, 48, 48, 49, 50, 50, 50,
63, 57, 58, 76, 70, 51, 77, 56, 71, 176,
109, 51, 51, 59, 72, 110, 64, 60, 61, 62,
65, 73, 78, 74, 66, 177, 81, 67, 342, 79,
80, 84, 89, 75, 68, 82, 83, 69, 92, 85,
105, 136, 93, 111, 129, 86, 90, 106, 137, 91,
130, 112, 94, 95, 107, 96, 146, 97, 168, 98,
147, 99, 40, 40, 108, 100, 341, 101, 340, 169,
102, 103, 48, 48, 48, 104, 116, 116, 116, 154,
115, 49, 50, 50, 50, 155, 115, 115, 117, 117,
51, 118, 118, 118, 339, 160, 51, 51, 141, 161,
142, 181, 181, 116, 116, 116, 118, 118, 118, 192,
193, 51, 201, 338, 143, 337, 202, 51, 51, 118,
118, 118, 194, 212, 213, 214, 217, 195, 226, 227,
236, 215, 245, 234, 218, 235, 235, 235, 237, 254,
271, 275, 276, 235, 235, 235, 336, 246, 335, 334,
255, 235, 235, 235, 333, 272, 42, 42, 44, 44,
332, 331, 330, 329, 328, 327, 326, 325, 324, 323,
322, 321, 320, 319, 318, 317, 316, 315, 314, 313,
312, 311, 310, 309, 308, 307, 306, 305, 304, 303,
302, 301, 300, 299, 298, 297, 296, 295, 294, 293,
292, 291, 290, 289, 288, 287, 286, 285, 284, 283,
282, 281, 280, 279, 278, 277, 274, 273, 270, 269,
268, 267, 266, 265, 264, 263, 262, 261, 260, 259,
258, 257, 256, 253, 252, 251, 250, 249, 248, 247,
244, 243, 242, 241, 240, 239, 238, 233, 232, 231,
230, 229, 228, 225, 224, 223, 222, 221, 220, 219,
216, 211, 210, 209, 208, 207, 206, 205, 204, 203,
200, 199, 198, 197, 196, 191, 190, 189, 188, 187,
186, 185, 184, 183, 182, 180, 179, 178, 175, 174,
173, 172, 171, 170, 167, 166, 165, 164, 163, 162,
159, 158, 157, 156, 153, 152, 151, 150, 149, 148,
145, 144, 140, 139, 138, 135, 134, 133, 132, 131,
128, 127, 126, 125, 124, 123, 122, 121, 120, 119,
45, 43, 114, 113, 88, 87, 55, 54, 53, 52,
46, 45, 43, 41, 343, 3, 343, 343, 343, 343,
343, 343, 343, 343, 343, 343, 343, 343, 343, 343,
343, 343, 343, 343, 343, 343, 343, 343, 343, 343,
343, 343, 343, 343, 343, 343, 343, 343, 343, 343,
343, 343, 343, 343, 343, 343, 343, 343, 343, 343,
343, 343, 343, 343
} ;
static yyconst flex_int16_t yy_chk[455] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 5, 5,
6, 6, 11, 11, 11, 11, 12, 12, 12, 12,
21, 20, 20, 25, 23, 12, 25, 346, 23, 111,
35, 12, 12, 20, 23, 35, 21, 20, 20, 20,
22, 24, 26, 24, 22, 111, 27, 22, 333, 26,
26, 28, 31, 24, 22, 27, 27, 22, 32, 28,
34, 75, 32, 36, 68, 28, 31, 34, 75, 31,
68, 36, 32, 33, 34, 33, 84, 33, 103, 33,
84, 33, 40, 40, 34, 33, 330, 33, 326, 103,
33, 33, 48, 48, 48, 33, 49, 49, 49, 91,
48, 50, 50, 50, 50, 91, 48, 48, 51, 51,
50, 51, 51, 51, 325, 96, 50, 50, 80, 96,
80, 115, 115, 116, 116, 116, 117, 117, 117, 132,
132, 116, 141, 324, 80, 323, 141, 116, 116, 118,
118, 118, 132, 154, 154, 155, 157, 132, 168, 168,
183, 155, 195, 181, 157, 181, 181, 181, 183, 204,
226, 230, 230, 234, 234, 234, 322, 195, 321, 319,
204, 235, 235, 235, 318, 226, 344, 344, 345, 345,
317, 316, 310, 309, 308, 306, 305, 303, 301, 300,
298, 297, 295, 294, 293, 292, 291, 288, 286, 285,
284, 283, 282, 278, 274, 272, 271, 270, 269, 268,
265, 264, 262, 260, 259, 258, 256, 254, 253, 252,
251, 250, 249, 247, 246, 245, 244, 243, 242, 240,
239, 238, 237, 236, 233, 231, 228, 227, 225, 222,
221, 220, 219, 216, 213, 212, 211, 210, 209, 208,
207, 206, 205, 203, 202, 201, 200, 199, 198, 197,
194, 193, 192, 191, 190, 189, 186, 179, 176, 174,
173, 172, 170, 167, 166, 164, 162, 160, 159, 158,
156, 153, 152, 149, 148, 147, 146, 144, 143, 142,
140, 139, 138, 136, 134, 131, 129, 128, 127, 126,
125, 124, 123, 122, 120, 114, 113, 112, 110, 109,
108, 106, 105, 104, 102, 101, 100, 99, 98, 97,
95, 94, 93, 92, 90, 89, 88, 87, 86, 85,
83, 81, 79, 77, 76, 74, 73, 71, 70, 69,
67, 66, 65, 63, 62, 61, 60, 59, 58, 57,
44, 42, 38, 37, 30, 29, 16, 15, 14, 13,
10, 9, 8, 7, 3, 343, 343, 343, 343, 343,
343, 343, 343, 343, 343, 343, 343, 343, 343, 343,
343, 343, 343, 343, 343, 343, 343, 343, 343, 343,
343, 343, 343, 343, 343, 343, 343, 343, 343, 343,
343, 343, 343, 343, 343, 343, 343, 343, 343, 343,
343, 343, 343, 343
} ;
static yy_state_type yy_last_accepting_state;
static char *yy_last_accepting_cpos;
extern int yy_flex_debug;
int yy_flex_debug = 1;
static yyconst flex_int16_t yy_rule_linenum[107] =
{ 0,
84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
94, 95, 96, 97, 98, 99, 100, 101, 102, 103,
104, 105, 106, 107, 108, 109, 110, 111, 112, 113,
114, 115, 116, 117, 118, 119, 120, 121, 122, 123,
124, 125, 126, 127, 128, 129, 130, 131, 132, 133,
134, 135, 136, 137, 138, 139, 140, 141, 142, 143,
144, 145, 146, 147, 148, 149, 150, 151, 152, 153,
154, 155, 156, 157, 158, 159, 160, 161, 162, 163,
164, 165, 166, 167, 168, 169, 170, 171, 172, 173,
174, 175, 176, 177, 178, 179, 180, 181, 182, 184,
190, 197, 314, 320, 327, 329
} ;
/* The intent behind this definition is that it'll catch
* any uses of REJECT which flex missed.
*/
#define REJECT reject_used_but_not_detected
#define yymore() yymore_used_but_not_detected
#define YY_MORE_ADJ 0
#define YY_RESTORE_YY_MORE_OFFSET
char *yytext;
#line 1 "src/mmlscan.l"
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* File....: mmlscan.l */
/* Name....: MML Lexcal Analyser */
/* Author..: Thorsten Koch */
/* Copyright by Author, All rights reserved */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Copyright (C) 2001-2017 by Thorsten Koch
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#line 27 "src/mmlscan.l"
#pragma clang diagnostic ignored "-Wsign-conversion"
#pragma clang diagnostic ignored "-Wconversion"
#pragma clang diagnostic ignored "-Wmissing-prototypes"
#pragma clang diagnostic ignored "-Wunused-macros"
#pragma clang diagnostic ignored "-Wmissing-noreturn"
#pragma clang diagnostic ignored "-Wunneeded-internal-declaration"
/*lint -e429 */
/*lint -e506 -e525 -e528 -e527 -e537 -e539 -e551 -e553 -e613 -e633 */
/*lint -e702 -e713 -e716 -e725 -e732 -e734 -e737 -e744 -e750 -e754 */
/*lint -e774 -e770 -e775 -e794 -e825 -e835 */
/*lint -esym(534,yy_init_globals) ignoring return value */
/*lint -esym(613,b,buf) -esym(563,find_rule) */
/*lint -esym(668,memset) possibly passing null pointer */
/*lint -esym(752,yyset_extra,yyget_extra) not referenced */
/*lint -esym(773,BEGIN) -esym(760,FLEX_DEBUG) */
/*lint -sem(yyerror, 1p && nulterm(1), r_no) */
#include
#include
#include
#include
#include
#include "bool.h"
#include "mshell.h"
#include "ratlptypes.h"
#include "numb.h"
#include "elem.h"
#include "tuple.h"
#include "mme.h"
#include "set.h"
#include "symbol.h"
#include "define.h"
#include "stmt.h"
#include "strstore.h"
#include "mmlparse2.h"
extern void yyerror(const char* s);
#define YY_DECL int yylex(YYSTYPE* lval)
YY_DECL;
static int yycolumn = 0;
static int yydecl = 0;
#line 857 "src/mmlscan.c"
#define INITIAL 0
#ifndef YY_NO_UNISTD_H
/* Special case for "unistd.h", since it is non-ANSI. We include it way
* down here because we want the user's section 1 to have been scanned first.
* The user has a chance to override it with an option.
*/
/* %if-c-only */
#include
/* %endif */
/* %if-c++-only */
/* %endif */
#endif
#ifndef YY_EXTRA_TYPE
#define YY_EXTRA_TYPE void *
#endif
/* %if-c-only Reentrant structure and macros (non-C++). */
/* %if-reentrant */
/* %if-c-only */
static int yy_init_globals (void );
/* %endif */
/* %if-reentrant */
/* %endif */
/* %endif End reentrant structures and macros. */
/* Accessor methods to globals.
These are made visible to non-reentrant scanners for convenience. */
int yylex_destroy (void );
int yyget_debug (void );
void yyset_debug (int debug_flag );
YY_EXTRA_TYPE yyget_extra (void );
void yyset_extra (YY_EXTRA_TYPE user_defined );
FILE *yyget_in (void );
void yyset_in (FILE * _in_str );
FILE *yyget_out (void );
void yyset_out (FILE * _out_str );
yy_size_t yyget_leng (void );
char *yyget_text (void );
int yyget_lineno (void );
void yyset_lineno (int _line_number );
/* %if-bison-bridge */
/* %endif */
/* Macros after this point can all be overridden by user definitions in
* section 1.
*/
#ifndef YY_SKIP_YYWRAP
#ifdef __cplusplus
extern "C" int yywrap (void );
#else
extern int yywrap (void );
#endif
#endif
/* %not-for-header */
#ifndef YY_NO_UNPUT
#endif
/* %ok-for-header */
/* %endif */
#ifndef yytext_ptr
static void yy_flex_strncpy (char *,yyconst char *,int );
#endif
#ifdef YY_NEED_STRLEN
static int yy_flex_strlen (yyconst char * );
#endif
#ifndef YY_NO_INPUT
/* %if-c-only Standard (non-C++) definition */
/* %not-for-header */
#ifdef __cplusplus
static int yyinput (void );
#else
static int input (void );
#endif
/* %ok-for-header */
/* %endif */
#endif
/* %if-c-only */
/* %endif */
/* Amount of stuff to slurp up with each read. */
#ifndef YY_READ_BUF_SIZE
#ifdef __ia64__
/* On IA-64, the buffer size is 16k, not 8k */
#define YY_READ_BUF_SIZE 16384
#else
#define YY_READ_BUF_SIZE 8192
#endif /* __ia64__ */
#endif
/* Copy whatever the last rule matched to the standard output. */
#ifndef ECHO
/* %if-c-only Standard (non-C++) definition */
/* This used to be an fputs(), but since the string might contain NUL's,
* we now use fwrite().
*/
#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0)
/* %endif */
/* %if-c++-only C++ definition */
/* %endif */
#endif
/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
* is returned in "result".
*/
#ifndef YY_INPUT
#define YY_INPUT(buf,result,max_size) \
/* %% [5.0] fread()/read() definition of YY_INPUT goes here unless we're doing C++ \ */\
if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
{ \
int c = '*'; \
size_t n; \
for ( n = 0; n < max_size && \
(c = getc( yyin )) != EOF && c != '\n'; ++n ) \
buf[n] = (char) c; \
if ( c == '\n' ) \
buf[n++] = (char) c; \
if ( c == EOF && ferror( yyin ) ) \
YY_FATAL_ERROR( "input in flex scanner failed" ); \
result = n; \
} \
else \
{ \
errno=0; \
while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
{ \
if( errno != EINTR) \
{ \
YY_FATAL_ERROR( "input in flex scanner failed" ); \
break; \
} \
errno=0; \
clearerr(yyin); \
} \
}\
\
/* %if-c++-only C++ definition \ */\
/* %endif */
#endif
/* No semi-colon after return; correct usage is to write "yyterminate();" -
* we don't want an extra ';' after the "return" because that will cause
* some compilers to complain about unreachable statements.
*/
#ifndef yyterminate
#define yyterminate() return YY_NULL
#endif
/* Number of entries by which start-condition stack grows. */
#ifndef YY_START_STACK_INCR
#define YY_START_STACK_INCR 25
#endif
/* Report a fatal error. */
#ifndef YY_FATAL_ERROR
/* %if-c-only */
#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
/* %endif */
/* %if-c++-only */
/* %endif */
#endif
/* %if-tables-serialization structures and prototypes */
/* %not-for-header */
/* %ok-for-header */
/* %not-for-header */
/* %tables-yydmap generated elements */
/* %endif */
/* end tables serialization structures and prototypes */
/* %ok-for-header */
/* Default declaration of generated scanner - a define so the user can
* easily add parameters.
*/
#ifndef YY_DECL
#define YY_DECL_IS_OURS 1
/* %if-c-only Standard (non-C++) definition */
extern int yylex (void);
#define YY_DECL int yylex (void)
/* %endif */
/* %if-c++-only C++ definition */
/* %endif */
#endif /* !YY_DECL */
/* Code executed at the beginning of each rule, after yytext and yyleng
* have been set up.
*/
#ifndef YY_USER_ACTION
#define YY_USER_ACTION
#endif
/* Code executed at the end of each rule. */
#ifndef YY_BREAK
#define YY_BREAK /*LINTED*/break;
#endif
/* %% [6.0] YY_RULE_SETUP definition goes here */
#define YY_RULE_SETUP \
YY_USER_ACTION
/* %not-for-header */
/** The main scanner function which does all the work.
*/
YY_DECL
{
yy_state_type yy_current_state;
char *yy_cp, *yy_bp;
int yy_act;
if ( !(yy_init) )
{
(yy_init) = 1;
#ifdef YY_USER_INIT
YY_USER_INIT;
#endif
if ( ! (yy_start) )
(yy_start) = 1; /* first start state */
if ( ! yyin )
/* %if-c-only */
yyin = stdin;
/* %endif */
/* %if-c++-only */
/* %endif */
if ( ! yyout )
/* %if-c-only */
yyout = stdout;
/* %endif */
/* %if-c++-only */
/* %endif */
if ( ! YY_CURRENT_BUFFER ) {
yyensure_buffer_stack ();
YY_CURRENT_BUFFER_LVALUE =
yy_create_buffer(yyin,YY_BUF_SIZE );
}
yy_load_buffer_state( );
}
{
/* %% [7.0] user's declarations go here */
#line 83 "src/mmlscan.l"
#line 1142 "src/mmlscan.c"
while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */
{
/* %% [8.0] yymore()-related code goes here */
yy_cp = (yy_c_buf_p);
/* Support of yytext. */
*yy_cp = (yy_hold_char);
/* yy_bp points to the position in yy_ch_buf of the start of
* the current run.
*/
yy_bp = yy_cp;
/* %% [9.0] code to set up and find next match goes here */
yy_current_state = (yy_start);
yy_match:
do
{
YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ;
if ( yy_accept[yy_current_state] )
{
(yy_last_accepting_state) = yy_current_state;
(yy_last_accepting_cpos) = yy_cp;
}
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 344 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
++yy_cp;
}
while ( yy_current_state != 343 );
yy_cp = (yy_last_accepting_cpos);
yy_current_state = (yy_last_accepting_state);
yy_find_action:
/* %% [10.0] code to find the action number goes here */
yy_act = yy_accept[yy_current_state];
YY_DO_BEFORE_ACTION;
/* %% [11.0] code for yylineno update goes here */
do_action: /* This label is used only to access EOF actions. */
/* %% [12.0] debug code goes here */
if ( yy_flex_debug )
{
if ( yy_act == 0 )
fprintf( stderr, "--scanner backing up\n" );
else if ( yy_act < 107 )
fprintf( stderr, "--accepting rule at line %ld (\"%s\")\n",
(long)yy_rule_linenum[yy_act], yytext );
else if ( yy_act == 107 )
fprintf( stderr, "--accepting default rule (\"%s\")\n",
yytext );
else if ( yy_act == 108 )
fprintf( stderr, "--(end of buffer or a NUL)\n" );
else
fprintf( stderr, "--EOF (start condition %d)\n", YY_START );
}
switch ( yy_act )
{ /* beginning of action switch */
/* %% [13.0] actions go here */
case 0: /* must back up */
/* undo the effects of YY_DO_BEFORE_ACTION */
*yy_cp = (yy_hold_char);
yy_cp = (yy_last_accepting_cpos);
yy_current_state = (yy_last_accepting_state);
goto yy_find_action;
case 1:
YY_RULE_SETUP
#line 84 "src/mmlscan.l"
{ yycolumn += yyleng; return POW; }
YY_BREAK
case 2:
YY_RULE_SETUP
#line 85 "src/mmlscan.l"
{ yycolumn += yyleng; return ASGN; }
YY_BREAK
case 3:
YY_RULE_SETUP
#line 86 "src/mmlscan.l"
{ yycolumn += yyleng; return CMP_EQ; }
YY_BREAK
case 4:
YY_RULE_SETUP
#line 87 "src/mmlscan.l"
{ yycolumn += yyleng; return CMP_LE; }
YY_BREAK
case 5:
YY_RULE_SETUP
#line 88 "src/mmlscan.l"
{ yycolumn += yyleng; return CMP_GE; }
YY_BREAK
case 6:
YY_RULE_SETUP
#line 89 "src/mmlscan.l"
{ yycolumn += yyleng; return CMP_LT; }
YY_BREAK
case 7:
YY_RULE_SETUP
#line 90 "src/mmlscan.l"
{ yycolumn += yyleng; return CMP_GT; }
YY_BREAK
case 8:
YY_RULE_SETUP
#line 91 "src/mmlscan.l"
{ yycolumn += yyleng; return CMP_NE; }
YY_BREAK
case 9:
YY_RULE_SETUP
#line 92 "src/mmlscan.l"
{ yycolumn += yyleng; return FAC; }
YY_BREAK
case 10:
YY_RULE_SETUP
#line 93 "src/mmlscan.l"
{ yycolumn += yyleng; return NOT; }
YY_BREAK
case 11:
YY_RULE_SETUP
#line 94 "src/mmlscan.l"
{ yycolumn += yyleng; return AND; }
YY_BREAK
case 12:
YY_RULE_SETUP
#line 95 "src/mmlscan.l"
{ yycolumn += yyleng; return OR; }
YY_BREAK
case 13:
YY_RULE_SETUP
#line 96 "src/mmlscan.l"
{ yycolumn += yyleng; return XOR; }
YY_BREAK
case 14:
YY_RULE_SETUP
#line 97 "src/mmlscan.l"
{ yycolumn += yyleng; yydecl = DECLSET; return DECLSET; }
YY_BREAK
case 15:
YY_RULE_SETUP
#line 98 "src/mmlscan.l"
{ yycolumn += yyleng; yydecl = DECLPAR; return DECLPAR; }
YY_BREAK
case 16:
YY_RULE_SETUP
#line 99 "src/mmlscan.l"
{ yycolumn += yyleng; yydecl = DECLVAR; return DECLVAR; }
YY_BREAK
case 17:
YY_RULE_SETUP
#line 100 "src/mmlscan.l"
{ yycolumn += yyleng; yydecl = DECLMAX; return DECLMAX; }
YY_BREAK
case 18:
YY_RULE_SETUP
#line 101 "src/mmlscan.l"
{ yycolumn += yyleng; yydecl = DECLMIN; return DECLMIN; }
YY_BREAK
case 19:
YY_RULE_SETUP
#line 102 "src/mmlscan.l"
{ yycolumn += yyleng; yydecl = DECLSUB; return DECLSUB; }
YY_BREAK
case 20:
YY_RULE_SETUP
#line 103 "src/mmlscan.l"
{ yycolumn += yyleng; yydecl = DECLSOS; return DECLSOS; }
YY_BREAK
case 21:
YY_RULE_SETUP
#line 104 "src/mmlscan.l"
{ yycolumn += yyleng; yydecl = DEFNUMB; return DEFNUMB; }
YY_BREAK
case 22:
YY_RULE_SETUP
#line 105 "src/mmlscan.l"
{ yycolumn += yyleng; yydecl = DEFSTRG; return DEFSTRG; }
YY_BREAK
case 23:
YY_RULE_SETUP
#line 106 "src/mmlscan.l"
{ yycolumn += yyleng; yydecl = DEFBOOL; return DEFBOOL; }
YY_BREAK
case 24:
YY_RULE_SETUP
#line 107 "src/mmlscan.l"
{ yycolumn += yyleng; yydecl = DEFSET; return DEFSET; }
YY_BREAK
case 25:
YY_RULE_SETUP
#line 108 "src/mmlscan.l"
{ yycolumn += yyleng; return IN; }
YY_BREAK
case 26:
YY_RULE_SETUP
#line 109 "src/mmlscan.l"
{ yycolumn += yyleng; return WITH; }
YY_BREAK
case 27:
YY_RULE_SETUP
#line 110 "src/mmlscan.l"
{ yycolumn += yyleng; return DO; }
YY_BREAK
case 28:
YY_RULE_SETUP
#line 111 "src/mmlscan.l"
{ yycolumn += yyleng; return BINARY; }
YY_BREAK
case 29:
YY_RULE_SETUP
#line 112 "src/mmlscan.l"
{ yycolumn += yyleng; return INTEGER; }
YY_BREAK
case 30:
YY_RULE_SETUP
#line 113 "src/mmlscan.l"
{ yycolumn += yyleng; return REAL; }
YY_BREAK
case 31:
YY_RULE_SETUP
#line 114 "src/mmlscan.l"
{ yycolumn += yyleng; return SUM; }
YY_BREAK
case 32:
YY_RULE_SETUP
#line 115 "src/mmlscan.l"
{ yycolumn += yyleng; return PROD; }
YY_BREAK
case 33:
YY_RULE_SETUP
#line 116 "src/mmlscan.l"
{ yycolumn += yyleng; return FORALL; }
YY_BREAK
case 34:
YY_RULE_SETUP
#line 117 "src/mmlscan.l"
{ yycolumn += yyleng; return EXISTS; }
YY_BREAK
case 35:
YY_RULE_SETUP
#line 118 "src/mmlscan.l"
{ yycolumn += yyleng; return VIF; }
YY_BREAK
case 36:
YY_RULE_SETUP
#line 119 "src/mmlscan.l"
{ yycolumn += yyleng; return IF; }
YY_BREAK
case 37:
YY_RULE_SETUP
#line 120 "src/mmlscan.l"
{ yycolumn += yyleng; return THEN; }
YY_BREAK
case 38:
YY_RULE_SETUP
#line 121 "src/mmlscan.l"
{ yycolumn += yyleng; return ELSE; }
YY_BREAK
case 39:
YY_RULE_SETUP
#line 122 "src/mmlscan.l"
{ yycolumn += yyleng; return END; }
YY_BREAK
case 40:
YY_RULE_SETUP
#line 123 "src/mmlscan.l"
{ yycolumn += yyleng; return TO; }
YY_BREAK
case 41:
YY_RULE_SETUP
#line 124 "src/mmlscan.l"
{ yycolumn += yyleng; return UNTIL; }
YY_BREAK
case 42:
YY_RULE_SETUP
#line 125 "src/mmlscan.l"
{ yycolumn += yyleng; return BY; }
YY_BREAK
case 43:
YY_RULE_SETUP
#line 126 "src/mmlscan.l"
{ yycolumn += yyleng; return UNION; }
YY_BREAK
case 44:
YY_RULE_SETUP
#line 127 "src/mmlscan.l"
{ yycolumn += yyleng; return INTER; }
YY_BREAK
case 45:
YY_RULE_SETUP
#line 128 "src/mmlscan.l"
{ yycolumn += yyleng; return SYMDIFF; }
YY_BREAK
case 46:
YY_RULE_SETUP
#line 129 "src/mmlscan.l"
{ yycolumn += yyleng; return CROSS; }
YY_BREAK
case 47:
YY_RULE_SETUP
#line 130 "src/mmlscan.l"
{ yycolumn += yyleng; return PROJ; }
YY_BREAK
case 48:
YY_RULE_SETUP
#line 131 "src/mmlscan.l"
{ yycolumn += yyleng; return WITHOUT; }
YY_BREAK
case 49:
YY_RULE_SETUP
#line 132 "src/mmlscan.l"
{ yycolumn += yyleng; return MOD; }
YY_BREAK
case 50:
YY_RULE_SETUP
#line 133 "src/mmlscan.l"
{ yycolumn += yyleng; return DIV; }
YY_BREAK
case 51:
YY_RULE_SETUP
#line 134 "src/mmlscan.l"
{ yycolumn += yyleng; return MIN; }
YY_BREAK
case 52:
YY_RULE_SETUP
#line 135 "src/mmlscan.l"
{ yycolumn += yyleng; return MAX; }
YY_BREAK
case 53:
YY_RULE_SETUP
#line 136 "src/mmlscan.l"
{ yycolumn += yyleng; return ARGMIN; }
YY_BREAK
case 54:
YY_RULE_SETUP
#line 137 "src/mmlscan.l"
{ yycolumn += yyleng; return ARGMAX; }
YY_BREAK
case 55:
YY_RULE_SETUP
#line 138 "src/mmlscan.l"
{ yycolumn += yyleng; return READ; }
YY_BREAK
case 56:
YY_RULE_SETUP
#line 139 "src/mmlscan.l"
{ yycolumn += yyleng; return AS; }
YY_BREAK
case 57:
YY_RULE_SETUP
#line 140 "src/mmlscan.l"
{ yycolumn += yyleng; return SKIP; }
YY_BREAK
case 58:
YY_RULE_SETUP
#line 141 "src/mmlscan.l"
{ yycolumn += yyleng; return USE; }
YY_BREAK
case 59:
YY_RULE_SETUP
#line 142 "src/mmlscan.l"
{ yycolumn += yyleng; return COMMENT; }
YY_BREAK
case 60:
YY_RULE_SETUP
#line 143 "src/mmlscan.l"
{ yycolumn += yyleng; return SCALE; }
YY_BREAK
case 61:
YY_RULE_SETUP
#line 144 "src/mmlscan.l"
{ yycolumn += yyleng; return SEPARATE; }
YY_BREAK
case 62:
YY_RULE_SETUP
#line 145 "src/mmlscan.l"
{ yycolumn += yyleng; return CHECKONLY; }
YY_BREAK
case 63:
YY_RULE_SETUP
#line 146 "src/mmlscan.l"
{ yycolumn += yyleng; return INDICATOR; }
YY_BREAK
case 64:
YY_RULE_SETUP
#line 147 "src/mmlscan.l"
{ yycolumn += yyleng; return CARD; }
YY_BREAK
case 65:
YY_RULE_SETUP
#line 148 "src/mmlscan.l"
{ yycolumn += yyleng; return ABS; }
YY_BREAK
case 66:
YY_RULE_SETUP
#line 149 "src/mmlscan.l"
{ yycolumn += yyleng; return VABS; }
YY_BREAK
case 67:
YY_RULE_SETUP
#line 150 "src/mmlscan.l"
{ yycolumn += yyleng; return SGN; }
YY_BREAK
case 68:
YY_RULE_SETUP
#line 151 "src/mmlscan.l"
{ yycolumn += yyleng; return ROUND; }
YY_BREAK
case 69:
YY_RULE_SETUP
#line 152 "src/mmlscan.l"
{ yycolumn += yyleng; return FLOOR; }
YY_BREAK
case 70:
YY_RULE_SETUP
#line 153 "src/mmlscan.l"
{ yycolumn += yyleng; return CEIL; }
YY_BREAK
case 71:
YY_RULE_SETUP
#line 154 "src/mmlscan.l"
{ yycolumn += yyleng; return LOG; }
YY_BREAK
case 72:
YY_RULE_SETUP
#line 155 "src/mmlscan.l"
{ yycolumn += yyleng; return LN; }
YY_BREAK
case 73:
YY_RULE_SETUP
#line 156 "src/mmlscan.l"
{ yycolumn += yyleng; return EXP; }
YY_BREAK
case 74:
YY_RULE_SETUP
#line 157 "src/mmlscan.l"
{ yycolumn += yyleng; return SQRT; }
YY_BREAK
case 75:
YY_RULE_SETUP
#line 158 "src/mmlscan.l"
{ yycolumn += yyleng; return SIN; }
YY_BREAK
case 76:
YY_RULE_SETUP
#line 159 "src/mmlscan.l"
{ yycolumn += yyleng; return COS; }
YY_BREAK
case 77:
YY_RULE_SETUP
#line 160 "src/mmlscan.l"
{ yycolumn += yyleng; return TAN; }
YY_BREAK
case 78:
YY_RULE_SETUP
#line 161 "src/mmlscan.l"
{ yycolumn += yyleng; return ASIN; }
YY_BREAK
case 79:
YY_RULE_SETUP
#line 162 "src/mmlscan.l"
{ yycolumn += yyleng; return ACOS; }
YY_BREAK
case 80:
YY_RULE_SETUP
#line 163 "src/mmlscan.l"
{ yycolumn += yyleng; return ATAN; }
YY_BREAK
case 81:
YY_RULE_SETUP
#line 164 "src/mmlscan.l"
{ yycolumn += yyleng; return POWER; }
YY_BREAK
case 82:
YY_RULE_SETUP
#line 165 "src/mmlscan.l"
{ yycolumn += yyleng; return SGNPOW; }
YY_BREAK
case 83:
YY_RULE_SETUP
#line 166 "src/mmlscan.l"
{ yycolumn += yyleng; return PRIORITY; }
YY_BREAK
case 84:
YY_RULE_SETUP
#line 167 "src/mmlscan.l"
{ yycolumn += yyleng; return STARTVAL; }
YY_BREAK
case 85:
YY_RULE_SETUP
#line 168 "src/mmlscan.l"
{ yycolumn += yyleng; return DEFAULT; }
YY_BREAK
case 86:
YY_RULE_SETUP
#line 169 "src/mmlscan.l"
{ yycolumn += yyleng; return SUBSETS; }
YY_BREAK
case 87:
YY_RULE_SETUP
#line 170 "src/mmlscan.l"
{ yycolumn += yyleng; return POWERSET; }
YY_BREAK
case 88:
YY_RULE_SETUP
#line 171 "src/mmlscan.l"
{ yycolumn += yyleng; return INDEXSET; }
YY_BREAK
case 89:
YY_RULE_SETUP
#line 172 "src/mmlscan.l"
{ yycolumn += yyleng; return PRINT; }
YY_BREAK
case 90:
YY_RULE_SETUP
#line 173 "src/mmlscan.l"
{ yycolumn += yyleng; return CHECK; }
YY_BREAK
case 91:
YY_RULE_SETUP
#line 174 "src/mmlscan.l"
{ yycolumn += yyleng; return INFTY; }
YY_BREAK
case 92:
YY_RULE_SETUP
#line 175 "src/mmlscan.l"
{ yycolumn += yyleng; return RANDOM; }
YY_BREAK
case 93:
YY_RULE_SETUP
#line 176 "src/mmlscan.l"
{ yycolumn += yyleng; return ORD; }
YY_BREAK
case 94:
YY_RULE_SETUP
#line 177 "src/mmlscan.l"
{ yycolumn += yyleng; return TYPE1; }
YY_BREAK
case 95:
YY_RULE_SETUP
#line 178 "src/mmlscan.l"
{ yycolumn += yyleng; return TYPE2; }
YY_BREAK
case 96:
YY_RULE_SETUP
#line 179 "src/mmlscan.l"
{ yycolumn += yyleng; return IMPLICIT; }
YY_BREAK
case 97:
YY_RULE_SETUP
#line 180 "src/mmlscan.l"
{ yycolumn += yyleng; return LENGTH; }
YY_BREAK
case 98:
YY_RULE_SETUP
#line 181 "src/mmlscan.l"
{ yycolumn += yyleng; return SUBSTR; }
YY_BREAK
case 99:
YY_RULE_SETUP
#line 182 "src/mmlscan.l"
{ yycolumn += yyleng; return MATCH; }
YY_BREAK
case 100:
YY_RULE_SETUP
#line 184 "src/mmlscan.l"
{
yycolumn += yyleng;
lval->numb = numb_new_ascii(yytext);
/* sscanf(yytext, "%lf", &lval->numb);*/
return NUMB;
}
YY_BREAK
case 101:
YY_RULE_SETUP
#line 190 "src/mmlscan.l"
{
yycolumn += yyleng;
lval->numb = numb_new_ascii(yytext);
/* sscanf(yytext, "%lf", &lval->numb);*/
return NUMB;
}
YY_BREAK
case 102:
YY_RULE_SETUP
#line 197 "src/mmlscan.l"
{
Symbol* sym;
Define* def;
char errmsg[256];
int what;
yycolumn += yyleng;
/* If it is sure that this is the name for a constraint or
* objective, or sos, we do not need to lookup the name.
*/
if (yydecl == DECLSUB || yydecl == DECLMIN || yydecl == DECLMAX
|| yydecl == DECLSOS)
yydecl = 0;
/* If it is sure that this is the name for a set, param or var
* we check only if the name is unused and otherwise give
* an appropriate error message.
*/
else if (yydecl == DECLSET || yydecl == DECLPAR || yydecl == DECLVAR
|| yydecl == DEFNUMB || yydecl == DEFSTRG || yydecl == DEFBOOL
|| yydecl == DEFSET)
{
if (NULL != symbol_lookup(yytext) || NULL != define_lookup(yytext))
{
/* Allow to declare parameter on the command line and ignore the
* redeclarations in the zimpl code later on
*/
if (yydecl == DECLPAR)
{
extern void yywarning(int no, const char* s);
sprintf(errmsg, "Redefinition of parameter %s ignored\n", yytext);
yywarning(252, errmsg);
yydecl = 0;
return EOF;
}
sprintf(errmsg, "Name \"%s\" already in use\n", yytext);
yyerror(errmsg);
}
what = yydecl;
yydecl = 0;
/* if this is a define, we have to install it here,
* so that recursive call succseed.
*/
switch(what)
{
case DEFNUMB :
lval->def = define_new(str_new(yytext), DEF_NUMB);
return DEFNAME;
case DEFSTRG :
lval->def = define_new(str_new(yytext), DEF_STRG);
return DEFNAME;
case DEFBOOL :
lval->def = define_new(str_new(yytext), DEF_BOOL);
return DEFNAME;
case DEFSET :
lval->def = define_new(str_new(yytext), DEF_SET);
return DEFNAME;
default :
break;
}
}
else
{
assert(yydecl == 0);
if (NULL != (sym = symbol_lookup(yytext)))
{
lval->sym = sym;
switch(symbol_get_type(sym))
{
case SYM_NUMB :
return NUMBSYM;
case SYM_STRG :
return STRGSYM;
case SYM_VAR :
return VARSYM;
case SYM_SET :
return SETSYM;
case SYM_ERR : /* should not happen */
sprintf(errmsg, "Symbol \"%s\" not initialised\n", yytext);
yyerror(errmsg);
default :
abort();
}
}
if (NULL != (def = define_lookup(yytext)))
{
lval->def = def;
switch(define_get_type(def))
{
case DEF_NUMB :
return NUMBDEF;
case DEF_STRG :
return STRGDEF;
case DEF_BOOL :
return BOOLDEF;
case DEF_SET :
return SETDEF;
case DEF_ERR : /* should not happen */
sprintf(errmsg, "Define \"%s\" not initialised\n", yytext);
yyerror(errmsg);
default :
abort();
}
}
}
lval->name = str_new(yytext);
return NAME;
}
YY_BREAK
case 103:
/* rule 103 can match eol */
YY_RULE_SETUP
#line 314 "src/mmlscan.l"
{
yycolumn += yyleng;
yytext[strlen(yytext) - 1] = '\0';
lval->strg = str_new(yytext + 1);
return STRG;
}
YY_BREAK
case 104:
/* rule 104 can match eol */
YY_RULE_SETUP
#line 320 "src/mmlscan.l"
{
yycolumn += yyleng;
yytext[strlen(yytext) - 1] = '\0';
lval->strg = str_new(yytext + 1);
return STRG;
}
YY_BREAK
case 105:
/* rule 105 can match eol */
YY_RULE_SETUP
#line 327 "src/mmlscan.l"
{ yycolumn += yyleng; }
YY_BREAK
case 106:
YY_RULE_SETUP
#line 329 "src/mmlscan.l"
{ yycolumn += yyleng; return *yytext; }
YY_BREAK
case YY_STATE_EOF(INITIAL):
#line 331 "src/mmlscan.l"
{ yycolumn += yyleng; return EOF; }
YY_BREAK
case 107:
YY_RULE_SETUP
#line 333 "src/mmlscan.l"
ECHO;
YY_BREAK
#line 1895 "src/mmlscan.c"
case YY_END_OF_BUFFER:
{
/* Amount of text matched not including the EOB char. */
int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
/* Undo the effects of YY_DO_BEFORE_ACTION. */
*yy_cp = (yy_hold_char);
YY_RESTORE_YY_MORE_OFFSET
if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
{
/* We're scanning a new file or input source. It's
* possible that this happened because the user
* just pointed yyin at a new source and called
* yylex(). If so, then we have to assure
* consistency between YY_CURRENT_BUFFER and our
* globals. Here is the right place to do so, because
* this is the first action (other than possibly a
* back-up) that will match for the new input source.
*/
(yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
/* %if-c-only */
YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
/* %endif */
/* %if-c++-only */
/* %endif */
YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
}
/* Note that here we test for yy_c_buf_p "<=" to the position
* of the first EOB in the buffer, since yy_c_buf_p will
* already have been incremented past the NUL character
* (since all states make transitions on EOB to the
* end-of-buffer state). Contrast this with the test
* in input().
*/
if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
{ /* This was really a NUL. */
yy_state_type yy_next_state;
(yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
yy_current_state = yy_get_previous_state( );
/* Okay, we're now positioned to make the NUL
* transition. We couldn't have
* yy_get_previous_state() go ahead and do it
* for us because it doesn't know how to deal
* with the possibility of jamming (and we don't
* want to build jamming into it because then it
* will run more slowly).
*/
yy_next_state = yy_try_NUL_trans( yy_current_state );
yy_bp = (yytext_ptr) + YY_MORE_ADJ;
if ( yy_next_state )
{
/* Consume the NUL. */
yy_cp = ++(yy_c_buf_p);
yy_current_state = yy_next_state;
goto yy_match;
}
else
{
/* %% [14.0] code to do back-up for compressed tables and set up yy_cp goes here */
yy_cp = (yy_last_accepting_cpos);
yy_current_state = (yy_last_accepting_state);
goto yy_find_action;
}
}
else switch ( yy_get_next_buffer( ) )
{
case EOB_ACT_END_OF_FILE:
{
(yy_did_buffer_switch_on_eof) = 0;
if ( yywrap( ) )
{
/* Note: because we've taken care in
* yy_get_next_buffer() to have set up
* yytext, we can now set up
* yy_c_buf_p so that if some total
* hoser (like flex itself) wants to
* call the scanner after we return the
* YY_NULL, it'll still work - another
* YY_NULL will get returned.
*/
(yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
yy_act = YY_STATE_EOF(YY_START);
goto do_action;
}
else
{
if ( ! (yy_did_buffer_switch_on_eof) )
YY_NEW_FILE;
}
break;
}
case EOB_ACT_CONTINUE_SCAN:
(yy_c_buf_p) =
(yytext_ptr) + yy_amount_of_matched_text;
yy_current_state = yy_get_previous_state( );
yy_cp = (yy_c_buf_p);
yy_bp = (yytext_ptr) + YY_MORE_ADJ;
goto yy_match;
case EOB_ACT_LAST_MATCH:
(yy_c_buf_p) =
&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
yy_current_state = yy_get_previous_state( );
yy_cp = (yy_c_buf_p);
yy_bp = (yytext_ptr) + YY_MORE_ADJ;
goto yy_find_action;
}
break;
}
default:
YY_FATAL_ERROR(
"fatal flex scanner internal error--no action found" );
} /* end of action switch */
} /* end of scanning one token */
} /* end of user's declarations */
} /* end of yylex */
/* %ok-for-header */
/* %if-c++-only */
/* %not-for-header */
/* %ok-for-header */
/* %endif */
/* yy_get_next_buffer - try to read in a new buffer
*
* Returns a code representing an action:
* EOB_ACT_LAST_MATCH -
* EOB_ACT_CONTINUE_SCAN - continue scanning from current position
* EOB_ACT_END_OF_FILE - end of file
*/
/* %if-c-only */
static int yy_get_next_buffer (void)
/* %endif */
/* %if-c++-only */
/* %endif */
{
char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
char *source = (yytext_ptr);
yy_size_t number_to_move, i;
int ret_val;
if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
YY_FATAL_ERROR(
"fatal flex scanner internal error--end of buffer missed" );
if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
{ /* Don't try to fill the buffer, so this is an EOF. */
if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
{
/* We matched a single character, the EOB, so
* treat this as a final EOF.
*/
return EOB_ACT_END_OF_FILE;
}
else
{
/* We matched some text prior to the EOB, first
* process it.
*/
return EOB_ACT_LAST_MATCH;
}
}
/* Try to read more data. */
/* First move last chars to start of buffer. */
number_to_move = (yy_size_t) ((yy_c_buf_p) - (yytext_ptr)) - 1;
for ( i = 0; i < number_to_move; ++i )
*(dest++) = *(source++);
if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
/* don't do the read, it's not guaranteed to return an EOF,
* just force an EOF
*/
YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
else
{
yy_size_t num_to_read =
YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
while ( num_to_read <= 0 )
{ /* Not enough room in the buffer - grow it. */
/* just a shorter name for the current buffer */
YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE;
int yy_c_buf_p_offset =
(int) ((yy_c_buf_p) - b->yy_ch_buf);
if ( b->yy_is_our_buffer )
{
yy_size_t new_size = b->yy_buf_size * 2;
if ( new_size <= 0 )
b->yy_buf_size += b->yy_buf_size / 8;
else
b->yy_buf_size *= 2;
b->yy_ch_buf = (char *)
/* Include room in for 2 EOB chars. */
yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 );
}
else
/* Can't grow it, we don't own it. */
b->yy_ch_buf = 0;
if ( ! b->yy_ch_buf )
YY_FATAL_ERROR(
"fatal error - scanner input buffer overflow" );
(yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
number_to_move - 1;
}
if ( num_to_read > YY_READ_BUF_SIZE )
num_to_read = YY_READ_BUF_SIZE;
/* Read in more data. */
YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
(yy_n_chars), num_to_read );
YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
}
if ( (yy_n_chars) == 0 )
{
if ( number_to_move == YY_MORE_ADJ )
{
ret_val = EOB_ACT_END_OF_FILE;
yyrestart(yyin );
}
else
{
ret_val = EOB_ACT_LAST_MATCH;
YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
YY_BUFFER_EOF_PENDING;
}
}
else
ret_val = EOB_ACT_CONTINUE_SCAN;
if ((int) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
/* Extend the array by 50%, plus the number we really need. */
int new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size );
if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
}
(yy_n_chars) += number_to_move;
YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
(yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
return ret_val;
}
/* yy_get_previous_state - get the state just before the EOB char was reached */
/* %if-c-only */
/* %not-for-header */
static yy_state_type yy_get_previous_state (void)
/* %endif */
/* %if-c++-only */
/* %endif */
{
yy_state_type yy_current_state;
char *yy_cp;
/* %% [15.0] code to get the start state into yy_current_state goes here */
yy_current_state = (yy_start);
for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
{
/* %% [16.0] code to find the next state goes here */
YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
if ( yy_accept[yy_current_state] )
{
(yy_last_accepting_state) = yy_current_state;
(yy_last_accepting_cpos) = yy_cp;
}
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 344 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
}
return yy_current_state;
}
/* yy_try_NUL_trans - try to make a transition on the NUL character
*
* synopsis
* next_state = yy_try_NUL_trans( current_state );
*/
/* %if-c-only */
static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state )
/* %endif */
/* %if-c++-only */
/* %endif */
{
int yy_is_jam;
/* %% [17.0] code to find the next state, and perhaps do backing up, goes here */
char *yy_cp = (yy_c_buf_p);
YY_CHAR yy_c = 1;
if ( yy_accept[yy_current_state] )
{
(yy_last_accepting_state) = yy_current_state;
(yy_last_accepting_cpos) = yy_cp;
}
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 344 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
yy_is_jam = (yy_current_state == 343);
return yy_is_jam ? 0 : yy_current_state;
}
#ifndef YY_NO_UNPUT
/* %if-c-only */
/* %endif */
#endif
/* %if-c-only */
#ifndef YY_NO_INPUT
#ifdef __cplusplus
static int yyinput (void)
#else
static int input (void)
#endif
/* %endif */
/* %if-c++-only */
/* %endif */
{
int c;
*(yy_c_buf_p) = (yy_hold_char);
if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
{
/* yy_c_buf_p now points to the character we want to return.
* If this occurs *before* the EOB characters, then it's a
* valid NUL; if not, then we've hit the end of the buffer.
*/
if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
/* This was really a NUL. */
*(yy_c_buf_p) = '\0';
else
{ /* need more input */
yy_size_t offset = (yy_c_buf_p) - (yytext_ptr);
++(yy_c_buf_p);
switch ( yy_get_next_buffer( ) )
{
case EOB_ACT_LAST_MATCH:
/* This happens because yy_g_n_b()
* sees that we've accumulated a
* token and flags that we need to
* try matching the token before
* proceeding. But for input(),
* there's no matching to consider.
* So convert the EOB_ACT_LAST_MATCH
* to EOB_ACT_END_OF_FILE.
*/
/* Reset buffer status. */
yyrestart(yyin );
/*FALLTHROUGH*/
case EOB_ACT_END_OF_FILE:
{
if ( yywrap( ) )
return EOF;
if ( ! (yy_did_buffer_switch_on_eof) )
YY_NEW_FILE;
#ifdef __cplusplus
return yyinput();
#else
return input();
#endif
}
case EOB_ACT_CONTINUE_SCAN:
(yy_c_buf_p) = (yytext_ptr) + offset;
break;
}
}
}
c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */
*(yy_c_buf_p) = '\0'; /* preserve yytext */
(yy_hold_char) = *++(yy_c_buf_p);
/* %% [19.0] update BOL and yylineno */
return c;
}
/* %if-c-only */
#endif /* ifndef YY_NO_INPUT */
/* %endif */
/** Immediately switch to a different input stream.
* @param input_file A readable stream.
*
* @note This function does not reset the start condition to @c INITIAL .
*/
/* %if-c-only */
void yyrestart (FILE * input_file )
/* %endif */
/* %if-c++-only */
/* %endif */
{
if ( ! YY_CURRENT_BUFFER ){
yyensure_buffer_stack ();
YY_CURRENT_BUFFER_LVALUE =
yy_create_buffer(yyin,YY_BUF_SIZE );
}
yy_init_buffer(YY_CURRENT_BUFFER,input_file );
yy_load_buffer_state( );
}
/* %if-c++-only */
/* %endif */
/** Switch to a different input buffer.
* @param new_buffer The new input buffer.
*
*/
/* %if-c-only */
void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer )
/* %endif */
/* %if-c++-only */
/* %endif */
{
/* TODO. We should be able to replace this entire function body
* with
* yypop_buffer_state();
* yypush_buffer_state(new_buffer);
*/
yyensure_buffer_stack ();
if ( YY_CURRENT_BUFFER == new_buffer )
return;
if ( YY_CURRENT_BUFFER )
{
/* Flush out information for old buffer. */
*(yy_c_buf_p) = (yy_hold_char);
YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
}
YY_CURRENT_BUFFER_LVALUE = new_buffer;
yy_load_buffer_state( );
/* We don't actually know whether we did this switch during
* EOF (yywrap()) processing, but the only time this flag
* is looked at is after yywrap() is called, so it's safe
* to go ahead and always set it.
*/
(yy_did_buffer_switch_on_eof) = 1;
}
/* %if-c-only */
static void yy_load_buffer_state (void)
/* %endif */
/* %if-c++-only */
/* %endif */
{
(yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
(yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
/* %if-c-only */
yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
/* %endif */
/* %if-c++-only */
/* %endif */
(yy_hold_char) = *(yy_c_buf_p);
}
/** Allocate and initialize an input buffer state.
* @param file A readable stream.
* @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
*
* @return the allocated buffer state.
*/
/* %if-c-only */
YY_BUFFER_STATE yy_create_buffer (FILE * file, int size )
/* %endif */
/* %if-c++-only */
/* %endif */
{
YY_BUFFER_STATE b;
b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) );
if ( ! b )
YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
b->yy_buf_size = (yy_size_t)size;
/* yy_ch_buf has to be 2 characters longer than the size given because
* we need to put in 2 end-of-buffer characters.
*/
b->yy_ch_buf = (char *) yyalloc(b->yy_buf_size + 2 );
if ( ! b->yy_ch_buf )
YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
b->yy_is_our_buffer = 1;
yy_init_buffer(b,file );
return b;
}
/* %if-c++-only */
/* %endif */
/** Destroy the buffer.
* @param b a buffer created with yy_create_buffer()
*
*/
/* %if-c-only */
void yy_delete_buffer (YY_BUFFER_STATE b )
/* %endif */
/* %if-c++-only */
/* %endif */
{
if ( ! b )
return;
if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
if ( b->yy_is_our_buffer )
yyfree((void *) b->yy_ch_buf );
yyfree((void *) b );
}
/* Initializes or reinitializes a buffer.
* This function is sometimes called more than once on the same buffer,
* such as during a yyrestart() or at EOF.
*/
/* %if-c-only */
static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file )
/* %endif */
/* %if-c++-only */
/* %endif */
{
int oerrno = errno;
yy_flush_buffer(b );
/* %if-c-only */
b->yy_input_file = file;
/* %endif */
/* %if-c++-only */
/* %endif */
b->yy_fill_buffer = 1;
/* If b is the current buffer, then yy_init_buffer was _probably_
* called from yyrestart() or through yy_get_next_buffer.
* In that case, we don't want to reset the lineno or column.
*/
if (b != YY_CURRENT_BUFFER){
b->yy_bs_lineno = 1;
b->yy_bs_column = 0;
}
/* %if-c-only */
b->yy_is_interactive = 0;
/* %endif */
/* %if-c++-only */
/* %endif */
errno = oerrno;
}
/** Discard all buffered characters. On the next scan, YY_INPUT will be called.
* @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
*
*/
/* %if-c-only */
void yy_flush_buffer (YY_BUFFER_STATE b )
/* %endif */
/* %if-c++-only */
/* %endif */
{
if ( ! b )
return;
b->yy_n_chars = 0;
/* We always need two end-of-buffer characters. The first causes
* a transition to the end-of-buffer state. The second causes
* a jam in that state.
*/
b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
b->yy_buf_pos = &b->yy_ch_buf[0];
b->yy_at_bol = 1;
b->yy_buffer_status = YY_BUFFER_NEW;
if ( b == YY_CURRENT_BUFFER )
yy_load_buffer_state( );
}
/* %if-c-or-c++ */
/** Pushes the new state onto the stack. The new state becomes
* the current state. This function will allocate the stack
* if necessary.
* @param new_buffer The new state.
*
*/
/* %if-c-only */
void yypush_buffer_state (YY_BUFFER_STATE new_buffer )
/* %endif */
/* %if-c++-only */
/* %endif */
{
if (new_buffer == NULL)
return;
yyensure_buffer_stack();
/* This block is copied from yy_switch_to_buffer. */
if ( YY_CURRENT_BUFFER )
{
/* Flush out information for old buffer. */
*(yy_c_buf_p) = (yy_hold_char);
YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
}
/* Only push if top exists. Otherwise, replace top. */
if (YY_CURRENT_BUFFER)
(yy_buffer_stack_top)++;
YY_CURRENT_BUFFER_LVALUE = new_buffer;
/* copied from yy_switch_to_buffer. */
yy_load_buffer_state( );
(yy_did_buffer_switch_on_eof) = 1;
}
/* %endif */
/* %if-c-or-c++ */
/** Removes and deletes the top of the stack, if present.
* The next element becomes the new top.
*
*/
/* %if-c-only */
void yypop_buffer_state (void)
/* %endif */
/* %if-c++-only */
/* %endif */
{
if (!YY_CURRENT_BUFFER)
return;
yy_delete_buffer(YY_CURRENT_BUFFER );
YY_CURRENT_BUFFER_LVALUE = NULL;
if ((yy_buffer_stack_top) > 0)
--(yy_buffer_stack_top);
if (YY_CURRENT_BUFFER) {
yy_load_buffer_state( );
(yy_did_buffer_switch_on_eof) = 1;
}
}
/* %endif */
/* %if-c-or-c++ */
/* Allocates the stack if it does not exist.
* Guarantees space for at least one push.
*/
/* %if-c-only */
static void yyensure_buffer_stack (void)
/* %endif */
/* %if-c++-only */
/* %endif */
{
yy_size_t num_to_alloc;
if (!(yy_buffer_stack)) {
/* First allocation is just for 2 elements, since we don't know if this
* scanner will even need a stack. We use 2 instead of 1 to avoid an
* immediate realloc on the next call.
*/
num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */
(yy_buffer_stack) = (struct yy_buffer_state**)yyalloc
(num_to_alloc * sizeof(struct yy_buffer_state*)
);
if ( ! (yy_buffer_stack) )
YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
(yy_buffer_stack_max) = num_to_alloc;
(yy_buffer_stack_top) = 0;
return;
}
if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
/* Increase the buffer to prepare for a possible push. */
yy_size_t grow_size = 8 /* arbitrary grow size */;
num_to_alloc = (yy_buffer_stack_max) + grow_size;
(yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc
((yy_buffer_stack),
num_to_alloc * sizeof(struct yy_buffer_state*)
);
if ( ! (yy_buffer_stack) )
YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
/* zero only the new slots.*/
memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
(yy_buffer_stack_max) = num_to_alloc;
}
}
/* %endif */
/* %if-c-only */
/** Setup the input buffer state to scan directly from a user-specified character buffer.
* @param base the character buffer
* @param size the size in bytes of the character buffer
*
* @return the newly allocated buffer state object.
*/
YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size )
{
YY_BUFFER_STATE b;
if ( size < 2 ||
base[size-2] != YY_END_OF_BUFFER_CHAR ||
base[size-1] != YY_END_OF_BUFFER_CHAR )
/* They forgot to leave room for the EOB's. */
return 0;
b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) );
if ( ! b )
YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
b->yy_buf_pos = b->yy_ch_buf = base;
b->yy_is_our_buffer = 0;
b->yy_input_file = 0;
b->yy_n_chars = b->yy_buf_size;
b->yy_is_interactive = 0;
b->yy_at_bol = 1;
b->yy_fill_buffer = 0;
b->yy_buffer_status = YY_BUFFER_NEW;
yy_switch_to_buffer(b );
return b;
}
/* %endif */
/* %if-c-only */
/** Setup the input buffer state to scan a string. The next call to yylex() will
* scan from a @e copy of @a str.
* @param yystr a NUL-terminated string to scan
*
* @return the newly allocated buffer state object.
* @note If you want to scan bytes that may contain NUL values, then use
* yy_scan_bytes() instead.
*/
YY_BUFFER_STATE yy_scan_string (yyconst char * yystr )
{
return yy_scan_bytes(yystr,strlen(yystr) );
}
/* %endif */
/* %if-c-only */
/** Setup the input buffer state to scan the given bytes. The next call to yylex() will
* scan from a @e copy of @a bytes.
* @param yybytes the byte buffer to scan
* @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
*
* @return the newly allocated buffer state object.
*/
YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len )
{
YY_BUFFER_STATE b;
char *buf;
yy_size_t n;
yy_size_t i;
/* Get memory for full buffer, including space for trailing EOB's. */
n = _yybytes_len + 2;
buf = (char *) yyalloc(n );
if ( ! buf )
YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
for ( i = 0; i < _yybytes_len; ++i )
buf[i] = yybytes[i];
buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
b = yy_scan_buffer(buf,n );
if ( ! b )
YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
/* It's okay to grow etc. this buffer, and we should throw it
* away when we're done.
*/
b->yy_is_our_buffer = 1;
return b;
}
/* %endif */
#ifndef YY_EXIT_FAILURE
#define YY_EXIT_FAILURE 2
#endif
/* %if-c-only */
static void yy_fatal_error (yyconst char* msg )
{
(void) fprintf( stderr, "%s\n", msg );
exit( YY_EXIT_FAILURE );
}
/* %endif */
/* %if-c++-only */
/* %endif */
/* Redefine yyless() so it works in section 3 code. */
#undef yyless
#define yyless(n) \
do \
{ \
/* Undo effects of setting up yytext. */ \
int yyless_macro_arg = (n); \
YY_LESS_LINENO(yyless_macro_arg);\
yytext[yyleng] = (yy_hold_char); \
(yy_c_buf_p) = yytext + yyless_macro_arg; \
(yy_hold_char) = *(yy_c_buf_p); \
*(yy_c_buf_p) = '\0'; \
yyleng = yyless_macro_arg; \
} \
while ( 0 )
/* Accessor methods (get/set functions) to struct members. */
/* %if-c-only */
/* %if-reentrant */
/* %endif */
/** Get the current line number.
*
*/
int yyget_lineno (void)
{
return yylineno;
}
/** Get the input stream.
*
*/
FILE *yyget_in (void)
{
return yyin;
}
/** Get the output stream.
*
*/
FILE *yyget_out (void)
{
return yyout;
}
/** Get the length of the current token.
*
*/
yy_size_t yyget_leng (void)
{
return yyleng;
}
/** Get the current token.
*
*/
char *yyget_text (void)
{
return yytext;
}
/* %if-reentrant */
/* %endif */
/** Set the current line number.
* @param _line_number line number
*
*/
void yyset_lineno (int _line_number )
{
yylineno = _line_number;
}
/** Set the input stream. This does not discard the current
* input buffer.
* @param _in_str A readable stream.
*
* @see yy_switch_to_buffer
*/
void yyset_in (FILE * _in_str )
{
yyin = _in_str ;
}
void yyset_out (FILE * _out_str )
{
yyout = _out_str ;
}
int yyget_debug (void)
{
return yy_flex_debug;
}
void yyset_debug (int _bdebug )
{
yy_flex_debug = _bdebug ;
}
/* %endif */
/* %if-reentrant */
/* %if-bison-bridge */
/* %endif */
/* %endif if-c-only */
/* %if-c-only */
static int yy_init_globals (void)
{
/* Initialization is the same as for the non-reentrant scanner.
* This function is called from yylex_destroy(), so don't allocate here.
*/
(yy_buffer_stack) = 0;
(yy_buffer_stack_top) = 0;
(yy_buffer_stack_max) = 0;
(yy_c_buf_p) = (char *) 0;
(yy_init) = 0;
(yy_start) = 0;
/* Defined in main.c */
#ifdef YY_STDINIT
yyin = stdin;
yyout = stdout;
#else
yyin = (FILE *) 0;
yyout = (FILE *) 0;
#endif
/* For future reference: Set errno on error, since we are called by
* yylex_init()
*/
return 0;
}
/* %endif */
/* %if-c-only SNIP! this currently causes conflicts with the c++ scanner */
/* yylex_destroy is for both reentrant and non-reentrant scanners. */
int yylex_destroy (void)
{
/* Pop the buffer stack, destroying each element. */
while(YY_CURRENT_BUFFER){
yy_delete_buffer(YY_CURRENT_BUFFER );
YY_CURRENT_BUFFER_LVALUE = NULL;
yypop_buffer_state();
}
/* Destroy the stack itself. */
yyfree((yy_buffer_stack) );
(yy_buffer_stack) = NULL;
/* Reset the globals. This is important in a non-reentrant scanner so the next time
* yylex() is called, initialization will occur. */
yy_init_globals( );
/* %if-reentrant */
/* %endif */
return 0;
}
/* %endif */
/*
* Internal utility routines.
*/
#ifndef yytext_ptr
static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
{
int i;
for ( i = 0; i < n; ++i )
s1[i] = s2[i];
}
#endif
#ifdef YY_NEED_STRLEN
static int yy_flex_strlen (yyconst char * s )
{
int n;
for ( n = 0; s[n]; ++n )
;
return n;
}
#endif
void *yyalloc (yy_size_t size )
{
return (void *) malloc( size );
}
void *yyrealloc (void * ptr, yy_size_t size )
{
/* The cast to (char *) in the following accommodates both
* implementations that use char* generic pointers, and those
* that use void* generic pointers. It works with the latter
* because both ANSI C and C++ allow castless assignment from
* any pointer type to void*, and deal with argument conversions
* as though doing an assignment.
*/
return (void *) realloc( (char *) ptr, size );
}
void yyfree (void * ptr )
{
free( (char *) ptr ); /* see yyrealloc() for (char *) cast */
}
/* %if-tables-serialization definitions */
/* %define-yytables The name for this specific scanner's tables. */
#define YYTABLES_NAME "yytables"
/* %endif */
/* %ok-for-header */
#line 333 "src/mmlscan.l"
static const Stmt* yystmt = NULL;
void yyerror(const char* s)
{
fprintf(stderr, "*** Error 800: File %s Line %d : %s\n",
stmt_get_filename(yystmt), stmt_get_lineno(yystmt), s);
show_source(stderr, stmt_get_text(yystmt), yycolumn);
zpl_exit(EXIT_FAILURE);
}
void yywarning(int no, const char* s)
{
if (stmt_trigger_warning(no))
fprintf(stderr,
"*** Warning %d: File %s Line %d : %s\n",
no, stmt_get_filename(yystmt), stmt_get_lineno(yystmt), s);
}
const Stmt* scan_get_stmt(void)
{
return yystmt;
}
int scan_get_column(void)
{
return yycolumn;
}
void parse_stmt(const Stmt* stmt)
{
YY_BUFFER_STATE state;
yy_delete_buffer(YY_CURRENT_BUFFER);
yystmt = stmt;
yycolumn = 0;
state = yy_scan_string(stmt_get_text(stmt));
if (yyparse() != 0)
{
fprintf(stderr, "*** Error 801: Parser failed\n");
zpl_exit(EXIT_FAILURE);
}
yy_delete_buffer(state);
}
zimpl-3.3.4/src/ratsoswrite.c 0000640 0012352 0006025 00000005432 13057565713 016065 0 ustar bzfgamra optimi /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* File....: ratsoswrite.c */
/* Name....: SOS File Write */
/* Author..: Thorsten Koch, Daniel Junglas */
/* Copyright by Author, All rights reserved */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Copyright (C) 2005-2017 by Thorsten Koch
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include
#include
#include
#include
#include
#include
#include "mshell.h"
#include "bool.h"
#include "ratlp.h"
#include "ratlpstore.h"
#include "mme.h"
/* Write SOS definitions to a file.
* A specification for the SOS file format can be found in the
* ILOG CPLEX Reference Manual.
*/
void lps_sosfile(
const Lps* lp,
FILE* fp,
LpFormat format,
const char* text)
{
const Sos* sos;
const Sse* sse;
int name_size;
char* vtmp;
assert(lp != NULL);
assert(fp != NULL);
assert(format == LP_FORM_LPF || format == LP_FORM_MPS);
name_size = lps_getnamesize(lp, format);
vtmp = malloc((size_t)name_size);
assert(vtmp != NULL);
if (text != NULL)
fprintf(fp, "* %s\n", text);
fprintf(fp, "NAME %8.8s\n", lp->name);
for(sos = lp->sos_root; sos != NULL; sos = sos->next)
{
fprintf(fp, "* %s\n", sos->name);
fprintf(fp, " S%d %d\n",
sos->type == SOS_TYPE1 ? 1 : 2,
sos->priority);
for (sse = sos->first; sse != NULL; sse = sse->next)
{
lps_makename(vtmp, name_size, sse->var->name, sse->var->number);
fprintf(fp, " %-*s %.10g\n",
name_size - 1, vtmp, mpq_get_d(sse->weight));
}
}
fprintf(fp, "ENDATA\n");
free(vtmp);
}
zimpl-3.3.4/src/elem.h 0000640 0012352 0006025 00000006660 13057565713 014432 0 ustar bzfgamra optimi /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* File....: elem.h */
/* Name....: Element Functions */
/* Author..: Thorsten Koch */
/* Copyright by Author, All rights reserved */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Copyright (C) 2001-2017 by Thorsten Koch
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _ELEM_H_
#define _ELEM_H_
#ifndef _BOOL_H_
#error "Need to include bool.h before elem.h"
#endif
#ifndef _NUMB_H_
#error "Need to include numb.h before elem.h"
#endif
#ifdef __cplusplus
extern "C" {
#endif
enum element_type
{
ELEM_ERR = 0, ELEM_FREE, ELEM_NUMB, ELEM_STRG, ELEM_NAME
};
typedef enum element_type ElemType;
typedef struct element Elem;
#define ELEM_NULL ((Elem*)0)
extern void elem_init(void);
extern void elem_exit(void);
/*lint -sem( elem_new_numb, @p == 1) */
extern Elem* elem_new_numb(const Numb* n);
/*lint -sem( elem_new_strg, nulterm(1), 1p, @p == 1) */
extern Elem* elem_new_strg(const char* s);
/*lint -sem( elem_new_name, nulterm(1), 1p, @p == 1) */
extern Elem* elem_new_name(const char* s);
/*lint -sem( elem_free, custodial(1), 1p == 1) */
extern void elem_free(Elem* elem);
/*lint -sem( elem_is_valid, 1p == 1) */
extern Bool elem_is_valid(const Elem* elem);
/*lint -sem( elem_copy, 1p == 1, @p == 1) */
extern Elem* elem_copy(const Elem* elem);
/*lint -sem( elem_cmp, 1p == 1 && 2p == 1) */
extern Bool elem_cmp(const Elem* elem_a, const Elem* elem_b);
/*lint -sem( elem_get_type, 1p == 1) */
extern ElemType elem_get_type(const Elem* elem);
/*lint -sem( elem_get_numb, 1p == 1) */
extern const Numb* elem_get_numb(const Elem* elem);
/*lint -sem( elem_get_strg, 1p == 1, @p && nulterm(@)) */
extern const char* elem_get_strg(const Elem* elem);
/*lint -sem( elem_get_name, 1p == 1, @p && nulterm(@)) */
extern const char* elem_get_name(const Elem* elem);
/*lint -sem( elem_print, 1p == 1 && 2p == 1) */
extern void elem_print(FILE* fp, const Elem* elem, Bool use_quotes);
/*lint -sem( elem_hash, 1p == 1) */
extern unsigned int elem_hash(const Elem* elem);
/*lint -sem( elem_tostr, 1p == 1, @p && nulterm(@)) */
extern char* elem_tostr(const Elem* elem);
#ifdef __cplusplus
}
#endif
#endif /* _ELEM_H_ */
zimpl-3.3.4/src/symbol.h 0000640 0012352 0006025 00000007515 13057565713 015015 0 ustar bzfgamra optimi /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* File....: symbol.h */
/* Name....: Symbol Table Functions */
/* Author..: Thorsten Koch */
/* Copyright by Author, All rights reserved */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Copyright (C) 2001-2017 by Thorsten Koch
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _SYMBOL_H_
#define _SYMBOL_H_
#ifndef _BOOL_H_
#error "Need to include bool.h before symbol.h"
#endif
#ifndef _TUPLE_H_
#error "Need to include tuple.h before symbol.h"
#endif
#ifndef _SET_H_
#error "Need to include set.h before symbol.h"
#endif
#ifndef _MME_H_
#error "Need to include mme.h before symbol.h"
#endif
#ifdef __cplusplus
extern "C" {
#endif
/*lint -sem( symbol_new, nulterm(1), 1p && 3p == 1 && 4n >= 0, @p == 1) */
extern Symbol* symbol_new(const char* name,
SymbolType type, const Set* set, int estimated_size, const Entry* deflt);
extern void symbol_exit(void);
/*lint -sem( symbol_is_valid, 1p == 1) */
extern Bool symbol_is_valid(const Symbol* symbol);
/*lint -sem( symbol_lookup, nulterm(1), 1p, r_null) */
extern Symbol* symbol_lookup(const char* name);
/*lint -sem( symbol_has_entry, 1p == 1 && 2p == 1) */
extern Bool symbol_has_entry(const Symbol* sym, const Tuple* tuple);
/*lint -sem( symbol_lookup_entry, 1p == 1 && 2p == 1) */
extern const Entry* symbol_lookup_entry(const Symbol* sym, const Tuple* tuple);
/*lint -sem( symbol_add_entry, custodial(2), 1p == 1 && 2p == 1) */
extern void symbol_add_entry(Symbol* sym, Entry* entry);
/*lint -sem( symbol_get_dim, 1p == 1, @n >= 0) */
extern int symbol_get_dim(const Symbol* sym);
/*lint -sem( symbol_get_iset, 1p == 1, @p == 1) */
extern const Set* symbol_get_iset(const Symbol* sym);
/*lint -sem( symbol_get_name, 1p == 1, @p && nulterm(@)) */
extern const char* symbol_get_name(const Symbol* sym);
/*lint -sem( symbol_get_type, 1p == 1) */
extern SymbolType symbol_get_type(const Symbol* sym);
/*lint -sem( symbol_get_numb, 1p == 1) */
extern const Numb* symbol_get_numb(const Symbol* sym, int idx);
/*lint -sem( symbol_get_strg, 1p == 1, @p && nulterm(@)) */
extern const char* symbol_get_strg(const Symbol* sym, int idx);
/*lint -sem( symbol_get_set, 1p == 1, @p == 1) */
extern const Set* symbol_get_set(const Symbol* sym, int idx);
/*lint -sem( symbol_get_var, 1p == 1, @p == 1) */
extern Var* symbol_get_var(const Symbol* sym, int idx);
/*lint -sem( symbol_print, 1p == 1 && 2p == 1) */
extern void symbol_print(FILE* fp, const Symbol* sym);
/*lint -sem( symbol_print_all, 1p == 1) */
extern void symbol_print_all(FILE* fp);
#ifdef __cplusplus
}
#endif
#endif /* _SYMBOL_H_ */
zimpl-3.3.4/src/source.c 0000640 0012352 0006025 00000004367 13057565713 015005 0 ustar bzfgamra optimi /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* File....: source.c */
/* Name....: Source Code Printing Function */
/* Author..: Thorsten Koch */
/* Copyright by Author, All rights reserved */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Copyright (C) 2001-2017 by Thorsten Koch
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include
#include
#include
#include
#include "bool.h"
#include "mshell.h"
#include "ratlptypes.h"
#include "numb.h"
#include "elem.h"
#include "tuple.h"
#include "mme.h"
void show_source(FILE* fp, const char* text, int column)
{
int len;
int beg;
int end;
assert(fp != NULL);
assert(text != NULL);
assert(column >= 0);
if (column > 0)
column--;
len = strlen(text);
beg = column - 30;
end = column + 30;
if (beg < 0)
{
end -= beg;
beg = 0;
}
if (end > len)
{
beg -= end - len;
end = len;
}
if (beg < 0)
beg = 0;
assert(beg >= 0);
assert(end <= len);
assert(beg <= end);
fprintf(fp, "*** %-*s\n", end - beg, &text[beg]);
fprintf(fp, "*** %*s^^^\n", column - beg, "");
}
zimpl-3.3.4/src/mshell.h 0000640 0012352 0006025 00000006712 13057565713 014772 0 ustar bzfgamra optimi /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* File....: mshell.h */
/* Name....: Memory Allocation Shell */
/* Author..: Thorsten Koch */
/* Copyright by Author, All rights reserved */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Copyright (C) 2007-2017 by Thorsten Koch
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _MSHELL_H_
#define _MSHELL_H_
#ifdef __cplusplus
extern "C" {
#endif
/*lint -sem( mem_malloc, nulterm(2), 1n > 0 && 2p, @P == malloc(1n)) */
extern void* mem_malloc(size_t, const char*, const int);
/*lint -sem( mem_calloc, nulterm(3), 1n > 0 && 2n > 0 && 3p, @P == malloc(1n * 2n)) */
extern void* mem_calloc(size_t, size_t, const char*, const int);
/*lint -sem( mem_realloc, custodial(1), nulterm(3), 1p > 0 && 2n > 0 && 3p, @P == malloc(2n)) */
extern void* mem_realloc(void*, size_t, const char*, const int);
/*lint -sem( mem_strdup, nulterm(1), nulterm(2), 1p > 0 && 2p > 0, @P == malloc(1P) && nulterm(@p)) */
extern char* mem_strdup(const char*, const char*, const int);
/*lint -sem( mem_free, custodial(1), nulterm(2), 1p > 0 && 2p) */
extern void mem_free(void*, const char*, const int);
#ifndef _MSHELL_C_
#ifdef strdup
#undef strdup
#endif /* strdup */
/*lint -e652 -e683*/
#define malloc(a) mem_malloc((a), __FILE__, __LINE__)
#define calloc(a, b) mem_calloc((a), (b), __FILE__, __LINE__)
#define realloc(a, b) mem_realloc((a), (b), __FILE__, __LINE__)
#define strdup(a) mem_strdup((a), __FILE__, __LINE__)
#define free(a) mem_free((a), __FILE__, __LINE__)
/*line +e652 +e683*/
#endif /* _MSHELL_C_ */
#ifndef NO_MSHELL
extern size_t mem_used(void);
extern void mem_maximum(FILE* fp);
extern void mem_display(FILE* fp);
extern void mem_check_x(const void* p, const char* file, const int line);
extern void mem_check_all_x(const char* file, const int line);
extern void mem_hide_x(void* p, const char* file, const int line);
#define mem_check(a) mem_check_x(a, __FILE__, __LINE__)
#define mem_check_all() mem_check_all_x(__FILE__, __LINE__)
#define mem_hide(a) mem_hide_x(a, __FILE__, __LINE__)
#else /* NO_MSHELL */
#define mem_used() /**/
#define mem_maximum(a) /**/
#define mem_display(a) /**/
#define mem_check(a) /**/
#define mem_check_all() /**/
#define mem_hide(a) /**/
#endif /* !NO_MSHELL */
#ifdef __cplusplus
}
#endif
#endif /* _MSHELL_H_ */
zimpl-3.3.4/src/inst.h 0000640 0012352 0006025 00000040300 13057565713 014452 0 ustar bzfgamra optimi /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* File....: inst.h */
/* Name....: Instruction Functions */
/* Author..: Thorsten Koch */
/* Copyright by Author, All rights reserved */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Copyright (C) 2001-2017 by Thorsten Koch
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _INST_H_
#define _INST_H_
#ifdef __cplusplus
extern "C" {
#endif
#define INST_NULL ((Inst)0)
/* ??? */
extern CodeNode* i_expr_sin(CodeNode* self);
extern CodeNode* i_expr_cos(CodeNode* self);
extern CodeNode* i_expr_tan(CodeNode* self);
extern CodeNode* i_expr_asin(CodeNode* self);
extern CodeNode* i_expr_acos(CodeNode* self);
extern CodeNode* i_expr_atan(CodeNode* self);
/* inst.c
*/
/*lint -sem( i_bool_and, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_bool_and(CodeNode* self);
/*lint -sem( i_bool_eq, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_bool_eq(CodeNode* self);
/*lint -sem( i_bool_exists, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_bool_exists(CodeNode* self);
/*lint -sem( i_bool_false, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_bool_false(CodeNode* self);
/*lint -sem( i_bool_ge, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_bool_ge(CodeNode* self);
/*lint -sem( i_bool_gt, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_bool_gt(CodeNode* self);
/*lint -sem( i_bool_is_elem, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_bool_is_elem(CodeNode* self);
/*lint -sem( i_bool_le, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_bool_le(CodeNode* self);
/*lint -sem( i_bool_lt, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_bool_lt(CodeNode* self);
/*lint -sem( i_bool_ne, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_bool_ne(CodeNode* self);
/*lint -sem( i_bool_not, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_bool_not(CodeNode* self);
/*lint -sem( i_bool_or, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_bool_or(CodeNode* self);
/*lint -sem( i_bool_seq, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_bool_seq(CodeNode* self);
/*lint -sem( i_bool_sneq, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_bool_sneq(CodeNode* self);
/*lint -sem( i_bool_sseq, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_bool_sseq(CodeNode* self);
/*lint -sem( i_bool_subs, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_bool_subs(CodeNode* self);
/*lint -sem( i_bool_true, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_bool_true(CodeNode* self);
/*lint -sem( i_bool_xor, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_bool_xor(CodeNode* self);
/*lint -sem( i_bound_new, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_bound_new(CodeNode* self);
/*lint -sem( i_check, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_check(CodeNode* self);
/*lint -sem( i_constraint_list, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_constraint_list(CodeNode* self);
/*lint -sem( i_constraint, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_constraint(CodeNode* self);
/*lint -sem( i_rangeconst, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_rangeconst(CodeNode* self);
/*lint -sem( i_elem_list_add, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_elem_list_add(CodeNode* self);
/*lint -sem( i_elem_list_new, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_elem_list_new(CodeNode* self);
/*lint -sem( i_entry, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_entry(CodeNode* self);
/*lint -sem( i_entry_list_add, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_entry_list_add(CodeNode* self);
/*lint -sem( i_entry_list_new, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_entry_list_new(CodeNode* self);
/*lint -sem( i_entry_list_powerset, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_entry_list_powerset(CodeNode* self);
/*lint -sem( i_entry_list_subsets, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_entry_list_subsets(CodeNode* self);
/*lint -sem( i_expr_abs, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_expr_abs(CodeNode* self);
/*lint -sem( i_expr_sgn, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_expr_sgn(CodeNode* self);
/*lint -sem( i_expr_add, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_expr_add(CodeNode* self);
/*lint -sem( i_expr_card, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_expr_card(CodeNode* self);
/*lint -sem( i_expr_ceil, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_expr_ceil(CodeNode* self);
/*lint -sem( i_expr_div, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_expr_div(CodeNode* self);
/*lint -sem( i_expr_exp, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_expr_exp(CodeNode* self);
/*lint -sem( i_expr_sqrt, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_expr_sqrt(CodeNode* self);
/*lint -sem( i_expr_fac, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_expr_fac(CodeNode* self);
/*lint -sem( i_expr_floor, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_expr_floor(CodeNode* self);
/*lint -sem( i_expr_if_else, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_expr_if_else(CodeNode* self);
/*lint -sem( i_expr_intdiv, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_expr_intdiv(CodeNode* self);
/*lint -sem( i_expr_length, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_expr_length(CodeNode* self);
/*lint -sem( i_expr_ln, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_expr_ln(CodeNode* self);
/*lint -sem( i_expr_log, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_expr_log(CodeNode* self);
/*lint -sem( i_expr_ord, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_expr_ord(CodeNode* self);
/*lint -sem( i_expr_prod, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_expr_prod(CodeNode* self);
/*lint -sem( i_expr_rand, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_expr_rand(CodeNode* self);
/*lint -sem( i_expr_round, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_expr_round(CodeNode* self);
/*lint -sem( i_expr_sum, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_expr_sum(CodeNode* self);
/*lint -sem( i_expr_max, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_expr_max(CodeNode* self);
/*lint -sem( i_expr_max2, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_expr_max2(CodeNode* self);
/*lint -sem( i_expr_sglmax, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_expr_sglmax(CodeNode* self);
/*lint -sem( i_expr_min, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_expr_min(CodeNode* self);
/*lint -sem( i_expr_min2, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_expr_min2(CodeNode* self);
/*lint -sem( i_expr_sglmin, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_expr_sglmin(CodeNode* self);
/*lint -sem( i_expr_mul, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_expr_mul(CodeNode* self);
/*lint -sem( i_expr_mod, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_expr_mod(CodeNode* self);
/*lint -sem( i_expr_neg, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_expr_neg(CodeNode* self);
/*lint -sem( i_expr_pow, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_expr_pow(CodeNode* self);
/*lint -sem( i_expr_sub, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_expr_sub(CodeNode* self);
/*lint -sem( i_expr_substr, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_expr_substr(CodeNode* self);
/*lint -sem( i_forall, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_forall(CodeNode* self);
/*lint -sem( i_idxset_new, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_idxset_new(CodeNode* self);
/*lint -sem( i_idxset_pseudo_new, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_idxset_pseudo_new(CodeNode* self);
/*lint -sem( i_list_matrix, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_list_matrix(CodeNode* self);
/*lint -sem( i_local_deref, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_local_deref(CodeNode* self);
/*lint -sem( i_matrix_list_new, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_matrix_list_new(CodeNode* self);
/*lint -sem( i_matrix_list_add, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_matrix_list_add(CodeNode* self);
/*lint -sem( i_newdef, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_newdef(CodeNode* self);
/*lint -sem( i_newsym_para1, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_newsym_para1(CodeNode* self);
/*lint -sem( i_newsym_para2, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_newsym_para2(CodeNode* self);
/*lint -sem( i_newsym_set1, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_newsym_set1(CodeNode* self);
/*lint -sem( i_newsym_set2, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_newsym_set2(CodeNode* self);
/*lint -sem( i_newsym_var, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_newsym_var(CodeNode* self);
/*lint -sem( i_nop, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_nop(CodeNode* self);
/*lint -sem( i_object_max, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_object_max(CodeNode* self);
/*lint -sem( i_object_min, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_object_min(CodeNode* self);
/*lint -sem( i_print, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_print(CodeNode* self);
/*lint -sem( i_set_argmax, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_set_argmax(CodeNode* self);
/*lint -sem( i_set_argmin, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_set_argmin(CodeNode* self);
/*lint -sem( i_set_cross, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_set_cross(CodeNode* self);
/*lint -sem( i_set_empty, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_set_empty(CodeNode* self);
/*lint -sem( i_set_expr, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_set_expr(CodeNode* self);
/*lint -sem( i_set_idxset, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_set_idxset(CodeNode* self);
/*lint -sem( i_set_indexset, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_set_indexset(CodeNode* self);
/*lint -sem( i_set_inter, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_set_inter(CodeNode* self);
/*lint -sem( i_set_inter2, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_set_inter2(CodeNode* self);
/*lint -sem( i_set_minus, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_set_minus(CodeNode* self);
/*lint -sem( i_set_new_tuple, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_set_new_tuple(CodeNode* self);
/*lint -sem( i_set_new_elem, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_set_new_elem(CodeNode* self);
/*lint -sem( i_set_proj, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_set_proj(CodeNode* self);
/*lint -sem( i_set_pseudo, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_set_pseudo(CodeNode* self);
/*lint -sem( i_set_range, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_set_range(CodeNode* self);
/*lint -sem( i_set_range2, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_set_range2(CodeNode* self);
/*lint -sem( i_set_sdiff, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_set_sdiff(CodeNode* self);
/*lint -sem( i_set_union, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_set_union(CodeNode* self);
/*lint -sem( i_set_union2, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_set_union2(CodeNode* self);
/*lint -sem( i_sos, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_sos(CodeNode* self);
/*lint -sem( i_soset, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_soset(CodeNode* self);
/*lint -sem( i_subto, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_subto(CodeNode* self);
/*lint -sem( i_symbol_deref, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_symbol_deref(CodeNode* self);
/*lint -sem( i_define_deref, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_define_deref(CodeNode* self);
/*lint -sem( i_term_add, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_term_add(CodeNode* self);
/*lint -sem( i_term_coeff, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_term_coeff(CodeNode* self);
/*lint -sem( i_term_const, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_term_const(CodeNode* self);
/*lint -sem( i_term_expr, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_term_expr(CodeNode* self);
/*lint -sem( i_term_mul, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_term_mul(CodeNode* self);
/*lint -sem( i_term_quadratic, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_term_power(CodeNode* self);
/*lint -sem( i_term_power, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_term_sub(CodeNode* self);
/*lint -sem( i_term_sum, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_term_sum(CodeNode* self);
/*lint -sem( i_tuple_new, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_tuple_new(CodeNode* self);
/*lint -sem( i_tuple_empty, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_tuple_empty(CodeNode* self);
/*lint -sem( i_tuple_list_add, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_tuple_list_add(CodeNode* self);
/*lint -sem( i_tuple_list_new, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_tuple_list_new(CodeNode* self);
/* iread.c
*/
/*lint -sem( i_read_new, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_read_new(CodeNode* self);
/*lint -sem( i_read_param, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_read_param(CodeNode* self);
/*lint -sem( i_read_comment, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_read_comment(CodeNode* self);
/*lint -sem( i_read_match, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_read_match(CodeNode* self);
/*lint -sem( i_read_use, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_read_use(CodeNode* self);
/*lint -sem( i_read_skip, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_read_skip(CodeNode* self);
/*lint -sem( i_read, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_read(CodeNode* self);
/* vinst.c
*/
/*lint -sem( i_vabs, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_vabs(CodeNode* self);
/*lint -sem( i_vbool_and, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_vbool_and(CodeNode* self);
/*lint -sem( i_vbool_eq, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_vbool_eq(CodeNode* self);
/*lint -sem( i_vbool_ne, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_vbool_ne(CodeNode* self);
/*lint -sem( i_vbool_ge, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_vbool_ge(CodeNode* self);
/*lint -sem( i_vbool_gt, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_vbool_gt(CodeNode* self);
/*lint -sem( i_vbool_le, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_vbool_le(CodeNode* self);
/*lint -sem( i_vbool_lt, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_vbool_lt(CodeNode* self);
/*lint -sem( i_vbool_not, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_vbool_not(CodeNode* self);
/*lint -sem( i_vbool_or, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_vbool_or(CodeNode* self);
/*lint -sem( i_vbool_xor, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_vbool_xor(CodeNode* self);
/*lint -sem( i_vexpr_fun, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_vexpr_fun(CodeNode* self);
/*lint -sem( i_vif, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_vif(CodeNode* self);
/*lint -sem( i_vif_else, 1p == 1, type(1), @p == 1p) */
extern CodeNode* i_vif_else(CodeNode* self);
#ifdef __cplusplus
}
#endif
#endif /* _INST_H_ */
zimpl-3.3.4/src/metaio.h 0000640 0012352 0006025 00000005147 13057565713 014765 0 ustar bzfgamra optimi /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* File....: metaio.h */
/* Name....: Meta Input/Output */
/* Author..: Thorsten Koch */
/* Copyright by Author, All rights reserved */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Copyright (C) 2006-2017 by Thorsten Koch
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _METAIO_H_
#define _METAIO_H_
#ifndef _BOOL_H_
#error "Need to include bool.h before metaio.h"
#endif
#ifdef __cplusplus
extern "C" {
#endif
typedef struct meta_file_ptr MFP;
/* metaio.c
*/
/*lint -sem( mio_add_strg_file, nulterm(1), nulterm(2), 1p && 2p) */
extern void mio_add_strg_file(const char* name, const char* content, Bool use_copy);
extern void mio_init(void);
extern void mio_exit(void);
/*lint -sem( mio_open, nulterm(2), 2p) */
/*lint -function( fopen(1), mio_open(1)) */
/*lint -function( fopen(r), mio_open(r)) */
extern MFP* mio_open(const char* name, const char* ext);
/*lint -function( fclose, mio_close) */
extern void mio_close(MFP* mfp);
/*lint -function( fgetc, mio_getc) */
extern int mio_getc(const MFP* mfp);
/*lint -function( fgets(1), mio_gets(2)) */
/*lint -function( fgets(2), mio_gets(3)) */
/*lint -function( fgets(3), mio_gets(1)) */
/*lint -function( fgets(r), mio_gets(r)) */
extern char* mio_gets(const MFP* mfp, char* buf, int len);
/*lint -sem( mio_get_line, 1p) */
extern char* mio_get_line(const MFP* mfp);
#ifdef __cplusplus
}
#endif
#endif /* _METAIO_H_ */
zimpl-3.3.4/src/local.h 0000640 0012352 0006025 00000004364 13057565713 014601 0 ustar bzfgamra optimi /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* File....: local.h */
/* Name....: Local Parameter Functions */
/* Author..: Thorsten Koch */
/* Copyright by Author, All rights reserved */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Copyright (C) 2001-2017 by Thorsten Koch
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _LOCAL_H_
#define _LOCAL_H_
#ifndef _ELEM_H_
#error "Need to include elem.h before local.h"
#endif
#ifndef _TUPLE_H_
#error "Need to include tuple.h before local.h"
#endif
#ifdef __cplusplus
extern "C" {
#endif
extern void local_init(void);
extern void local_exit(void);
extern void local_drop_frame(void);
/*lint -sem( local_lookup, nulterm(1), 1p, r_null) */
extern const Elem* local_lookup(const char* name);
/*lint -sem( local_install_tuple, 1p == 1 && 2p == 1) */
extern void local_install_tuple(const Tuple* patt, const Tuple* vals);
/*lint -sem( local_print_all, 1p == 1) */
extern void local_print_all(FILE* fp);
/*lint -sem( local_tostrall, @p && nulterm(@)) */
extern char* local_tostrall(void);
#ifdef __cplusplus
}
#endif
#endif /* _LOCAL_H_ */
zimpl-3.3.4/src/zimpllib.c 0000640 0012352 0006025 00000023242 13057565713 015320 0 ustar bzfgamra optimi /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* File....: zimpllib.c */
/* Name....: ZIMPL Library Interface */
/* Author..: Thorsten Koch */
/* Copyright by Author, All rights reserved */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Copyright (C) 2005-2017 by Thorsten Koch
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "lint.h"
#include "bool.h"
#include "mshell.h"
#include "stkchk.h"
#include "blkmem.h"
#include "random.h"
#include "ratlptypes.h"
#include "numb.h"
#include "elem.h"
#include "tuple.h"
#include "mme.h"
#include "set.h"
#include "symbol.h"
#include "define.h"
#include "bound.h"
#include "mono.h"
#include "term.h"
#include "stmt.h"
#include "local.h"
#include "list.h"
#include "entry.h"
#include "xlpglue.h"
#include "prog.h"
#include "metaio.h"
#include "strstore.h"
#include "zimpllib.h"
extern int yydebug;
extern int yy_flex_debug;
int verbose = VERB_QUIET;
static jmp_buf zpl_read_env;
static Bool is_longjmp_ok = FALSE;
void zpl_print_banner(FILE* fp, Bool with_license)
{
const char* const banner =
"****************************************************\n" \
"* Zuse Institute Mathematical Programming Language *\n" \
"* Release %-5s Copyright (C)2012 by Thorsten Koch *\n" \
"****************************************************\n";
const char* const license =
"* This is free software and you are welcome to *\n" \
"* redistribute it under certain conditions *\n" \
"* ZIMPL comes with ABSOLUTELY NO WARRANTY *\n" \
"****************************************************\n";
if (verbose >= VERB_NORMAL)
{
fprintf(fp, banner, VERSION);
if (with_license || verbose > VERB_NORMAL)
fprintf(fp, "%s", license);
fputc('\n', fp);
}
}
void zpl_exit(int retval)
{
if (is_longjmp_ok)
longjmp(zpl_read_env, retval);
#if defined(NDEBUG) || defined(COVERAGE)
exit(retval);
#else
abort(); /* to get a stack trace */
#endif
}
static Bool is_valid_identifier(const char* s)
{
assert(s != NULL);
/* Identifiers start with a letter or a '_'
*/
if (!isalpha(*s) || *s == '_')
return FALSE;
/* Then letters, digits or '_' can follow.
*/
while(isalnum(*++s) || *s == '_')
;
return *s == '\0';
}
void zpl_var_print(FILE* fp, const Var* var)
{
const char* name = xlp_getvarname(prog_get_lp(), var);
VarClass class = xlp_getclass(prog_get_lp(), var);
Bound* lower = xlp_getlower(prog_get_lp(), var);
Bound* upper = xlp_getupper(prog_get_lp(), var);
fprintf(fp, "\"%s\" ", name);
switch(class)
{
case VAR_CON :
fprintf(fp, "real [");
break;
case VAR_IMP :
fprintf(fp, "implicit integer [");
break;
case VAR_INT :
fprintf(fp, "integer [");
break;
default :
abort();
}
bound_print(fp, lower);
fprintf(fp, ",");
bound_print(fp, upper);
fprintf(fp, "] ");
bound_free(upper);
bound_free(lower);
}
void zpl_add_parameter(const char* def)
{
const char* warning =
"--- Warning 175: Illegal syntax for command line define \"%s\" -- ignored\n";
Set* set;
Symbol* sym;
Tuple* tuple;
Entry* entry;
char* name;
char* value;
assert(def != NULL);
name = strdup(def);
value = strchr(name, '=');
if (value == NULL)
{
fprintf(stderr, warning, def);
free(name);
return;
}
*value = '\0';
value++;
if (strlen(name) == 0 || strlen(value) == 0 || !is_valid_identifier(name))
{
if (verbose > VERB_QUIET)
fprintf(stderr, warning, def);
free(name);
return;
}
set = set_pseudo_new();
sym = symbol_new(str_new(name), SYM_ERR, set, 1, ENTRY_NULL);
tuple = tuple_new(0);
if (!numb_is_number(value))
entry = entry_new_strg(tuple, str_new(value));
else
{
Numb* numb = numb_new_ascii(value);
entry = entry_new_numb(tuple, numb);
numb_free(numb);
}
symbol_add_entry(sym, entry);
tuple_free(tuple);
set_free(set);
free(name);
}
Bool zpl_read(const char* filename, Bool with_management, void* user_data)
{
Prog* prog = NULL;
void* lp = NULL;
Bool ret = FALSE;
stkchk_init();
yydebug = 0;
yy_flex_debug = 0;
zpl_print_banner(stdout, FALSE);
blk_init();
str_init();
rand_init(13021967UL);
numb_init(with_management);
elem_init();
set_init();
mio_init();
interns_init();
local_init();
if (0 == setjmp(zpl_read_env))
{
Set* set;
is_longjmp_ok = TRUE;
set = set_pseudo_new();
(void)symbol_new(SYMBOL_NAME_INTERNAL, SYM_VAR, set, 100, NULL);
set_free(set);
prog = prog_new();
prog_load(prog, NULL, filename);
if (prog_is_empty(prog))
fprintf(stderr, "*** Error 168: No program statements to execute\n");
else
{
if (verbose >= VERB_DEBUG)
prog_print(stderr, prog);
lp = xlp_alloc(filename, FALSE, user_data);
prog_execute(prog, lp);
ret = TRUE;
}
}
is_longjmp_ok = FALSE;
if (lp != NULL)
xlp_free(lp);
if (prog != NULL)
prog_free(prog);
local_exit();
interns_exit();
mio_exit();
symbol_exit();
define_exit();
set_exit();
elem_exit();
numb_exit();
str_exit();
blk_exit();
return ret;
}
Bool zpl_read_with_args(char** argv, int argc, Bool with_management, void* user_data)
{
const char* options = "D:mP:s:v:";
unsigned long seed = 13021967UL;
char** param_table;
int param_count = 0;
int c;
int i;
Prog* prog = NULL;
void* lp = NULL;
Bool ret = FALSE;
char* inppipe = NULL;
Bool use_startval = FALSE;
stkchk_init();
yydebug = 0;
yy_flex_debug = 0;
param_table = malloc(sizeof(*param_table));
zpl_print_banner(stdout, FALSE);
/* getopt might be called more than once
*/
optind = 1;
while((c = getopt(argc, argv, options)) != -1)
{
switch(c)
{
case 'D' :
param_table =
realloc(param_table, ((unsigned int)param_count + 1) * sizeof(*param_table));
param_table[param_count] = strdup(optarg);
if (verbose >= VERB_DEBUG)
printf("Parameter %d [%s]\n", param_count, param_table[param_count]);
param_count++;
break;
case 'm' :
use_startval = TRUE;
break;
case 'P' :
inppipe = strdup(optarg);
break;
case 's' :
seed = (unsigned long)atol(optarg);
break;
case 'v' :
verbose = atoi(optarg);
break;
case '?':
fprintf(stderr, "Unknown option '%c'\n", c);
return FALSE;
default :
abort();
}
}
if ((argc - optind) < 1)
{
fprintf(stderr, "Filename missing\n");
free(param_table);
return FALSE;
}
blk_init();
str_init();
rand_init(seed);
numb_init(with_management);
elem_init();
set_init();
mio_init();
interns_init();
local_init();
if (0 == setjmp( zpl_read_env))
{
Set* set;
is_longjmp_ok = TRUE;
/* Make symbol to hold entries of internal variables
*/
set = set_pseudo_new();
(void)symbol_new(SYMBOL_NAME_INTERNAL, SYM_VAR, set, 100, NULL);
set_free(set);
/* Now store the param defines
*/
for(i = 0; i < param_count; i++)
zpl_add_parameter(param_table[i]);
prog = prog_new();
for(i = optind; i < argc; i++)
prog_load(prog, inppipe, argv[i]);
if (prog_is_empty(prog))
fprintf(stderr, "*** Error 168: No program statements to execute\n");
else
{
if (verbose >= VERB_DEBUG)
prog_print(stderr, prog);
lp = xlp_alloc(argv[optind], use_startval, user_data);
prog_execute(prog, lp);
ret = TRUE;
}
}
is_longjmp_ok = FALSE;
if (lp != NULL)
xlp_free(lp);
/* Now clean up.
*/
if (inppipe != NULL)
free(inppipe);
for(i = 0; i < param_count; i++)
free(param_table[i]);
free(param_table);
if (prog != NULL)
prog_free(prog);
local_exit();
interns_exit();
mio_exit();
symbol_exit();
define_exit();
set_exit();
elem_exit();
numb_exit();
str_exit();
blk_exit();
return ret;
}
zimpl-3.3.4/src/ratlptypes.h 0000640 0012352 0006025 00000006343 13057565713 015715 0 ustar bzfgamra optimi /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* File....: ratlptypes.h */
/* Name....: Rational Number LP Storage Library */
/* Author..: Thorsten Koch */
/* Copyright by Author, All rights reserved */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Copyright (C) 2003-2017 by Thorsten Koch
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _RATLPTYPES_H_
#define _RATLPTYPES_H_
#ifndef _BOOL_H_
#error "Need to include bool.h before ratlp.h"
#endif
#ifdef __cplusplus
extern "C" {
#endif
enum con_type { CON_FREE = 0, CON_LHS, CON_RHS, CON_RANGE, CON_EQUAL };
enum var_type { VAR_FREE = 0, VAR_LOWER, VAR_UPPER, VAR_BOXED, VAR_FIXED };
enum sos_type { SOS_ERR = 0, SOS_TYPE1, SOS_TYPE2 };
enum var_class { VAR_CON = 0, VAR_IMP, VAR_INT };
enum lp_direct { LP_MIN = 0, LP_MAX };
enum lp_type { LP_ERR = 0, LP_LP, LP_IP };
enum lp_format { LP_FORM_ERR = 0, LP_FORM_LPF, LP_FORM_HUM, LP_FORM_MPS, LP_FORM_RLP, LP_FORM_PIP };
#if 0 /* not used anymore ??? */
enum presolve_result
{
PRESOLVE_ERROR = 0, PRESOLVE_OKAY, PRESOLVE_INFEASIBLE,
PRESOLVE_UNBOUNDED, PRESOLVE_VANISHED
};
typedef enum presolve_result PSResult;
#endif
typedef struct nonzero Nzo;
typedef struct variable Var;
typedef struct constraint Con;
typedef struct soset Sos;
typedef struct soselement Sse;
typedef struct qmatentry Qme;
typedef struct lpstorage Lps;
typedef enum con_type ConType;
typedef enum sos_type SosType;
typedef enum var_class VarClass;
typedef enum lp_direct LpDirect;
typedef enum lp_type LpType;
typedef enum lp_format LpFormat;
#define LP_FLAG_CON_SCALE 0x01
#define LP_FLAG_CON_SEPAR 0x02
#define LP_FLAG_CON_CHECK 0x04
#define LP_FLAG_CON_INDIC 0x08
#define HAS_LOWER(var) ((var)->type != VAR_FREE && (var)->type != VAR_UPPER)
#define HAS_UPPER(var) ((var)->type != VAR_FREE && (var)->type != VAR_LOWER)
#define HAS_LHS(con) ((con)->type != CON_FREE && (con)->type != CON_RHS)
#define HAS_RHS(con) ((con)->type != CON_FREE && (con)->type != CON_LHS)
#ifdef __cplusplus
}
#endif
#endif /* _RATLPTYPES_H_ */
zimpl-3.3.4/src/ratlpstore.c 0000640 0012352 0006025 00000124425 13057565713 015702 0 ustar bzfgamra optimi /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* File....: lpstore.c */
/* Name....: Store Linear Programm */
/* Author..: Thorsten Koch */
/* Copyright by Author, All rights reserved */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Copyright (C) 2003-2017 by Thorsten Koch
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include
#include
#include
#include
#include
#include
#include "lint.h"
#include "bool.h"
#include "mshell.h"
#include "gmpmisc.h"
#include "ratlptypes.h"
#include "numb.h"
#include "bound.h"
#include "mme.h"
#include "mono.h"
#include "term.h"
#include "ratlp.h"
#include "ratlpstore.h"
#ifdef _MSC_VER
#pragma warning (disable: 4100)
#endif
#define LPF_NAME_LEN 16
#define MPS_NAME_LEN 8
#define PIP_NAME_LEN 255
#define MIN_NAME_LEN 8
struct storage
{
int size;
Nzo* begin;
Sto* next;
};
static const unsigned int sto_size = 1000;
#ifndef LHT_BUCKETS
#define LHT_BUCKETS 1000003U
#endif
enum lps_hash_type { LHT_ERR = 0, LHT_VAR, LHT_CON, LHT_SOS };
typedef struct lps_hash_element LpsHElem;
typedef enum lps_hash_type LpsHashType;
struct lps_hash_element
{
LpsHElem* next;
union
{
Con* con;
Var* var;
Sos* sos;
} value;
};
struct lps_hash
{
unsigned int size;
int elems;
LpsHashType type;
LpsHElem** bucket;
};
static void hash_statist(FILE* fp, const LpsHash* hash);
static Bool hash_valid(const LpsHash* hash)
{
return hash != NULL
&& (hash->type == LHT_CON || hash->type == LHT_VAR || hash->type == LHT_SOS);
}
static unsigned int hashit(const char* s)
{
unsigned int hcode = 0;
/* I am not too sure this works well for 64bit integers.
*/
/*lint -e{506} supress "Constant value Boolean"
*/
assert(sizeof(hcode) == 4);
for(; *s != '\0'; s++)
hcode = 31 * hcode + (unsigned char)*s;
return hcode;
}
static LpsHash* lps_hash_new(LpsHashType type)
{
LpsHash* hash = calloc(1, sizeof(*hash));
assert(hash != NULL);
hash->size = LHT_BUCKETS;
hash->elems = 0;
hash->type = type;
hash->bucket = calloc(hash->size, sizeof(*hash->bucket));
assert(hash->bucket != NULL);
assert(hash_valid(hash));
return hash;
}
static void lps_hash_free(LpsHash* hash)
{
LpsHElem* he;
LpsHElem* hq;
unsigned int i;
assert(hash_valid(hash));
#if 0
#ifndef NDEBUG
hash_statist(stdout, hash);
#endif
#endif
for(i = 0; i < hash->size; i++)
{
for(he = hash->bucket[i]; he != NULL; he = hq)
{
hq = he->next;
free(he);
}
}
free(hash->bucket);
free(hash);
}
/* Liefert NULL wenn nicht gefunden.
*/
static Var* hash_lookup_var(const LpsHash* hash, const char* name)
{
unsigned int hcode;
LpsHElem* he;
assert(hash_valid(hash));
assert(hash->type == LHT_VAR);
assert(name != NULL);
hcode = hashit(name) % hash->size;
for(he = hash->bucket[hcode]; he != NULL; he = he->next)
if (!strcmp(he->value.var->name, name))
break;
return (he == NULL) ? (Var*)0 : he->value.var;
}
/* Liefert NULL wenn nicht gefunden.
*/
static Con* hash_lookup_con(const LpsHash* hash, const char* name)
{
unsigned int hcode;
LpsHElem* he;
assert(hash_valid(hash));
assert(hash->type == LHT_CON);
assert(name != NULL);
hcode = hashit(name) % hash->size;
for(he = hash->bucket[hcode]; he != NULL; he = he->next)
if (!strcmp(he->value.con->name, name))
break;
return (he == NULL) ? (Con*)0 : he->value.con;
}
/* Liefert NULL wenn nicht gefunden.
*/
static Sos* hash_lookup_sos(const LpsHash* hash, const char* name)
{
unsigned int hcode;
LpsHElem* he;
assert(hash_valid(hash));
assert(hash->type == LHT_SOS);
assert(name != NULL);
hcode = hashit(name) % hash->size;
for(he = hash->bucket[hcode]; he != NULL; he = he->next)
if (!strcmp(he->value.sos->name, name))
break;
return (he == NULL) ? (Sos*)0 : he->value.sos;
}
static void hash_add_var(LpsHash* hash, Var* var)
{
LpsHElem* he = calloc(1, sizeof(*he));
unsigned int hcode;
assert(hash_valid(hash));
assert(var != NULL);
assert(hash->type == LHT_VAR);
assert(he != NULL);
hcode = hashit(var->name) % hash->size;
he->value.var = var;
he->next = hash->bucket[hcode];
hash->bucket[hcode] = he;
hash->elems++;
assert(hash_lookup_var(hash, var->name) == var);
}
static void hash_del_var(LpsHash* hash, const Var* var)
{
LpsHElem* he;
LpsHElem* next;
unsigned int hcode;
assert(hash_valid(hash));
assert(var != NULL);
assert(hash->type == LHT_VAR);
hcode = hashit(var->name) % hash->size;
for(he = hash->bucket[hcode], next = NULL; he != NULL; next = he, he = he->next)
if (he->value.var == var)
break;
assert(he != NULL);
if (next == NULL)
hash->bucket[hcode] = he->next;
else
next->next = he->next;
hash->elems--;
free(he);
assert(hash_valid(hash));
}
static void hash_add_con(LpsHash* hash, Con* con)
{
LpsHElem* he = calloc(1, sizeof(*he));
unsigned int hcode;
assert(hash_valid(hash));
assert(con != NULL);
assert(hash->type == LHT_CON);
assert(he != NULL);
hcode = hashit(con->name) % hash->size;
he->value.con = con;
he->next = hash->bucket[hcode];
hash->bucket[hcode] = he;
hash->elems++;
assert(hash_lookup_con(hash, con->name) == con);
}
static void hash_add_sos(LpsHash* hash, Sos* sos)
{
LpsHElem* he = calloc(1, sizeof(*he));
unsigned int hcode;
assert(hash_valid(hash));
assert(sos != NULL);
assert(hash->type == LHT_SOS);
assert(he != NULL);
hcode = hashit(sos->name) % hash->size;
he->value.sos = sos;
he->next = hash->bucket[hcode];
hash->bucket[hcode] = he;
hash->elems++;
assert(hash_lookup_sos(hash, sos->name) == sos);
}
static void hash_del_con(LpsHash* hash, const Con* con)
{
LpsHElem* he;
LpsHElem* next;
unsigned int hcode;
assert(hash_valid(hash));
assert(con != NULL);
assert(hash->type == LHT_CON);
hcode = hashit(con->name) % hash->size;
for(he = hash->bucket[hcode], next = NULL; he != NULL; next = he, he = he->next)
if (he->value.con == con)
break;
assert(he != NULL);
if (next == NULL)
hash->bucket[hcode] = he->next;
else
next->next = he->next;
hash->elems--;
free(he);
assert(hash_valid(hash));
}
static void hash_statist(FILE* fp, const LpsHash* hash)
{
LpsHElem* he;
int min = (int)hash->size;
int max = 0;
int sum = 0;
int zeros = 0;
int filled = 0;
int count;
double avg = 0.0;
unsigned int i;
assert(fp != NULL);
assert(hash_valid(hash));
for(i = 0; i < hash->size; i++)
{
count = 0;
for(he = hash->bucket[i]; he != NULL; he = he->next)
count++;
if (count == 0)
zeros++;
else
filled++;
if (count < min)
min = count;
if (count > max)
max = count;
sum += count;
}
assert(sum == hash->elems);
if (filled > 0)
avg = (double)sum / (double)filled;
fprintf(fp,
"HashStat: size=%u sum=%d min=%d max=%d avg=%.1f zero=%d filled=%d\n",
hash->size, sum, min, max, avg, zeros, filled);
}
#ifndef NDEBUG
static Bool lps_valid(const Lps* lp)
{
const char* err1 = "Wrong Previous Variable";
const char* err2 = "Wrong Variable Previous Nonzero";
const char* err3 = "Wrong Variable Nonzero Count";
const char* err4 = "Wrong Variable Count";
const char* err5 = "Wrong Previous Constraint";
const char* err6 = "Wrong Constraint Previous Nonzero";
const char* err7 = "Wrong Constraint Nonzero Count";
const char* err8 = "Wrong Constraint Count";
const char* err9 = "Wrong Variable";
const char* err10 = "Wrong Constraint";
const char* err11 = "Storage-size error";
const char* err12 = "Wrong Variable SID";
const char* err13 = "Wrong Constraint SID";
const char* err14 = "Strange lhs/rhs";
const char* err15 = "Wrong SOS SID";
const char* err16 = "Wrong SOS Variable SID";
const char* err18 = "Wrong SOS element count";
const char* err19 = "Wrong SOS count";
Var* var;
Var* var_prev;
Con* con;
Con* con_prev;
Nzo* nzo;
Nzo* nzo_prev;
Sto* sto;
Sos* sos;
Sse* sse;
int var_count;
int con_count;
int nzo_count;
int sto_count;
int sos_count;
int sse_count;
assert(lp != NULL);
/* Variable Test
*/
var_count = lp->vars;
for(var = lp->var_root, var_prev = NULL; var != NULL; var = var->next)
{
if (var->sid != VAR_SID)
{
fprintf(stderr, "%s\n", err12);
return FALSE;
}
if (var_prev == var->prev)
var_prev = var;
else
{
fprintf(stderr, "%s\n", err1);
return FALSE;
}
var_count--;
nzo_count = var->size;
for(nzo = var->first, nzo_prev = NULL; nzo != NULL; nzo = nzo->var_next)
{
if (nzo_prev == nzo->var_prev)
nzo_prev = nzo;
else
{
fprintf(stderr, "%s\n", err2);
return FALSE;
}
if (nzo->var != var)
{
fprintf(stderr, "%s\n", err9);
return FALSE;
}
nzo_count--;
}
if (nzo_count)
{
fprintf(stderr, "%s\n", err3);
return FALSE;
}
}
if (var_count)
{
fprintf(stderr, "%s\n", err4);
return FALSE;
}
/* Constraint Test
*/
con_count = lp->cons;
for(con = lp->con_root, con_prev = NULL; con != NULL; con = con->next)
{
if (con->sid != CON_SID)
{
fprintf(stderr, "%s\n", err13);
return FALSE;
}
if (con_prev == con->prev)
con_prev = con;
else
{
fprintf(stderr, "%s\n", err5);
return FALSE;
}
switch(con->type)
{
case CON_FREE :
case CON_LHS :
case CON_RHS :
break;
case CON_RANGE :
if (mpq_cmp(con->lhs, con->rhs) >= 0)
{
fprintf(stderr, "%s %s %g %g\n",
err14, con->name, mpq_get_d(con->lhs), mpq_get_d(con->rhs));
return FALSE;
}
break;
case CON_EQUAL :
if (!mpq_equal(con->lhs, con->rhs))
{
fprintf(stderr, "%s %s %g %g\n",
err14, con->name, mpq_get_d(con->lhs), mpq_get_d(con->rhs));
return FALSE;
}
break;
default :
abort();
}
con_count--;
nzo_count = con->size;
for(nzo = con->first, nzo_prev = NULL; nzo != NULL; nzo = nzo->con_next)
{
if (nzo_prev == nzo->con_prev)
nzo_prev = nzo;
else
{
fprintf(stderr, "%s\n", err6);
return FALSE;
}
if (nzo->con != con)
{
fprintf(stderr, "%s\n", err10);
return FALSE;
}
nzo_count--;
}
if (nzo_count)
{
fprintf(stderr, "%s\n", err7);
return FALSE;
}
}
if (con_count)
{
fprintf(stderr, "%s\n", err8);
return FALSE;
}
/* SOS Test
*/
sos_count = lp->soss;
for(sos = lp->sos_root; sos != NULL; sos = sos->next)
{
if (sos->sid != SOS_SID)
{
fprintf(stderr, "%s\n", err15);
return FALSE;
}
sos_count--;
sse_count = sos->sses;
for(sse = sos->first; sse != NULL; sse = sse->next)
{
if (sse->var->sid != VAR_SID)
{
fprintf(stderr, "%s\n", err16);
return FALSE;
}
sse_count--;
}
if (sse_count)
{
fprintf(stderr, "%s\n", err18);
return FALSE;
}
}
if (sos_count)
{
fprintf(stderr, "%s\n", err19);
return FALSE;
}
/* Storage Test
*/
sto_count = 0;
for(sto = lp->sto_root; sto != NULL; sto = sto->next)
{
assert(sto->begin != NULL);
sto_count++;
}
if (sto_count * (int)sto_size < lp->nonzeros)
{
fprintf(stderr, "%s %d %u %d\n",
err11, sto_count, sto_size, lp->nonzeros);
return FALSE;
}
return TRUE;
}
#endif /* !NDEBUG */
static void lps_storage(Lps* lp)
{
Sto* s;
Nzo* n;
unsigned int i;
assert(lps_valid(lp));
assert(lp->next == NULL);
s = malloc(sizeof(*s));
assert(s != NULL);
n = malloc(sto_size * sizeof(*n));
assert(n != NULL);
for(i = 0; i < sto_size - 1; i++)
{
n[i].var_next = &n[i + 1];
mpq_init(n[i].value);
#ifndef NDEBUG
n[i].var_prev = NULL;
n[i].con_next = NULL;
n[i].con_prev = NULL;
n[i].var = NULL;
n[i].con = NULL;
#endif
}
n[i].var_next = NULL;
mpq_init(n[i].value);
#ifndef NDEBUG
n[i].var_prev = NULL;
n[i].con_next = NULL;
n[i].con_prev = NULL;
n[i].var = NULL;
n[i].con = NULL;
#endif
s->size = sto_size;
s->begin = n;
s->next = lp->sto_root;
lp->sto_root = s;
lp->next = s->begin;
}
Lps* lps_alloc(
const char* name)
{
Lps* lp;
assert(name != NULL);
lp = malloc(sizeof(*lp));
assert(lp != NULL);
lp->name = strdup(name);
lp->probname = NULL;
lp->objname = NULL;
lp->rhsname = NULL;
lp->bndname = NULL;
lp->rngname = NULL;
lp->type = LP_LP;
lp->direct = LP_MIN;
lp->vars = 0;
lp->cons = 0;
lp->soss = 0;
lp->nonzeros = 0;
lp->var_root = NULL;
lp->con_root = NULL;
lp->sos_root = NULL;
lp->sto_root = NULL;
lp->next = NULL;
lp->var_hash = lps_hash_new(LHT_VAR);
lp->con_hash = lps_hash_new(LHT_CON);
lp->sos_hash = lps_hash_new(LHT_SOS);
lp->var_last = NULL;
lp->con_last = NULL;
lp->sos_last = NULL;
lp->name_len = 0;
assert(lps_valid(lp));
return lp;
}
void lps_free(Lps* lp)
{
Var* var;
Var* var_next;
Con* con;
Con* con_next;
Sos* sos;
Sos* sos_next;
Sse* sse;
Sse* sse_next;
Sto* sto;
Sto* sto_next;
unsigned int i;
assert(lps_valid(lp));
lps_hash_free(lp->var_hash);
lps_hash_free(lp->con_hash);
lps_hash_free(lp->sos_hash);
for(sto = lp->sto_root; sto != NULL; sto = sto_next)
{
for(i = 0; i < sto_size; i++)
mpq_clear(sto->begin[i].value);
sto_next = sto->next;
free(sto->begin);
free(sto);
}
for(var = lp->var_root; var != NULL; var = var_next)
{
var_next = var->next;
var->sid = 0x0;
mpq_clear(var->cost);
mpq_clear(var->lower);
mpq_clear(var->upper);
mpq_clear(var->value);
mpq_clear(var->startval);
free(var->name);
free(var);
}
for(con = lp->con_root; con != NULL; con = con_next)
{
Qme* qme;
Qme* qme_next;
con_next = con->next;
con->sid = 0x0;
for(qme = con->qme_first; qme != NULL; qme = qme_next)
{
qme_next = qme->next;
mpq_clear(qme->value);
free(qme);
}
mpq_clear(con->lhs);
mpq_clear(con->rhs);
mpq_clear(con->scale);
if (con->term != NULL)
term_free(con->term);
free(con->name);
free(con);
}
for(sos = lp->sos_root; sos != NULL; sos = sos_next)
{
sos_next = sos->next;
sos->sid = 0x0;
for(sse = sos->first; sse != NULL; sse = sse_next)
{
sse_next = sse->next;
mpq_clear(sse->weight);
free(sse);
}
free(sos->name);
free(sos);
}
if (lp->probname != NULL)
free(lp->probname);
if (lp->objname != NULL)
free(lp->objname);
if (lp->rhsname != NULL)
free(lp->rhsname);
if (lp->bndname != NULL)
free(lp->bndname);
if (lp->rngname != NULL)
free(lp->rngname);
free(lp->name);
free(lp);
}
void lps_number(const Lps* lp)
{
Var* var;
Con* con;
int i;
assert(lps_valid(lp));
for(var = lp->var_root, i = 0; var != NULL; var = var->next, i++)
{
assert(var != NULL);
assert(var->sid == VAR_SID);
var->number = i;
}
assert(i == lp->vars);
for(con = lp->con_root, i = 0; con != NULL; con = con->next, i++)
{
assert(con != NULL);
assert(con->sid == CON_SID);
con->number = i;
}
assert(i == lp->cons);
}
Var* lps_getvar(
const Lps* lp,
const char* name)
{
Var* vr;
assert(lps_valid(lp));
assert(name != NULL);
vr = hash_lookup_var(lp->var_hash, name);
assert((vr == NULL) || (vr->sid == VAR_SID));
assert((vr == NULL) || (!strcmp(vr->name, name)));
#ifndef NDEBUG
{
const Var* var;
for(var = lp->var_root; var != NULL; var = var->next)
if (!strcmp(var->name, name))
break;
assert(var == vr);
}
#endif
return vr;
}
Con* lps_getcon(
const Lps* lp,
const char* name)
{
Con* cr;
assert(lps_valid(lp));
assert(name != NULL);
cr = hash_lookup_con(lp->con_hash, name);
assert((cr == NULL) || (cr->sid == CON_SID));
assert((cr == NULL) || (!strcmp(cr->name, name)));
#ifndef NDEBUG
{
const Con* con;
for(con = lp->con_root; con != NULL; con = con->next)
if (!strcmp(con->name, name))
break;
assert(con == cr);
}
#endif
return cr;
}
Sos* lps_getsos(
const Lps* lp,
const char* name)
{
Sos* sr;
assert(lps_valid(lp));
assert(name != NULL);
sr = hash_lookup_sos(lp->sos_hash, name);
assert((sr == NULL) || (sr->sid == VAR_SID));
assert((sr == NULL) || (!strcmp(sr->name, name)));
#ifndef NDEBUG
{
const Sos* sos;
for(sos = lp->sos_root; sos != NULL; sos = sos->next)
if (!strcmp(sos->name, name))
break;
assert(sos == sr);
}
#endif
return sr;
}
Nzo* lps_getnzo(
const Lps* lp,
const Con* con,
const Var* var)
{
Nzo* nzo;
assert(lps_valid(lp));
assert(con != NULL);
assert(con->sid == CON_SID);
assert(var != NULL);
assert(var->sid == VAR_SID);
/* Whatever is shorter
*/
if (var->size <= con->size)
{
for(nzo = var->first; nzo != NULL; nzo = nzo->var_next)
if (nzo->con == con)
break;
}
else
{
for(nzo = con->first; nzo != NULL; nzo = nzo->con_next)
if (nzo->var == var)
break;
}
assert((nzo == NULL) || ((nzo->var == var) && (nzo->con == con)));
return nzo;
}
Var* lps_addvar(
Lps* lp,
const char* name)
{
Var* v;
assert(lps_valid(lp));
assert(name != NULL);
assert(lps_getvar(lp, name) == NULL);
v = malloc(sizeof(*v));
assert(v != NULL);
mpq_init(v->cost);
mpq_init(v->lower);
mpq_init(v->upper);
mpq_init(v->value);
mpq_init(v->startval);
v->sid = VAR_SID;
v->name = strdup(name);
v->number = lp->vars;
v->vclass = VAR_CON;
v->type = VAR_FREE;
v->is_used = FALSE;
v->priority = 0;
v->size = 0;
v->first = NULL;
v->next = NULL;
v->prev = lp->var_last;
lp->var_last = v;
if (v->prev == NULL)
lp->var_root = v;
else
{
assert(v->prev->next == NULL);
v->prev->next = v;
}
lp->vars++;
hash_add_var(lp->var_hash, v);
assert(lps_valid(lp));
return v;
}
void lps_delvar(
Lps* lp,
Var* var)
{
assert(lps_valid(lp));
/* remove non-zeros
*/
while(var->first != NULL)
lps_delnzo(lp, var->first);
assert(var->size == 0);
/* Correkt "next" links
*/
if (var->prev != NULL)
{
var->prev->next = var->next;
assert(lp->var_root != var);
}
else
{
assert(lp->var_root == var);
lp->var_root = var->next;
assert(lp->var_root != NULL || lp->vars == 0);
}
/* Correkt "prev" links
*/
if (var->next != NULL)
{
var->next->prev = var->prev;
assert(lp->var_last != var);
}
else
{
assert(lp->var_last == var);
lp->var_last = var->prev;
assert(lp->var_last != NULL || lp->vars == 0);
}
hash_del_var(lp->var_hash, var);
mpq_clear(var->cost);
mpq_clear(var->lower);
mpq_clear(var->upper);
mpq_clear(var->value);
mpq_clear(var->startval);
var->sid = 0;
free(var->name);
free(var);
lp->vars--;
assert(lps_valid(lp));
}
Con* lps_addcon(
Lps* lp,
const char* name)
{
Con* c;
assert(lps_valid(lp));
assert(name != NULL);
assert(lps_getcon(lp, name) == NULL);
c = calloc(1, sizeof(*c));
assert(c != NULL);
mpq_init(c->lhs);
mpq_init(c->rhs);
mpq_init(c->scale);
c->sid = CON_SID;
c->name = strdup(name);
c->number = lp->cons;
c->size = 0;
c->type = CON_FREE;
c->flags = 0;
c->ind_var = NULL;
c->ind_dir = TRUE;
c->first = NULL;
c->qme_first = NULL;
c->term = NULL;
c->next = NULL;
c->prev = lp->con_last;
lp->con_last = c;
if (c->prev == NULL)
lp->con_root = c;
else
{
assert(c->prev->next == NULL);
c->prev->next = c;
}
lp->cons++;
hash_add_con(lp->con_hash, c);
assert(lps_valid(lp));
return c;
}
void lps_delcon(
Lps* lp,
Con* con)
{
assert(lps_valid(lp));
/* remove non-zeros
*/
while(con->first != NULL)
lps_delnzo(lp, con->first);
assert(con->size == 0);
/* Correkt "next" links
*/
if (con->prev != NULL)
{
con->prev->next = con->next;
assert(lp->con_root != con);
}
else
{
assert(lp->con_root == con);
lp->con_root = con->next;
assert(lp->con_root != NULL || lp->cons == 0);
}
/* Correkt "prev" links
*/
if (con->next != NULL)
{
con->next->prev = con->prev;
assert(lp->con_last != con);
}
else
{
assert(lp->con_last == con);
lp->con_last = con->prev;
assert(lp->con_last != NULL || lp->cons == 0);
}
hash_del_con(lp->con_hash, con);
con->sid = 0x0;
mpq_clear(con->lhs);
mpq_clear(con->rhs);
mpq_clear(con->scale);
free(con->name);
free(con);
lp->cons--;
/* ??? qme_first term ? */
assert(lps_valid(lp));
}
Sos* lps_addsos(
Lps* lp,
const char* name,
SosType type,
int priority)
{
Sos* sos;
assert(lps_valid(lp));
assert(name != NULL);
assert(lps_getsos(lp, name) == NULL);
sos = malloc(sizeof(*sos));
assert(sos != NULL);
sos->sid = SOS_SID;
sos->name = strdup(name);
sos->type = type;
sos->priority = priority;
sos->sses = 0;
sos->first = NULL;
sos->next = NULL;
if (lp->sos_last != NULL)
lp->sos_last->next = sos;
lp->sos_last = sos;
if (lp->sos_root == NULL)
lp->sos_root = sos;
lp->soss++;
hash_add_sos(lp->sos_hash, sos);
assert(lps_valid(lp));
return sos;
}
/*ARGSUSED*/
void lps_addqme(
UNUSED Lps* lp,
Con* con,
Var* var1,
Var* var2,
const mpq_t value)
{
Qme* qme = malloc(sizeof(*qme));
assert(qme != NULL);
qme->sid = QME_SID;
qme->var1 = var1;
qme->var2 = var2;
mpq_init(qme->value);
mpq_set(qme->value, value);
qme->next = con->qme_first;
con->qme_first = qme;
var1->is_used = TRUE;
var2->is_used = TRUE;
}
/*ARGSUSED*/
void lps_addterm(
UNUSED Lps* lp,
Con* con,
const Term* term)
{
int i;
int k;
assert(con != NULL);
/* assert(term_valid(term));*/
assert(con->term == NULL);
con->term = term_copy(term);
for(i = 0; i < term_get_elements(term); i++)
{
const Mono* mono = term_get_element(term, i);
for(k = 0; k < mono_get_degree(mono); k++)
mono_get_var(mono, k)->is_used = TRUE;
}
}
void lps_addsse(
Sos* sos,
Var* var,
const mpq_t weight)
{
Sse* sse;
assert(sos != NULL);
assert(sos->sid == SOS_SID);
assert(var != NULL);
assert(var->sid == VAR_SID);
sse = malloc(sizeof(*sse));
assert(sse != NULL);
mpq_init(sse->weight);
mpq_set(sse->weight, weight);
sse->var = var;
sse->next = sos->first;
sos->first = sse;
sos->sses++;
sse->var->is_used = TRUE;
}
void lps_addnzo(
Lps* lp,
Con* con,
Var* var,
const mpq_t value)
{
Nzo* nzo;
assert(lps_valid(lp));
assert(con != NULL);
assert(con->sid == CON_SID);
assert(var != NULL);
assert(var->sid == VAR_SID);
/* Ins LP aufnehmen
*/
if (lp->next == NULL)
lps_storage(lp);
nzo = lp->next;
assert(nzo != NULL);
lp->next = nzo->var_next;
lp->nonzeros++;
mpq_set(nzo->value, value);
/* In die Spalte aufnehmen
*/
nzo->var = var;
nzo->var_prev = NULL;
nzo->var_next = var->first;
var->first = nzo;
var->size++;
if (nzo->var_next != NULL)
{
assert(nzo->var_next->var_prev == NULL);
nzo->var_next->var_prev = nzo;
}
/* In die Zeile aufnehmen
*/
nzo->con = con;
nzo->con_prev = NULL;
nzo->con_next = con->first;
con->first = nzo;
con->size++;
if (nzo->con_next != NULL)
{
assert(nzo->con_next->con_prev == NULL);
nzo->con_next->con_prev = nzo;
}
assert(lps_valid(lp));
}
void lps_delnzo(
Lps* lp,
Nzo* nzo)
{
assert(lps_valid(lp));
assert(nzo != NULL);
/* Aus der Spalte nahmen
*/
if (nzo == nzo->var->first)
nzo->var->first = nzo->var_next;
if (nzo->var_prev != NULL)
nzo->var_prev->var_next = nzo->var_next;
if (nzo->var_next != NULL)
nzo->var_next->var_prev = nzo->var_prev;
nzo->var->size--;
/* Aus der Zeile nahmen
*/
if (nzo == nzo->con->first)
nzo->con->first = nzo->con_next;
if (nzo->con_prev != NULL)
nzo->con_prev->con_next = nzo->con_next;
if (nzo->con_next != NULL)
nzo->con_next->con_prev = nzo->con_prev;
nzo->con->size--;
/* Aus dem LP nehmen
*/
nzo->var_next = lp->next;
lp->next = nzo;
lp->nonzeros--;
assert(lps_valid(lp));
}
void lps_setval(
Nzo* nzo,
const mpq_t value)
{
assert(nzo != NULL);
mpq_set(nzo->value, value);
}
void lps_getval(
const Nzo* nzo,
mpq_t value)
{
assert(nzo != NULL);
mpq_set(value, nzo->value);
}
void lps_setdir(
Lps* lp,
LpDirect direct)
{
assert(lps_valid(lp));
lp->direct = direct;
}
void lps_setprobname(
Lps* lp,
const char* name)
{
assert(lp != NULL);
assert(name != NULL);
if (lp->probname != NULL)
free(lp->probname);
lp->probname = strdup(name);
}
void lps_setobjname(
Lps* lp,
const char* name)
{
assert(lp != NULL);
assert(name != NULL);
if (lp->objname != NULL)
free(lp->objname);
lp->objname = strdup(name);
}
void lps_setrhsname(
Lps* lp,
const char* name)
{
assert(lp != NULL);
assert(name != NULL);
if (lp->rhsname != NULL)
free(lp->rhsname);
lp->rhsname = strdup(name);
}
void lps_setbndname(
Lps* lp,
const char* name)
{
assert(lp != NULL);
assert(name != NULL);
if (lp->bndname != NULL)
free(lp->bndname);
lp->bndname = strdup(name);
}
void lps_setrngname(
Lps* lp,
const char* name)
{
assert(lp != NULL);
assert(name != NULL);
if (lp->rngname != NULL)
free(lp->rngname);
lp->rngname = strdup(name);
}
void lps_getcost(
const Var* var,
mpq_t cost)
{
assert(var != NULL);
assert(var->sid == VAR_SID);
mpq_set(cost, var->cost);
}
Bool lps_haslower(const Var* var)
{
assert(var != NULL);
assert(var->sid == VAR_SID);
return HAS_LOWER(var);
}
void lps_setcost(
Var* var,
const mpq_t cost)
{
assert(var != NULL);
assert(var->sid == VAR_SID);
mpq_set(var->cost, cost);
}
void lps_getlower(const Var* var, mpq_t lower)
{
assert(var != NULL);
assert(var->sid == VAR_SID);
mpq_set(lower, var->lower);
}
void lps_setlower(
Var* var,
const mpq_t lower)
{
assert(var != NULL);
assert(var->sid == VAR_SID);
mpq_set(var->lower, lower);
/* FREE -> LOWER
* LOWER -> LOWER
* UPPER -> BOXED/FIXED
* BOXED -> BOXED/FIXED
* FIXED -> BOXED/FIXED
*/
if (var->type == VAR_FREE)
var->type = VAR_LOWER;
else if (var->type != VAR_LOWER)
{
assert(var->type == VAR_UPPER || var->type == VAR_BOXED || var->type == VAR_FIXED);
var->type = mpq_equal(var->lower, var->upper) ? VAR_FIXED : VAR_BOXED;
}
}
Bool lps_hasupper(const Var* var)
{
assert(var != NULL);
assert(var->sid == VAR_SID);
return HAS_UPPER(var);
}
void lps_getupper(const Var* var, mpq_t upper)
{
assert(var != NULL);
assert(var->sid == VAR_SID);
mpq_set(upper, var->upper);
}
void lps_setupper(
Var* var,
const mpq_t upper)
{
assert(var != NULL);
assert(var->sid == VAR_SID);
mpq_set(var->upper, upper);
/* FREE -> LOWER
* LOWER -> LOWER
* UPPER -> BOXED/FIXED
* BOXED -> BOXED/FIXED
* FIXED -> BOXED/FIXED
*/
if (var->type == VAR_FREE)
var->type = VAR_UPPER;
else if (var->type != VAR_UPPER)
{
assert(var->type == VAR_LOWER || var->type == VAR_BOXED || var->type == VAR_FIXED);
var->type = mpq_equal(var->lower, var->upper) ? VAR_FIXED : VAR_BOXED;
}
}
void lps_setlhs(
Con* con,
const mpq_t lhs)
{
assert(con != NULL);
assert(con->sid == CON_SID);
mpq_set(con->lhs, lhs);
/* FREE -> LHS
* LHS -> LHS
* RHS -> RANGE/EQUAL
* RANGE -> RANGE/EQUAL
* EQUAL -> RANGE/EQUAL
*/
if (con->type == CON_FREE)
con->type = CON_LHS;
else if (con->type != CON_LHS)
{
assert(con->type == CON_RHS || con->type == CON_RANGE || con->type == CON_EQUAL);
con->type = mpq_equal(con->lhs, con->rhs) ? CON_EQUAL : CON_RANGE;
}
}
void lps_setrhs(
Con* con,
const mpq_t rhs)
{
assert(con != NULL);
assert(con->sid == CON_SID);
mpq_set(con->rhs, rhs);
/* FREE -> RHS
* RHS -> RHS
* LHS -> RANGE/EQUAL
* RANGE -> RANGE/EQUAL
* EQUAL -> RANGE/EQUAL
*/
if (con->type == CON_FREE)
con->type = CON_RHS;
else if (con->type != CON_RHS)
{
assert(con->type == CON_LHS || con->type == CON_RANGE || con->type == CON_EQUAL);
con->type = mpq_equal(con->lhs, con->rhs) ? CON_EQUAL : CON_RANGE;
}
}
void lps_setcontype( Con* con, ConType type)
{
assert(con != NULL);
assert(con->sid == CON_SID);
con->type = type;
}
ConType lps_contype(const Con* con)
{
assert(con != NULL);
assert(con->sid == CON_SID);
return con->type;
}
VarType lps_vartype(const Var* var)
{
assert(var != NULL);
assert(var->sid == VAR_SID);
return var->type;
}
VarClass lps_getclass(const Var *var)
{
assert(var != NULL);
assert(var->sid == VAR_SID);
return var->vclass;
}
void lps_setclass(Var *var, VarClass vclass)
{
assert(var != NULL);
assert(var->sid == VAR_SID);
var->vclass = vclass;
}
void lps_getlhs(
const Con* con,
mpq_t lhs)
{
assert(con != NULL);
assert(con->sid == CON_SID);
mpq_set(lhs, con->lhs);
}
void lps_getrhs(
const Con* con,
mpq_t rhs)
{
assert(con != NULL);
assert(con->sid == CON_SID);
mpq_set(rhs, con->rhs);
}
const char* lps_varname(const Var* var)
{
assert(var != NULL);
assert(var->sid == VAR_SID);
return var->name;
}
void lps_setvartype(
Var* var,
VarType type)
{
assert(var != NULL);
assert(var->sid == VAR_SID);
var->type = type;
}
unsigned int lps_flags(const Con* con)
{
assert(con != NULL);
assert(con->sid == CON_SID);
return con->flags;
}
void lps_addflags(
Con* con,
unsigned int flags)
{
assert(con != NULL);
assert(con->sid == CON_SID);
con->flags |= flags;
}
void lps_setscale(
Con* con,
const mpq_t scale)
{
assert(con != NULL);
assert(con->sid == CON_SID);
mpq_set(con->scale, scale);
}
void lps_setpriority(
Var* var,
int priority)
{
assert(var != NULL);
assert(var->sid == VAR_SID);
var->priority = priority;
}
void lps_setvalue(
Var* var,
const mpq_t value)
{
assert(var != NULL);
assert(var->sid == VAR_SID);
mpq_set(var->value, value);
}
void lps_setstartval(
Var* var,
const mpq_t startval)
{
assert(var != NULL);
assert(var->sid == VAR_SID);
mpq_set(var->startval, startval);
}
void lps_setnamelen(
Lps* lp,
int name_len)
{
lp->name_len = name_len;
}
void lps_setindicator(
Con* con,
Var* var,
Bool on_true)
{
assert(con != NULL);
assert(con->sid == CON_SID);
assert(var != NULL);
assert(var->sid == VAR_SID);
con->ind_var = var;
con->ind_dir = on_true;
}
void lps_stat(const Lps* lp)
{
assert(lps_valid(lp));
printf("Name: %s Variables: %d Constraints: %d Non Zeros: %d\n",
lp->name, lp->vars, lp->cons, lp->nonzeros);
}
int lps_getnamesize(const Lps* lp, LpFormat format)
{
int name_size = 0;
assert(lp != NULL);
switch(format)
{
case LP_FORM_LPF :
name_size = 1 + ((lp->name_len < MIN_NAME_LEN) ? LPF_NAME_LEN : lp->name_len);
break;
case LP_FORM_HUM :
name_size = 4096;
break;
case LP_FORM_MPS :
name_size = 1 + ((lp->name_len < MIN_NAME_LEN) ? MPS_NAME_LEN : lp->name_len);
break;
case LP_FORM_RLP :
name_size = 1 + ((lp->name_len < MIN_NAME_LEN) ? LPF_NAME_LEN : lp->name_len);
break;
case LP_FORM_PIP :
name_size = 1 + ((lp->name_len < MIN_NAME_LEN) ? PIP_NAME_LEN : lp->name_len);
break;
default :
abort();
}
assert(name_size > MIN_NAME_LEN);
return name_size;
}
void lps_write(
const Lps* lp,
FILE* fp,
LpFormat format,
const char* text)
{
assert(lp != NULL);
assert(fp != NULL);
lps_number(lp);
switch(format)
{
case LP_FORM_LPF :
case LP_FORM_RLP :
case LP_FORM_PIP :
case LP_FORM_HUM :
lpf_write(lp, fp, format, text);
break;
case LP_FORM_MPS :
mps_write(lp, fp, text);
break;
default :
abort();
}
}
static Bool lpfstrncpy(char* t, const char* s, int len)
{
/* '@' was excluded, to make sure the appendix is unique.
*/
static const char* const allowed = "!#$%&()/,.;?_{}|~";
Bool was_smashed = FALSE;
while(--len >= 0 && *s != '\0')
{
if (isalnum(*s) || strchr(allowed, *s) != NULL)
*t = *s;
else
{
*t = '_';
was_smashed = TRUE;
}
s++;
t++;
}
*t = '\0';
return was_smashed;
}
static void make_full_name(
char* target,
int size,
const char* name)
{
const char* s = name;
Bool first = TRUE;
Bool in_string = FALSE;
int i = 0;
assert(target != NULL);
assert(size >= MIN_NAME_LEN);
assert(name != NULL);
/* We allways start with a space
*/
while(*s != '\0' && size > i + 6)
{
if (*s != '#' && *s != '$')
target[i++] = *s;
else
{
if (first)
{
first = FALSE;
target[i++] = '[';
}
else
{
if (in_string)
{
target[i++] = '\"';
in_string = FALSE;
}
target[i++] = ',';
}
if (*s == '$')
{
assert(!in_string);
in_string = TRUE;
target[i++] = '\"';
}
}
assert(size >= i);
s++;
}
if (size > i + 2)
{
if (in_string)
target[i++] = '\"';
if (!first)
target[i++] = ']';
}
target[i++] = '\0';
assert(size >= i);
}
/* size has to be big enough to store a '@', a '\0'
* and the var or row number.
*/
void lps_makename(
char* target,
int size,
const char* name,
int no)
{
char temp[9];
int len;
int nlen;
assert(target != NULL);
assert(size > MIN_NAME_LEN); /* 8+1, so we have at least '@' + 7 digits + '\0' */
assert(name != NULL);
assert(no >= -1);
assert(no <= 0xFFFFFFF); /* 7 hex digits = 268,435,455 */
nlen = (int)strlen(name);
/* There are 3 possibilities:
*
* i) name is smaller than size and does not contain problematic chars
* -> just copy it.
* ii) as above but contains unvalid chars
* -> copy it, transform the chars to '_' and append "@varnum".
* iii) the name is longer than the size.
* -> do as in ii) but only copy as much chars as fit.
* iv) no == -1
* -> generate a full human readable name
*/
if (no == -1)
make_full_name(target, size, name);
else if (nlen < size)
{
if (lpfstrncpy(target, name, nlen))
{
sprintf(temp, "@%x", no);
len = size - (int)strlen(temp) - 1;
assert(len >= 0);
/* Trick: if len > strlen(target) it doesn't matter,
* lpfstrncmp always appends a '\0' and the strcat below
* will append temp at the right place.
* Otherwise it will be appended at len, which is the
* latest possible position.
*/
target[len] = '\0';
strcat(target, temp);
}
}
else
{
sprintf(temp, "@%x", no);
len = size - (int)strlen(temp) - 1; /* -1 for '\0' */
assert(len >= 0);
(void)lpfstrncpy(target, name, len);
strcat(target, temp);
}
assert(strlen(target) <= (size_t)size - 1);
}
void lps_transtable(const Lps* lp, FILE* fp, LpFormat format, const char* head)
{
Var* var;
Con* con;
char* temp;
int namelen;
assert(lps_valid(lp));
assert(fp != NULL);
assert(head != NULL);
assert(format == LP_FORM_LPF || format == LP_FORM_MPS || format == LP_FORM_RLP || format == LP_FORM_PIP);
namelen = lps_getnamesize(lp, format);
temp = malloc((size_t)namelen);
assert(temp != NULL);
lps_number(lp);
for(var = lp->var_root; var != NULL; var = var->next)
{
lps_makename(temp, namelen, var->name, var->number);
if (var->type == VAR_FIXED)
fprintf(fp, "%s\tv %7d\t%-*s\t\"%s\"\t%.16e\n",
head, var->number, namelen - 1, temp, var->name, mpq_get_d(var->lower));
else
{
if (var->size > 0 || !mpq_equal(var->cost, const_zero))
fprintf(fp, "%s\tv %7d\t%-*s\t\"%s\"\n",
head, var->number, namelen - 1, temp, var->name);
}
}
for(con = lp->con_root; con != NULL; con = con->next)
{
lps_makename(temp, namelen, con->name, con->number);
fprintf(fp, "%s\tc %7d\t%-*s\t\"%s\"\t%.16e\n",
head, con->number, namelen - 1, temp, con->name, mpq_get_d(con->scale));
}
free(temp);
}
void lps_scale(const Lps* lp)
{
Con* con;
Nzo* nzo;
mpq_t maxi;
mpq_t v;
assert(lps_valid(lp));
mpq_init(maxi);
mpq_init(v);
for(con = lp->con_root; con != NULL; con = con->next)
{
if ((con->flags & LP_FLAG_CON_SCALE) > 0)
{
mpq_set_ui(maxi, 0, 1); /* = 0 */
for(nzo = con->first; nzo != NULL; nzo = nzo->con_next)
{
mpq_abs(v, nzo->value);
if (mpq_cmp(v, maxi) > 0)
mpq_set(maxi, v);
}
mpq_inv(con->scale, maxi); /* scale = 1 / maxi */
if (HAS_RHS(con))
mpq_mul(con->rhs, con->rhs, con->scale);
if (HAS_LHS(con))
mpq_mul(con->lhs, con->lhs, con->scale);
for(nzo = con->first; nzo != NULL; nzo = nzo->con_next)
mpq_mul(nzo->value, nzo->value, con->scale);
}
}
mpq_clear(v);
mpq_clear(maxi);
}
Bool lps_has_sos(const Lps* lp)
{
assert(lps_valid(lp));
return lp->soss > 0;
}
Bool lps_con_sumup(const Con* con, mpq_t sum)
{
Bool usable = TRUE;
Nzo* nzo;
mpq_t val;
mpq_set_si(sum, 0, 1);
mpq_init(val);
for(nzo = con->first; nzo != NULL; nzo = nzo->con_next)
{
if (nzo->var->vclass != VAR_INT)
{
usable = FALSE;
break;
}
mpq_mul(val, nzo->value, nzo->var->startval);
mpq_add(sum, sum, val);
}
mpq_clear(val);
return usable;
}
/* ------------------------------------------------------------------------- */
/* Emacs Local Variables: */
/* Emacs mode:c */
/* Emacs c-basic-offset:3 */
/* Emacs tab-width:8 */
/* Emacs indent-tabs-mode:nil */
/* Emacs End: */
/* ------------------------------------------------------------------------- */
zimpl-3.3.4/src/xlpglue.c 0000640 0012352 0006025 00000041314 13057565713 015156 0 ustar bzfgamra optimi /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* File....: xlpglue.c */
/* Name....: LP Storage Interface */
/* Author..: Thorsten Koch */
/* Copyright by Author, All rights reserved */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Copyright (C) 2001-2017 by Thorsten Koch
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/**@file xlpglue.c
* @brief Mathematical Program Storage Interface
* @author Thorsten Koch
*
* The function defined in this file are the once that have to be implemented
* to hook Zimpl up as an reader in some other program. You have then to link
* the Zimpl library together with your xlpglue.c implementation.
*
* Please note one important point: While the lps, var, con, and user_data pointers are
* passed arround in these routines, they are never used themselves by Zimpl. It is the choice
* of the implementor of the xlpglue interface whether to use these, have the different or the
* same, or set the to NULL.
*/
#include
#include
#include
#include
#include
#include "lint.h"
#include "bool.h"
#include "mshell.h"
#include "ratlptypes.h"
#include "numb.h"
#include "elem.h"
#include "tuple.h"
#include "mme.h"
#include "bound.h"
#include "mono.h"
#include "term.h"
#include "ratlp.h"
#include "gmpmisc.h"
#include "conname.h"
#include "stmt.h"
#include "hash.h"
#include "xlpglue.h"
#ifdef _MSC_VER
#pragma warning (disable: 4100) /* unreferenced formal parameter */
#endif
/*lint -esym(818, lp) 'lp' could be declared as pointing to const */
static Bool use_startval = FALSE;
/** Allocate storage for the mathematical program instance generated by Zimpl.
* xlp_alloc() is the first xlpglue routine that will be called by Zimpl.
* The user_data pointer may hold an arbitray value.
*
* @return The pointer returned from xlp_alloc is passed to all other xlpglue
* routines, but never referenced by Zimpl itself. When implementing an
* xlpglue interface you may choose to pass the user_data pointer as the Lps
* pointer if it suits your needs.
*/
/*ARGSUSED*/
Lps* xlp_alloc(
const char* name, /**< Instance name, will appear e.g. in MPS NAME section */
Bool need_startval, /**< Will we supply starting values for the variables? */
UNUSED void* user_data) /**< Pointer with arbitrary data. */
{
assert(name != NULL);
use_startval = need_startval;
return lps_alloc(name);
}
/** Free storage for mathematical program.
* xlp_free() is the last xlpglue routine that will be called by Zimpl.
*/
void xlp_free(
Lps* lp) /**< Pointer to storage as given by xlp_alloc */
{
assert(lp != NULL);
lps_free(lp);
}
#if 0 /* not used anymore ??? */
/** Does the mathematical program have SOS constraints?
* @return True if there is at least one SOS constraint, False otherwise.
*/
Bool xlp_hassos(
const Lps* lp) /**< Pointer to storage */
{
assert(lp != NULL);
return lps_has_sos(lp);
}
#endif
/** Does there already exists a constraint with the given name?
* @return True if there is already a constraint with name conname, False
* otherwise.
*/
/*ARGSUSED*/
Bool xlp_conname_exists(
const Lps* lp, /**< Pointer to storage */
const char* conname) /**< Constraint name to check */
{
assert(lp != NULL);
assert(conname != NULL);
return NULL != lps_getcon(lp, conname);
}
/** Check if a constraint is violate by the given starting values.
* @return True if the constraint violates the start values, False
* otherwise.
*/
static Bool check_con_is_invalid(
const Con* con) /**< Pointer to a previous added constraint */
{
Bool is_invalid = FALSE;
mpq_t lhs;
mpq_t rhs;
mpq_t sum;
assert(con != NULL);
if (!use_startval)
return FALSE;
mpq_init(sum);
mpq_init(lhs);
mpq_init(rhs);
/* Get sum of coefficients time startval if usable
* (no continous variables)
*/
if (lps_con_sumup(con, sum))
{
lps_getlhs(con, lhs);
lps_getrhs(con, rhs);
switch(lps_contype(con))
{
case CON_RHS :
if (mpq_cmp(sum, rhs) > 0 && stmt_trigger_warning(215))
{
is_invalid = TRUE;
fprintf(stderr, "--- Warning 215: Startvals violate constraint, sum of LHS (%g) <= RHS (%g)\n",
mpq_get_d(sum), mpq_get_d(rhs));
}
break;
case CON_LHS :
if (mpq_cmp(lhs, sum) > 0 && stmt_trigger_warning(215))
{
is_invalid = TRUE;
fprintf(stderr, "--- Warning 215: Startvals violate constraint, sum of LHS (%g) >= RHS (%g)\n",
mpq_get_d(sum), mpq_get_d(lhs));
}
break;
case CON_EQUAL : /* In case of EQUAL, both should be equal */
if ((!mpq_equal(lhs, sum) || !mpq_equal(rhs, sum)) && stmt_trigger_warning(215))
{
is_invalid = TRUE;
fprintf(stderr, "--- Warning 215: Startvals violate constraint, sum of LHS (%g) == RHS (%g)\n",
mpq_get_d(sum), mpq_get_d(rhs));
}
break;
case CON_RANGE :
if ((mpq_cmp(sum, rhs) > 0 || mpq_cmp(lhs, sum) > 0) && stmt_trigger_warning(215))
{
is_invalid = TRUE;
fprintf(stderr, "--- Warning 215: Startvals violate range, LHS (%g) <= Sum (%g) <= RHS (%g)\n",
mpq_get_d(lhs), mpq_get_d(sum), mpq_get_d(rhs));
}
break;
default :
abort();
}
}
mpq_clear(sum);
mpq_clear(rhs);
mpq_clear(lhs);
return is_invalid;
}
/** Add a constraint.
* Add a given a Zimpl term together with a right and/or left hand side as
* a constraint to the mathematical program. The form is lhs <= term <= rhs.
* @return True if the constraint violates the given start values, False
* otherwise.
*/
Bool xlp_addcon_term(
Lps* lp, /**< Pointer to storage */
const char* name, /**< Name of the constraint */
ConType contype, /**< Type of constraint (LHS, RHS, EQUAL, RANGE, etc) */
const Numb* lhs, /**< lhs <= term. Not used if contype is CON_RHS */
const Numb* rhs, /**< term <= rhs. Not used if contype is CON_LHS */
unsigned int flags, /**< special treatment flags, see ratlptypes.h */
const Term* term_org) /**< term to use */
{
Term* term;
Con* con;
mpq_t tlhs;
mpq_t trhs;
int i;
assert(lp != NULL);
assert(name != NULL);
assert(lhs != NULL);
assert(rhs != NULL);
assert(term_is_valid(term_org));
assert(numb_equal(term_get_constant(term_org), numb_zero()));
term = term_simplify(term_org);
con = lps_addcon(lp, name);
assert(con != NULL);
mpq_init(tlhs);
mpq_init(trhs);
numb_get_mpq(rhs, trhs);
numb_get_mpq(lhs, tlhs);
switch(contype)
{
case CON_RHS :
lps_setrhs(con, trhs);
break;
case CON_LHS :
lps_setlhs(con, tlhs);
break;
case CON_EQUAL : /* In case of EQUAL, both should be equal */
assert(mpq_equal(tlhs, trhs));
/*lint -fallthrough*/
case CON_RANGE :
lps_setlhs(con, tlhs);
lps_setrhs(con, trhs);
break;
default :
abort();
}
lps_addflags(con, flags);
mpq_clear(trhs);
mpq_clear(tlhs);
if ((term_get_degree(term) > 2) || !term_is_polynomial(term))
lps_addterm(lp, con, term);
else
{
for(i = 0; i < term_get_elements(term); i++)
{
const Mono* mono = term_get_element(term, i);
Var* var = mono_get_var(mono, 0);
MFun mfun = mono_get_function(mono);
mpq_t val1;
if (mfun == MFUN_TRUE || mfun == MFUN_FALSE)
{
lps_setindicator(con, var, mfun == MFUN_TRUE);
continue;
}
assert(!numb_equal(mono_get_coeff(mono), numb_zero()));
mpq_init(val1);
numb_get_mpq(mono_get_coeff(mono), val1);
if (mono_is_linear(mono))
{
Nzo* nzo = lps_getnzo(lp, con, var);
if (nzo == NULL)
lps_addnzo(lp, con, var, val1);
else
{
mpq_t val2;
mpq_init(val2);
lps_getval(nzo, val2);
mpq_add(val1, val1, val2);
if (mpq_equal(val1, const_zero))
lps_delnzo(lp, nzo);
else
lps_setval(nzo, val1);
mpq_clear(val2);
}
}
else
{
assert(term_get_degree(term) == 2);
lps_addqme(lp, con, var, mono_get_var(mono, 1), val1);
}
mpq_clear(val1);
}
}
term_free(term);
return check_con_is_invalid(con);
}
/** Add a new variable to the mathematical program.
* @return Pointer to the variable. This is never dereferenced in Zimpl and
* my be an arbitrary pointer used to reference this particular
* variable.
*/
Var* xlp_addvar(
Lps* lp, /**< Pointer to storage */
const char* name, /**< Name of the variable */
VarClass varclass, /**< Class of the variable (Continous, Implicit, Integer) */
const Bound* lower, /**< Lower bound of the variable */
const Bound* upper, /**< Upper bound of the variable */
const Numb* priority, /**< Priority value of branching order */
const Numb* startval) /**< Start value. If equal numb_unknown() startval is undefined */
{
Var* var;
mpq_t temp;
assert(lp != NULL);
assert(name != NULL);
assert(lower != NULL);
assert(upper != NULL);
assert(priority != NULL);
assert(startval != NULL);
var = lps_addvar(lp, name);
lps_setclass(var, varclass);
mpq_init(temp);
if (bound_get_type(lower) == BOUND_VALUE)
{
numb_get_mpq(bound_get_value(lower), temp);
lps_setlower(var, temp);
}
if (bound_get_type(upper) == BOUND_VALUE)
{
numb_get_mpq(bound_get_value(upper), temp);
lps_setupper(var, temp);
}
if (numb_equal(startval, numb_unknown()))
numb_get_mpq(numb_zero(), temp);
else
numb_get_mpq(startval, temp);
lps_setstartval(var, temp);
numb_get_mpq(priority, temp);
/*lint -e{663} supress "Suspicious array to pointer conversion" */
if (mpz_get_si(mpq_denref(temp)) != 1)
if (verbose > VERB_QUIET)
fprintf(stderr, "--- Warning 301: variable priority has to be integral\n");
/*lint -e{663} supress "Suspicious array to pointer conversion" */
lps_setpriority(var, (int)mpz_get_si(mpq_numref(temp)));
mpq_clear(temp);
return var;
}
/** Add a SOS constraint.
* Add a given a Zimpl term as an SOS constraint to the mathematical program.
* @return 0 if everything is ok, 1 bit is set if not all of the weights are
* unique, 2 bit is set if the weights are not integer.
*/
int xlp_addsos_term(
Lps* lp, /**< Pointer to storage */
const char* name, /**< Name of the constraint */
SosType type, /**< Type of SOS (1, 2) */
const Numb* priority, /**< Priority value for constraint */
const Term* term) /**< Term to use */
{
Sos* sos;
mpq_t temp;
Hash* hash;
int i;
Bool has_duplicates = FALSE;
Bool has_nonintprio = FALSE;
assert(lp != NULL);
assert(name != NULL);
assert(priority != NULL);
assert(term_is_valid(term));
assert(numb_equal(term_get_constant(term), numb_zero()));
mpq_init(temp);
numb_get_mpq(priority, temp);
/*lint -e{663} supress "Suspicious array to pointer conversion" */
if (mpz_get_si(mpq_denref(temp)) != 1)
has_nonintprio = TRUE;
/*lint -e{663} supress "Suspicious array to pointer conversion" */
sos = lps_addsos(lp, name, type, (int)mpz_get_si(mpq_numref(temp)));
assert(sos != NULL);
hash = hash_new(HASH_NUMB, term_get_elements(term));
assert(hash != NULL);
for(i = 0; i < term_get_elements(term); i++)
{
const Mono* mono = term_get_element(term, i);
const Numb* coeff = mono_get_coeff(mono);
Var* var = mono_get_var(mono, 0);
assert(!numb_equal(coeff, numb_zero()));
assert(mono_is_linear(mono));
/* Each weight is allowed only once.
*/
if (hash_has_numb(hash, coeff))
has_duplicates = TRUE;
hash_add_numb(hash, coeff);
numb_get_mpq(coeff, temp);
lps_addsse(sos, var, temp);
}
hash_free(hash);
mpq_clear(temp);
return (has_duplicates ? 1 : 0) + (has_nonintprio ? 2 : 0);
}
/** Get name of variable.
* @return The name of the variable.
*/
/*ARGSUSED*/
const char* xlp_getvarname(
UNUSED const Lps* lp, /**< Pointer to storage */
const Var* var) /**< Pointer to variable as returned by xlp_addvar() */
{
assert(var != NULL);
return lps_varname(var);
}
/** Get the class of the variable.
* @return The class of the variable.
*/
/*ARGSUSED*/
VarClass xlp_getclass(
UNUSED const Lps* lp, /**< Pointer to storage */
const Var* var) /**< Pointer to variable as returned by xlp_addvar() */
{
assert(var != NULL);
return lps_getclass(var);
}
/** Get the lower bound of the variable.
* @return The lower bound of the variable.
*/
/*ARGSUSED*/
Bound* xlp_getlower(
UNUSED const Lps* lp, /**< Pointer to storage */
const Var* var) /**< Pointer to variable as returned by xlp_addvar() */
{
Bound* bound;
Numb* numb;
mpq_t lower;
assert(var != NULL);
if (!lps_haslower(var))
bound = bound_new(BOUND_MINUS_INFTY, numb_zero());
else
{
mpq_init(lower);
lps_getlower(var, lower);
numb = numb_new_mpq(lower);
bound = bound_new(BOUND_VALUE, numb);
numb_free(numb);
mpq_clear(lower);
}
return bound;
}
/** Get the upper bound of the variable.
* @return The upper bound of the variable.
*/
/*ARGSUSED*/
Bound* xlp_getupper(
UNUSED const Lps* lp, /**< Pointer to storage */
const Var* var) /**< Pointer to variable as returned by xlp_addvar() */
{
Bound* bound;
Numb* numb;
mpq_t upper;
assert(var != NULL);
if (!lps_hasupper(var))
bound = bound_new(BOUND_INFTY, numb_zero());
else
{
mpq_init(upper);
lps_getupper(var, upper);
numb = numb_new_mpq(upper);
bound = bound_new(BOUND_VALUE, numb);
numb_free(numb);
mpq_clear(upper);
}
return bound;
}
/** Set the name of the objective function.
*/
void xlp_objname(
Lps* lp, /**< Pointer to storage */
const char* name) /**< The name of the objective function */
{
assert(lp != NULL);
assert(name != NULL);
lps_setobjname(lp, name);
}
/** Set the direction of optimization, i.e. minimization or maximization.
*/
void xlp_setdir(
Lps* lp, /**< Pointer to storage */
Bool minimize) /**< True if the problem should be minimized, False if it should be maximized */
{
assert(lp != NULL);
lps_setdir(lp, minimize ? LP_MIN : LP_MAX);
}
/** Add to the objective value coefficient of a variable.
*/
/*ARGSUSED*/
void xlp_addtocost(
UNUSED Lps* lp, /**< Pointer to storage */
Var* var, /**< Pointer to variable as returned by xlp_addvar() */
const Numb* cost) /**< Value to be added to the objective coefficient of the variable */
{
mpq_t val1;
mpq_t val2;
assert(var != NULL);
assert(cost != NULL);
mpq_init(val1);
mpq_init(val2);
lps_getcost(var, val1);
numb_get_mpq(cost, val2);
mpq_add(val1, val1, val2);
lps_setcost(var, val1);
mpq_clear(val1);
mpq_clear(val2);
}
zimpl-3.3.4/src/stkchk.h 0000640 0012352 0006025 00000004270 13057565713 014772 0 ustar bzfgamra optimi /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* File....: stkchk.h */
/* Name....: Stack usage checker */
/* Author..: Thorsten Koch */
/* Copyright by Author, All rights reserved */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Copyright (C) 2011-2017 by Thorsten Koch
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _STKCHK_H_
#define _STKCHK_H_
#ifdef __cplusplus
extern "C" {
#endif
#ifndef NDEBUG
extern const void* stkchk_start;
extern size_t stkchk_maxi;
extern void stkchk_init_x(void);
extern size_t stkchk_used_x(void);
/*lint -sem( stkchk_maximum_x, 1p) */
extern void stkchk_maximum_x(FILE* fp);
/*lint -sem( stkchk_display_x, 1p) */
extern void stkchk_display_x(FILE* fp);
#define stkchk_init() stkchk_init_x()
#define stkchk_used() stkchk_used_x()
#define stkchk_display(fp) stkchk_display_x(fp)
#define stkchk_maximum(fp) stkchk_maximum_x(fp)
#else
#define stkchk_init() /**/
#define stkchk_used() /**/
#define stkchk_display(fp) /**/
#define stkchk_maximum(fp) /**/
#endif /* NDEBUG */
#ifdef __cplusplus
}
#endif
#endif /* _STKCHK_H_ */
zimpl-3.3.4/src/ratmpswrite.c 0000640 0012352 0006025 00000022770 13057565713 016064 0 ustar bzfgamra optimi /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* File....: mpswrite.c */
/* Name....: MPS File Write */
/* Author..: Thorsten Koch */
/* Copyright by Author, All rights reserved */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Copyright (C) 2001-2017 by Thorsten Koch
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include
#include
#include
#include
#include
#include
#include "lint.h"
#include "mshell.h"
#include "bool.h"
#include "gmpmisc.h"
#include "ratlptypes.h"
#include "numb.h"
#include "bound.h"
#include "mme.h"
#include "mono.h"
#include "term.h"
#include "ratlp.h"
#include "ratlpstore.h"
static void write_data(
FILE* fp,
Bool use_field5,
const int indicator1,
const int indicator2,
const char* name1,
const char* name2,
const mpq_t value)
{
assert(name1 != NULL);
assert(name2 != NULL);
if (use_field5)
{
/* Field: 1 2 3 4 5 6
* Columns: 2-3 5-12 15-22 25-36 40-47 50-61
* 1 2 3 4 5 6
* 1234567890123456789012345678901234567890123456789012345678901234567890
* -AB-NNNNNNNN--NNNNNNNN--FFFFFFFFFFFF
* x$SE@5b2 c1_718 45.786
*/
fprintf(fp, " %c%c %-8.8s %-8.8s %12g\n",
toupper(indicator1), toupper(indicator2), name1, name2, mpq_get_d(value));
}
else
{
fprintf(fp, " %c%c %-8.8s %-8.8s\n",
toupper(indicator1), toupper(indicator2), name1, name2);
}
}
static void write_vars(
const Lps* lp,
FILE* fp,
VarClass varclass,
int name_size)
{
static Bool first = TRUE;
const Var* var;
const Nzo* nzo;
char* vtmp;
char* ctmp;
mpq_t temp;
assert(lp != NULL);
assert(fp != NULL);
vtmp = malloc((size_t)name_size);
ctmp = malloc((size_t)name_size);
assert(vtmp != NULL);
assert(ctmp != NULL);
mpq_init(temp);
for(var = lp->var_root; var != NULL; var = var->next)
{
if (var->vclass != varclass)
continue;
/* Only variables with a cost not equal zero, need to be included
* in the objective function
*/
if (!mpq_equal(var->cost, const_zero))
{
lps_makename(vtmp, name_size, var->name, var->number);
if (lp->direct == LP_MIN)
mpq_set(temp, var->cost);
else
{
mpq_neg(temp, var->cost);
if (first)
{
if (verbose > 0)
{
fprintf(stderr, "%s\n%s\n",
"--- Warning: Objective function inverted to make",
" minimization problem for MPS output\n");
}
first = FALSE;
}
}
write_data(fp, TRUE, ' ', ' ', vtmp, "OBJECTIV", temp);
}
for(nzo = var->first; nzo != NULL; nzo = nzo->var_next)
{
assert(nzo->var == var);
assert(!mpq_equal(nzo->value, const_zero));
lps_makename(vtmp, name_size, var->name, var->number);
lps_makename(ctmp, name_size, nzo->con->name, nzo->con->number);
write_data(fp, TRUE, ' ', ' ', vtmp, ctmp, nzo->value);
}
}
mpq_clear(temp);
free(vtmp);
free(ctmp);
}
void mps_write(
const Lps* lp,
FILE* fp,
const char* text)
{
const Var* var;
const Con* con;
int indicator;
Bool has_ranges = FALSE;
int name_size;
char* vtmp;
char* ctmp;
mpq_t temp;
assert(lp != NULL);
assert(fp != NULL);
name_size = lps_getnamesize(lp, LP_FORM_MPS);
vtmp = malloc((size_t)name_size);
ctmp = malloc((size_t)name_size);
assert(vtmp != NULL);
assert(ctmp != NULL);
mpq_init(temp);
if (text != NULL)
fprintf(fp, "%s", text);
fprintf(fp, "NAME %8.8s\n", lp->name);
fprintf(fp, "ROWS\n");
write_data(fp, FALSE, 'N', ' ', "OBJECTIV", "", const_zero);
for(con = lp->con_root; con != NULL; con = con->next)
{
if (con->size > 0)
{
lps_makename(ctmp, name_size, con->name, con->number);
switch(lps_contype(con))
{
case CON_EQUAL:
indicator = 'E';
break;
case CON_LHS:
indicator = 'G';
break;
case CON_RHS:
indicator = 'L';
break;
case CON_RANGE:
indicator = 'E';
has_ranges = TRUE;
break;
default :
abort();
}
write_data(fp, FALSE, indicator, ' ', ctmp, "", const_zero);
}
}
fprintf(fp, "COLUMNS\n");
/* First integer/binary variables
*/
#if 0 /* ??? Would be nice if known in advance */
if (lp->type != LP_LP)
#endif
{
fprintf(fp, " MARK0000 'MARKER' 'INTORG'\n");
write_vars(lp, fp, VAR_INT, name_size);
fprintf(fp, " MARK0001 'MARKER' 'INTEND'\n");
}
write_vars(lp, fp, VAR_CON, name_size);
write_vars(lp, fp, VAR_IMP, name_size);
fprintf(fp, "RHS\n");
for(con = lp->con_root; con != NULL; con = con->next)
{
lps_makename(ctmp, name_size, con->name, con->number);
switch(lps_contype(con))
{
case CON_EQUAL:
if (!mpq_equal(con->rhs, const_zero))
write_data(fp, TRUE, ' ', ' ', "RHS", ctmp, con->rhs);
break;
case CON_LHS:
if (!mpq_equal(con->lhs, const_zero))
write_data(fp, TRUE, ' ', ' ', "RHS", ctmp, con->lhs);
break;
case CON_RHS:
if (!mpq_equal(con->rhs, const_zero))
write_data(fp, TRUE, ' ', ' ', "RHS", ctmp, con->rhs);
break;
case CON_RANGE:
if (!mpq_equal(con->lhs, const_zero))
write_data(fp, TRUE, ' ', ' ', "RHS", ctmp, con->lhs);
break;
default :
abort();
}
}
if (has_ranges)
{
fprintf(fp, "RANGES\n");
for(con = lp->con_root; con != NULL; con = con->next)
{
if (lps_contype(con) == CON_RANGE)
{
lps_makename(ctmp, name_size, con->name, con->number);
/* lhs > rhs => temp is positive
* range is lhs <= x <= lhs + temp = rhs
*/
mpq_sub(temp, con->rhs, con->lhs);
assert(!mpq_equal(temp, const_zero));
write_data(fp, TRUE, ' ', ' ', "RNG", ctmp, temp);
}
}
}
fprintf(fp, "BOUNDS\n");
/* Variables with size == 0, have to be included because
* they might contain bounds. Detailed checking should
* be done in a preprocessing routine.
*/
for(var = lp->var_root; var != NULL; var = var->next)
{
/* A variable without any entries in the matrix
* or the objective function can be ignored.
* If we have SOS we do not know and include it.
*/
if (var->size == 0 && mpq_equal(var->cost, const_zero) && !lps_has_sos(lp))
continue;
/* 0, oo -> nix
* l, oo -> LO
* 0, u -> UP
* l = u -> FX
* -oo -> MI
* oo -> PL
*/
lps_makename(vtmp, name_size, var->name, var->number);
if (var->type == VAR_FIXED)
write_data(fp, TRUE, 'F', 'X', "BOUND", vtmp, var->lower);
else
{
if (var->type == VAR_LOWER || var->type == VAR_BOXED)
write_data(fp, TRUE, 'L', 'O', "BOUND", vtmp, var->lower);
else
write_data(fp, FALSE, 'M', 'I', "BOUND", vtmp, const_zero);
if (var->type == VAR_UPPER || var->type == VAR_BOXED)
write_data(fp, TRUE, 'U', 'P', "BOUND", vtmp, var->upper);
else
write_data(fp, FALSE, 'P', 'L', "BOUND", vtmp, const_zero);
}
}
if (lps_has_sos(lp))
{
const Sos* sos;
const Sse* sse;
fprintf(fp, "SOS\n");
for(sos = lp->sos_root; sos != NULL; sos = sos->next)
{
write_data(fp, FALSE, 'S', sos->type == SOS_TYPE1 ? '1' : '2', sos->name, "", const_zero);
for (sse = sos->first; sse != NULL; sse = sse->next)
{
lps_makename(vtmp, name_size, sse->var->name, sse->var->number);
write_data(fp, TRUE, ' ', ' ', "", vtmp, sse->weight);
}
}
}
fprintf(fp, "ENDATA\n");
mpq_clear(temp);
free(vtmp);
free(ctmp);
}
zimpl-3.3.4/src/ratpresolve.c 0000640 0012352 0006025 00000037453 13057565713 016055 0 ustar bzfgamra optimi /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* File....: lpstore.c */
/* Name....: Store Linear Programm */
/* Author..: Thorsten Koch */
/* Copyright by Author, All rights reserved */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Copyright (C) 2003-2017 by Thorsten Koch
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#if 0 /* Not used anymore ??? */
#include
#include
#include
#include
#include
#include
#include "lint.h"
#include "mshell.h"
#include "bool.h"
#include "gmpmisc.h"
#include "ratlptypes.h"
#include "numb.h"
#include "bound.h"
#include "mme.h"
#include "mono.h"
#include "term.h"
#include "ratlp.h"
#include "ratlpstore.h"
/*lint -e{818} supress "Pointer parameter 'var' could be declared as pointing to const" */
static void remove_fixed_var(
Lps* lp,
Var* var,
int verbose_level)
{
Nzo* nzo;
mpq_t x;
mpq_t temp;
Bool is_zero;
assert(lp != NULL);
assert(var != NULL);
assert(var->type == VAR_FIXED && mpq_equal(var->lower, var->upper));
if (verbose_level > 0)
printf("Removing variable %s fixed to %g\n", var->name, mpq_get_d(var->lower));
mpq_init(x);
mpq_init(temp);
is_zero = mpq_equal(var->lower, x /* zero */);
while(var->first != NULL)
{
nzo = var->first;
/* Do we have to ajust the lhs/rhs ?
*/
if (!is_zero)
{
mpq_mul(x, var->lower, nzo->value);
/* do we have a valid rhs ?
*/
if (HAS_RHS(nzo->con))
{
mpq_sub(temp, nzo->con->rhs, x);
lps_setrhs(nzo->con, temp);
}
/* do we have a valid lhs ?
*/
if (HAS_LHS(nzo->con))
{
mpq_sub(temp, nzo->con->lhs, x);
lps_setlhs(nzo->con, temp);
}
}
lps_delnzo(lp, nzo);
}
mpq_clear(temp);
mpq_clear(x);
}
static PSResult simple_rows(
Lps* lp,
Bool* again,
int verbose_level)
{
Bool have_up;
Bool have_lo;
mpq_t up;
mpq_t lo;
Nzo* nzo;
Var* var;
Con* con;
Con* con_next;
int rem_rows = 0;
int rem_nzos = 0;
mpq_init(up);
mpq_init(lo);
for(con = lp->con_root; con != NULL; con = con_next)
{
con_next = con->next;
/* infeasible range row
*/
if (con->type == CON_RANGE && mpq_cmp(con->lhs, con->rhs) > 0)
{
printf("Infeasible range row %s lhs=%g rhs=%g\n",
con->name, mpq_get_d(con->lhs), mpq_get_d(con->rhs));
return PRESOLVE_INFEASIBLE;
}
/* empty row ?
*/
if (con->size == 0)
{
if ( (HAS_RHS(con) && mpq_cmp(con->rhs, const_zero) < 0)
|| (HAS_LHS(con) && mpq_cmp(con->lhs, const_zero) > 0))
{
printf("Infeasible empty row %s lhs=%g rhs=%g\n",
con->name, mpq_get_d(con->lhs), mpq_get_d(con->rhs));
return PRESOLVE_INFEASIBLE;
}
if (verbose_level > 0)
printf("Empty row %s removed\n", con->name);
lps_delcon(lp, con);
rem_rows++;
continue;
}
/* unconstraint constraint
*/
if (con->type == CON_FREE)
{
if (verbose_level > 0)
printf("Unconstraint row %s removed\n", con->name);
rem_rows++;
rem_nzos += con->size;
lps_delcon(lp, con);
continue;
}
/* row singleton
*/
if (con->size == 1)
{
have_up = FALSE;
have_lo = FALSE;
nzo = con->first;
var = nzo->var;
if (mpq_cmp(nzo->value, const_zero) > 0) /* x > 0 */
{
if (HAS_RHS(con))
{
mpq_div(up, con->rhs, nzo->value);
have_up = TRUE;
}
if (HAS_LHS(con))
{
mpq_div(lo, con->lhs, nzo->value);
have_lo = TRUE;
}
}
else if (mpq_cmp(nzo->value, const_zero) < 0) /* x < 0 */
{
if (HAS_RHS(con))
{
mpq_div(lo, con->rhs, nzo->value);
have_lo = TRUE;
}
if (HAS_LHS(con))
{
mpq_div(up, con->lhs, nzo->value);
have_up = TRUE;
}
}
else if ((HAS_RHS(con) && !mpq_equal(con->rhs, const_zero))
|| (HAS_LHS(con) && !mpq_equal(con->lhs, const_zero)))
{
/* x == 0 rhs/lhs != 0 */
printf("Infeasibel row %s Zero row singleton with non zero lhs or rhs\n",
con->name);
return PRESOLVE_INFEASIBLE;
}
assert(!HAS_LOWER(var) || !HAS_UPPER(var) || mpq_cmp(var->lower, var->upper) <= 0);
if (have_up && (!HAS_UPPER(var) || mpq_cmp(up, var->upper) < 0))
lps_setupper(var, up);
if (have_lo && (!HAS_LOWER(var) || mpq_cmp(lo, var->lower) > 0))
lps_setlower(var, lo);
if (HAS_LOWER(var) && HAS_UPPER(var) && mpq_cmp(var->lower, var->upper) > 0)
{
printf("Row %s implise infeasible bounds on var %s, lower=%g upper=%g\n",
con->name, var->name, mpq_get_d(var->lower), mpq_get_d(var->upper));
return PRESOLVE_INFEASIBLE;
}
if (verbose_level > 1)
printf("Row %s singleton var %s set to lower=%g upper=%g\n",
con->name, var->name, mpq_get_d(var->lower), mpq_get_d(var->upper));
rem_rows++;
rem_nzos++;
lps_delcon(lp, con);
continue;
}
}
assert(rem_rows != 0 || rem_nzos == 0);
if (rem_rows > 0)
{
*again = TRUE;
if (verbose_level > 0)
printf("Simple row presolve removed %d rows and %d non-zeros\n",
rem_rows, rem_nzos);
}
mpq_clear(up);
mpq_clear(lo);
return PRESOLVE_OKAY;
}
static PSResult handle_col_singleton(
Lps* lp,
Var* var,
int verbose_level,
int* rem_cols,
int* rem_nzos)
{
Nzo* nzo;
Con* con;
int cmpres;
mpq_t maxobj;
assert(lp != NULL);
assert(var != NULL);
assert(verbose_level >= 0);
assert(rem_cols != NULL);
assert(rem_nzos != NULL);
nzo = var->first;
con = nzo->con;
assert(!mpq_equal(nzo->value, const_zero));
mpq_init(maxobj);
mpq_set(maxobj, var->cost);
if (lp->direct == LP_MIN)
mpq_neg(maxobj, maxobj);
/* Value is positive
*/
if (mpq_cmp(nzo->value, const_zero) > 0.0)
{
/* max -3 x
* s.t. 5 x (<= 8)
* l <= x
*
* and we have NO lhs, (rhs does not matter)
*/
if (!HAS_LHS(con))
{
cmpres = mpq_cmp(maxobj, const_zero);
/* The objective is either zero or negative
*/
if (cmpres <= 0)
{
/* If we have no lower bound
*/
if (!HAS_LOWER(var))
{
/* ... but a negative objective, so we get unbounded
*/
if (cmpres < 0)
{
printf("Unbounded var %s\n", var->name);
return PRESOLVE_UNBOUNDED;
}
/* With a zero objective and no bounds, there is not
* much we can do.
*/
}
else
{
/* now we know we want to go to the lower bound.
*/
lps_setupper(var, var->lower);
remove_fixed_var(lp, var, verbose_level);
(*rem_cols)++;
(*rem_nzos)++;
return PRESOLVE_OKAY;
}
}
}
/* max 3 x
* s.t. 5 x (>= 8)
* x <= u
*
* and we have NO rhs, (lhs does not matter)
*/
if (!HAS_RHS(con))
{
cmpres = mpq_cmp(maxobj, const_zero);
/* The objective is either zero or positive
*/
if (cmpres >= 0)
{
/* If we have no upper bound
*/
if (!HAS_UPPER(var))
{
/* ... but a positive objective, so we get unbounded
*/
if (cmpres > 0)
{
printf("Unbounded var %s\n", var->name);
return PRESOLVE_UNBOUNDED;
}
/* With a zero objective and no bounds, there is not
* much we can do.
*/
}
else
{
/* now we know we want to go to the upper bound.
*/
lps_setlower(var, var->upper);
remove_fixed_var(lp, var, verbose_level);
(*rem_cols)++;
(*rem_nzos)++;
return PRESOLVE_OKAY;
}
}
}
}
else
{
/* Value is negative
*/
assert(mpq_cmp(nzo->value, const_zero) < 0.0);
/* max -3 x
* s.t. -5 x (>= 8)
* l <= x
*/
if (!HAS_RHS(con))
{
cmpres = mpq_cmp(maxobj, const_zero);
if (cmpres <= 0)
{
if (!HAS_LOWER(var))
{
if (cmpres < 0)
{
printf("Unbounded var %s\n", var->name);
return PRESOLVE_UNBOUNDED;
}
}
else
{
lps_setupper(var, var->lower);
remove_fixed_var(lp, var, verbose_level);
(*rem_cols)++;
(*rem_nzos)++;
return PRESOLVE_OKAY;
}
}
}
/* max 3 x
* s.t. -5 x (<= 8)
* x <= u
*/
if (!HAS_LHS(con))
{
cmpres = mpq_cmp(maxobj, const_zero);
if (cmpres >= 0)
{
if (!HAS_UPPER(var))
{
if (cmpres > 0)
{
printf("Unbounded var %s\n", var->name);
return PRESOLVE_UNBOUNDED;
}
}
else
{
lps_setlower(var, var->upper);
remove_fixed_var(lp, var, verbose_level);
(*rem_cols)++;
(*rem_nzos)++;
return PRESOLVE_OKAY;
}
}
}
}
mpq_clear(maxobj);
return PRESOLVE_OKAY;
}
static PSResult simple_cols(
Lps* lp,
Bool* again,
int verbose_level)
{
PSResult res;
mpq_t maxobj;
int rem_cols = 0;
int rem_nzos = 0;
Var* var;
mpq_init(maxobj);
for(var = lp->var_root; var != NULL; var = var->next)
{
if (var->type == VAR_FIXED && var->size == 0)
continue;
/* Empty column ?
*/
if (var->size == 0)
{
mpq_set(maxobj, var->cost);
if (lp->direct == LP_MIN)
mpq_neg(maxobj, maxobj);
if (mpq_cmp(maxobj, const_zero) > 0)
{
/* Do we not have an upper bound ?
*/
if (!HAS_UPPER(var))
{
printf("Var %s unbounded\n", var->name);
return PRESOLVE_UNBOUNDED;
}
lps_setlower(var, var->upper);
}
else if (mpq_cmp(maxobj, const_zero) < 0)
{
/* Do we not have an lower bound ?
*/
if (!HAS_LOWER(var))
{
printf("Var %s unbounded\n", var->name);
return PRESOLVE_UNBOUNDED;
}
lps_setupper(var, var->lower);
}
else
{
assert(mpq_equal(maxobj, const_zero));
/* any value within the bounds is ok
*/
if (HAS_LOWER(var))
lps_setupper(var, var->lower);
else if (HAS_UPPER(var))
lps_setlower(var, var->upper);
else
{
lps_setlower(var, const_zero);
lps_setupper(var, const_zero);
}
}
if (verbose_level > 1)
printf("Empty var %s fixed\n", var->name);
rem_cols++;
continue;
}
/* infeasible bounds ?
*/
if (var->type == VAR_BOXED && mpq_cmp(var->lower, var->upper) > 0)
{
printf("Var %s infeasible bounds lower=%g upper=%g\n",
var->name, mpq_get_d(var->lower), mpq_get_d(var->upper));
return PRESOLVE_INFEASIBLE;
}
/* Fixed column ?
*/
if (var->type == VAR_FIXED)
{
assert(var->size > 0);
rem_cols++;
rem_nzos += var->size;
remove_fixed_var(lp, var, verbose_level);
continue;
}
/* Column singleton
*/
if (var->size == 1)
{
res = handle_col_singleton(lp, var, verbose_level, &rem_cols, &rem_nzos);
if (res != PRESOLVE_OKAY)
return res;
}
}
assert(rem_cols != 0 || rem_nzos == 0);
if (rem_cols > 0)
{
*again = TRUE;
if (verbose_level > 0)
printf("Simple col presolve removed %d cols and %d non-zeros\n",
rem_cols, rem_nzos);
}
mpq_clear(maxobj);
return PRESOLVE_OKAY;
}
PSResult lps_presolve(Lps* lp, int verbose_level)
{
PSResult ret = PRESOLVE_OKAY;
Bool again;
/*
Bool rcagain;
Bool rragain;
*/
do
{
again = FALSE;
if (ret == PRESOLVE_OKAY)
ret = simple_rows(lp, &again, verbose_level);
if (ret == PRESOLVE_OKAY)
ret = simple_cols(lp, &again, verbose_level);
assert(ret == PRESOLVE_OKAY || again == FALSE);
}
while(again);
#if 0
if (ret == OKAY)
ret = redundantCols(lp, rcagain);
if (ret == OKAY)
ret = redundantRows(lp, rragain);
again = (ret == OKAY) && (rcagain || rragain);
/* This has to be a loop, otherwise we could end up with
* empty rows.
*/
while(again)
{
again = false;
if (ret == OKAY)
ret = simpleRows(lp, again);
if (ret == OKAY)
ret = simpleCols(lp, again);
assert(ret == OKAY || again == false);
}
VERBOSE1({ std::cout << "IREDSM25 redundant simplifier removed "
<< m_remRows << " rows, "
<< m_remNzos << " nzos, changed "
<< m_chgBnds << " col bounds "
<< m_chgLRhs << " row bounds,"
<< std::endl; });
#endif
/* ??? does not work, because vars are not deleted */
if (lp->vars == 0 || lp->cons == 0)
{
/* ??? Check if this is ok.
*/
assert(lp->vars == 0 && lp->cons == 0);
printf("Simplifier removed all variables and constraints\n");
ret = PRESOLVE_VANISHED;
}
return ret;
}
#endif
zimpl-3.3.4/src/code.h 0000640 0012352 0006025 00000027552 13057565713 014425 0 ustar bzfgamra optimi /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* File....: code.h */
/* Name....: Code Functions */
/* Author..: Thorsten Koch */
/* Copyright by Author, All rights reserved */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Copyright (C) 2001-2017 by Thorsten Koch
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _CODE_H_
#define _CODE_H_
#ifndef _BOOL_H_
#error "Need to include bool.h before code.h"
#endif
#ifndef _RATLPTYPES_H_
#error "Need to include ratlptypes.h before code.h"
#endif
#ifndef _MME_H_
#error "Need to include mme.h before code.h"
#endif
#ifdef __cplusplus
extern "C" {
#endif
/*lint -sem( code_new_inst, 1p == 1 && 2n >= 0, @p == 1) */
extern CodeNode* code_new_inst(Inst inst, int childs, ...);
/*lint -sem( code_new_numb, custodial(1), 1p == 1, @p == 1) */
extern CodeNode* code_new_numb(Numb* numb);
/*lint -sem( code_new_strg, nulterm(1), 1p, @p == 1) */
extern CodeNode* code_new_strg(const char* strg);
/*lint -sem( code_new_name, nulterm(1), 1p, @p == 1) */
extern CodeNode* code_new_name(const char* name);
/*lint -sem( code_new_size, @p == 1) */
extern CodeNode* code_new_size(int size);
/*lint -sem( code_new_varclass, @p == 1) */
extern CodeNode* code_new_varclass(VarClass varclass);
/*lint -sem( code_new_contype, @p == 1) */
extern CodeNode* code_new_contype(ConType contype);
/*lint -sem( code_new_bits, @p == 1) */
extern CodeNode* code_new_bits(unsigned int bits);
/*lint -sem( code_new_symbol, @p == 1) */
extern CodeNode* code_new_symbol(Symbol* sym);
/*lint -sem( code_new_define, @p == 1) */
extern CodeNode* code_new_define(Define* def);
/*lint -sem( code_new_bound, @p == 1) */
extern CodeNode* code_new_bound(BoundType type);
/*lint -sem( code_free, custodial(1), 1p == 1) */
extern void code_free(CodeNode* node);
/*lint -sem( code_free_value, @p == 1) */
extern void code_free_value(CodeNode* node);
/*lint -sem( code_is_valid, 1p == 1) */
extern Bool code_is_valid(const CodeNode* node);
/*lint -sem( code_get_type, 1p == 1) */
extern CodeType code_get_type(const CodeNode* node);
/*lint -sem( code_get_inst, 1p == 1, @p) */
extern Inst code_get_inst(const CodeNode* node);
/*lint -sem( code_set_root, custodial(1), 1p == 1) */
extern void code_set_root(CodeNode* node);
/*lint -sem( code_get_root, @p == 1) */
extern CodeNode* code_get_root(void);
/*lint -sem( code_set_child, custodial(3), 1p == 1 && 2n >= 0 && 3p == 1) */
extern void code_set_child(CodeNode* node, int idx, CodeNode* child);
/*lint -sem( code_errmsg, 1p == 1) */
extern void code_errmsg(const CodeNode* node);
#if 0
/*lint -sem( code_check_type, 1p == 1, @p == 1p) */
extern CodeNode* code_check_type(CodeNode* node, CodeType expected);
#endif
/*lint -sem( code_eval, 1p == 1, @p == 1p) */
extern CodeNode* code_eval(CodeNode* node);
/*lint -sem( code_prune_tree, 1p == 1) */
extern Bool code_prune_tree(CodeNode* node);
/*lint -sem( code_get_child, 1p == 1 && 2n >= 0, @p == 1) */
extern CodeNode* code_get_child(const CodeNode* node, int no);
/*lint -sem( code_get_numb, 1p == 1) */
extern const Numb* code_get_numb(CodeNode* node);
/*lint -sem( code_get_strg, 1p == 1, @p && nulterm(@)) */
extern const char* code_get_strg(CodeNode* node);
/*lint -sem( code_get_name, 1p == 1, @p && nulterm(@)) */
extern const char* code_get_name(CodeNode* node);
extern unsigned int code_get_inst_count(void);
/*lint -sem( code_get_tuple, 1p == 1, @p == 1) */
extern void code_clear_inst_count(void);
extern const Tuple* code_get_tuple(CodeNode* node);
/*lint -sem( code_get_set, 1p == 1, @p == 1) */
extern const Set* code_get_set(CodeNode* node);
/*lint -sem( code_get_idxset, 1p == 1, @p == 1) */
extern const IdxSet* code_get_idxset(CodeNode* node);
/*lint -sem( code_get_entry, 1p == 1, @p == 1) */
extern const Entry* code_get_entry(CodeNode* node);
/*lint -sem( code_get_term, 1p == 1, @p == 1) */
extern const Term* code_get_term(CodeNode* node);
/*lint -sem( code_get_size, 1p == 1) */
extern int code_get_size(CodeNode* node);
/*lint -sem( code_get_bool, 1p == 1) */
extern Bool code_get_bool(CodeNode* node);
/*lint -sem( code_get_list, 1p == 1, @p == 1) */
extern const List* code_get_list(CodeNode* node);
/*lint -sem( code_get_varclass, 1p == 1) */
extern VarClass code_get_varclass(CodeNode* node);
/*lint -sem( code_get_contype, 1p == 1) */
extern ConType code_get_contype(CodeNode* node);
/*lint -sem( code_get_rdef, 1p == 1, @p == 1) */
extern const RDef* code_get_rdef(CodeNode* node);
/*lint -sem( code_get_rpar, 1p == 1, @p == 1) */
extern const RPar* code_get_rpar(CodeNode* node);
/*lint -sem( code_get_bits, 1p == 1) */
extern unsigned int code_get_bits(CodeNode* node);
/*lint -sem( code_get_symbol, 1p == 1) */
extern Symbol* code_get_symbol(CodeNode* node);
/*lint -sem( code_get_define, 1p == 1) */
extern Define* code_get_define(CodeNode* node);
/*lint -sem( code_get_bound, 1p == 1) */
extern const Bound* code_get_bound(CodeNode* node);
/*lint -sem( code_value_numb, custodial(2), 1p == 1) */
extern void code_value_numb(CodeNode* node, Numb* numb);
/*lint -sem( code_value_strg, nulterm(2), 1p == 1 && 2p) */
extern void code_value_strg(CodeNode* node, const char* strg);
/*lint -sem( code_value_name, nulterm(2), 1p == 1 && 2p) */
extern void code_value_name(CodeNode* node, const char* name);
/*lint -sem( code_value_tuple, custodial(2), 1p == 1 && 2p == 1) */
extern void code_value_tuple(CodeNode* node, Tuple* tuple);
/*lint -sem( code_value_set, custodial(2), 1p == 1 && 2p == 1) */
extern void code_value_set(CodeNode* node, Set* set);
/*lint -sem( code_value_idxset, custodial(2), 1p == 1 && 2p == 1) */
extern void code_value_idxset(CodeNode* node, IdxSet* idxset);
/*lint -sem( code_value_entry, custodial(2), 1p == 1 && 2p == 1) */
extern void code_value_entry(CodeNode* node, Entry* entry);
/*lint -sem( code_value_term, custodial(2), 1p == 1 && 2p == 1) */
extern void code_value_term(CodeNode* node, Term* term);
/*lint -sem( code_value_steal_child_term, 1p == 1 && 2n >= 0, @p == 1p) */
extern Term* code_value_steal_term(CodeNode* node, int no);
/*lint -sem( code_value_bool, 1p == 1) */
extern void code_value_bool(CodeNode* node, Bool bool);
/*lint -sem( code_value_size, 1p == 1) */
extern void code_value_size(CodeNode* node, int size);
/*lint -sem( code_value_list, custodial(2), 1p == 1 && 2p == 1) */
extern void code_value_list(CodeNode* node, List* list);
/*lint -sem( code_value_varclass, 1p == 1) */
extern void code_value_varclass(CodeNode* node, VarClass varclass);
/*lint -sem( code_value_contype, 1p == 1) */
extern void code_value_contype(CodeNode* node, ConType contype);
/*lint -sem( code_value_rdef, custodial(2), 1p == 1 && 2p == 1) */
extern void code_value_rdef(CodeNode* node, RDef* rdef);
/*lint -sem( code_value_rpar, custodial(2), 1p == 1 && 2p == 1) */
extern void code_value_rpar(CodeNode* node, RPar* rpar);
/*lint -sem( code_value_bits, 1p == 1) */
extern void code_value_bits(CodeNode* node, unsigned int bits);
/*lint -sem( code_value_bound, custodial(2), 1p == 1 && 2p == 1) */
extern void code_value_bound(CodeNode* node, Bound* bound);
/*lint -sem( code_value_void, 1p == 1) */
extern void code_value_void(CodeNode* node);
/*lint -sem( code_copy_value, 1p == 1 && 2p == 1) */
extern void code_copy_value(CodeNode* dst, const CodeNode* src);
/*lint -sem( code_eval_child, 1p == 1 && 2n >= 0, @p == 1p) */
extern CodeNode* code_eval_child(const CodeNode* node, int no);
/*lint -sem( code_eval_child_numb, 1p == 1 && 2n >= 0) */
extern const Numb* code_eval_child_numb(const CodeNode* node, int no);
/*lint -sem( char* code_eval_child_strg, 1p == 1 && 2n >= 0,
@p && nulterm(@)) */
extern const char* code_eval_child_strg(const CodeNode* node, int no);
/*lint -sem( code_eval_child_name, 1p == 1 && 2n >= 0,
@p && nulterm(@)) */
extern const char* code_eval_child_name(const CodeNode* node, int no);
/*lint -sem( code_eval_child_tuple, 1p == 1 && 2n >= 0, @p == 1) */
extern const Tuple* code_eval_child_tuple(const CodeNode* node, int no);
/*lint -sem( code_eval_child_set, 1p == 1 && 2n >= 0, @p == 1) */
extern const Set* code_eval_child_set(const CodeNode* node, int no);
/*lint -sem( code_eval_child_idxset, 1p == 1 && 2n >= 0, @p == 1) */
extern const IdxSet* code_eval_child_idxset(const CodeNode* node, int no);
/*lint -sem( code_eval_child_entry, 1p == 1 && 2n >= 0, @p == 1) */
extern const Entry* code_eval_child_entry(const CodeNode* node, int no);
/*lint -sem( code_eval_child_term, 1p == 1 && 2n >= 0, @p == 1) */
extern const Term* code_eval_child_term(const CodeNode* node, int no);
/*lint -sem( code_eval_child_size, 1p == 1 && 2n >= 0, @n >= 0) */
extern int code_eval_child_size(const CodeNode* node, int no);
/*lint -sem( code_eval_child_bool, 1p == 1 && 2n >= 0) */
extern Bool code_eval_child_bool(const CodeNode* node, int no);
/*lint -sem( code_eval_child_list, 1p == 1 && 2n >= 0, @p == 1) */
extern const List* code_eval_child_list(const CodeNode* node, int no);
/*lint -sem( code_eval_child_varclass, 1p == 1 && 2n >= 0) */
extern VarClass code_eval_child_varclass(const CodeNode* node, int no);
/*lint -sem( code_eval_child_contype, 1p == 1 && 2n >= 0) */
extern ConType code_eval_child_contype(const CodeNode* node, int no);
/*lint -sem( code_eval_child_rdef, 1p == 1 && 2n >= 0, @p == 1) */
extern const RDef* code_eval_child_rdef(const CodeNode* node, int no);
/*lint -sem( code_eval_child_rpar, 1p == 1 && 2n >= 0, @p == 1) */
extern const RPar* code_eval_child_rpar(const CodeNode* node, int no);
/*lint -sem( code_eval_child_bits, 1p == 1 && 2n >= 0) */
extern unsigned int code_eval_child_bits(const CodeNode* node, int no);
/*lint -sem( code_eval_child_symbol, 1p == 1 && 2n >= 0) */
extern Symbol* code_eval_child_symbol(const CodeNode* node, int no);
/*lint -sem( code_eval_child_define, 1p == 1 && 2n >= 0) */
extern Define* code_eval_child_define(const CodeNode* node, int no);
/*lint -sem( code_eval_child_bound, 1p == 1 && 2n >= 0) */
extern const Bound* code_eval_child_bound(const CodeNode* node, int no);
#ifdef __cplusplus
}
#endif
#endif /* _CODE_H_ */
zimpl-3.3.4/src/rdefpar.h 0000640 0012352 0006025 00000007025 13057565713 015127 0 ustar bzfgamra optimi /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* File....: rdefpar.c */
/* Name....: Read Definition / Parameter */
/* Author..: Thorsten Koch */
/* Copyright by Author, All rights reserved */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Copyright (C) 2001-2017 by Thorsten Koch
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _RDEFPAR_H_
#define _RDEFPAR_H_
#ifdef __cplusplus
extern "C" {
#endif
typedef struct read_param RPar;
typedef struct read_definition RDef;
/*lint -sem( rdef_new, nulterm(1), nulterm(2), 1p && 2p, @p == 1) */
extern RDef* rdef_new(const char* filename, const char* pattern);
/*lint -sem( rdef_free, custodial(1), 1p == 1) */
extern void rdef_free(RDef* rdef);
/*lint -sem( rdef_is_valid, 1p == 1) */
extern Bool rdef_is_valid(const RDef* rdef);
/*lint -sem( rdef_copy, 1p == 1, @p == 1) */
extern RDef* rdef_copy(const RDef* rdef);
/*lint -sem( rdef_set_param, 1p == 1 && 2p == 1) */
extern void rdef_set_param(RDef* rdef, const RPar* rpar);
/*lint -sem( rdef_get_filename, 1p == 1, @p && nulterm(@)) */
extern const char* rdef_get_filename(const RDef* rdef);
/*lint -sem( rdef_get_pattern, 1p == 1, @p && nulterm(@)) */
extern const char* rdef_get_pattern(const RDef* rdef);
/*lint -sem( rdef_get_comment, 1p == 1, @p && nulterm(@)) */
extern const char* rdef_get_comment(const RDef* rdef);
/*lint -sem( rdef_get_match, 1p == 1) */
extern const char* rdef_get_match(const RDef* rdef);
/*lint -sem( rdef_get_use, 1p == 1) */
extern int rdef_get_use(const RDef* rdef);
/*lint -sem( rdef_get_skip, 1p == 1) */
extern int rdef_get_skip(const RDef* rdef);
/*lint -sem( rpar_new_skip, @p == 1) */
extern RPar* rpar_new_skip(int skip);
/*lint -sem( rpar_new_use, @p == 1) */
extern RPar* rpar_new_use(int use);
/*lint -sem( rpar_new_comment, 1p && nulterm(1), @p == 1) */
extern RPar* rpar_new_comment(const char* comment);
/*lint -sem( rpar_new_match, 1p && nulterm(1), @p == 1) */
extern RPar* rpar_new_match(const char* match);
/*lint -sem( rpar_free, custodial(1), 1p == 1) */
extern void rpar_free(RPar* rpar);
/*lint -sem( rpar_is_valid, 1p == 1) */
extern Bool rpar_is_valid(const RPar* rpar);
/*lint -sem( rpar_copy, 1p == 1, @p == 1) */
extern RPar* rpar_copy(const RPar* rpar);
#ifdef __cplusplus
}
#endif
#endif /* _RDEFPAR_H_ */
zimpl-3.3.4/src/bool.h 0000640 0012352 0006025 00000003257 13057565713 014442 0 ustar bzfgamra optimi /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* File....: bool.h */
/* Name....: Define Boolean type */
/* Author..: Thorsten Koch */
/* Copyright by Author, All rights reserved */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Copyright (C) 2003-2017 by Thorsten Koch
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _BOOL_H_
#define _BOOL_H_
#ifdef __cplusplus
extern "C" {
#endif
typedef int Bool;
#ifndef TRUE
#define TRUE ((Bool)1)
#endif
#ifndef FALSE
#define FALSE ((Bool)0)
#endif
#ifdef __cplusplus
}
#endif
#endif /* _BOOL_H_ */
zimpl-3.3.4/src/setmulti.c 0000640 0012352 0006025 00000044452 13057565713 015352 0 ustar bzfgamra optimi /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* File....: setmulti.c */
/* Name....: Set Multi Functions */
/* Author..: Thorsten Koch */
/* Copyright by Author, All rights reserved */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Copyright (C) 2001-2017 by Thorsten Koch
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include
#include
#include
#include
#include
#include "lint.h"
#include "bool.h"
#include "mshell.h"
#include "ratlptypes.h"
#include "numb.h"
#include "elem.h"
#include "tuple.h"
#include "mme.h"
#include "entry.h"
#include "list.h"
#include "hash.h"
#include "stmt.h"
#include "set.h"
#include "set4.h"
#ifdef _MSC_VER
#pragma warning (disable: 4100) /* unreferenced formal parameter */
#endif
#define SET_MULTI_SID 0x5345544d
#define SET_MULTI_ITER_SID 0x53454d49
/* This is a bloody hack. But there seems to be no easy way to give
* additional information to the compare routine needed for qsort().
*/
static const Set* cmp_set = NULL;
static int cmp_dim = 0;
/* -------------------------------------------------------------------------
* --- valid
* -------------------------------------------------------------------------
*/
static Bool set_multi_is_valid(const Set* set)
{
return set != NULL
&& SID_ok2(set->multi, SET_MULTI_SID)
&& set->head.refc > 0
&& set->head.dim > 1
&& set->multi.subset != NULL
&& set->multi.set != NULL;
}
static Bool set_multi_iter_is_valid(const SetIter* iter)
{
return iter != NULL
&& SID_ok2(iter->multi, SET_MULTI_ITER_SID)
&& iter->multi.members >= 0
&& iter->multi.now >= 0
&& ( (iter->multi.members == 0 && iter->multi.dim == 0 && iter->multi.subset == NULL)
|| (iter->multi.members >= 0 && iter->multi.dim > 0 && iter->multi.subset != NULL));
}
/* -------------------------------------------------------------------------
* --- internal
* -------------------------------------------------------------------------
*/
static int subset_cmp(const void* a, const void* b)
{
const int* aa = (const int*)a;
const int* bb = (const int*)b;
int i;
for(i = 0; i < cmp_dim; i++)
{
int d = aa[i] - bb[i];
if (d != 0)
return d;
}
return 0;
}
static int order_cmp(const void* a, const void* b)
{
const int* aa = (const int*)a;
const int* bb = (const int*)b;
int ai;
int bi;
assert(cmp_set != NULL);
assert(cmp_dim >= 0);
assert(cmp_dim < cmp_set->head.dim);
ai = *aa * cmp_set->head.dim + cmp_dim;
bi = *bb * cmp_set->head.dim + cmp_dim;
return cmp_set->multi.subset[ai] - cmp_set->multi.subset[bi];
}
/* -------------------------------------------------------------------------
* --- new
* -------------------------------------------------------------------------
*/
Set* set_multi_new_from_list(const List* list, SetCheckType check)
{
const Tuple* tuple;
ListElem* le = NULL;
Set* set;
int n;
int i;
int k;
int dim;
Bool is_entrylist;
Hash* hash = NULL;
assert(list_is_valid(list));
is_entrylist = list_is_entrylist(list);
n = list_get_elems(list);
tuple = is_entrylist
? entry_get_tuple(list_get_entry(list, &le))
: list_get_tuple(list, &le);
dim = tuple_get_dim(tuple);
assert(n > 0);
assert(dim > 1);
set = calloc(1, sizeof(*set));
assert(set != NULL);
set->head.refc = 1;
set->head.dim = dim;
set->head.members = 0;
set->head.type = SET_MULTI;
set->multi.set = calloc((size_t)dim, sizeof(*set->multi.set));
set->multi.subset = calloc((size_t)(n * dim), sizeof(*set->multi.subset));
set->multi.order = calloc((size_t)dim, sizeof(*set->multi.order));
assert(set->multi.set != NULL);
assert(set->multi.subset != NULL);
assert(set->multi.order != NULL);
for(k = 0; k < dim; k++)
set->multi.set [k] = set_list_new(n, SET_DEFAULT);
if (check != SET_CHECK_NONE)
hash = hash_new(HASH_TUPLE, n);
le = NULL;
for(i = 0; i < n; i++)
{
tuple = is_entrylist
? entry_get_tuple(list_get_entry(list, &le))
: list_get_tuple(list, &le);
assert(tuple != NULL);
assert(hash != NULL || check == SET_CHECK_NONE);
if (hash != NULL && hash_has_tuple(hash, tuple))
{
if (check == SET_CHECK_WARN)
{
if (stmt_trigger_warning(164))
{
fprintf(stderr, "--- Warning 164: Duplicate element ");
tuple_print(stderr, tuple);
fprintf(stderr, " for set rejected\n");
}
}
}
else
{
if (hash != NULL)
hash_add_tuple(hash, tuple);
for(k = 0; k < dim; k++)
set->multi.subset[set->head.members * dim + k] =
set_list_add_elem(set->multi.set[k],
tuple_get_elem(tuple, k), SET_CHECK_QUIET);
set->head.members++;
}
}
if (hash != NULL)
hash_free(hash);
/* Bloody hack!
*/
cmp_set = set;
cmp_dim = dim;
/* Sort subset
*/
qsort(set->multi.subset, (size_t)set->head.members,
(size_t)dim * sizeof(*set->multi.subset), subset_cmp);
/* This could be done also later On-Demand
*/
for(k = 0; k < dim; k++)
{
set->multi.order[k] = calloc(set->head.members, sizeof(**set->multi.order));
assert(set->multi.order[k] != NULL);
for(i = 0; i < set->head.members; i++)
set->multi.order[k][i] = i;
/* No need to sort order[0] because subset ist already sorted.
*/
if (k > 0)
{
cmp_dim = k;
qsort(set->multi.order[k], (size_t)set->head.members,
sizeof(**set->multi.order), order_cmp);
}
#ifndef NDEBUG
/* Make sure order is sorted
*/
for(i = 0; i < set->head.members - 1; i++)
{
int a = set->multi.order[k][i] * set->head.dim + k;
int b = set->multi.order[k][i + 1] * set->head.dim + k;
assert(set->multi.subset[a] <= set->multi.subset[b]);
}
#endif /* !NDEBUG */
}
SID_set2(set->multi, SET_MULTI_SID);
assert(set_multi_is_valid(set));
return set;
}
/* -------------------------------------------------------------------------
* --- copy
* -------------------------------------------------------------------------
*/
static Set* set_multi_copy(const Set* source)
{
Set* set = (Set*)source;
int i;
assert(set_multi_is_valid(source));
set->head.refc++;
for(i = 0; i < set->head.dim; i++)
(void)set_copy(set->multi.set[i]);
return set;
}
/* -------------------------------------------------------------------------
* --- free
* -------------------------------------------------------------------------
*/
static void set_multi_free(Set* set)
{
int i;
assert(set_multi_is_valid(set));
for(i = 0; i < set->head.dim; i++)
set_free(set->multi.set[i]);
set->head.refc--;
if (set->head.refc == 0)
{
SID_del2(set->multi);
for(i = 0; i < set->head.dim; i++)
free(set->multi.order[i]);
free(set->multi.order);
free(set->multi.set);
free(set->multi.subset);
free(set);
}
}
/* -------------------------------------------------------------------------
* --- lookup
* -------------------------------------------------------------------------
*/
static int subset_idx_cmp(const void* a, const void* b)
{
const int* key = (const int*)a;
const int* subset = (const int*)b;
int i;
assert(key != NULL);
assert(subset != NULL);
assert(cmp_dim > 0);
for(i = 0; i < cmp_dim; i++)
{
int d = key[i] - subset[i];
if (d != 0)
return d;
}
return 0;
}
static int order_idx_cmp(const void* a, const void* b)
{
const int* key = (const int*)a;
const int* order = (const int*)b;
assert(key != NULL);
assert(order != NULL);
assert(cmp_set != NULL);
assert(cmp_dim >= 0);
assert(cmp_dim < cmp_set->head.dim);
assert(*order >= 0);
assert(*order < cmp_set->head.members);
return *key - cmp_set->multi.subset[*order * cmp_set->head.dim + cmp_dim];
}
/* return the index of the element, -1 if not found
*/
static int set_multi_lookup_idx(const Set* set, const Tuple* tuple, int offset)
{
int* idx;
ptrdiff_t result;
int i;
int k;
assert(set_multi_is_valid(set));
assert(tuple_is_valid(tuple));
assert(offset >= 0);
assert(offset < tuple_get_dim(tuple));
idx = malloc((size_t)set->head.dim * sizeof(*idx));
assert(idx != NULL);
for(i = 0; i < set->head.dim; i++)
{
idx[i] = set_lookup_idx(set->multi.set[i], tuple, offset + i);
if (idx[i] < 0)
{
free(idx);
return -1;
}
}
cmp_dim = set->head.dim;
result = (ptrdiff_t)bsearch(idx, set->multi.subset, (size_t)set->head.members,
(size_t)set->head.dim * sizeof(*set->multi.subset), subset_idx_cmp);
free(idx);
if (result == 0)
return -1;
assert((result - (ptrdiff_t)set->multi.subset)
% (ptrdiff_t)(set->head.dim * sizeof(*set->multi.subset)) == 0);
k = (result - (ptrdiff_t)set->multi.subset)
/ (ptrdiff_t)(set->head.dim * sizeof(*set->multi.subset));
assert(k >= 0);
assert(k < set->head.members);
return k;
}
/* -------------------------------------------------------------------------
* --- get_tuple
* -------------------------------------------------------------------------
*/
static void set_multi_get_tuple(
const Set* set,
int idx,
Tuple* tuple,
int offset)
{
int i;
assert(set_multi_is_valid(set));
assert(idx >= 0);
assert(idx <= set->head.members);
assert(tuple_is_valid(tuple));
assert(offset >= 0);
assert(offset + set->head.dim <= tuple_get_dim(tuple));
for(i = 0; i < set->head.dim; i++)
{
tuple_set_elem(tuple, offset + i,
elem_copy(set_list_get_elem(set->multi.set[i],
set->multi.subset[idx * set->head.dim + i])));
}
}
/* -------------------------------------------------------------------------
* --- iter_init
* -------------------------------------------------------------------------
*/
static SetIter* set_multi_iter_init(
const Set* set,
const Tuple* pattern,
int offset)
{
SetIter* iter;
int* idx;
int i;
int j;
int k;
int m;
int first;
int last;
ptrdiff_t result;
int fixed_idx = -1;
assert(set_multi_is_valid(set));
assert(pattern == NULL || tuple_is_valid(pattern));
assert(offset >= 0);
assert(pattern == NULL || offset < tuple_get_dim(pattern));
iter = calloc(1, sizeof(*iter));
assert(iter != NULL);
idx = malloc((size_t)set->head.dim * sizeof(*idx));
assert(idx != NULL);
for(i = 0; i < set->head.dim; i++)
{
if (pattern == NULL
|| elem_get_type(tuple_get_elem(pattern, offset + i)) == ELEM_NAME)
idx[i] = -1;
else
{
idx[i] = set_lookup_idx(set->multi.set[i], pattern, offset + i);
if (idx[i] < 0)
break;
fixed_idx = i;
}
}
/* Impossible pattern ?
*/
if (i < set->head.dim)
{
iter->multi.members = 0;
iter->multi.now = 0;
}
else
{
iter->multi.dim = set->head.dim;
iter->multi.subset = calloc((size_t)set->head.members,
(size_t)set->head.dim * sizeof(*iter->multi.subset));
assert(iter->multi.subset);
/* Pattern matches all members ?
*/
if (fixed_idx < 0)
{
iter->multi.members = set->head.members;
iter->multi.now = 0;
memcpy(iter->multi.subset, set->multi.subset,
(size_t)(iter->multi.members * iter->multi.dim) * sizeof(*iter->multi.subset));
}
else
{
assert(fixed_idx >= 0);
cmp_set = set;
cmp_dim = fixed_idx;
result = (ptrdiff_t)bsearch(
&idx[fixed_idx],
set->multi.order[fixed_idx],
(size_t)set->head.members,
sizeof(**set->multi.order),
order_idx_cmp);
#if 0
if (result == 0)
{
for(i = 0; i < set->head.members; i++)
fprintf(stderr, "%d %d %d\n", i, set->multi.order[fixed_idx][i],
set->multi.subset[set->multi.order[fixed_idx][i] * set->head.dim + fixed_idx]);
}
#endif
assert(result != 0);
k = (result - (ptrdiff_t)set->multi.order[fixed_idx])
/ (ptrdiff_t)sizeof(**set->multi.order);
assert(k >= 0);
assert(k < set->head.members);
j = set->multi.order[fixed_idx][k];
assert(j >= 0);
assert(j < set->head.members);
assert(idx[fixed_idx] == set->multi.subset[j * set->head.dim + fixed_idx]);
#if 0
fprintf(stderr, "@ fixe_idx: %d idx[]=%d k=%d j=%d\n",
fixed_idx, idx[fixed_idx], k, j);
#endif
for(first = k; first >= 0; first--)
{
j = set->multi.order[fixed_idx][first] * set->head.dim + fixed_idx;
if (idx[fixed_idx] != set->multi.subset[j])
{
assert(idx[fixed_idx] > set->multi.subset[j]);
break;
}
}
for(last = k; last < set->head.members; last++)
{
j = set->multi.order[fixed_idx][last] * set->head.dim + fixed_idx;
if (idx[fixed_idx] != set->multi.subset[j])
{
assert(idx[fixed_idx] < set->multi.subset[j]);
break;
}
}
assert(first + 1 < last);
m = 0;
for(k = first + 1; k < last; k++)
{
j = set->multi.order[fixed_idx][k];
assert(idx[fixed_idx] == set->multi.subset[j * set->head.dim + fixed_idx]);
for(i = 0; i < set->head.dim; i++)
{
/* can entry match ?
*/
if (idx[i] >= 0 && idx[i] != set->multi.subset[j * set->head.dim + i])
break;
iter->multi.subset[m * set->head.dim + i] =
set->multi.subset[j * set->head.dim + i];
}
if (i == set->head.dim)
m++;
}
iter->multi.members = m;
iter->multi.now = 0;
}
}
#if 0
fprintf(stderr, "set_multi_iter_init dim=%d members=%d\n",
set->head.dim, iter->multi.members);
for(i = 0; i < set->head.dim; i++)
fprintf(stderr, "idx[%d]=%d\n", i, idx[i]);
#endif
free(idx);
SID_set2(iter->multi, SET_MULTI_ITER_SID);
assert(set_multi_iter_is_valid(iter));
return iter;
}
/* -------------------------------------------------------------------------
* --- iter_next
* -------------------------------------------------------------------------
*/
/* FALSE means, there is no further element
*/
static Bool set_multi_iter_next(
SetIter* iter,
const Set* set,
Tuple* tuple,
int offset)
{
int i;
assert(set_multi_iter_is_valid(iter));
assert(set_multi_is_valid(set));
assert(tuple_is_valid(tuple));
assert(offset >= 0);
assert(offset + set->head.dim <= tuple_get_dim(tuple));
if (iter->multi.now >= iter->multi.members)
return FALSE;
for(i = 0; i < iter->multi.dim; i++)
{
tuple_set_elem(tuple, offset + i,
elem_copy(set_list_get_elem(set->multi.set[i],
iter->multi.subset[iter->multi.now * iter->multi.dim + i])));
}
iter->multi.now++;
return TRUE;
}
/* -------------------------------------------------------------------------
* --- iter_exit
* -------------------------------------------------------------------------
*/
/*ARGSUSED*/
static void set_multi_iter_exit(SetIter* iter, UNUSED const Set* set)
{
assert(set_multi_iter_is_valid(iter));
SID_del2(iter->multi);
if (iter->multi.subset != NULL)
free(iter->multi.subset);
free(iter);
}
/* -------------------------------------------------------------------------
* --- iter_reset
* -------------------------------------------------------------------------
*/
/*ARGSUSED*/
static void set_multi_iter_reset(SetIter* iter, UNUSED const Set* set)
{
assert(set_multi_iter_is_valid(iter));
iter->multi.now = 0;
}
/* -------------------------------------------------------------------------
* --- vtab_init
* -------------------------------------------------------------------------
*/
void set_multi_init(SetVTab* vtab)
{
vtab[SET_MULTI].set_copy = set_multi_copy;
vtab[SET_MULTI].set_free = set_multi_free;
vtab[SET_MULTI].set_lookup_idx = set_multi_lookup_idx;
vtab[SET_MULTI].set_get_tuple = set_multi_get_tuple;
vtab[SET_MULTI].iter_init = set_multi_iter_init;
vtab[SET_MULTI].iter_next = set_multi_iter_next;
vtab[SET_MULTI].iter_exit = set_multi_iter_exit;
vtab[SET_MULTI].iter_reset = set_multi_iter_reset;
vtab[SET_MULTI].set_is_valid = set_multi_is_valid;
}
zimpl-3.3.4/src/set4.c 0000640 0012352 0006025 00000041110 13057565713 014347 0 ustar bzfgamra optimi /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* File....: set4.c */
/* Name....: Set Functions */
/* Author..: Thorsten Koch */
/* Copyright by Author, All rights reserved */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Copyright (C) 2001-2017 by Thorsten Koch
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include
#include
#include
#include
#include "bool.h"
#include "mshell.h"
#include "ratlptypes.h"
#include "numb.h"
#include "elem.h"
#include "tuple.h"
#include "mme.h"
#include "entry.h"
#include "list.h"
#include "hash.h"
#include "stmt.h"
#include "set.h"
#include "set4.h"
#define TEST_DUBLICATE 0
#define SET_SID 0x5365745f
#ifndef NDEBUG
static
#endif
SetVTab* set_vtab_global = NULL;
void set_init()
{
assert(set_vtab_global == NULL);
set_vtab_global = calloc((size_t)SET_TYPES, sizeof(*set_vtab_global));
assert(set_vtab_global != NULL);
set_empty_init(set_vtab_global);
set_pseudo_init(set_vtab_global);
set_list_init(set_vtab_global);
set_range_init(set_vtab_global);
set_prod_init(set_vtab_global);
set_multi_init(set_vtab_global);
#if 0
set_union_init(set_vtab_global);
set_inter_init(set_vtab_global);
set_minus_init(set_vtab_global);
set_sdiff_init(set_vtab_global);
#endif
}
void set_exit()
{
assert(set_vtab_global != NULL);
free(set_vtab_global);
set_vtab_global = NULL;
}
Set* set_new_from_list(const List* list, SetCheckType check)
{
ListElem* le = NULL;
int dim;
Set* set = NULL;
assert(list_is_valid(list));
assert(list_get_elems(list) > 0);
if (list_is_elemlist(list))
set = set_list_new_from_elems(list, check);
else if (list_is_tuplelist(list))
{
dim = tuple_get_dim(list_get_tuple(list, &le));
if (dim == 1)
set = set_list_new_from_tuples(list, check);
else
set = set_multi_new_from_list(list, check);
}
else
{
assert(list_is_entrylist(list));
dim = tuple_get_dim(entry_get_tuple(list_get_entry(list, &le)));
if (dim == 1)
set = set_list_new_from_entries(list, check);
else
set = set_multi_new_from_list(list, check);
}
assert(set_is_valid(set));
return set;
}
void set_free(Set* set)
{
set_vtab_global[set->head.type].set_free(set);
}
Bool set_is_valid(const Set* set)
{
return set != NULL && set_vtab_global[set->head.type].set_is_valid(set);
}
Set* set_copy(const Set* set)
{
return set_vtab_global[set->head.type].set_copy(set);
}
inline int set_lookup_idx(const Set* set, const Tuple* tuple, int offset)
{
return set_vtab_global[set->head.type].set_lookup_idx(set, tuple, offset);
}
Bool set_lookup(const Set* set, const Tuple* tuple)
{
if (set->head.dim != tuple_get_dim(tuple))
return FALSE;
return set_vtab_global[set->head.type].set_lookup_idx(set, tuple, 0) >= 0;
}
inline void set_get_tuple_intern(const Set* set, int idx, Tuple* tuple, int offset)
{
set_vtab_global[set->head.type].set_get_tuple(set, idx, tuple, offset);
}
Tuple* set_get_tuple(const Set* set, int idx)
{
Tuple* tuple;
tuple = tuple_new(set->head.dim);
assert(set_is_valid(set));
assert(idx >= 0);
assert(idx < set->head.members);
set_get_tuple_intern(set, idx, tuple, 0);
return tuple;
}
inline SetIter* set_iter_init_intern(const Set* set, const Tuple* pattern, int offset)
{
return set_vtab_global[set->head.type].iter_init(set, pattern, offset);
}
SetIter* set_iter_init(const Set* set, const Tuple* pattern)
{
return set_iter_init_intern(set, pattern, 0);
}
inline Bool set_iter_next_intern(SetIter* iter, const Set* set, Tuple* tuple, int offset)
{
return set_vtab_global[set->head.type].iter_next(iter, set, tuple, offset);
}
Tuple* set_iter_next(SetIter* iter, const Set* set)
{
Tuple* tuple;
tuple = tuple_new(set->head.dim);
if (set_iter_next_intern(iter, set, tuple, 0))
return tuple;
tuple_free(tuple);
return NULL;
}
inline void set_iter_exit_intern(SetIter* iter, const Set* set)
{
set_vtab_global[set->head.type].iter_exit(iter, set);
}
void set_iter_exit(SetIter* iter, const Set* set)
{
set_iter_exit_intern(iter, set);
}
inline void set_iter_reset_intern(SetIter* iter, const Set* set)
{
set_vtab_global[set->head.type].iter_reset(iter, set);
}
int set_get_dim(const Set* set)
{
assert(set_is_valid(set));
return set->head.dim;
}
int set_get_members(const Set* set)
{
assert(set_is_valid(set));
return set->head.members;
}
void set_print(FILE* fp, const Set* set)
{
SetIter* iter;
Tuple* tuple;
Bool first = TRUE;
assert(fp != NULL);
assert(set_is_valid(set));
switch(set->head.type)
{
case SET_EMPTY :
fprintf(fp, "Empty: ");
break;
case SET_PSEUDO :
fprintf(fp, "Pseudo: ");
break;
case SET_LIST :
fprintf(fp, "List: ");
break;
case SET_RANGE :
fprintf(fp, "Range: ");
break;
case SET_PROD :
fprintf(fp, "Product: ");
break;
case SET_MULTI :
fprintf(fp, "Multi: ");
break;
default :
abort();
}
fprintf(fp, "|%d|", set->head.dim);
fprintf(fp, "{");
iter = set_iter_init(set, NULL);
while(NULL != (tuple = set_iter_next(iter, set)))
{
if (first)
first = FALSE;
else
fprintf(fp, ",");
tuple_print(fp, tuple);
tuple_free(tuple);
}
set_iter_exit(iter, set);
fprintf(fp, "}");
}
/* In A or in B */
Set* set_union(const Set* set_a, const Set* set_b)
{
Set* set;
SetIter* iter;
List* list = NULL;
Tuple* tuple;
assert(set_is_valid(set_a));
assert(set_is_valid(set_b));
assert(set_a->head.dim == set_b->head.dim
|| set_a->head.type == SET_EMPTY
|| set_b->head.type == SET_EMPTY);
iter = set_iter_init(set_a, NULL);
while(NULL != (tuple = set_iter_next(iter, set_a)))
{
if (list == NULL)
list = list_new_tuple(tuple);
else
list_add_tuple(list, tuple);
tuple_free(tuple);
}
set_iter_exit(iter, set_a);
iter = set_iter_init(set_b, NULL);
while(NULL != (tuple = set_iter_next(iter, set_b)))
{
if (!set_lookup(set_a, tuple))
{
if (list == NULL)
list = list_new_tuple(tuple);
else
list_add_tuple(list, tuple);
}
tuple_free(tuple);
}
set_iter_exit(iter, set_b);
if (list == NULL)
{
assert(set_get_members(set_a) + set_get_members(set_b) == 0);
set = set_empty_new(
set_a->head.type == SET_EMPTY ? set_b->head.dim : set_a->head.dim);
}
else
{
set = set_new_from_list(list, SET_CHECK_NONE);
assert(set_get_members(set) <= set_get_members(set_a) + set_get_members(set_b));
list_free(list);
}
return set;
}
/* In A and in B */
Set* set_inter(const Set* set_a, const Set* set_b)
{
Set* set;
SetIter* iter;
List* list = NULL;
Tuple* tuple;
assert(set_is_valid(set_a));
assert(set_is_valid(set_b));
assert(set_a->head.dim == set_b->head.dim
|| set_a->head.type == SET_EMPTY
|| set_b->head.type == SET_EMPTY);
iter = set_iter_init(set_a, NULL);
while(NULL != (tuple = set_iter_next(iter, set_a)))
{
if (set_lookup(set_b, tuple))
{
if (list == NULL)
list = list_new_tuple(tuple);
else
list_add_tuple(list, tuple);
}
tuple_free(tuple);
}
set_iter_exit(iter, set_a);
if (list == NULL)
set = set_empty_new(
set_a->head.type == SET_EMPTY ? set_b->head.dim : set_a->head.dim);
else
{
set = set_new_from_list(list, SET_CHECK_NONE);
assert(set_get_members(set) <= set_get_members(set_a) + set_get_members(set_b));
list_free(list);
}
return set;
}
/* In A but not in B */
Set* set_minus(const Set* set_a, const Set* set_b)
{
Set* set;
SetIter* iter;
List* list = NULL;
Tuple* tuple;
assert(set_is_valid(set_a));
assert(set_is_valid(set_b));
assert(set_a->head.dim == set_b->head.dim
|| set_a->head.type == SET_EMPTY
|| set_b->head.type == SET_EMPTY);
iter = set_iter_init(set_a, NULL);
while(NULL != (tuple = set_iter_next(iter, set_a)))
{
if (!set_lookup(set_b, tuple))
{
if (list == NULL)
list = list_new_tuple(tuple);
else
list_add_tuple(list, tuple);
}
tuple_free(tuple);
}
set_iter_exit(iter, set_a);
if (list == NULL)
{
assert(set_is_subseteq(set_a, set_b));
set = set_empty_new(
set_a->head.type == SET_EMPTY ? set_b->head.dim : set_a->head.dim);
}
else
{
set = set_new_from_list(list, SET_CHECK_NONE);
assert(set_get_members(set) <= set_get_members(set_a));
list_free(list);
}
return set;
}
/* In A and not in B or in B and not in A (Symetric difference) */
Set* set_sdiff(const Set* set_a, const Set* set_b)
{
Set* set;
SetIter* iter;
List* list = NULL;
Tuple* tuple;
assert(set_is_valid(set_a));
assert(set_is_valid(set_b));
assert(set_a->head.dim == set_b->head.dim
|| set_a->head.type == SET_EMPTY
|| set_b->head.type == SET_EMPTY);
iter = set_iter_init(set_a, NULL);
while(NULL != (tuple = set_iter_next(iter, set_a)))
{
if (!set_lookup(set_b, tuple))
{
if (list == NULL)
list = list_new_tuple(tuple);
else
list_add_tuple(list, tuple);
}
tuple_free(tuple);
}
set_iter_exit(iter, set_a);
iter = set_iter_init(set_b, NULL);
while(NULL != (tuple = set_iter_next(iter, set_b)))
{
if (!set_lookup(set_a, tuple))
{
if (list == NULL)
list = list_new_tuple(tuple);
else
list_add_tuple(list, tuple);
}
tuple_free(tuple);
}
set_iter_exit(iter, set_b);
if (list == NULL)
{
assert(set_is_equal(set_a, set_b));
set = set_empty_new(
set_a->head.type == SET_EMPTY ? set_b->head.dim : set_a->head.dim);
}
else
{
set = set_new_from_list(list, SET_CHECK_NONE);
assert(set_get_members(set) <= set_get_members(set_a) + set_get_members(set_b));
list_free(list);
}
return set;
}
/* project set_a to a new set, using the elements index in the tuple.
*/
Set* set_proj(const Set* set, const Tuple* pattern)
{
Tuple* tuple;
Tuple* new_tuple;
SetIter* iter;
List* list = NULL;
int i;
int dim;
int* idx;
Set* new_set;
assert(set_is_valid(set));
assert(tuple_is_valid(pattern));
dim = tuple_get_dim(pattern);
idx = malloc(sizeof(*idx) * dim);
assert(idx != NULL);
for(i = 0; i < dim; i++)
{
assert(numb_is_int(elem_get_numb(tuple_get_elem(pattern, i))));
idx[i] = numb_toint(elem_get_numb(tuple_get_elem(pattern, i))) - 1;
}
iter = set_iter_init(set, NULL);
while(NULL != (tuple = set_iter_next(iter, set)))
{
new_tuple = tuple_new(dim);
for(i = 0; i < dim; i++)
tuple_set_elem(new_tuple, i, elem_copy(tuple_get_elem(tuple, idx[i])));
if (list == NULL)
list = list_new_tuple(new_tuple);
else
list_add_tuple(list, new_tuple);
tuple_free(tuple);
tuple_free(new_tuple);
}
set_iter_exit(iter, set);
free(idx);
if (list == NULL)
{
assert(set_get_members(set) == 0);
new_set = set_empty_new(dim);
}
else
{
new_set = set_new_from_list(list, SET_CHECK_QUIET);
assert(set_get_members(new_set) <= set_get_members(set));
list_free(list);
}
return new_set;
}
/* Is A subset (or equal) of B */
Bool set_is_subseteq(const Set* set_a, const Set* set_b)
{
SetIter* iter;
Tuple* tuple;
Bool is_subset = TRUE;
assert(set_is_valid(set_a));
assert(set_is_valid(set_b));
/* If A is the empty set and B is non empty,
* A is a subset of B
*/
if (set_a->head.members == 0)
return TRUE;
if (set_a->head.dim != set_b->head.dim)
{
if (stmt_trigger_warning(165))
{
fprintf(stderr, "--- Warning 165: Comparison of different dimension sets.\n");
set_print(stderr, set_a);
fputc('\n', stderr);
set_print(stderr, set_b);
fputc('\n', stderr);
}
return FALSE;
}
if (set_a->head.members > set_b->head.members)
return FALSE;
iter = set_iter_init(set_a, NULL);
while(is_subset && NULL != (tuple = set_iter_next(iter, set_a)))
{
is_subset = set_lookup(set_b, tuple);
tuple_free(tuple);
}
set_iter_exit(iter, set_a);
return is_subset;
}
/* A is real subset of B */
Bool set_is_subset(const Set* set_a, const Set* set_b)
{
assert(set_is_valid(set_a));
assert(set_is_valid(set_b));
if (set_a->head.members >= set_b->head.members)
return FALSE;
return set_is_subseteq(set_a, set_b);
}
/* A has the same elements as B */
Bool set_is_equal(const Set* set_a, const Set* set_b)
{
assert(set_is_valid(set_a));
assert(set_is_valid(set_b));
if (set_a->head.members != set_b->head.members)
return FALSE;
return set_is_subseteq(set_a, set_b);
}
/* n elements in set
* k elements in subset
* i index for counter
*/
/*lint -sem(counter_inc, 1p == 3n && 2n > 0 && 3n > 0 && 4n >= 0, @n > 0) */
static int counter_inc(int* counter, int n, int k, int i)
{
int ret = 0;
counter[i]++;
if (counter[i] == n - i)
{
if (i == k - 1)
return 1;
ret = counter_inc(counter, n, k, i + 1);
counter[i] = counter[i + 1] + 1;
}
return ret;
}
List* set_subsets_list(
const Set* set,
int subset_size,
List* list,
int* idx)
{
int* counter;
int i;
Set* subset;
Tuple* tuple;
Entry* entry;
Numb* numb;
assert(set_is_valid(set));
assert(subset_size >= 0);
assert(subset_size <= set->head.members);
assert(idx != NULL);
if (subset_size == 0)
{
subset = set_empty_new(set_get_dim(set));
numb = numb_new_integer(*idx);
*idx += 1;
tuple = tuple_new(1);
tuple_set_elem(tuple, 0, elem_new_numb(numb));
entry = entry_new_set(tuple, subset);
list = list_new_entry(entry);
numb_free(numb);
entry_free(entry);
tuple_free(tuple);
set_free(subset);
return list;
}
counter = malloc(sizeof(*counter) * subset_size);
assert(counter != NULL);
for(i = 0; i < subset_size; i++)
counter[i] = subset_size - 1 - i;
do
{
List* subset_list = NULL;
for(i = 0; i < subset_size; i++)
{
tuple = set_get_tuple(set, counter[i]);
if (subset_list == NULL)
subset_list = list_new_tuple(tuple);
else
list_add_tuple(subset_list, tuple);
tuple_free(tuple);
}
assert(subset_list != NULL);
subset = set_new_from_list(subset_list, SET_CHECK_NONE); /* NO_HASH ? */
list_free(subset_list);
numb = numb_new_integer(*idx);
*idx += 1;
tuple = tuple_new(1);
tuple_set_elem(tuple, 0, elem_new_numb(numb));
entry = entry_new_set(tuple, subset);
if (list == NULL)
list = list_new_entry(entry);
else
list_add_entry(list, entry);
numb_free(numb);
entry_free(entry);
tuple_free(tuple);
set_free(subset);
}
while(!counter_inc(counter, set->head.members, subset_size, 0));
free(counter);
assert(list != NULL);
return list;
}
zimpl-3.3.4/src/term.h 0000640 0012352 0006025 00000012026 13057565713 014450 0 ustar bzfgamra optimi /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* File....: term.h */
/* Name....: Term Functions */
/* Author..: Thorsten Koch */
/* Copyright by Author, All rights reserved */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Copyright (C) 2001-2017 by Thorsten Koch
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _TERM_H_
#define _TERM_H_
#ifndef _BOOL_H_
#error "Need to include bool.h before term.h"
#endif
#ifndef _MONO_H_
#error "Need to include mono.h before term.h"
#endif
#ifdef __cplusplus
extern "C" {
#endif
typedef struct term Term;
/* term.c
*/
/*lint -sem( term_new, 1n > 0, @p == 1) */
extern Term* term_new(int size);
/*lint -sem( term_add_elem, 1p == 1 && 2p == 1 && 3p == 1) */
extern void term_add_elem(Term* term, const Entry* entry, const Numb* coeff, MFun mfun);
#if 0 /* ??? not used */
/*lint -sem( term_mul_elem, 1p == 1 && 2p == 1 && 3p == 1) */
extern void term_mul_elem(Term* term, const Entry* entry, const Numb* coeff);
#endif
/*lint -sem( term_free, custodial(1), 1p == 1) */
extern void term_free(Term* term);
/*lint -sem( term_is_valid, 1p == 1) */
extern Bool term_is_valid(const Term* term);
/*lint -sem( term_copy, 1p == 1, @p == 1) */
extern Term* term_copy(const Term* term);
/*lint -sem( term_print, 1p == 1 && 2p == 1) */
extern void term_print(FILE* fp, const Term* term, Bool print_symbol_index);
/*lint -sem( term_append_term, 1p == 1 && 2p == 1) */
extern void term_append_term(Term* term_a, const Term* term_b);
/*lint -sem( term_add_term, 1p == 1 && 2p == 1, @p == 1) */
extern Term* term_add_term(const Term* term_a, const Term* term_b);
/*lint -sem( term_sub_term, 1p == 1 && 2p == 1, @p == 1) */
extern Term* term_sub_term(const Term* term_a, const Term* term_b);
/*lint -sem( term_mul_term, 1p == 1 && 2p == 1, @p == 1) */
extern Term* term_mul_term(const Term* term_a, const Term* term_b);
/*lint -sem( term_simplify, 1p == 1, @p == 1) */
extern Term* term_simplify(const Term* term_org);
/*lint -sem( term_add_constant, 1p == 1 && 2p == 1) */
extern void term_add_constant(Term* term, const Numb* value);
/*lint -sem( term_sub_constant, 1p == 1 && 2p == 1) */
extern void term_sub_constant(Term* term, const Numb* value);
/*lint -sem( term_mul_coeff, 1p == 1 && 2p == 1) */
extern void term_mul_coeff(Term* term, const Numb* value);
/*lint -sem( term_get_constant, 1p == 1) */
extern const Numb* term_get_constant(const Term* term);
#if 0 /* ??? not used */
/*lint -sem( term_negate, 1p == 1) */
extern void term_negate(Term* term);
#endif
/*lint -sem( term_to_objective, 1p == 1) */
extern void term_to_objective(const Term* term);
/*lint -sem( term_get_elements, 1p == 1, @n >= 0) */
extern int term_get_elements(const Term* term);
/*lint -sem( term_get_element, 1p == 1, @p == 1) */
extern Mono* term_get_element(const Term* term, int i);
/*lint -sem( term_get_lower_bound, 1p == 1, @p == 1) */
extern Bound* term_get_lower_bound(const Term* term);
/*lint -sem( term_get_upper_bound, 1p == 1, @p == 1) */
extern Bound* term_get_upper_bound(const Term* term);
/*lint -sem( term_is_all_integer, 1p == 1) */
extern Bool term_is_all_integer(const Term* term);
/*lint -sem( term_is_linear, 1p == 1) */
extern Bool term_is_linear(const Term* term);
/*lint -sem( term_is_polynomial, 1p == 1) */
extern Bool term_is_polynomial(const Term* term);
/*lint -sem( term_get_degree, 1p == 1) */
extern int term_get_degree(const Term* term);
/*lint -sem( term_make_conditional, 1p == 1 && 2p == 1, @p == 1) */
extern Term* term_make_conditional(const Term* ind_term, const Term* cond_term, Bool is_true);
#ifdef __cplusplus
}
#endif
#endif /* _TERM_H_ */
zimpl-3.3.4/src/prog.c 0000640 0012352 0006025 00000013527 13057565713 014452 0 ustar bzfgamra optimi /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* File....: prog.c */
/* Name....: Program Functions */
/* Author..: Thorsten Koch */
/* Copyright by Author, All rights reserved */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Copyright (C) 2001-2017 by Thorsten Koch
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include
#include
#include
#include
#include
#include
#include "lint.h"
#include "bool.h"
#include "mshell.h"
#include "ratlptypes.h"
#include "numb.h"
#include "elem.h"
#include "tuple.h"
#include "mme.h"
#include "set.h"
#include "symbol.h"
#include "entry.h"
#include "idxset.h"
#include "rdefpar.h"
#include "bound.h"
#include "define.h"
#include "mono.h"
#include "term.h"
#include "list.h"
#include "local.h"
#include "code.h"
#include "stmt.h"
#include "prog.h"
#define PROG_SID 0x50726f67
#define PROG_EXTEND_SIZE 100
static void* lp_data = NULL;
struct program
{
SID
int size;
int used;
int extend;
Stmt** stmt;
};
void* prog_get_lp()
{
return lp_data;
}
Prog* prog_new()
{
Prog* prog = calloc(1, sizeof(*prog));
assert(prog != NULL);
prog->size = PROG_EXTEND_SIZE;
prog->used = 0;
prog->extend = PROG_EXTEND_SIZE;
prog->stmt = calloc((size_t)prog->size, sizeof(*prog->stmt));
SID_set(prog, PROG_SID);
assert(prog_is_valid(prog));
return prog;
}
void prog_free(Prog* prog)
{
int i;
assert(prog_is_valid(prog));
assert(prog->stmt != NULL);
SID_del(prog);
for(i = 0; i < prog->used; i++)
stmt_free(prog->stmt[i]);
free(prog->stmt);
free(prog);
}
Bool prog_is_valid(const Prog* prog)
{
return ((prog != NULL) && SID_ok(prog, PROG_SID));
}
Bool prog_is_empty(const Prog* prog)
{
return prog->used == 0;
}
void prog_add_stmt(Prog* prog, Stmt* stmt)
{
assert(prog_is_valid(prog));
assert(stmt_is_valid(stmt));
assert(prog->used <= prog->size);
if (prog->used == prog->size)
{
prog->size += prog->extend;
prog->extend += prog->extend;
prog->stmt = realloc(
prog->stmt, (size_t)prog->size * sizeof(*prog->stmt));
assert(prog->stmt != NULL);
}
assert(prog->used < prog->size);
prog->stmt[prog->used] = stmt;
prog->used++;
}
void prog_print(FILE* fp, const Prog* prog)
{
int i;
assert(prog_is_valid(prog));
fprintf(fp, "Statements: %d\n", prog->used);
for(i = 0; i < prog->used; i++)
stmt_print(fp, prog->stmt[i]);
}
void prog_execute(const Prog* prog, void* lp)
{
int i;
assert(prog_is_valid(prog));
code_clear_inst_count();
lp_data = lp;
for(i = 0; i < prog->used; i++)
{
stmt_parse(prog->stmt[i]);
stmt_execute(prog->stmt[i]);
/* These calls should make sure, that all output is really
* flushed out, even in a Batch environment.
*/
fflush(stdout);
fflush(stderr);
#ifdef USE_FSYNC
/* This is to force the output do disk. It is to my knowledge
* only needed on AIX batch systems that seem not to flush
* the output buffer. If then the job is killed for some reason
* no output is generated.
*/
(void)fsync(fileno(stdout));
(void)fsync(fileno(stderr));
#endif
}
if (verbose >= VERB_NORMAL)
printf("Instructions evaluated: %u\n", code_get_inst_count());
}
char* prog_tostr(const Prog* prog, const char* prefix, const char* title, int max_output_line_len)
{
size_t len;
char* text;
int pos = 0;
int i;
assert(prog_is_valid(prog));
assert(prefix != NULL);
assert(max_output_line_len > (int)strlen(prefix));
/* prefix + title + \n
* prog->used * (\n + prefix + stmt)
* \0
*/
len = strlen(prefix) + strlen(title) + 2;
for(i = 0; i < prog->used; i++)
{
int line_len = strlen(stmt_get_text(prog->stmt[i]));
int max_eff_line_len = max_output_line_len - strlen(prefix) - 1;
len += line_len + ((line_len + max_eff_line_len - 1) / max_eff_line_len) * (strlen(prefix) + 1);
}
text = calloc(len, sizeof(*text));
pos = sprintf(&text[pos], "%s%s", prefix, title);
for(i = 0; i < prog->used; i++)
{
const char* s = stmt_get_text(prog->stmt[i]);
int k = 0;
while(*s != '\0')
{
if (k % max_output_line_len == 0)
{
k = sprintf(&text[pos], "\n%s", prefix);
pos += k;
}
text[pos] = *s;
pos++;
s++;
k++;
}
}
text[pos++] = '\n';
text[pos] = '\0';
/* for(i = 0; i < prog->used; i++)
* pos += sprintf(&text[pos], "%s%s\n", prefix, stmt_get_text(prog->stmt[i]));
*/
assert((size_t)pos + 1 == len);
return text;
}
zimpl-3.3.4/src/blkmem.h 0000640 0012352 0006025 00000003261 13057565713 014751 0 ustar bzfgamra optimi /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* File....: blkmem.h */
/* Name....: Block Memory Functions */
/* Author..: Thorsten Koch */
/* Copyright by Author, All rights reserved */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Copyright (C) 2007-2017 by Thorsten Koch
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _BLKMEM_H_
#define _BLKMEM_H_
#ifdef __cplusplus
extern "C" {
#endif
extern void blk_init(void);
extern void blk_exit(void);
extern void* blk_alloc(int size);
extern void blk_free(void* p, int size);
#ifdef __cplusplus
}
#endif
#endif /* _BLKMEM_H_ */
zimpl-3.3.4/src/zimpl.c 0000640 0012352 0006025 00000034235 13057565713 014635 0 ustar bzfgamra optimi /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* File....: zimpl.c */
/* Name....: Zuse Institute Mathematical Programming Language */
/* Author..: Thorsten Koch */
/* Copyright by Author, All rights reserved */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Copyright (C) 2001-2017 by Thorsten Koch
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include
#include
#include
#include
#include
#include
#include
#include
#include "lint.h"
#include "bool.h"
#include "mshell.h"
#include "stkchk.h"
#include "random.h"
#include "blkmem.h"
#include "ratlptypes.h"
#include "numb.h"
#include "elem.h"
#include "tuple.h"
#include "mme.h"
#include "set.h"
#include "symbol.h"
#include "define.h"
#include "bound.h"
#include "mono.h"
#include "term.h"
#include "stmt.h"
#include "local.h"
#include "list.h"
#include "entry.h"
#include "conname.h"
#include "xlpglue.h"
#include "zlpglue.h"
#include "prog.h"
#include "metaio.h"
#include "strstore.h"
#include "zimpllib.h"
extern int yydebug;
extern int yy_flex_debug;
static const char* const options = "bD:fF:hl:mn:o:OP:rs:t:v:V";
static const char* const usage = "usage: %s [options] file ...\n";
static const char* const title = "This file was automatically generated by Zimpl";
static const char* const help =
"\n" \
" -b enable bison debugging output.\n" \
" -D name=value assign value to parameter name.\n" \
" -f enable flex debugging output.\n" \
" -F filter filter output, for example \"gzip -c >%%s.gz\"\n" \
" -h show this help.\n" \
" -l length Maximum length of names in output file.\n" \
" -m write CPLEX MIP start value file.\n"
" -n cm|cn|cf name constraint make/name/full\n" \
" -o outfile select name for the output file. Default is the name of\n" \
" the input file without extension.\n" \
" -P cmd Pipe input through command, e.g. \"cpp -DONLY_X %%s\"\n" \
" -r write CPLEX branching order file.\n" \
" -s seed random number generator seed.\n" \
" -t lp|mps|hum|rlp|pip select output format. Either LP (default), MPS format,\n" \
" human readable HUM, randomly permuted LP, or PIP polynomial IP.\n" \
" -v[0-5] verbosity level: 0 = quiet, 1 = default, up to 5 = debug\n" \
" -V print program version\n" \
" filename is the name of the input ZPL file.\n" \
"\n" ;
/* " -O optimize LP by preprocessing.\n" \
*/
#ifdef WITH_CALLTRACE /* Does only work with gcc */
void __cyg_profile_func_enter(void *this_fn, void *call_site) __attribute__((no_instrument_function));
void __cyg_profile_func_exit(void *this_fn, void *call_site) __attribute__((no_instrument_function));
static int call_depth = 0;
void __cyg_profile_func_enter(void *this_fn, void *call_site)
{
call_depth++;
fprintf(stderr, "%p %d\n", this_fn, call_depth);
}
void __cyg_profile_func_exit(void *this_fn, void *call_site)
{
call_depth--;
}
#endif
static char* add_extention(const char* filename, const char* extension)
{
char* basename;
assert(filename != NULL);
assert(strlen(filename) > 0);
assert(extension != NULL);
basename = malloc(strlen(filename) + strlen(extension) + 1);
assert(basename != NULL);
strcpy(basename, filename);
/*lint -e{429} suppress 'Custodial pointer 'basename' (line 96) has not been freed or returned' */
return strcat(basename, extension);
}
static const char* strip_path(const char* filename)
{
const char* s;
assert(filename != NULL);
assert(strlen(filename) > 0);
s = strrchr(filename, DIRSEP);
return (s == NULL) ? filename : s + 1;
}
static char* strip_extension(char* filename)
{
int i;
assert(filename != NULL);
assert(strlen(filename) > 0);
for(i = (int)strlen(filename) - 1; i >= 0; i--)
if (filename[i] == DIRSEP || filename[i] == '.')
break;
if (i >= 0 && filename[i] == '.')
filename[i] = '\0';
i = (int)strlen(filename);
if (i == 0 || filename[i - 1] == DIRSEP)
{
fprintf(stderr, "*** Error 101: Bad filename\n");
exit(EXIT_FAILURE);
}
return filename;
}
static void check_write_ok(FILE* fp, const char* filename)
{
if (ferror(fp))
{
fprintf(stderr, "*** Error 102: File write error\n");
perror(filename);
}
}
int main(int argc, char* const* argv)
{
Prog* prog;
Set* set;
void* lp;
const char* extension = "";
char* filter = strdup("%s");
char* outfile;
char* tblfile;
char* ordfile;
char* mstfile;
char* basefile = NULL;
char* inppipe = NULL;
char* outpipe;
LpFormat format = LP_FORM_LPF;
FILE* fp;
Bool write_order = FALSE;
Bool write_mst = FALSE;
Bool presolve = FALSE;
int name_length = 0;
char* prog_text;
unsigned long seed = 13021967UL;
char** param_table;
int param_count = 0;
int c;
int i;
FILE* (*openfile)(const char*, const char*) = fopen;
int (*closefile)(FILE*) = fclose;
stkchk_init();
yydebug = 0;
yy_flex_debug = 0;
verbose = VERB_NORMAL;
param_table = malloc(sizeof(*param_table));
while((c = getopt(argc, argv, options)) != -1)
{
switch(c)
{
case 'b' :
yydebug = 1;
break;
case 'D' :
param_table =
realloc(param_table, ((unsigned int)param_count + 1) * sizeof(*param_table));
param_table[param_count] = strdup(optarg);
param_count++;
break;
case 'h' :
zpl_print_banner(stdout, TRUE);
printf(usage, argv[0]);
puts(help);
exit(0);
case 'f' :
yy_flex_debug = 1;
break;
case 'F' :
free(filter);
filter = strdup(optarg);
openfile = popen;
closefile = pclose;
break;
case 'l' :
name_length = atoi(optarg);
break;
case 'm' :
write_mst = TRUE;
break;
case 'n' :
if (*optarg != 'c')
{
fprintf(stderr, usage, argv[0]);
exit(0);
}
switch(optarg[1])
{
case 'm' :
conname_format(CON_FORM_MAKE);
break;
case 'n' :
conname_format(CON_FORM_NAME);
break;
case 'f' :
conname_format(CON_FORM_FULL);
break;
default :
fprintf(stderr, usage, argv[0]);
exit(0);
}
break;
case 'o' :
basefile = strdup(optarg);
break;
case 'O' :
presolve = TRUE;
break;
case 'P' :
inppipe = strdup(optarg);
break;
case 's' :
seed = (unsigned long)atol(optarg);
break;
case 'r' :
write_order = TRUE;
break;
case 't' :
switch(tolower(*optarg))
{
case 'h' :
format = LP_FORM_HUM;
break;
case 'm' :
format = LP_FORM_MPS;
break;
case 'l' :
format = LP_FORM_LPF;
break;
case 'p' :
format = LP_FORM_PIP;
break;
case 'r' :
format = LP_FORM_RLP;
break;
default :
if (verbose > VERB_QUIET)
fprintf(stderr,
"--- Warning 103: Output format \"%s\" not supported, using LP format\n",
optarg);
format = LP_FORM_LPF;
break;
}
break;
case 'v' :
verbose = atoi(optarg);
break;
case 'V' :
printf("%s\n", VERSION);
exit(0);
case '?':
fprintf(stderr, usage, argv[0]);
exit(0);
default :
abort();
}
}
if ((argc - optind) < 1)
{
fprintf(stderr, usage, argv[0]);
exit(0);
}
zpl_print_banner(stdout, TRUE);
if (basefile == NULL)
basefile = strip_extension(strdup(strip_path(argv[optind])));
switch(format)
{
case LP_FORM_LPF :
extension = ".lp";
break;
case LP_FORM_MPS :
extension = ".mps";
break;
case LP_FORM_HUM :
extension = ".hum";
break;
case LP_FORM_RLP :
extension = ".rlp";
break;
case LP_FORM_PIP :
extension = ".pip";
break;
default :
abort();
}
assert(extension != NULL);
outfile = add_extention(basefile, extension);
tblfile = add_extention(basefile, ".tbl");
ordfile = add_extention(basefile, ".ord");
mstfile = add_extention(basefile, ".mst");
outpipe = malloc(strlen(basefile) + strlen(filter) + 256);
assert(outpipe != NULL);
blk_init();
str_init();
rand_init(seed);
numb_init(TRUE);
elem_init();
set_init();
mio_init();
interns_init();
local_init();
/* Make symbol to hold entries of internal variables
*/
set = set_pseudo_new();
(void)symbol_new(SYMBOL_NAME_INTERNAL, SYM_VAR, set, 100, NULL);
set_free(set);
/* Now store the param defines
*/
for(i = 0; i < param_count; i++)
zpl_add_parameter(param_table[i]);
/* Next we read in the zpl program(s)
*/
prog = prog_new();
for(i = optind; i < argc; i++)
prog_load(prog, inppipe, argv[i]);
if (prog_is_empty(prog))
{
fprintf(stderr, "*** Error 168: No program statements to execute\n");
exit(EXIT_FAILURE);
}
if (verbose >= VERB_DEBUG)
prog_print(stderr, prog);
lp = xlp_alloc(argv[optind], write_mst || write_order, NULL);
zlp_setnamelen(lp, name_length);
prog_execute(prog, lp);
/* Presolve
*/
if (presolve)
fprintf(stderr, "--- Warning: Presolve no longer support. If you need it, send me an email\n");
#if 0
if (!zlp_presolve())
exit(EXIT_SUCCESS);
#endif
if (verbose >= VERB_NORMAL)
zlp_stat(lp);
/* Write order file
*/
if (write_order)
{
sprintf(outpipe, filter, ordfile, "ord");
if (verbose >= VERB_NORMAL)
printf("Writing [%s]\n", outpipe);
if (NULL == (fp = (*openfile)(outpipe, "w")))
{
fprintf(stderr, "*** Error 104: File open failed ");
perror(ordfile);
exit(EXIT_FAILURE);
}
zlp_orderfile(lp, fp, format);
check_write_ok(fp, ordfile);
(void)(*closefile)(fp);
}
/* Write MST file
*/
if (write_mst)
{
sprintf(outpipe, filter, mstfile, "mst");
if (verbose >= VERB_NORMAL)
printf("Writing [%s]\n", outpipe);
if (NULL == (fp = (*openfile)(outpipe, "w")))
{
fprintf(stderr, "*** Error 104: File open failed ");
perror(mstfile);
exit(EXIT_FAILURE);
}
zlp_mstfile(lp, fp, format);
check_write_ok(fp, mstfile);
(void)(*closefile)(fp);
}
/* Write Output
*/
sprintf(outpipe, filter, outfile, "lp");
if (verbose >= VERB_NORMAL)
printf("Writing [%s]\n", outpipe);
if (NULL == (fp = (*openfile)(outpipe, "w")))
{
fprintf(stderr, "*** Error 104: File open failed ");
perror(outfile);
exit(EXIT_FAILURE);
}
if (format != LP_FORM_RLP)
prog_text = prog_tostr(prog, format == LP_FORM_MPS ? "* " : "\\ ", title, 128);
else
{
prog_text = malloc(strlen(title) + 4);
assert(prog_text != NULL);
sprintf(prog_text, "\\%s\n", title);
}
zlp_write(lp, fp, format, prog_text);
check_write_ok(fp, outfile);
(void)(*closefile)(fp);
/* We do not need the translation table for human readable format
* Has to be written after the LP file, so the scaling has been done.
*/
if (format != LP_FORM_HUM)
{
/* Write translation table
*/
sprintf(outpipe, filter, tblfile, "tbl");
if (verbose >= VERB_NORMAL)
printf("Writing [%s]\n", outpipe);
if (NULL == (fp = (*openfile)(outpipe, "w")))
{
fprintf(stderr, "*** Error 104: File open failed");
perror(tblfile);
exit(EXIT_FAILURE);
}
zlp_transtable(lp, fp, format);
check_write_ok(fp, tblfile);
(void)(*closefile)(fp);
}
free(prog_text);
if (verbose >= VERB_DEBUG)
symbol_print_all(stderr);
#if defined(__INSURE__) || !defined(NDEBUG) || defined(FREEMEM)
/* Now clean up.
*/
if (inppipe != NULL)
free(inppipe);
for(i = 0; i < param_count; i++)
free(param_table[i]);
free(param_table);
prog_free(prog);
local_exit();
interns_exit();
xlp_free(lp);
mio_exit();
symbol_exit();
define_exit();
set_exit();
elem_exit();
numb_exit();
str_exit();
blk_exit();
free(mstfile);
free(ordfile);
free(outfile);
free(tblfile);
free(basefile);
free(filter);
free(outpipe);
if (verbose >= VERB_NORMAL)
{
mem_display(stdout);
stkchk_maximum(stdout);
}
#endif /* __INSURE__ || !NDEBUG || FREEMEM */
return 0;
}
zimpl-3.3.4/src/ratlpstore.h 0000640 0012352 0006025 00000010154 13057565713 015700 0 ustar bzfgamra optimi /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* File....: ratlpstore.h */
/* Name....: Rational Number Store Linear Programm */
/* Author..: Thorsten Koch */
/* Copyright by Author, All rights reserved */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Copyright (C) 2003-2017 by Thorsten Koch
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _RATLPSTORE_H_
#define _RATLPSTORE_H_
#ifndef __GMP_H__
#error "Need to include gmp.h before ratlpstore.h"
#endif
#ifndef _BOOL_H_
#error "Need to include bool.h before ratlpstore.h"
#endif
#ifndef _RATLPTYPES_H_
#error "Need to include ratlptypes.h before ratlpstore.h"
#endif
#ifdef __cplusplus
extern "C" {
#endif
typedef struct storage Sto;
typedef struct lps_hash LpsHash;
struct nonzero
{
Var* var;
Con* con;
Nzo* var_prev;
Nzo* var_next;
Nzo* con_prev;
Nzo* con_next;
mpq_t value;
};
struct variable
{
unsigned int sid;
char* name;
int number;
VarClass vclass;
VarType type;
Bool is_used;
int size;
mpq_t cost;
mpq_t lower;
mpq_t upper;
mpq_t value;
mpq_t startval;
int priority;
Var* prev;
Var* next;
Nzo* first;
};
#define VAR_SID 0x5e564152
struct constraint
{
unsigned int sid;
char* name;
int number;
unsigned int flags;
ConType type;
int size;
mpq_t lhs;
mpq_t rhs;
mpq_t scale;
Var* ind_var;
Bool ind_dir;
Con* prev;
Con* next;
Nzo* first;
Qme* qme_first;
Term* term;
};
#define CON_SID 0x5e434f4e
struct lpstorage
{
char* name;
LpType type; /* ??? Wird noch nicht automatisch gesetzt */
LpDirect direct;
char* probname;
char* objname;
char* rhsname;
char* bndname;
char* rngname;
int vars;
int cons;
int soss;
int nonzeros;
Var* var_root;
Con* con_root;
Sos* sos_root;
Sto* sto_root;
Nzo* next;
LpsHash* var_hash;
LpsHash* con_hash;
LpsHash* sos_hash;
Var* var_last;
Con* con_last;
Sos* sos_last;
int name_len;
};
struct soselement
{
Var* var;
mpq_t weight;
Sse* next;
};
struct soset
{
unsigned int sid;
char* name;
SosType type;
int priority;
int sses;
Sos* next;
Sse* first;
};
#define SOS_SID 0x5e534f53
struct qmatentry
{
unsigned int sid;
const Var* var1;
const Var* var2;
mpq_t value;
Qme* next;
};
#define QME_SID 0x514D656E
/* Internal functions
*/
/*lint -sem( lps_getnamesize, 1p, @n > 8) */
int lps_getnamesize(const Lps* lp, LpFormat format);
/*lint -sem( lps_makename, nulterm(3), 1p && 2n > 0 && 3p && 4n >= -1) */
void lps_makename(char* target, int size, const char* name, int no);
#ifdef __cplusplus
}
#endif
#endif /* _RATLPSTORE_H_ */
zimpl-3.3.4/src/stmt.h 0000640 0012352 0006025 00000006306 13057565713 014474 0 ustar bzfgamra optimi /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* File....: stmt.h */
/* Name....: Statement Functions */
/* Author..: Thorsten Koch */
/* Copyright by Author, All rights reserved */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Copyright (C) 2001-2017 by Thorsten Koch
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _STMT_H_
#define _STMT_H_
#ifndef _BOOL_H_
#error "Need to include bool.h before stmt.h"
#endif
#ifdef __cplusplus
extern "C" {
#endif
enum statement_type
{
STMT_ERR = 0, STMT_SET, STMT_PARAM, STMT_VAR, STMT_MIN, STMT_MAX,
STMT_CONS, STMT_DEF, STMT_DO, STMT_SOS
};
typedef enum statement_type StmtType;
typedef struct statement Stmt;
/* stmt.c
*/
/*lint -sem( stmt_new, nulterm(2), nulterm(4), 2p && 3n >= 0 && 4p, @p == 1) */
extern Stmt* stmt_new(StmtType type, const char* filename, int lineno,
const char* text);
/*lint -sem( stmt_free, custodial(1), 1p == 1) */
extern void stmt_free(Stmt* stmt);
/*lint -sem( stmt_is_valid, 1p == 1) */
extern Bool stmt_is_valid(const Stmt* stmt);
/*lint -sem( stmt_get_filename, 1p == 1, @p && nulterm(@)) */
extern const char* stmt_get_filename(const Stmt* stmt);
/*lint -sem( stmt_get_lineno, 1p == 1, @n > 0) */
extern int stmt_get_lineno(const Stmt* stmt);
/*lint -sem( stmt_get_text, 1p == 1, @p && nulterm(@)) */
extern const char* stmt_get_text(const Stmt* stmt);
/*lint -sem( stmt_parse, 1p == 1) */
extern void stmt_parse(Stmt* stmt);
/*lint -sem( stmt_execute, 1p == 1) */
extern void stmt_execute(const Stmt* stmt);
/*lint -sem( stmt_print, 1p == 1 && 2p == 1) */
extern void stmt_print(FILE* fp, const Stmt* stmt);
/*lint -sem( stmt_trigger_warning, 1n >= 0) */
extern Bool stmt_trigger_warning(int no);
/* mmlparse.y
*/
extern int yyparse(void);
/* mmlscan.l
*/
/*lint -sem( parse_stmt, 1p) */
extern void parse_stmt(const Stmt* stmt);
extern const Stmt* scan_get_stmt(void);
extern int scan_get_column(void);
#ifdef __cplusplus
}
#endif
#endif /* _STMT_H_ */
zimpl-3.3.4/src/entry.c 0000640 0012352 0006025 00000013646 13057565713 014646 0 ustar bzfgamra optimi /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* File....: entry.c */
/* Name....: Symbol Table Entry Functions */
/* Author..: Thorsten Koch */
/* Copyright by Author, All rights reserved */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Copyright (C) 2001-2017 by Thorsten Koch
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include
#include
#include
#include
#include "bool.h"
#include "mshell.h"
#include "ratlptypes.h"
#include "numb.h"
#include "elem.h"
#include "tuple.h"
#include "mme.h"
#include "set.h"
#include "symbol.h"
#include "entry.h"
#include "zimpllib.h"
#define ENTRY_SID 0x456e7472
typedef union entry_value EntryValue;
union entry_value
{
Numb* numb;
const char* strg;
Set* set;
Var* var;
};
struct entry
{
SID
int refc;
Tuple* tuple;
SymbolType type;
EntryValue value;
};
Entry* entry_new_numb(const Tuple* tuple, const Numb* numb)
{
Entry* entry = calloc(1, sizeof(*entry));
assert(entry != NULL);
assert(tuple != NULL);
entry->refc = 1;
entry->tuple = tuple_copy(tuple);
entry->type = SYM_NUMB;
entry->value.numb = numb_copy(numb);
SID_set(entry, ENTRY_SID);
assert(entry_is_valid(entry));
mem_check(entry);
return entry;
}
Entry* entry_new_strg(const Tuple* tuple, const char* strg)
{
Entry* entry = calloc(1, sizeof(*entry));
assert(entry != NULL);
assert(tuple != NULL);
assert(strg != NULL);
entry->refc = 1;
entry->tuple = tuple_copy(tuple);
entry->type = SYM_STRG;
entry->value.strg = strg;
SID_set(entry, ENTRY_SID);
assert(entry_is_valid(entry));
return entry;
}
Entry* entry_new_set(const Tuple* tuple, const Set* set)
{
Entry* entry = calloc(1, sizeof(*entry));
assert(entry != NULL);
assert(tuple != NULL);
assert(set != NULL);
entry->refc = 1;
entry->tuple = tuple_copy(tuple);
entry->type = SYM_SET;
entry->value.set = set_copy(set);
SID_set(entry, ENTRY_SID);
assert(entry_is_valid(entry));
return entry;
}
Entry* entry_new_var(const Tuple* tuple, Var* var)
{
Entry* entry = calloc(1, sizeof(*entry));
assert(entry != NULL);
assert(tuple != NULL);
assert(var != NULL);
entry->refc = 1;
entry->tuple = tuple_copy(tuple);
entry->type = SYM_VAR;
entry->value.var = var;
SID_set(entry, ENTRY_SID);
assert(entry_is_valid(entry));
return entry;
}
void entry_free(Entry* entry)
{
assert(entry_is_valid(entry));
entry->refc--;
if (entry->refc == 0)
{
SID_del(entry);
switch(entry->type)
{
case SYM_NUMB :
numb_free(entry->value.numb);
break;
case SYM_STRG :
break;
case SYM_SET :
set_free(entry->value.set);
break;
case SYM_VAR :
break;
default :
abort();
}
tuple_free(entry->tuple);
free(entry);
}
}
Bool entry_is_valid(const Entry* entry)
{
if (entry == NULL || !SID_ok(entry, ENTRY_SID))
return FALSE;
mem_check(entry);
return TRUE;
}
Entry* entry_copy(const Entry* source)
{
Entry* entry = (Entry*)source;
assert(entry_is_valid(entry));
entry->refc++;
return entry;
}
Bool entry_cmp(const Entry* entry, const Tuple* tuple)
{
assert(entry_is_valid(entry));
assert(tuple_is_valid(tuple));
return tuple_cmp(entry->tuple, tuple);
}
SymbolType entry_get_type(const Entry* entry)
{
assert(entry_is_valid(entry));
return entry->type;
}
const Tuple* entry_get_tuple(const Entry* entry)
{
assert(entry_is_valid(entry));
assert(tuple_is_valid(entry->tuple));
return entry->tuple;
}
const Numb* entry_get_numb(const Entry* entry)
{
assert(entry_is_valid(entry));
assert(entry->type == SYM_NUMB);
return entry->value.numb;
}
const char* entry_get_strg(const Entry* entry)
{
assert(entry_is_valid(entry));
assert(entry->type == SYM_STRG);
return entry->value.strg;
}
const Set* entry_get_set(const Entry* entry)
{
assert(entry_is_valid(entry));
assert(entry->type == SYM_SET);
return entry->value.set;
}
Var* entry_get_var(const Entry* entry)
{
assert(entry_is_valid(entry));
assert(entry->type == SYM_VAR);
return entry->value.var;
}
void entry_print(FILE* fp, const Entry* entry)
{
assert(entry_is_valid(entry));
tuple_print(fp, entry->tuple);
fprintf(fp, " -> ");
switch(entry->type)
{
case SYM_NUMB :
fprintf(fp, "%.16g", numb_todbl(entry->value.numb));
break;
case SYM_STRG :
fprintf(fp, "\"%s\"", entry->value.strg);
break;
case SYM_SET :
set_print(fp, entry->value.set);
break;
case SYM_VAR :
zpl_var_print(fp, entry->value.var);
break;
default :
fprintf(fp, "Entry-ERR");
break;
}
}
zimpl-3.3.4/src/numbgmp.c 0000640 0012352 0006025 00000041106 13057565713 015142 0 ustar bzfgamra optimi /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* File....: numbgmp.c */
/* Name....: Number Functions using gmp */
/* Author..: Thorsten Koch */
/* Copyright by Author, All rights reserved */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Copyright (C) 2001-2017 by Thorsten Koch
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include
#include
#include
#include
#include
#include
#include
#include
/* #define TRACE 1 */
#include "bool.h"
#include "lint.h"
#include "mshell.h"
#include "random.h"
#include "gmpmisc.h"
#include "mme.h"
#include "numb.h"
#define NUMB_STORE_SIZE 1000
#define NUMB_SID 0x4e756d62
typedef struct numb_storage NumbStore;
/* Note: In case of gmt use refc and infinity indicator.
*/
struct number
{
SID
union
{
mpq_t numb;
Numb* next;
} value;
};
struct numb_storage
{
Numb* begin;
NumbStore* next;
};
static NumbStore* store_anchor = NULL;
static Numb* store_free = NULL;
static int store_count = 0;
/* constants
*/
static Numb* numb_const_zero = NULL;
static Numb* numb_const_one = NULL;
static Numb* numb_const_minusone = NULL;
static Numb* numb_const_unknown = NULL;
/* ??? numb_const_unkown is a hack. GMP has no way to indicate NaN or Infinity.
* But we need this for example to convey that the startvalue of a variable has
* not been set.
*/
static void extend_storage(void)
{
NumbStore* store = calloc(1, sizeof(*store));
Numb* numb;
int i;
assert(store != NULL);
store->begin = malloc(NUMB_STORE_SIZE * sizeof(*store->begin));
store->next = store_anchor;
store_anchor = store;
for(i = 0; i < NUMB_STORE_SIZE - 1; i++)
{
numb = &store->begin[i];
numb->value.next = &store->begin[i + 1];
SID_set(numb, NUMB_SID);
assert(numb_is_valid(numb));
}
numb = &store->begin[i];
numb->value.next = store_free;
SID_set(numb, NUMB_SID);
assert(numb_is_valid(numb));
store_free = &store->begin[0];
assert(store->begin != NULL);
assert(store_anchor != NULL);
assert(store_free != NULL);
}
void numb_init(Bool with_management)
{
store_anchor = NULL;
store_free = NULL;
gmp_init(verbose >= VERB_VERBOSE, with_management);
numb_const_zero = numb_new();
numb_const_one = numb_new_integer(1);
numb_const_minusone = numb_new_integer(-1);
numb_const_unknown = numb_new_ascii("7e21");
}
void numb_exit()
{
NumbStore* store;
NumbStore* next;
numb_free(numb_const_zero);
numb_free(numb_const_one);
numb_free(numb_const_minusone);
numb_free(numb_const_unknown);
numb_const_zero = NULL;
numb_const_one = NULL;
numb_const_minusone = NULL;
numb_const_unknown = NULL;
if (store_count != 0)
printf("Numb store count %d\n", store_count);
for(store = store_anchor; store != NULL; store = next)
{
next = store->next;
/* ??? mpq_clear() is not called for the used ones.
* This would be faster then doing it in numb_free.
*/
/* ??? SIDs are not cleared.
*/
free(store->begin);
free(store);
}
store_anchor = NULL;
store_free = NULL;
store_count = 0;
gmp_exit();
}
/* value is zero */
Numb* numb_new(void)
{
Numb* numb;
Trace("numb_new");
if (store_free == NULL)
extend_storage();
assert(store_free != NULL);
numb = store_free;
store_free = numb->value.next;
store_count++;
mpq_init(numb->value.numb);
return numb;
}
Numb* numb_new_ascii(const char* val)
{
Numb* numb = numb_new();
assert(numb != NULL);
gmp_str2mpq(numb->value.numb, val);
return numb;
}
Numb* numb_new_integer(int val)
{
Numb* numb = numb_new();
assert(numb != NULL);
mpq_set_si(numb->value.numb, val, 1);
return numb;
}
Numb* numb_new_mpq(const mpq_t val)
{
Numb* numb = numb_new();
assert(numb != NULL);
mpq_set(numb->value.numb, val);
return numb;
}
void numb_free(Numb* numb)
{
Trace("numb_free");
assert(numb_is_valid(numb));
mpq_clear(numb->value.numb);
numb->value.next = store_free;
store_free = numb;
store_count--;
}
Bool numb_is_valid(const Numb* numb)
{
return numb != NULL && SID_ok(numb, NUMB_SID);
}
Numb* numb_copy(const Numb* source)
{
Numb* numb = numb_new();
assert(numb_is_valid(source));
assert(numb_is_valid(numb));
mpq_set(numb->value.numb, source->value.numb);
return numb;
}
/* TRUE wenn gleich, sonst FALSE
*/
Bool numb_equal(const Numb* numb_a, const Numb* numb_b)
{
assert(numb_is_valid(numb_a));
assert(numb_is_valid(numb_b));
return mpq_equal(numb_a->value.numb, numb_b->value.numb) != 0;
}
/* Return a positive value if op1 > op2, zero if op1 = op2, and a negative value if op1 < op2
*/
int numb_cmp(const Numb* numb_a, const Numb* numb_b)
{
assert(numb_is_valid(numb_a));
assert(numb_is_valid(numb_b));
return mpq_cmp(numb_a->value.numb, numb_b->value.numb);
}
void numb_set(Numb* numb_a, const Numb* numb_b)
{
assert(numb_is_valid(numb_a));
assert(numb_is_valid(numb_b));
mpq_set(numb_a->value.numb, numb_b->value.numb);
}
void numb_add(Numb* numb_a, const Numb* numb_b)
{
assert(numb_is_valid(numb_a));
assert(numb_is_valid(numb_b));
mpq_add(numb_a->value.numb, numb_a->value.numb, numb_b->value.numb);
}
Numb* numb_new_add(const Numb* numb_a, const Numb* numb_b)
{
Numb* numb = numb_new();
assert(numb != NULL);
assert(numb_is_valid(numb_a));
assert(numb_is_valid(numb_b));
mpq_add(numb->value.numb, numb_a->value.numb, numb_b->value.numb);
return numb;
}
void numb_sub(Numb* numb_a, const Numb* numb_b)
{
assert(numb_is_valid(numb_a));
assert(numb_is_valid(numb_b));
mpq_sub(numb_a->value.numb, numb_a->value.numb, numb_b->value.numb);
}
Numb* numb_new_sub(const Numb* numb_a, const Numb* numb_b)
{
Numb* numb = numb_new();
assert(numb != NULL);
assert(numb_is_valid(numb_a));
assert(numb_is_valid(numb_b));
mpq_sub(numb->value.numb, numb_a->value.numb, numb_b->value.numb);
return numb;
}
void numb_mul(Numb* numb_a, const Numb* numb_b)
{
assert(numb_is_valid(numb_a));
assert(numb_is_valid(numb_b));
mpq_mul(numb_a->value.numb, numb_a->value.numb, numb_b->value.numb);
}
Numb* numb_new_mul(const Numb* numb_a, const Numb* numb_b)
{
Numb* numb = numb_new();
assert(numb != NULL);
assert(numb_is_valid(numb_a));
assert(numb_is_valid(numb_b));
mpq_mul(numb->value.numb, numb_a->value.numb, numb_b->value.numb);
return numb;
}
void numb_div(Numb* numb_a, const Numb* numb_b)
{
assert(numb_is_valid(numb_a));
assert(numb_is_valid(numb_b));
mpq_div(numb_a->value.numb, numb_a->value.numb, numb_b->value.numb);
}
Numb* numb_new_div(const Numb* numb_a, const Numb* numb_b)
{
Numb* numb = numb_new();
assert(numb != NULL);
assert(numb_is_valid(numb_a));
assert(numb_is_valid(numb_b));
mpq_div(numb->value.numb, numb_a->value.numb, numb_b->value.numb);
return numb;
}
void numb_intdiv(Numb* numb_a, const Numb* numb_b)
{
mpz_t q;
assert(numb_is_valid(numb_a));
assert(numb_is_valid(numb_b));
mpq_div(numb_a->value.numb, numb_a->value.numb, numb_b->value.numb);
mpz_init(q);
mpz_tdiv_q(q, mpq_numref(numb_a->value.numb), mpq_denref(numb_a->value.numb));
mpq_set_z(numb_a->value.numb, q);
mpz_clear(q);
}
Numb* numb_new_intdiv(const Numb* numb_a, const Numb* numb_b)
{
Numb* numb = numb_new();
mpz_t q;
assert(numb != NULL);
assert(numb_is_valid(numb_a));
assert(numb_is_valid(numb_b));
mpq_div(numb->value.numb, numb_a->value.numb, numb_b->value.numb);
mpz_init(q);
mpz_tdiv_q(q, mpq_numref(numb->value.numb), mpq_denref(numb->value.numb));
mpq_set_z(numb->value.numb, q);
mpz_clear(q);
return numb;
}
void numb_mod(Numb* numb_a, const Numb* numb_b)
{
mpz_t a;
mpz_t b;
mpz_t r;
assert(numb_is_valid(numb_a));
assert(numb_is_valid(numb_b));
mpz_init(a);
mpz_init(b);
mpz_init(r);
mpz_mul(a, mpq_numref(numb_a->value.numb), mpq_denref(numb_b->value.numb));
mpz_mul(b, mpq_numref(numb_b->value.numb), mpq_denref(numb_a->value.numb));
mpz_mod(r, a, b);
mpq_set_z(numb_a->value.numb, r);
mpz_clear(r);
mpz_clear(b);
mpz_clear(a);
}
Numb* numb_new_mod(const Numb* numb_a, const Numb* numb_b)
{
Numb* numb = numb_new();
mpz_t a;
mpz_t b;
mpz_t r;
assert(numb != NULL);
assert(numb_is_valid(numb_a));
assert(numb_is_valid(numb_b));
mpz_init(a);
mpz_init(b);
mpz_init(r);
mpz_mul(a, mpq_numref(numb_a->value.numb), mpq_denref(numb_b->value.numb));
mpz_mul(b, mpq_numref(numb_b->value.numb), mpq_denref(numb_a->value.numb));
mpz_mod(r, a, b);
mpq_set_z(numb->value.numb, r);
mpz_clear(r);
mpz_clear(b);
mpz_clear(a);
return numb;
}
Numb* numb_new_pow(const Numb* base, int expo)
{
Numb* numb = numb_new();
int i;
Bool is_negative = FALSE;
assert(numb != NULL);
assert(numb_is_valid(base));
if (expo < 0)
{
is_negative = TRUE;
expo = -expo;
}
mpq_set_si(numb->value.numb, 1, 1); /* set to 1 */
for(i = 1; i <= expo; i++)
mpq_mul(numb->value.numb, numb->value.numb, base->value.numb);
if (is_negative)
mpq_inv(numb->value.numb, numb->value.numb);
return numb;
}
Numb* numb_new_fac(int n)
{
Numb* numb = numb_new();
mpz_t z;
assert(numb != NULL);
assert(n >= 0);
mpz_init(z);
mpz_fac_ui(z, n);
mpq_set_z(numb->value.numb, z);
mpz_clear(z);
return numb;
}
void numb_neg(Numb* numb)
{
assert(numb_is_valid(numb));
mpq_neg(numb->value.numb, numb->value.numb);
}
void numb_abs(Numb* numb)
{
assert(numb_is_valid(numb));
mpq_abs(numb->value.numb, numb->value.numb);
}
void numb_sgn(Numb* numb)
{
assert(numb_is_valid(numb));
/*lint -e(634) Strong type mismatch (type 'Bool') in equality or conditional */
switch(mpq_sgn(numb->value.numb))
{
case -1 :
mpq_set(numb->value.numb, const_minus_one);
break;
case 0 :
mpq_set(numb->value.numb, const_zero);
break;
case 1 :
mpq_set(numb->value.numb, const_one);
break;
default :
abort();
}
}
int numb_get_sgn(const Numb* numb)
{
assert(numb_is_valid(numb));
/*lint -e(634) Strong type mismatch (type 'Bool') in equality or conditional */
return mpq_sgn(numb->value.numb);
}
void numb_round(Numb* numb)
{
mpz_t q;
mpq_t h;
assert(numb_is_valid(numb));
mpz_init(q);
mpq_init(h);
mpq_set_d(h, 0.5);
/*lint -e(634) Strong type mismatch (type 'Bool') in equality or conditional */
if (mpq_sgn(numb->value.numb) >= 0)
mpq_add(numb->value.numb, numb->value.numb, h);
else
mpq_sub(numb->value.numb, numb->value.numb, h);
mpz_tdiv_q(q, mpq_numref(numb->value.numb), mpq_denref(numb->value.numb));
mpq_set_z(numb->value.numb, q);
mpz_clear(q);
mpq_clear(h);
}
void numb_ceil(Numb* numb)
{
mpz_t q;
assert(numb_is_valid(numb));
mpz_init(q);
mpz_cdiv_q(q, mpq_numref(numb->value.numb), mpq_denref(numb->value.numb));
mpq_set_z(numb->value.numb, q);
mpz_clear(q);
}
void numb_floor(Numb* numb)
{
mpz_t q;
assert(numb_is_valid(numb));
mpz_init(q);
mpz_fdiv_q(q, mpq_numref(numb->value.numb), mpq_denref(numb->value.numb));
mpq_set_z(numb->value.numb, q);
mpz_clear(q);
}
Numb* numb_new_log(const Numb* numb)
{
char temp[256];
double d;
assert(numb_is_valid(numb));
d = log10(mpq_get_d(numb->value.numb));
/* !finite == !isfinite == isnan || isinf */
if ((d != d) || (d == -HUGE_VAL)) /*lint !e777 */ /* == isnan(d) || isinf(d) */
{
sprintf(temp, "*** Error 700: log(%f)", mpq_get_d(numb->value.numb));
perror(temp);
return NULL;
}
sprintf(temp, "%.16e", d);
return numb_new_ascii(temp);
}
Numb* numb_new_sqrt(const Numb* numb)
{
char temp[256];
double d;
assert(numb_is_valid(numb));
d = sqrt(mpq_get_d(numb->value.numb));
/* !finite == !isfinite == isnan || isinf */
if (d != d) /*lint !e777 */ /* == isnan(d) || isinf(d) */
{
sprintf(temp, "*** Error 701: sqrt(%f)", mpq_get_d(numb->value.numb));
perror(temp);
return NULL;
}
sprintf(temp, "%.16e", d);
return numb_new_ascii(temp);
}
Numb* numb_new_exp(const Numb* numb)
{
char temp[32];
assert(numb_is_valid(numb));
sprintf(temp, "%.16e", exp(mpq_get_d(numb->value.numb)));
return numb_new_ascii(temp);
}
Numb* numb_new_ln(const Numb* numb)
{
char temp[256];
double d;
assert(numb_is_valid(numb));
d = log(mpq_get_d(numb->value.numb));
/* !finite == !isfinite == isnan || isinf */
if ((d != d) || (d == -HUGE_VAL)) /*lint !e777 */ /* == isnan(d) || isinf(d) */
{
sprintf(temp, "*** Error 702: ln(%f)", mpq_get_d(numb->value.numb));
perror(temp);
return NULL;
}
sprintf(temp, "%.16e", d);
return numb_new_ascii(temp);
}
Numb* numb_new_rand(const Numb* mini, const Numb* maxi)
{
Numb* numb = numb_new();
mpq_t maxint;
mpq_t factor;
assert(numb != NULL);
assert(numb_is_valid(mini));
assert(numb_is_valid(maxi));
assert(numb_cmp(mini, maxi) <= 0);
mpq_init(factor);
mpq_init(maxint);
mpq_set_ui(numb->value.numb, rand_get_int32(), 1);
mpq_set_ui(maxint, 4294967295UL, 1);
mpq_div(numb->value.numb, numb->value.numb, maxint);
mpq_sub(factor, maxi->value.numb, mini->value.numb);
mpq_mul(numb->value.numb, numb->value.numb, factor);
mpq_add(numb->value.numb, numb->value.numb, mini->value.numb);
mpq_clear(factor);
mpq_clear(maxint);
return numb;
}
double numb_todbl(const Numb* numb)
{
assert(numb_is_valid(numb));
return mpq_get_d(numb->value.numb);
}
void numb_get_mpq(const Numb* numb, mpq_t value)
{
assert(numb_is_valid(numb));
mpq_set(value, numb->value.numb);
}
void numb_print(FILE* fp, const Numb* numb)
{
assert(numb_is_valid(numb));
fprintf(fp, "%.16g", mpq_get_d(numb->value.numb));
}
unsigned int numb_hash(const Numb* numb)
{
union
{
struct
{
unsigned int a;
unsigned int b;
} i;
double d;
} d2i;
unsigned int hcode;
d2i.d = mpq_get_d(numb->value.numb);
hcode = d2i.i.a ^ d2i.i.b;
return hcode;
}
char* numb_tostr(const Numb* numb)
{
char* str;
assert(numb_is_valid(numb));
str = malloc(32);
assert(str != NULL);
sprintf(str, "%.16g", mpq_get_d(numb->value.numb));
return str;
}
const Numb* numb_zero()
{
return numb_const_zero;
}
const Numb* numb_one()
{
return numb_const_one;
}
const Numb* numb_minusone()
{
return numb_const_minusone;
}
const Numb* numb_unknown()
{
return numb_const_unknown;
}
Bool numb_is_int(const Numb* numb)
{
/* Do we have an integer ?
*/
if (mpz_get_si(mpq_denref(numb->value.numb)) == 1)
{
/* And is it small enough ?
*/
if (mpz_fits_sint_p(mpq_numref(numb->value.numb)) == 1)
return TRUE;
}
return FALSE;
}
int numb_toint(const Numb* numb)
{
assert(numb_is_valid(numb));
assert(numb_is_int(numb));
return mpz_get_si(mpq_numref(numb->value.numb));
}
Bool numb_is_number(const char *s)
{
/* 5 !*/
if (isdigit(*s))
return TRUE;
/* maybe -5 or .6 or -.7 ? */
if (*s != '+' && *s != '-' && *s != '.')
return FALSE;
s++;
/* -5 or .6 ! */
if (isdigit(*s))
return TRUE;
/* maybe -.7 ? */
if (*s != '.')
return FALSE;
s++;
return isdigit(*s);
}
zimpl-3.3.4/src/random.h 0000640 0012352 0006025 00000003351 13057565713 014762 0 ustar bzfgamra optimi /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* File....: random.h */
/* Name....: Random Number Functions */
/* Author..: Thorsten Koch */
/* Copyright by Author, All rights reserved */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Copyright (C) 2007-2017 by Thorsten Koch
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _RANDOM_H_
#define _RANDOM_H_
#ifdef __cplusplus
extern "C" {
#endif
extern void rand_init(unsigned long s);
extern unsigned int rand_get_int32(void);
/*lint -sem( rand_get_range, 1n < 2n) */
extern int rand_get_range(int mini, int maxi);
#ifdef __cplusplus
}
#endif
#endif /* RANDOM */
zimpl-3.3.4/src/depend 0000640 0012352 0006025 00000021470 13057565713 014515 0 ustar bzfgamra optimi $(OBJDIR)/zimpl.o: src/zimpl.c src/lint.h src/bool.h src/mshell.h src/stkchk.h \
src/random.h src/blkmem.h src/ratlptypes.h src/numb.h src/elem.h \
src/tuple.h src/mme.h src/set.h src/symbol.h src/define.h src/bound.h \
src/mono.h src/term.h src/stmt.h src/local.h src/list.h src/entry.h \
src/conname.h src/xlpglue.h src/zlpglue.h src/prog.h src/metaio.h \
src/strstore.h src/zimpllib.h
$(OBJDIR)/xlpglue.o: src/xlpglue.c src/lint.h src/bool.h src/mshell.h \
src/ratlptypes.h src/numb.h src/elem.h src/tuple.h src/mme.h src/bound.h \
src/mono.h src/term.h src/ratlp.h src/gmpmisc.h src/conname.h src/stmt.h \
src/hash.h src/xlpglue.h
$(OBJDIR)/zlpglue.o: src/zlpglue.c src/bool.h src/mshell.h src/ratlptypes.h \
src/numb.h src/elem.h src/tuple.h src/mme.h src/bound.h src/mono.h \
src/term.h src/ratlp.h src/zlpglue.h
$(OBJDIR)/ratlpstore.o: src/ratlpstore.c src/lint.h src/bool.h src/mshell.h \
src/gmpmisc.h src/ratlptypes.h src/numb.h src/bound.h src/mme.h \
src/mono.h src/term.h src/ratlp.h src/ratlpstore.h
$(OBJDIR)/ratlpfwrite.o: src/ratlpfwrite.c src/lint.h src/mshell.h src/bool.h \
src/gmpmisc.h src/ratlptypes.h src/numb.h src/bound.h src/mme.h \
src/mono.h src/term.h src/ratlp.h src/ratlpstore.h src/random.h
$(OBJDIR)/ratmpswrite.o: src/ratmpswrite.c src/lint.h src/mshell.h src/bool.h \
src/gmpmisc.h src/ratlptypes.h src/numb.h src/bound.h src/mme.h \
src/mono.h src/term.h src/ratlp.h src/ratlpstore.h
$(OBJDIR)/ratmstwrite.o: src/ratmstwrite.c src/lint.h src/mshell.h src/bool.h \
src/gmpmisc.h src/ratlptypes.h src/numb.h src/bound.h src/mme.h \
src/mono.h src/term.h src/ratlp.h src/ratlpstore.h
$(OBJDIR)/ratordwrite.o: src/ratordwrite.c src/lint.h src/mshell.h src/bool.h \
src/gmpmisc.h src/ratlptypes.h src/numb.h src/bound.h src/mme.h \
src/mono.h src/term.h src/ratlp.h src/ratlpstore.h
$(OBJDIR)/ratpresolve.o: src/ratpresolve.c
$(OBJDIR)/blkmem.o: src/blkmem.c src/mshell.h src/blkmem.h
$(OBJDIR)/bound.o: src/bound.c src/bool.h src/mshell.h src/mme.h src/numb.h \
src/bound.h
$(OBJDIR)/code.o: src/code.c src/bool.h src/mshell.h src/stkchk.h src/ratlptypes.h \
src/numb.h src/elem.h src/tuple.h src/mme.h src/set.h src/symbol.h \
src/entry.h src/idxset.h src/rdefpar.h src/bound.h src/define.h \
src/mono.h src/term.h src/list.h src/stmt.h src/local.h src/code.h \
src/inst.h
$(OBJDIR)/conname.o: src/conname.c src/bool.h src/mshell.h src/ratlptypes.h \
src/numb.h src/mme.h src/bound.h src/mono.h src/term.h src/elem.h \
src/tuple.h src/local.h src/stmt.h src/prog.h src/xlpglue.h \
src/conname.h
$(OBJDIR)/define.o: src/define.c src/bool.h src/mshell.h src/numb.h src/elem.h \
src/tuple.h src/mme.h src/define.h
$(OBJDIR)/elem.o: src/elem.c src/lint.h src/bool.h src/mshell.h src/numb.h \
src/elem.h src/mme.h src/strstore.h
$(OBJDIR)/entry.o: src/entry.c src/bool.h src/mshell.h src/ratlptypes.h src/numb.h \
src/elem.h src/tuple.h src/mme.h src/set.h src/symbol.h src/entry.h \
src/zimpllib.h
$(OBJDIR)/hash.o: src/hash.c src/bool.h src/mshell.h src/blkmem.h src/ratlptypes.h \
src/numb.h src/elem.h src/tuple.h src/mme.h src/set.h src/symbol.h \
src/entry.h src/mono.h src/hash.h
$(OBJDIR)/heap.o: src/heap.c src/bool.h src/mshell.h src/ratlptypes.h src/numb.h \
src/elem.h src/tuple.h src/mme.h src/set.h src/symbol.h src/entry.h \
src/heap.h
$(OBJDIR)/idxset.o: src/idxset.c src/bool.h src/mshell.h src/numb.h src/elem.h \
src/tuple.h src/mme.h src/set.h src/idxset.h
$(OBJDIR)/inst.o: src/inst.c src/bool.h src/mshell.h src/ratlptypes.h src/numb.h \
src/elem.h src/tuple.h src/mme.h src/set.h src/symbol.h src/define.h \
src/bound.h src/idxset.h src/mono.h src/term.h src/rdefpar.h \
src/conname.h src/stmt.h src/local.h src/list.h src/entry.h src/heap.h \
src/code.h src/inst.h src/prog.h src/xlpglue.h src/strstore.h
$(OBJDIR)/iread.o: src/iread.c src/bool.h src/mshell.h src/ratlptypes.h src/numb.h \
src/elem.h src/tuple.h src/mme.h src/set.h src/symbol.h src/define.h \
src/bound.h src/idxset.h src/mono.h src/term.h src/rdefpar.h \
src/conname.h src/stmt.h src/local.h src/list.h src/entry.h src/heap.h \
src/code.h src/inst.h src/xlpglue.h src/metaio.h src/strstore.h
$(OBJDIR)/list.o: src/list.c src/bool.h src/mshell.h src/blkmem.h src/ratlptypes.h \
src/numb.h src/elem.h src/tuple.h src/mme.h src/entry.h src/list.h
$(OBJDIR)/load.o: src/load.c src/lint.h src/bool.h src/mshell.h src/mme.h \
src/stmt.h src/prog.h src/metaio.h
$(OBJDIR)/local.o: src/local.c src/bool.h src/mshell.h src/numb.h src/elem.h \
src/tuple.h src/mme.h src/local.h
$(OBJDIR)/metaio.o: src/metaio.c src/bool.h src/mshell.h src/mme.h src/metaio.h
$(OBJDIR)/mmlparse2.o: src/mmlparse2.c src/bool.h src/mshell.h src/ratlptypes.h \
src/numb.h src/elem.h src/tuple.h src/mme.h src/set.h src/symbol.h \
src/entry.h src/idxset.h src/rdefpar.h src/bound.h src/define.h \
src/mono.h src/term.h src/list.h src/stmt.h src/local.h src/code.h \
src/inst.h
$(OBJDIR)/mmlscan.o: src/mmlscan.c src/bool.h src/mshell.h src/ratlptypes.h \
src/numb.h src/elem.h src/tuple.h src/mme.h src/set.h src/symbol.h \
src/define.h src/stmt.h src/strstore.h src/mmlparse2.h
$(OBJDIR)/mono.o: src/mono.c src/bool.h src/mshell.h src/ratlptypes.h src/numb.h \
src/elem.h src/tuple.h src/mme.h src/entry.h src/mono.h
$(OBJDIR)/mshell.o: src/mshell.c src/lint.h src/mshell.h
$(OBJDIR)/prog.o: src/prog.c src/lint.h src/bool.h src/mshell.h src/ratlptypes.h \
src/numb.h src/elem.h src/tuple.h src/mme.h src/set.h src/symbol.h \
src/entry.h src/idxset.h src/rdefpar.h src/bound.h src/define.h \
src/mono.h src/term.h src/list.h src/local.h src/code.h src/stmt.h \
src/prog.h
$(OBJDIR)/random.o: src/random.c src/lint.h src/mshell.h src/random.h
$(OBJDIR)/rdefpar.o: src/rdefpar.c src/bool.h src/mshell.h src/mme.h src/strstore.h \
src/rdefpar.h
$(OBJDIR)/source.o: src/source.c src/bool.h src/mshell.h src/ratlptypes.h \
src/numb.h src/elem.h src/tuple.h src/mme.h
$(OBJDIR)/setempty.o: src/setempty.c src/bool.h src/lint.h src/mshell.h src/numb.h \
src/elem.h src/tuple.h src/mme.h src/hash.h src/set.h src/set4.h
$(OBJDIR)/setpseudo.o: src/setpseudo.c src/bool.h src/lint.h src/mshell.h \
src/numb.h src/elem.h src/tuple.h src/mme.h src/hash.h src/set.h \
src/set4.h
$(OBJDIR)/setlist.o: src/setlist.c src/bool.h src/lint.h src/mshell.h \
src/ratlptypes.h src/numb.h src/elem.h src/tuple.h src/mme.h src/entry.h \
src/hash.h src/list.h src/stmt.h src/set.h src/set4.h
$(OBJDIR)/setrange.o: src/setrange.c src/bool.h src/lint.h src/mshell.h src/numb.h \
src/elem.h src/tuple.h src/mme.h src/hash.h src/stmt.h src/set.h \
src/set4.h
$(OBJDIR)/setprod.o: src/setprod.c src/bool.h src/mshell.h src/numb.h src/elem.h \
src/tuple.h src/mme.h src/hash.h src/set.h src/set4.h
$(OBJDIR)/setmulti.o: src/setmulti.c src/lint.h src/bool.h src/mshell.h \
src/ratlptypes.h src/numb.h src/elem.h src/tuple.h src/mme.h src/entry.h \
src/list.h src/hash.h src/stmt.h src/set.h src/set4.h
$(OBJDIR)/set4.o: src/set4.c src/bool.h src/mshell.h src/ratlptypes.h src/numb.h \
src/elem.h src/tuple.h src/mme.h src/entry.h src/list.h src/hash.h \
src/stmt.h src/set.h src/set4.h
$(OBJDIR)/stmt.o: src/stmt.c src/lint.h src/bool.h src/mshell.h src/stkchk.h \
src/ratlptypes.h src/numb.h src/elem.h src/tuple.h src/mme.h src/set.h \
src/symbol.h src/entry.h src/idxset.h src/rdefpar.h src/bound.h \
src/define.h src/mono.h src/term.h src/list.h src/local.h src/code.h \
src/inst.h src/stmt.h
$(OBJDIR)/stkchk.o: src/stkchk.c
$(OBJDIR)/strstore2.o: src/strstore2.c src/lint.h src/mshell.h src/strstore.h \
src/mme.h
$(OBJDIR)/symbol.o: src/symbol.c src/bool.h src/mshell.h src/ratlptypes.h \
src/numb.h src/elem.h src/tuple.h src/mme.h src/entry.h src/set.h \
src/hash.h src/stmt.h src/symbol.h
$(OBJDIR)/term2.o: src/term2.c src/bool.h src/mshell.h src/ratlptypes.h src/numb.h \
src/elem.h src/tuple.h src/mme.h src/bound.h src/entry.h src/mono.h \
src/hash.h src/term.h src/stmt.h src/prog.h src/xlpglue.h
$(OBJDIR)/tuple.o: src/tuple.c src/bool.h src/mshell.h src/blkmem.h src/numb.h \
src/elem.h src/mme.h src/stmt.h src/tuple.h
$(OBJDIR)/vinst.o: src/vinst.c src/lint.h src/bool.h src/mshell.h src/ratlptypes.h \
src/numb.h src/elem.h src/tuple.h src/mme.h src/set.h src/symbol.h \
src/define.h src/bound.h src/idxset.h src/mono.h src/term.h \
src/rdefpar.h src/conname.h src/stmt.h src/prog.h src/local.h src/list.h \
src/entry.h src/heap.h src/code.h src/inst.h src/xlpglue.h \
src/strstore.h
$(OBJDIR)/zimpllib.o: src/zimpllib.c src/lint.h src/bool.h src/mshell.h \
src/stkchk.h src/blkmem.h src/random.h src/ratlptypes.h src/numb.h \
src/elem.h src/tuple.h src/mme.h src/set.h src/symbol.h src/define.h \
src/bound.h src/mono.h src/term.h src/stmt.h src/local.h src/list.h \
src/entry.h src/xlpglue.h src/prog.h src/metaio.h src/strstore.h \
src/zimpllib.h
$(OBJDIR)/gmpmisc.o: src/gmpmisc.c src/bool.h src/mshell.h src/gmpmisc.h
$(OBJDIR)/numbgmp.o: src/numbgmp.c src/bool.h src/lint.h src/mshell.h src/random.h \
src/gmpmisc.h src/mme.h src/numb.h
zimpl-3.3.4/src/WIN/ 0000750 0012352 0006025 00000000000 13057565713 013763 5 ustar bzfgamra optimi zimpl-3.3.4/src/WIN/getopt.c 0000750 0012352 0006025 00000116363 13057565713 015446 0 ustar bzfgamra optimi
/* Getopt for GNU.
NOTE: getopt is now part of the C library, so if you don't know what
"Keep this file name-space clean" means, talk to drepper@gnu.org
before changing it!
Copyright (C) 1987,88,89,90,91,92,93,94,95,96,98,99,2000,2001
Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
/* This tells Alpha OSF/1 not to define a getopt prototype in .
Ditto for AIX 3.2 and . */
#ifndef _NO_PROTO
# define _NO_PROTO
#endif
#ifdef HAVE_CONFIG_H
# include
#endif
#if !defined __STDC__ || !__STDC__
/* This is a separate conditional since some stdc systems
reject `defined (const)'. */
# ifndef const
# define const
# endif
#endif
#include
/* Comment out all this code if we are using the GNU C Library, and are not
actually compiling the library itself. This code is part of the GNU C
Library, but also included in many other GNU distributions. Compiling
and linking in this code is a waste when using the GNU C library
(especially if it is a shared library). Rather than having every GNU
program understand `configure --with-gnu-libc' and omit the object files,
it is simpler to just do this in the source for each such file. */
#define GETOPT_INTERFACE_VERSION 2
#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2
# include
# if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION
# define ELIDE_CODE
# endif
#endif
#ifndef ELIDE_CODE
/* This needs to come after some library #include
to get __GNU_LIBRARY__ defined. */
#ifdef __GNU_LIBRARY__
/* Don't include stdlib.h for non-GNU C libraries because some of them
contain conflicting prototypes for getopt. */
# include
# include
#endif /* GNU C library. */
#ifdef VMS
# include
# if HAVE_STRING_H - 0
# include
# endif
#endif
#ifndef _
/* This is for other GNU distributions with internationalized messages. */
# if (HAVE_LIBINTL_H && ENABLE_NLS) || defined _LIBC
# include
# ifndef _
# define _(msgid) gettext (msgid)
# endif
# else
# define _(msgid) (msgid)
# endif
# if defined _LIBC && defined USE_IN_LIBIO
# include
# endif
#endif
/* This version of `getopt' appears to the caller like standard Unix `getopt'
but it behaves differently for the user, since it allows the user
to intersperse the options with the other arguments.
As `getopt' works, it permutes the elements of ARGV so that,
when it is done, all the options precede everything else. Thus
all application programs are extended to handle flexible argument order.
Setting the environment variable POSIXLY_CORRECT disables permutation.
Then the behavior is completely standard.
GNU application programs can use a third alternative mode in which
they can distinguish the relative order of options and other arguments. */
#include "getopt.h"
/* For communication from `getopt' to the caller.
When `getopt' finds an option that takes an argument,
the argument value is returned here.
Also, when `ordering' is RETURN_IN_ORDER,
each non-option ARGV-element is returned here. */
char *optarg;
/* Index in ARGV of the next element to be scanned.
This is used for communication to and from the caller
and for communication between successive calls to `getopt'.
On entry to `getopt', zero means this is the first call; initialize.
When `getopt' returns -1, this is the index of the first of the
non-option elements that the caller should itself scan.
Otherwise, `optind' communicates from one call to the next
how much of ARGV has been scanned so far. */
/* 1003.2 says this must be 1 before any call. */
int optind = 1;
/* Formerly, initialization of getopt depended on optind==0, which
causes problems with re-calling getopt as programs generally don't
know that. */
int __getopt_initialized;
/* The next char to be scanned in the option-element
in which the last option character we returned was found.
This allows us to pick up the scan where we left off.
If this is zero, or a null string, it means resume the scan
by advancing to the next ARGV-element. */
static char *nextchar;
/* Callers store zero here to inhibit the error message
for unrecognized options. */
int opterr = 1;
/* Set to an option character which was unrecognized.
This must be initialized on some systems to avoid linking in the
system's own getopt implementation. */
int optopt = '?';
/* Describe how to deal with options that follow non-option ARGV-elements.
If the caller did not specify anything,
the default is REQUIRE_ORDER if the environment variable
POSIXLY_CORRECT is defined, PERMUTE otherwise.
REQUIRE_ORDER means don't recognize them as options;
stop option processing when the first non-option is seen.
This is what Unix does.
This mode of operation is selected by either setting the environment
variable POSIXLY_CORRECT, or using `+' as the first character
of the list of option characters.
PERMUTE is the default. We permute the contents of ARGV as we scan,
so that eventually all the non-options are at the end. This allows options
to be given in any order, even with programs that were not written to
expect this.
RETURN_IN_ORDER is an option available to programs that were written
to expect options and other ARGV-elements in any order and that care about
the ordering of the two. We describe each non-option ARGV-element
as if it were the argument of an option with character code 1.
Using `-' as the first character of the list of option characters
selects this mode of operation.
The special argument `--' forces an end of option-scanning regardless
of the value of `ordering'. In the case of RETURN_IN_ORDER, only
`--' can cause `getopt' to return -1 with `optind' != ARGC. */
static enum
{
REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
} ordering;
/* Value of POSIXLY_CORRECT environment variable. */
static char *posixly_correct;
#ifdef __GNU_LIBRARY__
/* We want to avoid inclusion of string.h with non-GNU libraries
because there are many ways it can cause trouble.
On some systems, it contains special magic macros that don't work
in GCC. */
# include