Pristine Ack-5.5
[Ack-5.5.git] / lang / m2 / m2mm / LLmessage.c
1 /*
2  * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
3  * See the copyright notice in the ACK home directory, in the file "Copyright".
4  *
5  * Author: Ceriel J.H. Jacobs
6  */
7
8 /* S Y N T A X   E R R O R   R E P O R T I N G */
9
10 /* stripped down version from the one in the Modula-2 compiler */
11
12 /* $Id: LLmessage.c,v 1.3 1994/06/24 12:44:38 ceriel Exp $ */
13
14 /*      Defines the LLmessage routine. LLgen-generated parsers require the
15         existence of a routine of that name.
16         The routine must do syntax-error reporting and must be able to
17         insert tokens in the token stream.
18 */
19
20 #include        "idf.h"
21 #include        "LLlex.h"
22 #include        "Lpars.h"
23
24 extern char             *symbol2str();
25 extern struct idf       *gen_anon_idf();
26
27 LLmessage(tk)
28         register int tk;
29 {
30         if (tk > 0)     {
31                 /* if (tk > 0), it represents the token to be inserted.
32                 */
33                 error("%s missing before %s", symbol2str(tk), symbol2str(dot.tk_symb));
34
35                 aside = dot;
36
37                 dot.tk_symb = tk;
38
39                 switch (tk)     {
40                 /* The operands need some body */
41                 case IDENT:
42                         dot.TOK_IDF = gen_anon_idf();
43                         break;
44                 }
45         }
46         else if (tk  < 0) {
47                 error("garbage at end of program");
48         }
49         else    error("%s deleted", symbol2str(dot.tk_symb));
50 }