/ Check-in [b8b8ce5c]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Changes to lemon.c so that it compiles on OpenWatcom 1.3. Ticket #665. (CVS 1307)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | version_2
Files: files | file ages | folders
SHA1:b8b8ce5c81ef614d488e0f79df8935ef609dc4f2
User & Date: drh 2004-04-24 12:59:13
Context
2004-04-29
16:16
Fix a stack overflow problem with INSTEAD OF triggers. (CVS 1310) check-in: 5a33e0b0 user: drh tags: version_2
2004-04-24
12:59
Changes to lemon.c so that it compiles on OpenWatcom 1.3. Ticket #665. (CVS 1307) check-in: b8b8ce5c user: drh tags: version_2
2004-04-23
23:37
Add some extra debugging logic to lemon.c. Ticket #692. (CVS 1304) check-in: 635f674d user: drh tags: version_2
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to tool/lemon.c.

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
..
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
...
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
...
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
...
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
....
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
....
1443
1444
1445
1446
1447
1448
1449

1450
1451
1452
1453
1454
1455
1456
*/
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>

extern void qsort();
extern double strtod();
extern long strtol();
extern void free();
extern int access();
extern int atoi();

#ifndef __WIN32__
#   if defined(_WIN32) || defined(WIN32)
#	define __WIN32__
#   endif
#endif

/* #define PRIVATE static */
................................................................................

char *msort();
extern void *malloc();

/******** From the file "action.h" *************************************/
struct action *Action_new();
struct action *Action_sort();
void Action_add();

/********* From the file "assert.h" ************************************/
void myassert();
#ifndef NDEBUG
#  define assert(X) if(!(X))myassert(__FILE__,__LINE__)
#else
#  define assert(X)
................................................................................
  return rc;
}

/* Sort parser actions */
struct action *Action_sort(ap)
struct action *ap;
{
  ap = (struct action *)msort(ap,&ap->next,actioncmp);
  return ap;
}

void Action_add(app,type,sp,arg)
struct action **app;
enum e_action type;
struct symbol *sp;
................................................................................

    /* Get a pointer to the state described by the basis configuration set
    ** constructed in the preceding loop */
    newstp = getstate(lemp);

    /* The state "newstp" is reached from the state "stp" by a shift action
    ** on the symbol "sp" */
    Action_add(&stp->ap,SHIFT,sp,newstp);
  }
}

/*
** Construct the propagation links
*/
void FindLinks(lemp)
................................................................................
    stp = lemp->sorted[i];
    for(cfp=stp->cfp; cfp; cfp=cfp->next){  /* Loop over all configurations */
      if( cfp->rp->nrhs==cfp->dot ){        /* Is dot at extreme right? */
        for(j=0; j<lemp->nterminal; j++){
          if( SetFind(cfp->fws,j) ){
            /* Add a reduce action to the state "stp" which will reduce by the
            ** rule "cfp->rp" if the lookahead symbol is "lemp->symbols[j]" */
            Action_add(&stp->ap,REDUCE,lemp->symbols[j],cfp->rp);
          }
	}
      }
    }
  }

  /* Add the accepting token */
................................................................................
    }
  }
  return;
}

/* Sort the configuration list */
void Configlist_sort(){
  current = (struct config *)msort(current,&(current->next),Configcmp);
  currentend = 0;
  return;
}

/* Sort the basis configuration list */
void Configlist_sortbasis(){
  basis = (struct config *)msort(current,&(current->bp),Configcmp);
  basisend = 0;
  return;
}

/* Return a pointer to the head of the configuration list and
** reset the list */
struct config *Configlist_return(){
................................................................................
    printf("                   %d states, %d parser table entries, %d conflicts\n",
      lem.nstate, lem.tablesize, lem.nconflict);
  }
  if( lem.nconflict ){
    fprintf(stderr,"%d parsing conflicts.\n",lem.nconflict);
  }
  exit(lem.errorcnt + lem.nconflict);

}
/******************** From the file "msort.c" *******************************/
/*
** A generic merge-sort program.
**
** USAGE:
** Let "ptr" be a pointer to some structure which is at the head of







<
<
<
<
<
<
<







 







<







 







|







 







|







 







|







 







|






|







 







>







8
9
10
11
12
13
14







15
16
17
18
19
20
21
..
29
30
31
32
33
34
35

36
37
38
39
40
41
42
...
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
...
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
...
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
....
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
....
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
*/
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>








#ifndef __WIN32__
#   if defined(_WIN32) || defined(WIN32)
#	define __WIN32__
#   endif
#endif

/* #define PRIVATE static */
................................................................................

char *msort();
extern void *malloc();

/******** From the file "action.h" *************************************/
struct action *Action_new();
struct action *Action_sort();


/********* From the file "assert.h" ************************************/
void myassert();
#ifndef NDEBUG
#  define assert(X) if(!(X))myassert(__FILE__,__LINE__)
#else
#  define assert(X)
................................................................................
  return rc;
}

/* Sort parser actions */
struct action *Action_sort(ap)
struct action *ap;
{
  ap = (struct action *)msort((char *)ap,(char **)&ap->next,actioncmp);
  return ap;
}

void Action_add(app,type,sp,arg)
struct action **app;
enum e_action type;
struct symbol *sp;
................................................................................

    /* Get a pointer to the state described by the basis configuration set
    ** constructed in the preceding loop */
    newstp = getstate(lemp);

    /* The state "newstp" is reached from the state "stp" by a shift action
    ** on the symbol "sp" */
    Action_add(&stp->ap,SHIFT,sp,(char *)newstp);
  }
}

/*
** Construct the propagation links
*/
void FindLinks(lemp)
................................................................................
    stp = lemp->sorted[i];
    for(cfp=stp->cfp; cfp; cfp=cfp->next){  /* Loop over all configurations */
      if( cfp->rp->nrhs==cfp->dot ){        /* Is dot at extreme right? */
        for(j=0; j<lemp->nterminal; j++){
          if( SetFind(cfp->fws,j) ){
            /* Add a reduce action to the state "stp" which will reduce by the
            ** rule "cfp->rp" if the lookahead symbol is "lemp->symbols[j]" */
            Action_add(&stp->ap,REDUCE,lemp->symbols[j],(char *)cfp->rp);
          }
	}
      }
    }
  }

  /* Add the accepting token */
................................................................................
    }
  }
  return;
}

/* Sort the configuration list */
void Configlist_sort(){
  current = (struct config *)msort((char *)current,(char **)&(current->next),Configcmp);
  currentend = 0;
  return;
}

/* Sort the basis configuration list */
void Configlist_sortbasis(){
  basis = (struct config *)msort((char *)current,(char **)&(current->bp),Configcmp);
  basisend = 0;
  return;
}

/* Return a pointer to the head of the configuration list and
** reset the list */
struct config *Configlist_return(){
................................................................................
    printf("                   %d states, %d parser table entries, %d conflicts\n",
      lem.nstate, lem.tablesize, lem.nconflict);
  }
  if( lem.nconflict ){
    fprintf(stderr,"%d parsing conflicts.\n",lem.nconflict);
  }
  exit(lem.errorcnt + lem.nconflict);
  return (lem.errorcnt + lem.nconflict);
}
/******************** From the file "msort.c" *******************************/
/*
** A generic merge-sort program.
**
** USAGE:
** Let "ptr" be a pointer to some structure which is at the head of