# include "assert.h"
# include "cclass.h"
-# ifndef NORCSID
-static string rcsid = "$Id$";
-# endif
-p_mem alloc(), ralloc();
-string store();
-p_gram search();
-long ftell();
+#include "LLgen.h"
static int acount; /* count #of global actions */
static p_term t_list;
#define RULEINCR 32
/* Here are defined : */
-STATIC newnorder();
-STATIC newtorder();
-STATIC mkalt();
-STATIC mkterm();
-STATIC p_gram copyrule();
/* and of course LLparse() */
-STATIC
-newnorder(index) {
+STATIC void newnorder(int index) {
static int porder;
if (norder != -1) {
nonterms[porder].n_next = -1;
}
-STATIC
-newtorder(index) {
+STATIC void newtorder(int index) {
static int porder;
if (torder != -1) {
tokens[porder].t_next = -1;
}
-p_init()
+void p_init()
{
alt_table = (p_gram )alloc(ALTINCR*sizeof(t_gram));
n_alts = 0;
ff->ff_name = p;
ff->ff_next = start;
start = ff;
- while (ff = ff->ff_next) {
+ while ((ff = ff->ff_next)) {
if (! strcmp(p, ff->ff_name)) {
- error(linecount, "\"%s\" already used in a %%start", p);
+ error(linecount, "\"%s\" already used in a %%start", p, NULL);
break;
}
}
{ if (!lexical) {
lexical = store(lextoken.t_string);
}
- else error(linecount,"Duplicate %%lexical");
+ else error(linecount,"Duplicate %%lexical", NULL, NULL);
}
LLtdecr(24);
LL_NOSCANDONE(';');
prefix = store(lextoken.t_string);
if (strlen(prefix) > 6) {
error(linecount,
- "%%prefix too long");
+ "%%prefix too long", NULL, NULL);
prefix[6] = 0;
}
}
- else error(linecount,"Duplicate %%prefix");
+ else error(linecount,"Duplicate %%prefix", NULL, NULL);
}
LLtdecr(24);
LL_NOSCANDONE(';');
{
#ifdef NON_CORRECTING
if (non_corr) {
- warning(linecount, "%%onerror conflicts with -n option");
+ warning(linecount, "%%onerror conflicts with -n option", NULL, NULL);
}
else
#endif
if (! onerror) {
onerror = store(lextoken.t_string);
}
- else error(linecount,"Duplicate %%onerror");
+ else error(linecount,"Duplicate %%onerror", NULL, NULL);
}
LLtdecr(24);
LL_NOSCANDONE(';');
p = &nonterms[g_getcont(temp)];
if (p->n_rule) {
error(linecount,
-"Nonterminal %s already defined", lextoken.t_string);
+"Nonterminal %s already defined", lextoken.t_string, NULL);
}
/*
* Remember the order in which the nonterminals
{ if (lextoken.t_num > 0) {
p->n_flags |= PARAMS;
if (lextoken.t_num > 15) {
- error(linecount,"Too many parameters");
+ error(linecount,"Too many parameters", NULL, NULL);
}
else setntparams(p,lextoken.t_num);
}
if (t & DEF) {
if (haddefault) {
error(n_lc,
- "More than one %%default in alternation");
+ "More than one %%default in alternation", NULL, NULL);
}
haddefault = 1;
}
# line 282 "LLgen.g"
{ if (conflres & (COND|PREFERING|AVOIDING)) {
error(n_lc,
- "Resolver on last alternative not allowed");
+ "Resolver on last alternative not allowed", NULL, NULL);
}
mkalt(*p,conflres,n_lc,&alt_table[n_alts++]);
altcnt++;
# line 292 "LLgen.g"
{ if (conflres & (COND|PREFERING|AVOIDING)) {
error(o_lc,
- "No alternation conflict resolver allowed here");
+ "No alternation conflict resolver allowed here", NULL, NULL);
}
/*
if (conflres & DEF) {
# line 306 "LLgen.g"
-STATIC
-mkalt(prod,condition,lc,res) p_gram prod; register p_gram res; {
+STATIC void mkalt(p_gram prod, int condition, int lc, p_gram res) {
/*
* Create an alternation and initialise it.
*/
rule_table[n_rules++] =
*search(TERMINAL, "LLILLEGAL", BOTH);
if (*conflres & DEF) {
- error(linecount, "%%illegal not allowed in %%default rule");
+ error(linecount, "%%illegal not allowed in %%default rule", NULL, NULL);
}
#endif
}
if ((q->t_flags & RESOLVER) &&
(kind == PLUS || kind == FIXED)) {
error(linecount,
- "%%while not allowed in this term");
+ "%%while not allowed in this term", NULL, NULL);
}
/*
* A persistent fixed term is the same
# line 454 "LLgen.g"
-STATIC
-mkterm(prod,flags,lc,result) p_gram prod; register p_gram result; {
+STATIC void mkterm(p_gram prod, int flags, int lc, p_gram result) {
/*
* Create a term, initialise it and return
* a grammar element containing it
if (erroneous) {
if (g_gettype(pres) != TERMINAL){
warning(linecount,
- "Erroneous only allowed on terminal");
+ "Erroneous only allowed on terminal", NULL, NULL);
erroneous = 0;
}
else
LL_SAFE(C_PARAMS);
# line 522 "LLgen.g"
{ if (lextoken.t_num > 15) {
- error(linecount,"Too many parameters");
+ error(linecount,"Too many parameters", NULL, NULL);
} else g_setnpar(pres,lextoken.t_num);
if (g_gettype(pres) == TERMINAL) {
error(linecount,
- "Terminal with parameters");
+ "Terminal with parameters", NULL, NULL);
}
}
LLread();
ff = g_getsubparse(pres);
while (ff) {
if (ff->ff_nont == g_getcont(temp)) {
- warning(linecount, "\"%s\" used twice in %%substart", lextoken.t_string);
+ warning(linecount, "\"%s\" used twice in %%substart", lextoken.t_string, NULL);
break;
}
ff = ff->ff_next;
# line 621 "LLgen.g"
{ *t = lextoken.t_num;
if (*t <= 0 || *t >= 8192) {
- error(linecount,"Illegal number");
+ error(linecount,"Illegal number", NULL, NULL);
}
}
}
# include "assert.h"
# include "cclass.h"
-# ifndef NORCSID
-static string rcsid = "$Id$";
-# endif
-p_mem alloc(), ralloc();
-string store();
-p_gram search();
-long ftell();
+#include "LLgen.h"
static int acount; /* count #of global actions */
static p_term t_list;
#define RULEINCR 32
/* Here are defined : */
-STATIC newnorder();
-STATIC newtorder();
-STATIC mkalt();
-STATIC mkterm();
-STATIC p_gram copyrule();
/* and of course LLparse() */
-STATIC
-newnorder(index) {
+STATIC void newnorder(int index) {
static int porder;
if (norder != -1) {
nonterms[porder].n_next = -1;
}
-STATIC
-newtorder(index) {
+STATIC void newtorder(int index) {
static int porder;
if (torder != -1) {
tokens[porder].t_next = -1;
}
-p_init()
+void p_init()
{
alt_table = (p_gram )alloc(ALTINCR*sizeof(t_gram));
n_alts = 0;
/* LLgen.c */
void newnorder(int index);
void newtorder(int index);
-int p_init(void);
+void p_init(void);
void LL0_spec(void);
void mkalt(p_gram prod, int condition, int lc, p_gram res);
void mkterm(p_gram prod, int flags, int lc, p_gram result);
void install(char *target, char *source);
/* name.c */
-int name_init(void);
+void name_init(void);
p_entry newentry(char * str, p_entry next);
char * store(char * s);
int hash(char * str);
void reachwalk(p_gram p);
/* sets.c */
-int setinit(int nt_needed);
+void setinit(int nt_needed);
p_set get_set(void);
p_set setalloc(void);
int setunion(p_set a, p_set b);
int setintersect(p_set a, p_set b);
-int setminus(p_set a, p_set b);
+void setminus(p_set a, p_set b);
int setempty(p_set p);
int findindex(p_set set);
int setcount(p_set set, int *saved);
/* tokens.c */
-void copyact(int ch1, int ch2, int flag, int level);
+void copyact(char ch1, char ch2, int flag, int level);
int scanner(void);
int input(void);
-int unput(int c);
-int skipcomment(int flag);
+void unput(int c);
+void skipcomment(int flag);
char * vallookup(int s);
char * cpy(int s, char * p, int inserted);
-int LLmessage(int d);
+void LLmessage(int d);
#endif /* LLGEN_H */
* initialising routine.
*/
+#include <stdlib.h>
+#include <string.h>
+
# include "types.h"
# include "extern.h"
# include "assert.h"
if (type == TERMINAL) {
error(linecount,
"%s: is already a nonterminal",
- str);
+ str, NULL);
continue;
}
else if (type == NONTERM) {
error(linecount,
"%s : is already a token",
- str);
+ str, NULL);
continue;
}
}
if (option==ENTERING) {
error(linecount,
- "%s : is already defined",str);
+ "%s : is already defined",str, NULL);
}
p->h_type.g_lineno = linecount;
return &(p->h_type);
val = '\\';
break;
default :
- error(linecount,e_literal);
+ error(linecount,e_literal, NULL, NULL);
}
} else {
/*
if (str[1] > '3' || str[1] < '0' ||
str[2] > '7' || str[2] < '0' ||
str[3] > '7' || str[3] < '0' ||
- str[4] != '\0') error(linecount,e_literal);
+ str[4] != '\0') error(linecount,e_literal, NULL, NULL);
val = 64*str[1] - 73*'0' +
8*str[2] + str[3];
}
* No escape in literal
*/
if (str[1] == '\0') val = str[0];
- else error(linecount,e_literal);
+ else error(linecount,e_literal, NULL, NULL);
}
pt->t_tokno = val;
g_settype(&(p->h_type), LITERAL);
# include "assert.h"
# include "sets.h"
+#include "LLgen.h"
+
#define LLALT 9999
static int nt_highest;
extern int nbytes;
-extern p_mem alloc();
-extern p_set start_firsts;
-extern p_set setalloc();
-extern p_gram search();
-STATIC save_rule();
-STATIC save_set();
+STATIC void save_rule(p_gram p, int tail);
+STATIC void save_set(p_set p);
/* t_list will contain terms to be `flattened' */
static struct t_list {
used when LLgen called with -n -s options */
int act_nt;
-save_grammar(f) FILE *f; {
+void save_grammar(FILE *f) {
/*
* Save the grammar
*/
if (! p->n_rule) { /* undefined */
f_input = p->n_string;
error(p->n_lineno,"Nonterminal %s not defined",
- p->n_name);
+ p->n_name, NULL);
}
/* Save the first_set and follow set */
if (check == 0)
warning((sub_list + i)->sub_action->g_lineno,
"\"%s\" is not a startsymbol",
- (&nonterms[ff->ff_nont])->n_name);
+ (&nonterms[ff->ff_nont])->n_name, NULL);
}
save_set(temp_set);
save_set(temp_set);
fprintf(fgram, "#define LLNNONTERMINALS %d\n", nt_highest - assval + 1);
}
-STATIC
-save_rule(p, tail) register p_gram p; int tail; {
+STATIC void save_rule(p_gram p, int tail) {
/*
Walk through rule p, saving it. The non-terminal tail is
appended to the rule. It needs to be appended in this function
}
}
-STATIC
-save_set(p) p_set p; {
+STATIC void save_set(p_set p) {
register int k;
register unsigned i;
int j;
* Set manipulation and allocation routines.
*/
+#include <stdlib.h>
+#include <stdio.h>
+
# include "types.h"
# include "extern.h"
# include "sets.h"
# include "assert.h"
-# ifndef NORCSID
-static string rcsid9 = "$Id$";
-# endif
+#include "LLgen.h"
/* In this file the following routines are defined: */
-extern setinit();
-extern p_set setalloc();
-extern p_set get_set();
-extern int setunion();
-extern int setintersect();
-extern setminus();
-extern int setempty();
-extern int findindex();
-extern int setcount();
-
int nbytes;
static int setsize;
int tsetsize;
p_set *setptr, *maxptr;
static t_info set_info;
-p_mem alloc();
-setinit(nt_needed) {
+void setinit(int nt_needed) {
/*
* Initialises some variables needed for setcomputations
*/
set_info.i_incr = 20;
}
-p_set
-get_set() {
+p_set get_set() {
/*
* Allocate a set that cannot be freed
*/
return p;
}
-p_set
-setalloc() {
+p_set setalloc() {
/*
* Allocate a set which can later be freed.
*/
return p;
}
-int
-setunion(a,b) register p_set a,b; {
+int setunion(p_set a, p_set b) {
/*
* a = a union b.
* Return 1 if the set a changed
return nsub;
}
-int
-setintersect(a,b) register p_set a,b; {
+int setintersect(p_set a, p_set b) {
/*
* a = a intersect b.
* return 1 if the result is empty
return nempty;
}
-setminus(a,b) register p_set a,b; {
+void setminus(p_set a, p_set b) {
/*
* a = a setminus b
*/
} while (--i);
}
-int
-setempty(p) register p_set p; {
+int setempty(p_set p) {
/*
* Return 1 if the set p is empty
*/
return 1;
}
-int
-findindex(set) p_set set; {
+int findindex(p_set set) {
/*
* The set "set" will serve as a recovery set.
* Search for it in the table. If not present, enter it.
return nbytes * (maxptr++ - setptr);
}
-int
-setcount(set, saved) register p_set set; int *saved; {
+int setcount(p_set set, int *saved) {
register int i, j;
for (j = 0, i = 0; i < ntokens; i++) {
#define LL_assert(x) /* nothing */
#endif
+#include <stdio.h>
+#include <string.h>
+
extern int LLsymb;
#define LL_SAFE(x) /* Nothing */
# include "assert.h"
# include "cclass.h"
-# ifndef NORCSID
-static string rcsidc = "$Id$";
-# endif
+#include "LLgen.h"
/* Here are defined : */
-extern int scanner();
-extern LLmessage();
-extern int input();
-extern unput();
-extern skipcomment();
-# ifdef LINE_DIRECTIVE
-STATIC linedirective();
-# endif
-STATIC string cpy();
-STATIC string vallookup();
-STATIC copyact();
-
static int nparams;
# line 75 "tokens.g"
static int nostartline; /* = 0 if at the start of a line */
# endif
-STATIC
-copyact(ch1,ch2,flag,level) char ch1,ch2; {
+STATIC void copyact(char ch1, char ch2, int flag, int level) {
/*
* Copy an action to file f. Opening bracket is ch1, closing bracket
* is ch2.
case ')':
case '}':
case ']':
- error(linecount,"Parentheses mismatch");
+ error(linecount,"Parentheses mismatch", NULL, NULL);
break;
case '(':
text_seen = 1;
text_seen = 0;
nparams++;
if (ch == ',' && (flag & 2)) {
- warning(linecount, "Parameters may not be separated with a ','");
+ warning(linecount, "Parameters may not be separated with a ','", NULL, NULL);
ch = ';';
}
}
ch = input();
}
if (ch == '\n') {
- error(linecount,"Newline in string");
+ error(linecount,"Newline in string", NULL, NULL);
unput(match);
}
putc(ch,f);
if (ch == match) break;
/* Fall through */
case EOF :
- if (!level) error(saved,"Action does not terminate");
+ if (!level) error(saved,"Action does not terminate", NULL, NULL);
strip_grammar = sav_strip;
return;
default:
}
}
-scanner() {
+int scanner() {
/*
* Lexical analyser, what else
*/
for (;;) {
ch = input();
if (ch == '\n' || ch == EOF) {
- error(linecount,"Missing '");
+ error(linecount,"Missing '", NULL, NULL);
break;
}
if (ch == '\'') break;
}
w++;
}
- error(linecount,"Illegal reserved word");
+ error(linecount,"Illegal reserved word", NULL, NULL);
}
lextoken.t_string = ltext;
return C_IDENT;
static int backupc; /* for unput() */
static int nonline; /* = 1 if last char read was a newline */
-input() {
+int input() {
/*
* Low level input routine, used by all other input routines
*/
register c;
- if (c = backupc) {
+ if ((c = backupc)) {
/* Last char was "unput()". Deliver it again
*/
backupc = 0;
return c;
}
-unput(c) {
+void unput(int c) {
/*
* "unread" c
*/
backupc = c;
}
-skipcomment(flag) {
+void skipcomment(int flag) {
/*
* Skip comment. If flag != 0, the comment is inside a fragment
* of C-code, so keep it.
int saved; /* line count on which comment starts */
saved = linecount;
- if (input() != '*') error(linecount,"Illegal comment");
+ if (input() != '*') error(linecount,"Illegal comment", NULL, NULL);
if (flag) putc('*', fact);
do {
ch = input();
if (ch == '/') return;
}
} while (ch != EOF);
- error(saved,"Comment does not terminate");
+ error(saved,"Comment does not terminate", NULL, NULL);
}
# ifdef LINE_DIRECTIVE
-STATIC
-linedirective() {
+STATIC void linedirective() {
/*
* Read a line directive
*/
ch = input();
} while (ch != '\n' && c_class[ch] != ISDIG);
if (ch == '\n') {
- error(linecount,s_error);
+ error(linecount, s_error, NULL, NULL);
return;
}
i = 0;
*c++ = ch = input();
} while (ch != '"' && ch != '\n');
if (ch == '\n') {
- error(linecount,s_error);
+ error(linecount, s_error, NULL, NULL);
return;
}
*--c = '\0';
}
# endif
-STATIC string
-vallookup(s) {
+STATIC string vallookup(int s) {
/*
* Look up the keyword that has token number s
*/
return 0;
}
-STATIC string
-cpy(s,p,inserted) register string p; {
+STATIC string cpy(int s, char *p, int inserted) {
/*
* Create a piece of error message for token s and put it at p.
* inserted = 0 if the token s was deleted (in which case we have
return p;
}
-string strcpy();
-
-LLmessage(d) {
+void LLmessage(int d) {
/*
* d is either 0, in which case the current token has been deleted,
* or non-zero, in which case it represents a token that is inserted
#ifdef LLNONCORR
else
#endif
- error(linecount, "%s", buf);
+ error(linecount, "%s", buf, NULL);
/* Don't change this line to
* error(linecount, buf).
* The string in "buf" might contain '%' ...
# include "assert.h"
# include "cclass.h"
-# ifndef NORCSID
-static string rcsidc = "$Id$";
-# endif
-
-/* Here are defined : */
-extern int scanner();
-extern LLmessage();
-extern int input();
-extern unput();
-extern skipcomment();
-# ifdef LINE_DIRECTIVE
-STATIC linedirective();
-# endif
-STATIC string cpy();
-STATIC string vallookup();
-STATIC copyact();
-
static int nparams;
}
/* Classes */
static int nostartline; /* = 0 if at the start of a line */
# endif
-STATIC
-copyact(ch1,ch2,flag,level) char ch1,ch2; {
+STATIC void copyact(char ch1, char ch2, int flag, int level) {
/*
* Copy an action to file f. Opening bracket is ch1, closing bracket
* is ch2.
}
}
-scanner() {
+int scanner() {
/*
* Lexical analyser, what else
*/
static int backupc; /* for unput() */
static int nonline; /* = 1 if last char read was a newline */
-input() {
+int input() {
/*
* Low level input routine, used by all other input routines
*/
- register c;
+ int c;
if (c = backupc) {
/* Last char was "unput()". Deliver it again
return c;
}
-unput(c) {
+void unput(c) {
/*
* "unread" c
*/
backupc = c;
}
-skipcomment(flag) {
+void skipcomment(flag) {
/*
* Skip comment. If flag != 0, the comment is inside a fragment
* of C-code, so keep it.
}
# ifdef LINE_DIRECTIVE
-STATIC
-linedirective() {
+STATIC void linedirective() {
/*
* Read a line directive
*/
}
# endif
-STATIC string
-vallookup(s) {
+STATIC string vallookup(s) {
/*
* Look up the keyword that has token number s
*/
return 0;
}
-STATIC string
-cpy(s,p,inserted) register string p; {
+STATIC string cpy(int s,string p, int inserted) {
/*
* Create a piece of error message for token s and put it at p.
* inserted = 0 if the token s was deleted (in which case we have
return p;
}
-string strcpy();
-
-LLmessage(d) {
+void LLmessage(int d) {
/*
* d is either 0, in which case the current token has been deleted,
* or non-zero, in which case it represents a token that is inserted