Skip to content

Commit

Permalink
Restructuring and clean-up
Browse files Browse the repository at this point in the history
- Moved any min_lalr1-stuff into src/min_lalr1
- Removed all bootstrap phaes (use previously installed unicc for bootstrap)
- Reconfigured autotools
- Removed unicc.dtd
  • Loading branch information
phorward committed Oct 28, 2023
1 parent 15bf28d commit 885ab6e
Show file tree
Hide file tree
Showing 12 changed files with 238 additions and 1,871 deletions.
15 changes: 0 additions & 15 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,17 +1,2 @@
*.o
min_lalr1/min_lalr1

src/parse_boot1.c
src/parse_boot2.c
src/parse_boot2.h
src/parse_boot3.c
src/parse_boot3.h

boot_min_lalr1

unicc_boot1
unicc_boot2
unicc_boot3
unicc

Makefile
106 changes: 11 additions & 95 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,6 @@

bin_PROGRAMS = unicc$(EXEEXT)

if WITH_BOOTSTRAP
noinst_PROGRAMS = \
boot_min_lalr1$(EXEEXT) \
unicc_boot1$(EXEEXT) \
unicc_boot2$(EXEEXT) \
unicc_boot3$(EXEEXT)
endif

man1_MANS = unicc.man

uniccdir = $(datadir)/unicc
Expand All @@ -22,101 +14,25 @@ dist_targets_DATA = targets/c.tlt \
targets/javascript.tlt \
targets/json.tlt

dist_unicc_DATA = unicc.dtd LICENSE README.md
dist_unicc_DATA = LICENSE README.md

AM_CPPFLAGS = -DTLTDIR=\"$(targetsdir)\"

#
# All sources except the grammar parser are equal in all bootstrappers.
#

SOURCES = \
unicc_SOURCES = \
lib/phorward.c \
src/mem.c \
src/build.c \
src/debug.c \
src/error.c \
src/first.c \
src/lalr.c \
src/utils.c \
src/string.c \
src/integrity.c \
src/virtual.c \
src/rewrite.c \
src/debug.c \
src/lalr.c \
src/lex.c \
src/list.c \
src/build.c \
src/buildxml.c \
src/main.c \
src/mem.c \
src/parse.c \
src/rewrite.c \
src/string.c \
src/utils.c \
src/virtual.c \
src/xml.c

if WITH_BOOTSTRAP

BUILT_SOURCES = \
src/parse_boot1.c \
src/parse_boot2.c \
src/parse_boot2.h \
src/parse_boot3.c \
src/parse_boot3.h

# --- UniCC Bootstrap phase 0 --------------------------------------------------
#
# First we need to compile min_lalr1, which is a stand-alone parser generator
# that was written for experimental reasons before UniCC, but is needed by
# UniCC to bootstrap.
#

boot_min_lalr1_SOURCES = min_lalr1/min_lalr1.c

# --- UniCC Bootstrap phase 1 --------------------------------------------------
#
# This phase uses the experimental min_lalr1 Parser Generator to build a
# rudimentary parser for UniCC. min_lalr1 must be installed and in the PATH.
#

unicc_boot1_SOURCES = src/parse_boot1.c $(SOURCES)
unicc_boot1_CFLAGS = -DUNICC_BOOTSTRAP=1

src/parse_boot1.c: src/parse.min boot_min_lalr1$(EXEEXT)
./boot_min_lalr1$(EXEEXT) src/parse.min >$@ 2>/dev/null

# --- UniCC Bootstrap phase 2 --------------------------------------------------
#
# In this phase, the parser generated by min_lalr1 is will be used to parse the
# grammar definition of the UniCC parser (parse.par)
#

unicc_boot2_SOURCES = src/parse_boot2.c $(SOURCES)
unicc_boot2_CFLAGS = -DUNICC_BOOTSTRAP=2
#unicc_boot2_DEPENDENCIES = unicc_boot1$(EXEEXT)

src/parse_boot2.c src/parse_boot2.h: src/parse.par unicc_boot1$(EXEEXT)
./unicc_boot1$(EXEEXT) -svwb src/parse_boot2 src/parse.par

# --- UniCC Bootstrap phase 3 --------------------------------------------------
#
# In this phase, the UniCC parser compiled by UniCC will be used to build
# itself.
#

unicc_boot3_SOURCES = src/parse_boot3.c $(SOURCES)
unicc_boot3_CFLAGS = -DUNICC_BOOTSTRAP=3
#unicc_boot3_DEPENDENCIES = unicc_boot2$(EXEEXT)

src/parse_boot3.c src/parse_boot3.h: src/parse.par unicc_boot2$(EXEEXT)
./unicc_boot2$(EXEEXT) -svwb src/parse_boot3 src/parse.par

endif

# --- UniCC Final Build --------------------------------------------------------
#
# Using the third bootstrap phase, the final UniCC executable is built.
#

unicc_SOURCES = src/parse.c $(SOURCES)
#unicc_DEPENDENCIES = unicc_boot3$(EXEEXT)

if WITH_BOOTSTRAP
src/parse.c src/parse.h: src/parse.par unicc_boot3$(EXEEXT)
./unicc_boot3$(EXEEXT) -svwb src/parse src/parse.par
endif

103 changes: 16 additions & 87 deletions Makefile.gnu
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,32 @@ CFLAGS = -g -DUTF8 -DUNICODE -DDEBUG -Wall -I. $(CLOCAL)

SOURCES = \
lib/phorward.c \
src/mem.c \
src/build.c \
src/debug.c \
src/error.c \
src/first.c \
src/lalr.c \
src/utils.c \
src/string.c \
src/integrity.c \
src/virtual.c \
src/rewrite.c \
src/debug.c \
src/lalr.c \
src/lex.c \
src/list.c \
src/build.c \
src/main.c \
src/mem.c \
src/parse.c \
src/rewrite.c \
src/string.c \
src/utils.c \
src/virtual.c \
src/xml.c

all: unicc
OBJECTS = $(patsubst %.c,%.o,$(SOURCES))

boot_clean:
-rm min_lalr1/min_lalr1.o
-rm src/parse_boot1.o src/parse_boot2.o src/parse_boot3.o
-rm src/parse_boot1.c src/parse_boot2.c src/parse_boot2.h src/parse_boot3.c src/parse_boot3.h
-rm unicc_boot1 unicc_boot2 unicc_boot3 boot_min_lalr1
all: unicc

clean: boot_clean
clean:
-rm src/*.o
-rm unicc

src/proto.h: boot_clean
src/proto.h:
lib/pproto src/*.c | awk "/int _parse/ { next } { print }" >$@

make_install:
Expand All @@ -42,78 +39,10 @@ make_install:
make_uninstall:
-rm -f Makefile

# --- UniCC Bootstrap phase 0 --------------------------------------------------
#
# First we need to compile min_lalr1, which is a stand-alone parser generator
# that was written for experimental reasons before UniCC, but is needed by
# UniCC to bootstrap.
#

boot_min_lalr1_SOURCES = min_lalr1/min_lalr1.c
boot_min_lalr1_OBJECTS = $(patsubst %.c,%.o,$(boot_min_lalr1_SOURCES))

boot_min_lalr1: $(boot_min_lalr1_OBJECTS)
$(CC) -o $@ $(boot_min_lalr1_OBJECTS)

# --- UniCC Bootstrap phase 1 --------------------------------------------------
#
# This phase uses the experimental min_lalr1 Parser Generator to build a
# rudimentary parser for UniCC. min_lalr1 must be available and compiled
# with its delivered Makefile.gnu in a directory ../min_lalr from here.
#

unicc_boot1_SOURCES = src/parse_boot1.c $(SOURCES)
unicc_boot1_OBJECTS = $(patsubst %.c,%.o,$(unicc_boot1_SOURCES))

src/parse_boot1.c: src/parse.min boot_min_lalr1
./boot_min_lalr1 src/parse.min >$@ 2>/dev/null

unicc_boot1: $(unicc_boot1_OBJECTS)
$(CC) -o $@ $(unicc_boot1_OBJECTS)

# --- UniCC Bootstrap phase 2 --------------------------------------------------
#
# In this phase, the parser generated by min_lalr1 is will be used to parse the
# grammar definition of the UniCC parser (parse.par)
#

unicc_boot2_SOURCES = src/parse_boot2.c $(SOURCES)
unicc_boot2_OBJECTS = $(patsubst %.c,%.o,$(unicc_boot2_SOURCES))

src/parse_boot2.c src/parse_boot2.h: src/parse.par unicc_boot1
./unicc_boot1 -svwb src/parse_boot2 src/parse.par

unicc_boot2: $(unicc_boot2_OBJECTS)
$(CC) -o $@ $(unicc_boot2_OBJECTS)

# --- UniCC Bootstrap phase 3 --------------------------------------------------
#
# In this phase, the UniCC parser compiled by UniCC will be used to build
# itself.
#

unicc_boot3_SOURCES = src/parse_boot3.c $(SOURCES)
unicc_boot3_OBJECTS = $(patsubst %.c,%.o,$(unicc_boot3_SOURCES))

src/parse_boot3.c parse_boot3.h: src/parse.par unicc_boot2
./unicc_boot2 -svwb src/parse_boot3 src/parse.par

unicc_boot3: $(unicc_boot3_OBJECTS)
$(CC) -o $@ $(unicc_boot3_OBJECTS)

# --- UniCC Final Build --------------------------------------------------------
#
# Using the third bootstrap phase, the final UniCC executable is built.
#

unicc_SOURCES = src/parse.c $(SOURCES)
unicc_OBJECTS = $(patsubst %.c,%.o,$(unicc_SOURCES))

#src/parse.c src/parse.h: src/parse.par unicc_boot3
# ./unicc_boot3 -svwb src/parse src/parse.par
# --- UniCC --------------------------------------------------------------------

unicc: $(unicc_OBJECTS)
$(CC) -o $@ $(unicc_OBJECTS)
unicc: $(OBJECTS)
$(CC) -o $@ $(OBJECTS)

# --- UniCC Documentation ------------------------------------------------------
#
Expand Down
Loading

0 comments on commit 885ab6e

Please sign in to comment.