|
|
|
@ -31,6 +31,7 @@ extern long strtol();
|
|
|
|
|
extern void free();
|
|
|
|
|
extern int access();
|
|
|
|
|
extern int atoi();
|
|
|
|
|
extern char *getenv();
|
|
|
|
|
|
|
|
|
|
#ifndef __WIN32__
|
|
|
|
|
# if defined(_WIN32) || defined(WIN32)
|
|
|
|
@ -39,7 +40,7 @@ extern int atoi();
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/* #define PRIVATE static */
|
|
|
|
|
#define PRIVATE
|
|
|
|
|
#define PRIVATE static
|
|
|
|
|
|
|
|
|
|
#ifdef TEST
|
|
|
|
|
#define MAXRHS 5 /* Set low to exercise exception code */
|
|
|
|
@ -50,6 +51,8 @@ extern int atoi();
|
|
|
|
|
char *msort();
|
|
|
|
|
extern void *malloc();
|
|
|
|
|
|
|
|
|
|
extern void memory_error();
|
|
|
|
|
|
|
|
|
|
/******** From the file "action.h" *************************************/
|
|
|
|
|
struct action *Action_new();
|
|
|
|
|
struct action *Action_sort();
|
|
|
|
@ -291,7 +294,6 @@ struct lemon {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#define MemoryCheck(X) if((X)==0){ \
|
|
|
|
|
extern void memory_error(); \
|
|
|
|
|
memory_error(); \
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -445,14 +447,16 @@ struct acttab {
|
|
|
|
|
#define acttab_yylookahead(X,N) ((X)->aAction[N].lookahead)
|
|
|
|
|
|
|
|
|
|
/* Free all memory associated with the given acttab */
|
|
|
|
|
void acttab_free(acttab *p){
|
|
|
|
|
/*
|
|
|
|
|
PRIVATE void acttab_free(acttab *p){
|
|
|
|
|
free( p->aAction );
|
|
|
|
|
free( p->aLookahead );
|
|
|
|
|
free( p );
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/* Allocate a new acttab structure */
|
|
|
|
|
acttab *acttab_alloc(void){
|
|
|
|
|
PRIVATE acttab *acttab_alloc(void){
|
|
|
|
|
acttab *p = malloc( sizeof(*p) );
|
|
|
|
|
if( p==0 ){
|
|
|
|
|
fprintf(stderr,"Unable to allocate memory for a new acttab.");
|
|
|
|
@ -464,7 +468,7 @@ acttab *acttab_alloc(void){
|
|
|
|
|
|
|
|
|
|
/* Add a new action to the current transaction set
|
|
|
|
|
*/
|
|
|
|
|
void acttab_action(acttab *p, int lookahead, int action){
|
|
|
|
|
PRIVATE void acttab_action(acttab *p, int lookahead, int action){
|
|
|
|
|
if( p->nLookahead>=p->nLookaheadAlloc ){
|
|
|
|
|
p->nLookaheadAlloc += 25;
|
|
|
|
|
p->aLookahead = realloc( p->aLookahead,
|
|
|
|
@ -497,7 +501,7 @@ void acttab_action(acttab *p, int lookahead, int action){
|
|
|
|
|
**
|
|
|
|
|
** Return the offset into the action table of the new transaction.
|
|
|
|
|
*/
|
|
|
|
|
int acttab_insert(acttab *p){
|
|
|
|
|
PRIVATE int acttab_insert(acttab *p){
|
|
|
|
|
int i, j, k, n;
|
|
|
|
|
assert( p->nLookahead>0 );
|
|
|
|
|
|
|
|
|
@ -2603,7 +2607,7 @@ struct lemon *lemp;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ConfigPrint(fp,cfp)
|
|
|
|
|
PRIVATE void ConfigPrint(fp,cfp)
|
|
|
|
|
FILE *fp;
|
|
|
|
|
struct config *cfp;
|
|
|
|
|
{
|
|
|
|
@ -2640,7 +2644,7 @@ struct lemon *lemp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Print a plink chain */
|
|
|
|
|
PRIVATE void PlinkPrint(out,plp,tag)
|
|
|
|
|
void PlinkPrint(out,plp,tag)
|
|
|
|
|
FILE *out;
|
|
|
|
|
struct plink *plp;
|
|
|
|
|
char *tag;
|
|
|
|
@ -2657,7 +2661,7 @@ char *tag;
|
|
|
|
|
/* Print an action to the given file descriptor. Return FALSE if
|
|
|
|
|
** nothing was actually printed.
|
|
|
|
|
*/
|
|
|
|
|
int PrintAction(struct action *ap, FILE *fp, int indent){
|
|
|
|
|
PRIVATE int PrintAction(struct action *ap, FILE *fp, int indent){
|
|
|
|
|
int result = 1;
|
|
|
|
|
switch( ap->type ){
|
|
|
|
|
case SHIFT:
|
|
|
|
@ -2731,6 +2735,7 @@ struct lemon *lemp;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
extern int access();
|
|
|
|
|
/* Search for the file "name" which is in the same directory as
|
|
|
|
|
** the exacutable */
|
|
|
|
|
PRIVATE char *pathsearch(argv0,name,modemask)
|
|
|
|
@ -2741,7 +2746,6 @@ int modemask;
|
|
|
|
|
char *pathlist;
|
|
|
|
|
char *path,*cp;
|
|
|
|
|
char c;
|
|
|
|
|
extern int access();
|
|
|
|
|
|
|
|
|
|
#ifdef __WIN32__
|
|
|
|
|
cp = strrchr(argv0,'\\');
|
|
|
|
@ -2755,7 +2759,6 @@ int modemask;
|
|
|
|
|
if( path ) sprintf(path,"%s/%s",argv0,name);
|
|
|
|
|
*cp = c;
|
|
|
|
|
}else{
|
|
|
|
|
extern char *getenv();
|
|
|
|
|
pathlist = getenv("PATH");
|
|
|
|
|
if( pathlist==0 ) pathlist = ".:/bin:/usr/bin";
|
|
|
|
|
path = (char *)malloc( strlen(pathlist)+strlen(name)+2 );
|
|
|
|
@ -2894,7 +2897,7 @@ int *lineno;
|
|
|
|
|
** The following routine emits code for the destructor for the
|
|
|
|
|
** symbol sp
|
|
|
|
|
*/
|
|
|
|
|
void emit_destructor_code(out,sp,lemp,lineno)
|
|
|
|
|
PRIVATE void emit_destructor_code(out,sp,lemp,lineno)
|
|
|
|
|
FILE *out;
|
|
|
|
|
struct symbol *sp;
|
|
|
|
|
struct lemon *lemp;
|
|
|
|
@ -2932,7 +2935,7 @@ int *lineno;
|
|
|
|
|
/*
|
|
|
|
|
** Return TRUE (non-zero) if the given symbol has a destructor.
|
|
|
|
|
*/
|
|
|
|
|
int has_destructor(sp, lemp)
|
|
|
|
|
PRIVATE int has_destructor(sp, lemp)
|
|
|
|
|
struct symbol *sp;
|
|
|
|
|
struct lemon *lemp;
|
|
|
|
|
{
|
|
|
|
@ -3033,7 +3036,7 @@ int *lineno;
|
|
|
|
|
** union, also set the ".dtnum" field of every terminal and nonterminal
|
|
|
|
|
** symbol.
|
|
|
|
|
*/
|
|
|
|
|
void print_stack_union(out,lemp,plineno,mhflag)
|
|
|
|
|
PRIVATE void print_stack_union(out,lemp,plineno,mhflag)
|
|
|
|
|
FILE *out; /* The output stream */
|
|
|
|
|
struct lemon *lemp; /* The main info structure for this parser */
|
|
|
|
|
int *plineno; /* Pointer to the line number */
|
|
|
|
@ -3684,7 +3687,6 @@ char *SetNew(){
|
|
|
|
|
int i;
|
|
|
|
|
s = (char*)malloc( global_size );
|
|
|
|
|
if( s==0 ){
|
|
|
|
|
extern void memory_error();
|
|
|
|
|
memory_error();
|
|
|
|
|
}
|
|
|
|
|
for(i=0; i<global_size; i++) s[i] = 0;
|
|
|
|
|