Commit 8ea91dcb authored by Duncan White's avatar Duncan White

imported bugfixes from ~dcw/src/C/datadec/datadec-1.2 dir

parent 2c624798
Building on Solaris or Other Unices Building on Unices
----------------------------------- ------------------
1. Extract the datadec-1.1.tgz file, creating a datadec-1.0 directory 1. Extract the datadec-1.2.tgz file, creating a datadec-1.2 directory
2. Compile datadec: 2. Compile datadec:
cd datadec-1.1 cd datadec-1.2
make make
3. EITHER 3. Install it (run this as root) into /usr/local/bin and /usr/share/man/man1:
a. Install it (run this as root) into /usr/local/bin and /usr/man/man1:
make install make install
b. or, package datadec up and install it via adding the package: 4. check that datadec is now on your path, eg. rehash, which datadec
cd PKG/Solaris
make
then install the package (as root):
pkgadd -d datadec-1.0-1-sol8-sparc-dcw all
5. cd test; make; ./ctest
Building and Packaging Datadec on RPM-based Linux
-------------------------------------------------
Either download http://csgsoft.doc.ic.ac.uk/datadec/datadec-1.0-1.i386.rpm Notes on Packaging
and install it (rpm -i) from there, or do a source build: ------------------
1. Download the datadec-1.1.tgz file and save it in your RPM SOURCES directory. An alternative to (3) is to package datadec up and install it via installing
the package. There are many different packaging systems: over the years, we
have packaged datadec for Solaris, Redhat Linux and Debian/Ubuntu Linux, but
only the Debian/Ubuntu packaging is up to date.
2. Download the package spec file datadec.spec: - For Debian/Ubuntu/Debian-derived distros, the tarball includes the debian
subdirectory, this should work, invoke "dpkg-buildpackage -tc -rfakeroot"
3. Build the package using the spec file: as usual (on a machine with the debian packaging tools installed).
- Also in this directory is a (nontested) RPM .spec file, which may serve as
a basis for you to build an RPM, via
rpm -bb datadec.spec rpm -bb datadec.spec
(but it almost certainly won't work out of the box).
4. Now you can install the datadec-1.1-1.is386.rpm that you just built,
using rpm -i..
CC = gcc CC = gcc
#CC = cc #CC = cc
DEST = $(PREFIX)/usr DEST = $(PREFIX)/usr
BINDIR = $(DEST)/bin BINDIR = $(DEST)/bin
MANDIR = $(DEST)/man/man1 MANDIR = $(DEST)/man/man1
CFLAGS = -g -UDEBUGGING -Wall CFLAGS = -g -UDEBUGGING -Wall
LDLIBS = LDLIBS =
EXECS = datadec EXECS = datadec
datadec_srcs = datadec.c parser.c lexer.c struct.c decs.c optimize.c datadec_srcs = datadec.c parser.c lexer.c struct.c decs.c optimize.c
datadec_objs = datadec.o parser.o lexer.o struct.o decs.o optimize.o datadec_objs = datadec.o parser.o lexer.o struct.o decs.o optimize.o
all: $(EXECS) all: $(EXECS)
...@@ -19,6 +19,7 @@ install: $(EXECS) ...@@ -19,6 +19,7 @@ install: $(EXECS)
clean: clean:
/bin/rm -f *.o a.out core $(EXECS) /bin/rm -f *.o a.out core $(EXECS)
cd test; make clean
datadec: $(datadec_objs) datadec: $(datadec_objs)
$(CC) -g -o datadec $(datadec_objs) $(CC) -g -o datadec $(datadec_objs)
......
Datadec takes recursive data types modelled on those found in functional Datadec takes inductive (or recursive) data types modelled on those found in
languages (Hope, Miranda, Haskell etc) and generates ANSI C code to functional languages (Hope, Miranda, Haskell etc) and generates ANSI C code
implement them. to implement them.
Duncan C. White, dcw@doc.ic.ac.uk Duncan C. White, dcw@doc.ic.ac.uk
19th March 2002 19th March 2002
New! experimental free functions (run datadec with new -f option)
Duncan C. White, d.white@imperial.ac.uk
28th May 2014
An Example of Datadec in Action An Example of Datadec in Action
------------------------------- -------------------------------
...@@ -24,11 +29,11 @@ idtree = leaf( string id, illist l ) ...@@ -24,11 +29,11 @@ idtree = leaf( string id, illist l )
What does this mean? What does this mean?
The first rule declares that an intlist can take two basic "shapes" - The first rule declares that an intlist can take two basic "shapes" -
it is either empty, nil, or of the form cons(int,intlist). it is either empty, aka nil, or of the form cons(int,intlist).
nil and cons() are called constructors, and define different nil() and cons() are called constructors, and define different
"shapes" that objects of the type can take. "shapes" that objects of the type can take.
However, because the second argument of a cons() constructor is itself However, because the second argument of a cons() constructor is itself
an intlist, this type is said to be recursively defined. an intlist, this type is said to be recursively or inductively defined.
Functional programmers will recognise nil or cons() as the standard Functional programmers will recognise nil or cons() as the standard
way of defining a list, so more intuitively, intlist is simply way of defining a list, so more intuitively, intlist is simply
a list of integers! a list of integers!
...@@ -42,6 +47,9 @@ module which implements all the data types, a constructor function for ...@@ -42,6 +47,9 @@ module which implements all the data types, a constructor function for
each constructor, deconstructor functions to help you to take objects each constructor, deconstructor functions to help you to take objects
apart again and printing functions to help you with debugging. apart again and printing functions to help you with debugging.
(Plus, new May 2014: a tree-walking free function if you invoke datadec
with the new -f option).
Building and Packaging datadec Building and Packaging datadec
------------------------------ ------------------------------
...@@ -56,4 +64,3 @@ input file which declares some recursive data types (lists and trees), ...@@ -56,4 +64,3 @@ input file which declares some recursive data types (lists and trees),
and ctest.c is the test harness that uses them. cd into test and run make and ctest.c is the test harness that uses them. cd into test and run make
to turn cdata.in into cx.h and cx.c, and to compile cx.c and ctest.c and to turn cdata.in into cx.h and cx.c, and to compile cx.c and ctest.c and
link them.. link them..
datadec (1.2) trusty; urgency=low
* added experimental free_TYPE() generation (-f option to datadec)
-- Duncan C. White <dcw@doc.ic.ac.uk> Thu, 14 Aug 2014 15:06:06 +0100
datadec (1.1-1) unstable; urgency=low datadec (1.1-1) unstable; urgency=low
* Initial release, created by dh_make as a test * Initial release, created by dh_make as a test
......
...@@ -91,7 +91,7 @@ BOOL parse_data( char *exports, char *globals, char *begin, declnlist *dp ) ...@@ -91,7 +91,7 @@ BOOL parse_data( char *exports, char *globals, char *begin, declnlist *dp )
MUSTBE( tTYPE, "TYPE/EXPORT/GLOBAL/BEGIN expected" ); MUSTBE( tTYPE, "TYPE/EXPORT/GLOBAL/BEGIN expected" );
MUSTBE( tOPENCURLY, "{ expected" ); MUSTBE( tOPENCURLY, "{ expected" );
if( ! parse_declns( dp ) ) return FALSE; if( ! parse_declns( dp ) ) return FALSE;
MUSTBE( tCLOSECURLY, "{ expected" ); MUSTBE( tCLOSECURLY, "} expected" );
MUSTBE( tEOF, "Spurious characters found beyond EOF" ); MUSTBE( tEOF, "Spurious characters found beyond EOF" );
return TRUE; return TRUE;
...@@ -204,7 +204,7 @@ static BOOL parse_shape( char **tagname, paramlist *pl, printlist *print ) ...@@ -204,7 +204,7 @@ static BOOL parse_shape( char **tagname, paramlist *pl, printlist *print )
{ {
if( ! parse_params( pl ) ) return FALSE; if( ! parse_params( pl ) ) return FALSE;
MUSTBE( tCLOSEBR, "')' expected" ); MUSTBE( tCLOSEBR, "',' or ')' expected" );
} else } else
{ {
ungettok(); ungettok();
......
DEST = $(TOOLDIR) DEST = $(TOOLDIR)
LIBDIR = $(DEST)/lib/$(ARCH) LIBDIR = $(DEST)/lib/$(ARCH)
INCDIR = $(DEST)/include INCDIR = $(DEST)/include
CFLAGS = -I. -I$(INCDIR) -g -UDEBUGGING -Wall CFLAGS = -I. -I$(INCDIR) -g -UDEBUGGING -Wall
LDLIBS = -L$(LIBDIR) -lmem LDLIBS = -L$(LIBDIR) -lmem
TESTEXECS = ctest TESTEXECS = ctest
AUTOCRAP = ctest.o cx.[och] AUTOCRAP = ctest.o cx.[och]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment