1987-04-29 10:22:07 +00:00
|
|
|
/*
|
|
|
|
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
|
|
|
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
|
|
|
*
|
|
|
|
* Author: Ceriel J.H. Jacobs
|
|
|
|
*/
|
|
|
|
|
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 */
|
|
|
|
|
1994-06-24 14:02:31 +00:00
|
|
|
/* $Id$ */
|
1987-04-29 10:22:07 +00:00
|
|
|
|
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();
|
1987-09-23 16:39:43 +00:00
|
|
|
extern t_idf *gen_anon_idf();
|
1986-03-20 14:52:03 +00:00
|
|
|
|
|
|
|
LLmessage(tk)
|
1986-12-01 10:06:53 +00:00
|
|
|
register int tk;
|
1986-03-20 14:52:03 +00:00
|
|
|
{
|
1986-11-05 14:33:00 +00:00
|
|
|
if (tk > 0) {
|
|
|
|
/* if (tk > 0), it represents the token to be inserted.
|
1986-05-28 18:36:51 +00:00
|
|
|
*/
|
1987-09-23 16:39:43 +00:00
|
|
|
register t_token *dotp = ˙
|
1986-12-01 10:06:53 +00:00
|
|
|
|
1997-02-21 17:11:04 +00:00
|
|
|
#ifndef LLNONCORR
|
1989-11-17 11:52:33 +00:00
|
|
|
error("%s missing before %s", symbol2str(tk), symbol2str(dotp->tk_symb));
|
1997-02-21 17:11:04 +00:00
|
|
|
#endif
|
1986-12-01 10:06:53 +00:00
|
|
|
|
|
|
|
aside = *dotp;
|
|
|
|
|
|
|
|
dotp->tk_symb = tk;
|
|
|
|
|
|
|
|
switch (tk) {
|
|
|
|
/* The operands need some body */
|
|
|
|
case IDENT:
|
|
|
|
dotp->TOK_IDF = gen_anon_idf();
|
|
|
|
break;
|
|
|
|
case STRING:
|
|
|
|
dotp->tk_data.tk_str = (struct string *)
|
|
|
|
Malloc(sizeof (struct string));
|
|
|
|
dotp->TOK_SLE = 1;
|
|
|
|
dotp->TOK_STR = Salloc("", 1);
|
|
|
|
break;
|
|
|
|
case INTEGER:
|
|
|
|
dotp->TOK_INT = 1;
|
|
|
|
break;
|
|
|
|
case REAL:
|
1989-12-19 09:40:25 +00:00
|
|
|
dotp->tk_data.tk_real = new_real();
|
1991-03-06 10:52:34 +00:00
|
|
|
dotp->TOK_RSTR = Salloc("0.0", 4);
|
|
|
|
flt_str2flt(dotp->TOK_RSTR, &dotp->TOK_RVAL);
|
1986-12-01 10:06:53 +00:00
|
|
|
break;
|
|
|
|
}
|
1986-03-20 14:52:03 +00:00
|
|
|
}
|
1986-11-05 14:33:00 +00:00
|
|
|
else if (tk < 0) {
|
1997-02-21 17:11:04 +00:00
|
|
|
error("end of file expected");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
#ifndef LLNONCORR
|
|
|
|
error("%s deleted", symbol2str(dot.tk_symb));
|
|
|
|
#else
|
|
|
|
error("%s not expected", symbol2str(dot.tk_symb));
|
|
|
|
#endif
|
1986-11-05 14:33:00 +00:00
|
|
|
}
|
1991-11-27 13:40:52 +00:00
|
|
|
tk_nmb_at_last_syn_err = token_nmb;
|
1986-03-20 14:52:03 +00:00
|
|
|
}
|
|
|
|
|