ack/lang/m2/comp/LLmessage.c

63 lines
1.2 KiB
C
Raw Normal View History

1986-03-26 15:11:02 +00:00
/* S Y N T A X E R R O R R E P O R T I N G */
1986-05-28 18:36:51 +00:00
/* Defines the LLmessage routine. LLgen-generated parsers require the
existence of a routine of that name.
The routine must do syntax-error reporting and must be able to
insert tokens in the token stream.
*/
1986-03-20 14:52:03 +00:00
#include <alloc.h>
1986-03-26 15:11:02 +00:00
#include <em_arith.h>
1986-05-01 19:06:53 +00:00
#include <em_label.h>
1986-03-20 14:52:03 +00:00
#include "idf.h"
#include "LLlex.h"
#include "Lpars.h"
1986-05-28 18:36:51 +00:00
extern char *symbol2str();
extern struct idf *gen_anon_idf();
1986-09-25 19:39:06 +00:00
extern int err_occurred;
1986-03-20 14:52:03 +00:00
LLmessage(tk)
int tk;
{
if (tk) {
1986-05-28 18:36:51 +00:00
/* if (tk != 0), it represents the token to be inserted.
otherwize, the current token is deleted
*/
1986-03-20 14:52:03 +00:00
error("%s missing", symbol2str(tk));
insert_token(tk);
}
else
error("%s deleted", symbol2str(dot.tk_symb));
}
insert_token(tk)
int tk;
{
1986-10-06 20:36:30 +00:00
register struct token *dotp = &dot;
aside = *dotp;
1986-03-20 14:52:03 +00:00
1986-10-06 20:36:30 +00:00
dotp->tk_symb = tk;
1986-03-20 14:52:03 +00:00
switch (tk) {
/* The operands need some body */
case IDENT:
1986-10-06 20:36:30 +00:00
dotp->TOK_IDF = gen_anon_idf();
1986-03-20 14:52:03 +00:00
break;
case STRING:
1986-10-06 20:36:30 +00:00
dotp->tk_data.tk_str = (struct string *)
Malloc(sizeof (struct string));
dotp->TOK_SLE = 1;
dotp->TOK_STR = Salloc("", 1);
1986-03-20 14:52:03 +00:00
break;
case INTEGER:
1986-10-06 20:36:30 +00:00
dotp->TOK_INT = 1;
1986-03-20 14:52:03 +00:00
break;
case REAL:
1986-10-06 20:36:30 +00:00
dotp->TOK_REL = Salloc("0.0", 4);
1986-03-20 14:52:03 +00:00
break;
}
}