def.str
domacro.c
dumpidf.c
-em.c
-em.h
-emcode.def
error.c
eval.c
expr.c
macro.str
main.c
make.allocd
-make.emfun
-make.emmac
make.hfiles
make.next
make.tokcase
case '<':
if (AccFileSpecifier) {
PushBack(); /* pushback nch */
- ptok->tk_str =
- string_token("file specifier", '>');
+ ptok->tk_bts =
+ string_token(
+ "file specifier",
+ '>',
+ &(ptok->tk_len)
+ );
return ptok->tk_symb = FILESPECIFIER;
}
if (nch == '<')
}
if (ch == '\\') {
LoadChar(ch);
+ if (ch == '\n')
+ LineNumber++;
ch = quoted(ch);
}
val = val*256 + ch;
return ptok->tk_symb = INTEGER;
}
case STSTR: /* string */
- ptok->tk_str = string_token("string", '"');
+ ptok->tk_bts = string_token("string", '"', &(ptok->tk_len));
return ptok->tk_symb = STRING;
case STNUM: /* a numeric constant */
{
}
char *
-string_token(nm, stop_char)
+string_token(nm, stop_char, plen)
char *nm;
+ int *plen;
{
register int ch;
register int str_size;
break;
}
if (ch == '\\') {
- register int nch;
-
- LoadChar(nch);
- if (nch == '\n') {
+ LoadChar(ch);
+ if (ch == '\n')
LineNumber++;
- LoadChar(ch);
- continue;
- }
- else {
- str[pos++] = '\\';
- if (pos == str_size)
- str = Srealloc(str,
- str_size += RSTRSIZE);
- ch = nch;
- }
+ ch = quoted(ch);
}
str[pos++] = ch;
if (pos == str_size)
str = Srealloc(str, str_size += RSTRSIZE);
LoadChar(ch);
}
- str[pos++] = '\0';
+ str[pos++] = '\0'; /* for filenames etc. */
+ *plen = pos;
return str;
}
unsigned int tok_line; /* the line it (probably) comes from */
union {
struct idf *tok_idf; /* for IDENTIFIER & TYPE_IDENTIFIER */
- char *tok_str; /* for STRING: text */
+ struct { /* for STRING */
+ char *tok_bts; /* row of bytes */
+ int tok_len; /* length of row of bytes */
+ } tok_string;
struct { /* for INTEGER */
int tok_fund; /* INT or LONG */
arith tok_ival;
#define tk_file tok_file
#define tk_line tok_line
#define tk_idf tok_data.tok_idf
-#define tk_str tok_data.tok_str
+#define tk_bts tok_data.tok_string.tok_bts
+#define tk_len tok_data.tok_string.tok_len
#define tk_fund tok_data.tok_integer.tok_fund
#define tk_ival tok_data.tok_integer.tok_ival
#define tk_fval tok_data.tok_fval
dot.tk_idf = str2idf("int");
break;
case STRING:
- dot.tk_str = Salloc("", 1);
+ dot.tk_bts = Salloc("", 1);
+ dot.tk_len = 1;
break;
case INTEGER:
dot.tk_fund = INT;
# Libraries
SYSLIB = /user1/erikb/em/lib/libsystem.a
-LIBS = $(SYSLIB)
+EMLIB = /user1/erikb/em/lib/libemk.a
+EMMESLIB = /user1/erikb/em/lib/libem_mes.a
+LIBS = $(EMMESLIB) $(EMLIB) $(SYSLIB)
LIB_INCLUDES = /user1/erikb/em/h
# Where to install the compiler and its driver
input.o domacro.o replace.o init.o options.o \
scan.o skip.o stack.o type.o ch7mon.o label.o eval.o \
switch.o storage.o ival.o conversion.o \
- em.o blocks.o dataflow.o string.o
+ blocks.o dataflow.o string.o
# Objects of other generated C files
-GOBJ = char.o symbol2str.o next.o writeem.o
+GOBJ = char.o symbol2str.o next.o
# generated source files
-GSRC = char.c symbol2str.c next.c writeem.c \
+GSRC = char.c symbol2str.c next.c \
code.h declar.h decspecs.h def.h expr.h field.h \
- idf.h macro.h stack.h struct.h switch.h type.h \
- writeem.h
+ idf.h macro.h stack.h struct.h switch.h type.h
# .h files generated by `make hfiles'; PLEASE KEEP THIS UP-TO-DATE!
GHSRC = botch_free.h dataflow.h debug.h density.h errout.h \
idepth.h idfsize.h ifdepth.h inputtype.h inumlength.h lapbuf.h \
maxincl.h myalloc.h nobitfield.h nopp.h \
nparams.h numsize.h parbufsize.h pathlength.h predefine.h \
- proc_intf.h strsize.h target_sizes.h textsize.h use_tmp.h \
+ strsize.h target_sizes.h textsize.h use_tmp.h \
str_params.h spec_arith.h
# Other generated files, for 'make clean' only
switch.h: make.allocd
type.h: make.allocd
-writeem.c: make.emfun emcode.def
- ./make.emfun emcode.def >writeem.c
-
-writeem.h: make.emmac emcode.def
- ./make.emmac emcode.def >writeem.h
-
# Objects needed for 'main'
OBJ = $(COBJ) $(LOBJ) $(GOBJ)
ch7bin.o: Lpars.h arith.h botch_free.h expr.h idf.h label.h nobitfield.h nopp.h spec_arith.h storage.h struct.h type.h
cstoper.o: Lpars.h arith.h expr.h idf.h label.h nobitfield.h nopp.h sizes.h spec_arith.h target_sizes.h type.h
arith.o: Lpars.h alloc.h arith.h botch_free.h expr.h field.h idf.h label.h mes.h nobitfield.h nopp.h spec_arith.h storage.h type.h
-alloc.o: alloc.h assert.h debug.h myalloc.h
-code.o: LLlex.h Lpars.h alloc.h arith.h assert.h atw.h botch_free.h code.h dataflow.h debug.h declar.h decspecs.h def.h em.h expr.h idf.h label.h level.h mes.h nobitfield.h nopp.h proc_intf.h sizes.h spec_arith.h specials.h stack.h storage.h type.h use_tmp.h writeem.h
+alloc.o: alloc.h assert.h debug.h myalloc.h
+code.o: LLlex.h Lpars.h alloc.h arith.h assert.h atw.h botch_free.h code.h dataflow.h debug.h declar.h decspecs.h def.h expr.h idf.h label.h level.h mes.h nobitfield.h nopp.h sizes.h spec_arith.h specials.h stack.h storage.h type.h use_tmp.h
dumpidf.o: Lpars.h arith.h debug.h def.h expr.h field.h idf.h label.h nobitfield.h nopp.h spec_arith.h stack.h struct.h type.h
-error.o: LLlex.h arith.h debug.h em.h errout.h expr.h label.h nopp.h proc_intf.h spec_arith.h string.h tokenname.h use_tmp.h writeem.h
-field.o: Lpars.h arith.h assert.h code.h debug.h em.h expr.h field.h idf.h label.h nobitfield.h nopp.h proc_intf.h sizes.h spec_arith.h type.h writeem.h
+error.o: LLlex.h arith.h debug.h errout.h expr.h label.h nopp.h spec_arith.h string.h tokenname.h use_tmp.h
+field.o: Lpars.h arith.h assert.h code.h debug.h expr.h field.h idf.h label.h nobitfield.h nopp.h sizes.h spec_arith.h type.h
tokenname.o: LLlex.h Lpars.h arith.h idf.h nopp.h spec_arith.h tokenname.h
LLlex.o: LLlex.h Lpars.h alloc.h arith.h assert.h class.h debug.h def.h idf.h idfsize.h input.h nopp.h numsize.h sizes.h spec_arith.h strsize.h
LLmessage.o: LLlex.h Lpars.h alloc.h arith.h idf.h nopp.h spec_arith.h
-input.o: LLlex.h alloc.h arith.h assert.h debug.h idepth.h input.h inputtype.h interface.h nopp.h pathlength.h spec_arith.h
+input.o: LLlex.h alloc.h arith.h assert.h debug.h idepth.h input.h inputtype.h interface.h nopp.h pathlength.h spec_arith.h
domacro.o: LLlex.h Lpars.h alloc.h arith.h assert.h botch_free.h class.h debug.h idf.h idfsize.h ifdepth.h input.h interface.h macro.h nopp.h nparams.h parbufsize.h spec_arith.h storage.h textsize.h
replace.o: LLlex.h alloc.h arith.h assert.h class.h debug.h idf.h input.h interface.h macro.h nopp.h pathlength.h spec_arith.h string.h strsize.h
-init.o: alloc.h class.h idf.h interface.h macro.h nopp.h predefine.h string.h
+init.o: alloc.h class.h idf.h interface.h macro.h nopp.h predefine.h string.h
options.o: align.h arith.h class.h idf.h idfsize.h macro.h maxincl.h nobitfield.h nopp.h sizes.h spec_arith.h storage.h
scan.o: class.h idf.h input.h interface.h lapbuf.h macro.h nopp.h nparams.h
skip.o: LLlex.h arith.h class.h input.h interface.h nopp.h spec_arith.h
-stack.o: Lpars.h alloc.h arith.h botch_free.h debug.h def.h em.h idf.h level.h mes.h nobitfield.h nopp.h proc_intf.h spec_arith.h stack.h storage.h struct.h type.h use_tmp.h writeem.h
+stack.o: Lpars.h alloc.h arith.h botch_free.h debug.h def.h idf.h level.h mes.h nobitfield.h nopp.h spec_arith.h stack.h storage.h struct.h type.h use_tmp.h
type.o: Lpars.h align.h alloc.h arith.h def.h idf.h nobitfield.h nopp.h sizes.h spec_arith.h type.h
ch7mon.o: Lpars.h arith.h botch_free.h def.h expr.h idf.h label.h nobitfield.h nopp.h spec_arith.h storage.h type.h
label.o: Lpars.h arith.h def.h idf.h label.h level.h nobitfield.h nopp.h spec_arith.h type.h
-eval.o: Lpars.h align.h arith.h assert.h atw.h code.h dataflow.h debug.h def.h em.h expr.h idf.h label.h level.h mes.h nobitfield.h nopp.h proc_intf.h sizes.h spec_arith.h stack.h string.h type.h writeem.h
-switch.o: arith.h assert.h botch_free.h code.h debug.h density.h em.h expr.h idf.h label.h nobitfield.h nopp.h proc_intf.h spec_arith.h storage.h switch.h type.h writeem.h
+eval.o: Lpars.h align.h arith.h assert.h atw.h code.h dataflow.h debug.h def.h expr.h idf.h label.h level.h mes.h nobitfield.h nopp.h sizes.h spec_arith.h stack.h string.h type.h
+switch.o: Lpars.h arith.h assert.h botch_free.h code.h debug.h density.h expr.h idf.h label.h nobitfield.h nopp.h spec_arith.h storage.h switch.h type.h
storage.o: alloc.h assert.h botch_free.h debug.h storage.h
-ival.o: Lpars.h align.h arith.h assert.h class.h debug.h def.h em.h expr.h field.h idf.h label.h level.h nobitfield.h nopp.h proc_intf.h sizes.h spec_arith.h string.h struct.h type.h writeem.h
-conversion.o: Lpars.h arith.h em.h nobitfield.h proc_intf.h sizes.h spec_arith.h type.h writeem.h
-em.o: arith.h em.h label.h proc_intf.h spec_arith.h writeem.h
-blocks.o: arith.h atw.h em.h proc_intf.h sizes.h spec_arith.h writeem.h
+ival.o: Lpars.h align.h arith.h assert.h class.h debug.h def.h expr.h field.h idf.h label.h level.h nobitfield.h nopp.h sizes.h spec_arith.h string.h struct.h type.h
+conversion.o: Lpars.h arith.h nobitfield.h sizes.h spec_arith.h type.h
+blocks.o: arith.h atw.h sizes.h spec_arith.h
dataflow.o: dataflow.h
-string.o: arith.h nopp.h spec_arith.h str_params.h string.h
+string.o: arith.h nopp.h spec_arith.h str_params.h string.h
tokenfile.o: Lpars.h
declar.o: LLlex.h Lpars.h arith.h debug.h declar.h decspecs.h def.h expr.h field.h idf.h label.h nobitfield.h nopp.h sizes.h spec_arith.h struct.h type.h
-statement.o: LLlex.h Lpars.h arith.h botch_free.h code.h debug.h def.h em.h expr.h idf.h label.h nobitfield.h nopp.h proc_intf.h spec_arith.h stack.h storage.h type.h writeem.h
+statement.o: LLlex.h Lpars.h arith.h botch_free.h code.h debug.h def.h expr.h idf.h label.h nobitfield.h nopp.h spec_arith.h stack.h storage.h type.h
expression.o: LLlex.h Lpars.h arith.h expr.h idf.h label.h nobitfield.h nopp.h spec_arith.h type.h
program.o: LLlex.h Lpars.h alloc.h arith.h code.h declar.h decspecs.h def.h expr.h idf.h label.h nobitfield.h nopp.h spec_arith.h type.h
Lpars.o: Lpars.h
char.o: class.h
symbol2str.o: Lpars.h
-writeem.o: arith.h em.h label.h proc_intf.h spec_arith.h writeem.h
#define DEBUG 1 /* perform various self-tests */
-!File: proc_intf.h
-#define PROC_INTF 1 /* compile with procedural EM interface */
-
-
!File: use_tmp.h
#define USE_TMP 1 /* collect exa, exp, ina and inp commands
and let them precede the rest of
#ifndef SPECIAL_ARITHMETICS
-#define arith long /* native */
+#include <em_arith.h> /* obtain definition of "arith" */
#else SPECIAL_ARITHMETICS
/* $Header$ */
/* A S M */
-asm_seen(s)
+asm_seen(s, l)
char *s;
+ int l;
{
/* 'asm' '(' string ')' ';'
*/
/* $Header$ */
/* B L O C K S T O R I N G A N D L O A D I N G */
-#include "em.h"
+#include <em.h>
#include "arith.h"
#include "sizes.h"
#include "atw.h"
/* $Header$ */
/* C O D E - G E N E R A T I N G R O U T I N E S */
+#include <em.h>
+
#include "dataflow.h"
#include "use_tmp.h"
#include "botch_free.h"
#include "expr.h"
#include "sizes.h"
#include "stack.h"
-#include "em.h"
#include "level.h"
#include "decspecs.h"
#include "declar.h"
if (fund == FUNCTION)
C_exp(text);
else
- C_exa(text);
+ C_exa_dnam(text);
break;
case STATIC:
if (fund == FUNCTION)
C_inp(text);
else
- C_ina(text);
+ C_ina_dnam(text);
break;
}
}
if (strcmp(last_fn_given, FileName) != 0) {
/* previous function came from other file */
C_df_dlb(file_name_label = data_label());
- C_con_scon(last_fn_given = FileName, (arith)0);
+ C_con_scon(
+ last_fn_given = FileName,
+ (arith)(strlen(FileName) + 1)
+ );
}
/* enable debug trace of EM source */
C_fil_dlb(file_name_label, (arith)0);
/* $Header$ */
/* C O N V E R S I O N - C O D E G E N E R A T O R */
+#include <em.h>
#include "arith.h"
#include "type.h"
-#include "em.h"
#include "sizes.h"
#include "Lpars.h"
AccFileSpecifier = 1;
if (((tok = GetToken(&tk)) == FILESPECIFIER) || tok == STRING)
- filenm = tk.tk_str;
+ filenm = tk.tk_bts;
else {
lexerror("bad include syntax");
filenm = (char *)0;
LineNumber = l;
/* is there a filespecifier? */
if (GetToken(&tk) == STRING)
- FileName = tk.tk_str;
+ FileName = tk.tk_bts;
SkipRestOfLine();
}
}
LineNumber = tk.tk_ival;
if ((tok = GetToken(&tk)) == STRING)
- FileName = tk.tk_str;
+ FileName = tk.tk_bts;
else
if (tok != EOI) {
error("illegal # line");
/* E R R O R A N D D I A G N O S T I C R O U T I N E S */
#include <system.h>
+#include <em.h>
+
#include "nopp.h"
#include "use_tmp.h"
#include "errout.h"
#include "label.h"
#include "expr.h"
#include "LLlex.h"
-#include "em.h"
/* This file contains the (non-portable) error-message and diagnostic
functions. Beware, they are called with a variable number of
compare()
*/
+#include <em.h>
+
#include "debug.h"
#include "nobitfield.h"
#include "align.h"
#include "mes.h"
#include "atw.h"
-#include "em.h"
#define CRASH() crash("EVAL: CRASH at line %u", __LINE__)
#define roundup(n) ((n) < word_size ? word_size : (n))
label datlab = data_label();
C_df_dlb(datlab);
- C_con_scon(expr->SG_VALUE, (arith)0);
+ C_con_scon(expr->SG_VALUE, (arith)expr->SG_LEN);
C_lae_dlb(datlab, (arith)0);
}
break;
expr->ex_type = string_type;
expr->ex_lvalue = 0;
expr->ex_class = String;
- expr->SG_VALUE = dot.tk_str;
+ expr->SG_VALUE = dot.tk_bts;
+ expr->SG_LEN = dot.tk_len;
expr->SG_DATLAB = 0;
}
};
struct string {
- char *sg_value; /* string of characters repr. the constant */
+ char *sg_value; /* row of bytes repr. the constant */
+ int sg_len; /* length of the row */
label sg_datlab; /* global data-label */
};
#define VL_VALUE ex_object.ex_value.vl_value
#define VL_IDF ex_object.ex_value.vl_idf
#define SG_VALUE ex_object.ex_string.sg_value
+#define SG_LEN ex_object.ex_string.sg_len
#define SG_DATLAB ex_object.ex_string.sg_datlab
#define FL_VALUE ex_object.ex_float.fl_value
#define FL_DATLAB ex_object.ex_float.fl_datlab
#include "nobitfield.h"
#ifndef NOBITFIELD
+#include <em.h>
+
#include "debug.h"
#include "arith.h"
#include "sizes.h"
#include "Lpars.h"
#include "field.h"
-#include "em.h"
arith tmp_pointer_var(); /* eval.c */
char *symbol2str(); /* symbol2str.c */
/* $Header$ */
/* CODE FOR THE INITIALISATION OF GLOBAL VARIABLES */
+#include <em.h>
+
#include "debug.h"
#include "nobitfield.h"
#include "string.h"
-#include "em.h"
#include "arith.h"
#include "align.h"
#include "label.h"
*/
while (strings != 0) {
C_df_dlb(strings->SG_DATLAB);
- C_con_scon(strings->SG_VALUE, (arith)0);
+ C_con_scon(strings->SG_VALUE, (arith)strings->SG_LEN);
strings = strings->next;
}
}
*/
if (tp->tp_up->tp_fund == CHAR && expr->ex_class == String)
init_string(tpp, expr);
- else {
- /* " int i[24] = 12;" */
+ else /* " int i[24] = 12;" */
check_and_pad(expr, tpp);
- }
return 0; /* nothing left */
case STRUCT:
/* struct initialisation */
if (valid_type(tp, "struct") == 0)
return 0;
- if (ISCOMMA(expr)) {
- /* list of initialisation expressions */
+ if (ISCOMMA(expr)) /* list of initialisation expressions */
return do_struct(expr, tp);
- }
/* "struct foo f = 12;" */
check_and_pad(expr, tpp);
return 0;
case UNION:
- /* sorry, but .... */
error("union initialisation not allowed");
return 0;
case ERRONEOUS:
return 0;
- default:
- /* fundamental type */
- if (ISCOMMA(expr)) {
- /* " int i = {12};" */
+ default: /* fundamental type */
+ if (ISCOMMA(expr)) { /* " int i = {12};" */
if (IVAL(tpp, expr->OP_LEFT) != 0)
too_many_initialisers(expr);
/* return remainings of the list for the
{
label datlab = data_label();
- C_ina_pt(datlab);
+ C_ina_dlb(datlab);
C_con_dlb(datlab, (arith)0);
expr->SG_DATLAB = datlab;
store_string(expr);
/* init_string() initialises an array of characters by specifying
a string constant.
- Escaped characters should be converted into its corresponding
- ASCII character value. E.g. '\000' -> (char) 0.
Alignment is taken care of.
*/
init_string(tpp, expr)
char *s = expr->SG_VALUE;
arith ntopad;
- length = prepare_string(s);
+ length = expr->SG_LEN;
if (tp->tp_size == (arith)-1) {
/* set the dimension */
tp = *tpp = construct_type(ARRAY, tp->tp_up, length);
con_byte(0);
}
-/* prepare_string() strips the escaped characters of a
- string and replaces them by the ascii characters they stand for.
- The ascii length of the resulting string is returned, including the
- terminating null-character.
-*/
-int
-prepare_string(str)
- register char *str;
-{
- register char *t = str;
- register count = 1; /* there's always a null at the end ! */
-
- while (*str) {
- count++;
- if (*str == '\\') {
- switch (*++str) {
- case 'b':
- *t++ = '\b';
- str++;
- break;
- case 'f':
- *t++ = '\f';
- str++;
- break;
- case 'n':
- *t++ = '\n';
- str++;
- break;
- case 'r':
- *t++ = '\r';
- str++;
- break;
- case 't':
- *t++ = '\t';
- str++;
- break;
-
- /* octal value of: */
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- {
- register cnt = 0, oct = 0;
-
- do
- oct = oct * 8 + *str - '0';
- while (is_oct(*++str) && ++cnt < 3);
- *t++ = (char) oct;
- break;
- }
- default:
- *t++ = *str++;
- break;
- }
- }
- else
- *t++ = *str++;
- }
- *t = '\0'; /* don't forget this one !!! */
- return count;
-}
-
#ifndef NOBITFIELD
/* put_bf() takes care of the initialisation of (bit-)field
selectors of a struct: each time such an initialisation takes place,
/* $Header$ */
/* L A B E L D E F I N I T I O N */
-#define label unsigned int
+#include <em_label.h> /* obtain definition of "label" */
+
#define NO_LABEL (label) 0
extern label lab_count;
printf("\n#line %ld \"%s\"\n",
lastlineno, lastfilenm);
}
-
switch (DOT) {
-
case IDENTIFIER:
case TYPE_IDENTIFIER:
printf(dot.tk_idf->id_text);
printf(" ");
break;
-
case STRING:
- printf("\"%s\" ", dot.tk_str);
+ printf("\"%s\" ", dot.tk_bts);
break;
-
case INTEGER:
printf("%ld ", dot.tk_ival);
break;
-
case FLOATING:
printf("%s ", dot.tk_fval);
break;
-
case EOI:
case EOF:
return;
-
default: /* very expensive... */
printf("%s ", symbol2str(DOT));
}
/* DERIVED FROM $Header$ */
/* S T A C K / U N S T A C K R O U T I N E S */
+#include <system.h>
+#include <em.h>
+#include <em_reg.h>
+
#include "debug.h"
#include "use_tmp.h"
#include "botch_free.h"
-#include <system.h>
#include "alloc.h"
#include "Lpars.h"
#include "arith.h"
#include "storage.h"
#include "level.h"
#include "mes.h"
-#include "em.h"
/* #include <em_reg.h> */
/* STATEMENT SYNTAX PARSER */
{
+#include <em.h>
+
#include "debug.h"
#include "botch_free.h"
#include "expr.h"
#include "code.h"
#include "storage.h"
-#include "em.h"
#include "stack.h"
#include "def.h"
;
asm_statement
- { char *asm_string;
+ { char *asm_bts;
+ int asm_len;
}
:
ASM
'('
STRING
- { asm_string = dot.tk_str;
+ { asm_bts = dot.tk_bts;
+ asm_len = dot.tk_len;
}
')'
';'
- { asm_seen(asm_string);
+ { asm_seen(asm_bts, asm_len);
}
;
/* $Header$ */
/* S W I T C H - S T A T E M E N T A D M I N I S T R A T I O N */
+#include <em.h>
+
#include "debug.h"
#include "botch_free.h"
#include "density.h"
#include "assert.h"
#include "expr.h"
#include "type.h"
-#include "em.h"
extern char options[];