Pascal compiler now runs.

--HG--
branch : dtrg-buildsystem
rename : lang/basic/build.mk => lang/pc/build.mk
rename : lang/cem/cemcom.ansi/build.mk => lang/pc/comp/build.mk
rename : lang/basic/lib/build.mk => lang/pc/libpc/build.mk
This commit is contained in:
David Given 2013-05-14 20:47:04 +01:00
parent a6ebaeabd0
commit 66aebcdd91
39 changed files with 265 additions and 26 deletions

View file

@ -55,6 +55,7 @@ include util/topgen/build.mk
include lang/cem/build.mk
include lang/basic/build.mk
include lang/pc/build.mk
include mach/proto/as/build.mk
include mach/proto/ncg/build.mk

View file

@ -18,14 +18,14 @@ $(call cfile, $D/func.c)
$(call llgen, $(OBJDIR)/$D, $D/basic.g)
$(eval g := $(OBJDIR)/$D/token.h)
$(eval g := $(OBJDIR)/$D/tokentab.h)
$(eval $q: $g)
$(eval CLEANABLES += $g)
$g: $D/maketokentab $(OBJDIR)/$D/Lpars.h
@echo TOKENTAB $$@
@mkdir -p $$(dir $$@)
$(hide) cd $(OBJDIR)/$D && $(abspath $$^)
$(eval $q: $(OBJDIR)/$D/token.h)
$(eval $q: $(OBJDIR)/$D/Lpars.h)
$(eval $q: $(INCDIR)/print.h)

3
lang/pc/build.mk Normal file
View file

@ -0,0 +1,3 @@
include lang/pc/libpc/build.mk
include lang/pc/comp/build.mk

View file

@ -3,10 +3,8 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "parameters.h"
#include "debug.h"
#include "idfsize.h"
#include "numsize.h"
#include "strsize.h"
#include <alloc.h>
#include <em_arith.h>

View file

@ -10,6 +10,7 @@
#include <em_arith.h>
#include <em_label.h>
#include "parameters.h"
#include "LLlex.h"
#include "Lpars.h"
#include "idf.h"

View file

@ -1,3 +1,4 @@
#include "parameters.h"
#include "debug.h"
#include <alloc.h>

132
lang/pc/comp/build.mk Normal file
View file

@ -0,0 +1,132 @@
D := lang/pc/comp
define build-pc-allocd-header
$2: $1 $D/make.allocd
@echo ALLOCD $$@
@mkdir -p $$(dir $$@)
$(hide) $D/make.allocd < $$^ > $$@
$(eval CLEANABLES += $2)
$(eval $q: $2)
endef
define build-pc-next
$(eval CLEANABLES += $(OBJDIR)/$D/next.c)
$(OBJDIR)/$D/next.c: $D/make.next $1
@echo NEXT $$@
@mkdir -p $$(dir $$@)
$(hide) $$^ > $$@
$(call cfile, $(OBJDIR)/$D/next.c)
$(foreach f, $1, $(call build-pc-allocd-header, \
$f, $(OBJDIR)/$(basename $f).h))
endef
define build-pc-impl
$(call reset)
$(eval cflags += -I$(OBJDIR)/$D -I$D -DSTATIC=static)
$(call cfile, $D/LLlex.c)
$(call cfile, $D/LLmessage.c)
$(call cfile, $D/body.c)
$(call cfile, $D/chk_expr.c)
$(call cfile, $D/code.c)
$(call cfile, $D/cstoper.c)
$(call cfile, $D/def.c)
$(call cfile, $D/desig.c)
$(call cfile, $D/enter.c)
$(call cfile, $D/error.c)
$(call cfile, $D/idf.c)
$(call cfile, $D/input.c)
$(call cfile, $D/label.c)
$(call cfile, $D/lookup.c)
$(call cfile, $D/main.c)
$(call cfile, $D/misc.c)
$(call cfile, $D/node.c)
$(call cfile, $D/options.c)
$(call cfile, $D/progs.c)
$(call cfile, $D/readwrite.c)
$(call cfile, $D/scope.c)
$(call cfile, $D/stab.c)
$(call cfile, $D/tokenname.c)
$(call cfile, $D/type.c)
$(call cfile, $D/typequiv.c)
$(call llgen, $(OBJDIR)/$D, \
$(OBJDIR)/$D/tokenfile.g \
$D/program.g \
$D/declar.g \
$D/expression.g \
$D/statement.g)
$(eval CLEANABLES += $(OBJDIR)/$D/tokenfile.g)
$(OBJDIR)/$D/tokenfile.g: $D/make.tokfile $D/tokenname.c
@echo TOKENFILE $$@
@mkdir -p $$(dir $$@)
$(hide) sh $D/make.tokfile < $D/tokenname.c > $$@
$(call tabgen, $D/char.tab)
$(eval $q: $(OBJDIR)/$D/parameters.h)
$(eval CLEANABLES += $(OBJDIR)/$D/parameters.h)
$(OBJDIR)/$D/parameters.h: $D/Parameters
@echo PARAMETERS $$@
@mkdir -p $$(dir $$@)
$(hide) echo '#ifndef PARAMETERS_H' > $$@
$(hide) echo '#define PARAMETERS_H' >> $$@
$(hide) grep -v '^!' < $$^ >> $$@
$(hide) echo '#endif' >> $$@
$(eval CLEANABLES += $(OBJDIR)/$D/symbol2str.c)
$(OBJDIR)/$D/symbol2str.c: $D/make.tokcase $D/tokenname.c
@echo TOKCASE $$@
@mkdir -p $$(dir $$@)
$(hide) $D/make.tokcase < $D/tokenname.c > $$@
$(call cfile, $(OBJDIR)/$D/symbol2str.c)
$(call build-pc-next, \
$D/def.H \
$D/type.H \
$D/node.H \
$D/scope.H \
$D/desig.H \
$D/tmpvar.C \
$D/casestat.C)
$(call build-pc-allocd-header, $D/tmpvar.C, $(OBJDIR)/$D/tmpvar.c)
$(call cfile, $(OBJDIR)/$D/tmpvar.c)
$(call build-pc-allocd-header, $D/casestat.C, $(OBJDIR)/$D/casestat.c)
$(call cfile, $(OBJDIR)/$D/casestat.c)
$(eval $q: $(OBJDIR)/$D/Lpars.h)
$(eval $q: $(INCDIR)/idf_pkg.spec)
$(eval $q: $(INCDIR)/idf_pkg.body)
$(eval $q: $(INCDIR)/inp_pkg.spec)
$(eval $q: $(INCDIR)/inp_pkg.body)
$(eval $q: $(INCDIR)/alloc.h)
$(eval $q: $(INCDIR)/em_codeEK.h)
$(eval $q: $(INCDIR)/print.h)
$(eval $q: $(INCDIR)/system.h)
$(call file, $(LIBEM_MES))
$(call file, $(LIBEMK))
$(call file, $(LIBEM_DATA))
$(call file, $(LIBINPUT))
$(call file, $(LIBASSERT))
$(call file, $(LIBALLOC))
$(call file, $(LIBFLT_ARITH))
$(call file, $(LIBPRINT))
$(call file, $(LIBSYSTEM))
$(call file, $(LIBSTRING))
$(call cprogram, $(BINDIR)/em_pc)
$(call installto, $(PLATDEP)/em_pc)
$(call reset)
$(eval q := $D/em_pc.6)
$(call installto, $(INSDIR)/share/man/man6/em_pc.6)
endef
$(eval $(build-pc-impl))

View file

@ -1,4 +1,5 @@
/* C A S E S T A T E M E N T C O D E G E N E R A T I O N */
#include "parameters.h"
#include "debug.h"
#include <alloc.h>
@ -8,7 +9,6 @@
#include "LLlex.h"
#include "Lpars.h"
#include "chk_expr.h"
#include "density.h"
#include "main.h"
#include "node.h"
#include "type.h"

View file

@ -3,8 +3,10 @@
/* Check expressions, and try to evaluate them as far as possible.
*/
#include "parameters.h"
#include "debug.h"
#include <stdlib.h>
#include <alloc.h>
#include <assert.h>
#include <em_arith.h>

View file

@ -2,6 +2,7 @@
#include <stdlib.h>
#include <string.h>
#include "parameters.h"
#include "debug.h"
#include <assert.h>
#include <em.h>

View file

@ -2,8 +2,8 @@
#include <stdlib.h>
#include <string.h>
#include "parameters.h"
#include "debug.h"
#include "target_sizes.h"
#include <alloc.h>
#include <assert.h>

View file

@ -1,8 +1,6 @@
/* A debugging macro
*/
#include "debugcst.h"
#ifdef DEBUG
#define DO_DEBUG(x, y) ((x) && (y))
#else

View file

@ -1,7 +1,8 @@
/* D E C L A R A T I O N S */
{
/* next line DEBUG */
#include "parameters.h"
/* next line DEBUG */
#include "debug.h"
#include <alloc.h>
@ -19,7 +20,6 @@
#include "node.h"
#include "scope.h"
#include "type.h"
#include "dbsymtab.h"
#define PC_BUFSIZ (sizeof(struct file) - (int)((struct file *)0)->bufadr)

View file

@ -1,5 +1,6 @@
/* D E F I N I T I O N M E C H A N I S M */
#include "parameters.h"
#include "debug.h"
#include <alloc.h>

View file

@ -7,6 +7,7 @@
or perform a store.
*/
#include "parameters.h"
#include "debug.h"
#include <assert.h>

View file

@ -5,6 +5,7 @@
#include <em_arith.h>
#include <em_label.h>
#include "parameters.h"
#include "LLlex.h"
#include "def.h"
#include "idf.h"
@ -12,7 +13,6 @@
#include "node.h"
#include "scope.h"
#include "type.h"
#include "dbsymtab.h"
extern int proclevel;
extern int parlevel;

View file

@ -5,8 +5,8 @@
number of arguments!
*/
#include "parameters.h"
#include "debug.h"
#include "errout.h"
#if __STDC__
#include <stdarg.h>

View file

@ -1,4 +1,5 @@
/* I N S T A N T I A T I O N O F I D F P A C K A G E */
#include "parameters.h"
#include "idf.h"
#include <idf_pkg.body>

View file

@ -3,6 +3,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "parameters.h"
#include "f_info.h"
struct f_info file_info;
#include "input.h"

View file

@ -1,7 +1,5 @@
/* I N S T A N T I A T I O N O F I N P U T M O D U L E */
#include "inputtype.h"
#define INP_NPUSHBACK 3
#define INP_TYPE struct f_info
#define INP_VAR file_info

View file

@ -3,6 +3,7 @@
#include <alloc.h>
#include <em.h>
#include "parameters.h"
#include "LLlex.h"
#include "def.h"
#include "idf.h"

View file

@ -5,6 +5,7 @@
#include <em_label.h>
#include <assert.h>
#include "parameters.h"
#include "LLlex.h"
#include "def.h"
#include "idf.h"

View file

@ -2,6 +2,7 @@
#include <stdlib.h>
#include <string.h>
#include "parameters.h"
#include "debug.h"
#include <em.h>
@ -23,7 +24,6 @@
#include "tokenname.h"
#include "type.h"
#include "scope.h"
#include "dbsymtab.h"
char options[128];
char *ProgName;

View file

@ -1,3 +1,4 @@
echo '#include "parameters.h"'
echo '#include "debug.h"'
sed -n '
s:^.*[ ]ALLOCDEF[ ].*"\(.*\)".*$:struct \1 *h_\1 = 0;\

View file

@ -5,6 +5,7 @@
#include <alloc.h>
#include <em.h>
#include "parameters.h"
#include "LLlex.h"
#include "f_info.h"
#include "idf.h"

View file

@ -1,5 +1,6 @@
/* N O D E O F A N A B S T R A C T P A R S E T R E E */
#include "parameters.h"
#include "debug.h"
#include <alloc.h>

View file

@ -3,13 +3,11 @@
#include <em_arith.h>
#include <em_label.h>
#include "parameters.h"
#include "class.h"
#include "const.h"
#include "idfsize.h"
#include "main.h"
#include "type.h"
#include "nocross.h"
#include "dbsymtab.h"
#define MINIDFSIZE 9

View file

@ -1,6 +1,7 @@
/* The grammar of ISO-Pascal as given by the specification, BS6192: 1982. */
{
#include "parameters.h"
#include <alloc.h>
#include <em_arith.h>
#include <em_label.h>
@ -14,7 +15,6 @@
#include "main.h"
#include "node.h"
#include "scope.h"
#include "dbsymtab.h"
}
%lexical LLlex;

View file

@ -1,3 +1,4 @@
#include "parameters.h"
#include "debug.h"
#include <em.h>

View file

@ -1,5 +1,6 @@
/* R E A D ( L N ) & W R I T E ( L N ) */
#include "parameters.h"
#include "debug.h"
#include <assert.h>

View file

@ -1,5 +1,6 @@
/* S C O P E M E C H A N I S M */
#include "parameters.h"
#include "debug.h"
#include <alloc.h>

View file

@ -9,7 +9,7 @@
/* $Id$ */
#include "dbsymtab.h"
#include "parameters.h"
#ifdef DBSYMTAB

View file

@ -1,5 +1,6 @@
/* S T A T E M E N T S */
{
#include "parameters.h"
#include <alloc.h>
#include <em.h>
#include <stb.h>
@ -15,7 +16,6 @@
#include "node.h"
#include "scope.h"
#include "type.h"
#include "dbsymtab.h"
int slevel = 0; /* nesting level of statements */
}

View file

@ -1,5 +1,6 @@
/* T O K E N D E F I N I T I O N S */
#include "parameters.h"
#include "Lpars.h"
#include "idf.h"
#include "tokenname.h"

View file

@ -1,7 +1,5 @@
/* T Y P E D E S C R I P T O R S T R U C T U R E */
#include "dbsymtab.h"
struct paramlist { /* structure for parameterlist of a PROCEDURE */
struct paramlist *next;
struct def *par_def; /* "df" of parameter */
@ -131,7 +129,6 @@ extern struct type
*void_type,
*error_type; /* All from type.c */
#include "nocross.h"
#ifdef NOCROSS
#include "target_sizes.h"
#define word_align (AL_WORD)

View file

@ -1,5 +1,6 @@
/* T Y P E D E F I N I T I O N M E C H A N I S M */
#include "parameters.h"
#include "debug.h"
#include <alloc.h>
@ -18,7 +19,6 @@
#include "type.h"
#ifndef NOCROSS
#include "target_sizes.h"
int
word_align = AL_WORD,
int_align = AL_INT,

View file

@ -3,6 +3,7 @@
/* Routines for testing type equivalence & type compatibility.
*/
#include "parameters.h"
#include "debug.h"
#include <assert.h>

92
lang/pc/libpc/build.mk Normal file
View file

@ -0,0 +1,92 @@
define build-runtime-libpascal-impl
$(call reset)
$(eval objdir := $(PLATFORM))
$(call ackfile, lang/pc/libpc/abi.c)
$(call ackfile, lang/pc/libpc/abl.c)
$(call ackfile, lang/pc/libpc/abr.c)
$(call ackfile, lang/pc/libpc/arg.c)
$(call ackfile, lang/pc/libpc/ass.c)
$(call ackfile, lang/pc/libpc/asz.c)
$(call ackfile, lang/pc/libpc/atn.c)
$(call ackfile, lang/pc/libpc/bcp.c)
$(call ackfile, lang/pc/libpc/bts.e)
$(call ackfile, lang/pc/libpc/buff.c)
$(call ackfile, lang/pc/libpc/catch.c)
$(call ackfile, lang/pc/libpc/clock.c)
$(call ackfile, lang/pc/libpc/cls.c)
$(call ackfile, lang/pc/libpc/cvt.c)
$(call ackfile, lang/pc/libpc/diag.c)
$(call ackfile, lang/pc/libpc/dis.c)
$(call ackfile, lang/pc/libpc/efl.c)
$(call ackfile, lang/pc/libpc/eln.c)
$(call ackfile, lang/pc/libpc/encaps.e)
$(call ackfile, lang/pc/libpc/exp.c)
$(call ackfile, lang/pc/libpc/fef.e)
$(call ackfile, lang/pc/libpc/fif.e)
$(call ackfile, lang/pc/libpc/get.c)
$(call ackfile, lang/pc/libpc/gto.e)
$(call ackfile, lang/pc/libpc/hlt.c)
$(call ackfile, lang/pc/libpc/hol0.e)
$(call ackfile, lang/pc/libpc/incpt.c)
$(call ackfile, lang/pc/libpc/ini.c)
$(call ackfile, lang/pc/libpc/log.c)
$(call ackfile, lang/pc/libpc/mdi.c)
$(call ackfile, lang/pc/libpc/mdl.c)
$(call ackfile, lang/pc/libpc/new.c)
$(call ackfile, lang/pc/libpc/nfa.c)
$(call ackfile, lang/pc/libpc/nobuff.c)
$(call ackfile, lang/pc/libpc/notext.c)
$(call ackfile, lang/pc/libpc/opn.c)
$(call ackfile, lang/pc/libpc/outcpt.c)
$(call ackfile, lang/pc/libpc/pac.c)
$(call ackfile, lang/pc/libpc/pclose.c)
$(call ackfile, lang/pc/libpc/pcreat.c)
$(call ackfile, lang/pc/libpc/pentry.c)
$(call ackfile, lang/pc/libpc/perrno.c)
$(call ackfile, lang/pc/libpc/pexit.c)
$(call ackfile, lang/pc/libpc/popen.c)
$(call ackfile, lang/pc/libpc/put.c)
$(call ackfile, lang/pc/libpc/rcka.c)
$(call ackfile, lang/pc/libpc/rdc.c)
$(call ackfile, lang/pc/libpc/rdi.c)
$(call ackfile, lang/pc/libpc/rdl.c)
$(call ackfile, lang/pc/libpc/rdr.c)
$(call ackfile, lang/pc/libpc/rf.c)
$(call ackfile, lang/pc/libpc/rln.c)
$(call ackfile, lang/pc/libpc/rnd.c)
$(call ackfile, lang/pc/libpc/sav.e)
$(call ackfile, lang/pc/libpc/sig.e)
$(call ackfile, lang/pc/libpc/sin.c)
$(call ackfile, lang/pc/libpc/sqt.c)
$(call ackfile, lang/pc/libpc/string.c)
$(call ackfile, lang/pc/libpc/trap.e)
$(call ackfile, lang/pc/libpc/trp.e)
$(call ackfile, lang/pc/libpc/unp.c)
$(call ackfile, lang/pc/libpc/uread.c)
$(call ackfile, lang/pc/libpc/uwrite.c)
$(call ackfile, lang/pc/libpc/wdw.c)
$(call ackfile, lang/pc/libpc/wf.c)
$(call ackfile, lang/pc/libpc/wrc.c)
$(call ackfile, lang/pc/libpc/wrf.c)
$(call ackfile, lang/pc/libpc/wri.c)
$(call ackfile, lang/pc/libpc/wrl.c)
$(call ackfile, lang/pc/libpc/wrr.c)
$(call ackfile, lang/pc/libpc/wrs.c)
$(call ackfile, lang/pc/libpc/wrz.c)
$(call acklibrary, $(LIBDIR)/$(PLATFORM)/libpascal.a)
$(call installto, $(PLATIND)/$(PLATFORM)/libpascal.a)
$(call reset)
$(eval objdir := $(PLATFORM))
$(call ackfile, lang/pc/libpc/head_pc.e)
$(call installto, $(PLATIND)/$(PLATFORM)/pascal.o)
endef
build-runtime-libpascal = $(eval $(build-runtime-libpascal-impl))
$(eval RUNTIMES += libpascal)

View file

@ -60,6 +60,9 @@ define build-em_code-impl
$(call cfile, $D/em.c)
$(eval $q: $(INCDIR)/em_codeEK.h)
$(eval $q: $(INCDIR)/em_path.h)
$(eval $q: $(INCDIR)/system.h)
$(eval $q: $(INCDIR)/local.h)
$(call clibrary, $(LIBDIR)/libem$2.a)
$(eval LIBEM$1 := $o)