SQLite

Check-in [6ab3af8847]
Login

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

Overview
Comment:Synchronize lemon.c to the version on the 2.8 branch. (CVS 1513)
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 6ab3af8847a7b0f1508824c9d8e0ec9685219371
User & Date: drh 2004-05-31 23:13:45.000
Context
2004-05-31
23:56
Remove the sqlite3_error_string() API. (CVS 1514) (check-in: af8e2006d8 user: danielk1977 tags: trunk)
23:13
Synchronize lemon.c to the version on the 2.8 branch. (CVS 1513) (check-in: 6ab3af8847 user: drh tags: trunk)
19:34
Change the name of the sqlite3_freemem API function to just sqlite3_free. (CVS 1512) (check-in: f3b80bbb97 user: drh tags: trunk)
Changes
Unified Diff 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
*/
#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 */







<
<
<
<
<
<
<







8
9
10
11
12
13
14







15
16
17
18
19
20
21
*/
#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 */
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50

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)







<







29
30
31
32
33
34
35

36
37
38
39
40
41
42

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)
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
  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;







|







362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
  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;
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821

    /* 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)







|







799
800
801
802
803
804
805
806
807
808
809
810
811
812
813

    /* 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)
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
    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 */







|







900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
    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 */
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
    }
  }
  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(){







|






|







1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
    }
  }
  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(){
1443
1444
1445
1446
1447
1448
1449

1450
1451
1452
1453
1454
1455
1456
    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







>







1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
    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