mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: update lemon version, wmake wrappers
This commit is contained in:
@ -1,7 +1,9 @@
|
||||
/*
|
||||
* https://www.sqlite.org/src/artifact/70eedc31
|
||||
* Artifact 70eedc31614a58fe31a71025c17ebd1502a6ce9cfef0ed5e33acb0b5b737b291:
|
||||
* File tool/lemon.c part of check-in [4591ee03] at 2020-09-21
|
||||
/* OPENFOAM note
|
||||
*
|
||||
* https://sqlite.org/src/raw/
|
||||
* https://www.sqlite.org/src/artifact/25888183
|
||||
* Artifact 258881835bd5bccd0c74fb110fe54244ff18e8e7ef3d949cbdab7187f02132bb:
|
||||
* File tool/lemon.c part of check-in [f2f279b2]] at 2021-10-04
|
||||
*/
|
||||
/*
|
||||
** This file contains all sources (including headers) to the LEMON
|
||||
@ -406,7 +408,7 @@ struct lemon {
|
||||
struct symbol *errsym; /* The error symbol */
|
||||
struct symbol *wildcard; /* Token that matches anything */
|
||||
char *name; /* Name of the generated parser */
|
||||
char *arg; /* Declaration of the 3th argument to parser */
|
||||
char *arg; /* Declaration of the 3rd argument to parser */
|
||||
char *ctx; /* Declaration of 2nd argument to constructor */
|
||||
char *tokentype; /* Type of terminal symbols in the parser stack */
|
||||
char *vartype; /* The default type of non-terminal symbols */
|
||||
@ -923,8 +925,11 @@ void FindStates(struct lemon *lemp)
|
||||
lemp->errorcnt++;
|
||||
sp = lemp->startRule->lhs;
|
||||
}
|
||||
}else{
|
||||
}else if( lemp->startRule ){
|
||||
sp = lemp->startRule->lhs;
|
||||
}else{
|
||||
ErrorMsg(lemp->filename,0,"Internal error - no start rule\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* Make sure the start symbol doesn't occur on the right-hand side of
|
||||
@ -1033,7 +1038,7 @@ PRIVATE void buildshifts(struct lemon *lemp, struct state *stp)
|
||||
struct symbol *bsp; /* Symbol following the dot in configuration "bcfp" */
|
||||
struct state *newstp; /* A pointer to a successor state */
|
||||
|
||||
/* Each configuration becomes complete after it contibutes to a successor
|
||||
/* Each configuration becomes complete after it contributes to a successor
|
||||
** state. Initially, all configurations are incomplete */
|
||||
for(cfp=stp->cfp; cfp; cfp=cfp->next) cfp->status = INCOMPLETE;
|
||||
|
||||
@ -1089,7 +1094,7 @@ void FindLinks(struct lemon *lemp)
|
||||
** which the link is attached. */
|
||||
for(i=0; i<lemp->nstate; i++){
|
||||
stp = lemp->sorted[i];
|
||||
for(cfp=stp->cfp; cfp; cfp=cfp->next){
|
||||
for(cfp=stp?stp->cfp:0; cfp; cfp=cfp->next){
|
||||
cfp->stp = stp;
|
||||
}
|
||||
}
|
||||
@ -1098,7 +1103,7 @@ void FindLinks(struct lemon *lemp)
|
||||
** links are used in the follow-set computation. */
|
||||
for(i=0; i<lemp->nstate; i++){
|
||||
stp = lemp->sorted[i];
|
||||
for(cfp=stp->cfp; cfp; cfp=cfp->next){
|
||||
for(cfp=stp?stp->cfp:0; cfp; cfp=cfp->next){
|
||||
for(plp=cfp->bplp; plp; plp=plp->next){
|
||||
other = plp->cfp;
|
||||
Plink_add(&other->fplp,cfp);
|
||||
@ -1121,6 +1126,7 @@ void FindFollowSets(struct lemon *lemp)
|
||||
int change;
|
||||
|
||||
for(i=0; i<lemp->nstate; i++){
|
||||
assert( lemp->sorted[i]!=0 );
|
||||
for(cfp=lemp->sorted[i]->cfp; cfp; cfp=cfp->next){
|
||||
cfp->status = INCOMPLETE;
|
||||
}
|
||||
@ -1129,6 +1135,7 @@ void FindFollowSets(struct lemon *lemp)
|
||||
do{
|
||||
progress = 0;
|
||||
for(i=0; i<lemp->nstate; i++){
|
||||
assert( lemp->sorted[i]!=0 );
|
||||
for(cfp=lemp->sorted[i]->cfp; cfp; cfp=cfp->next){
|
||||
if( cfp->status==COMPLETE ) continue;
|
||||
for(plp=cfp->fplp; plp; plp=plp->next){
|
||||
@ -1178,7 +1185,14 @@ void FindActions(struct lemon *lemp)
|
||||
/* Add the accepting token */
|
||||
if( lemp->start ){
|
||||
sp = Symbol_find(lemp->start);
|
||||
if( sp==0 ) sp = lemp->startRule->lhs;
|
||||
if( sp==0 ){
|
||||
if( lemp->startRule==0 ){
|
||||
fprintf(stderr, "internal error on source line %d: no start rule\n",
|
||||
__LINE__);
|
||||
exit(1);
|
||||
}
|
||||
sp = lemp->startRule->lhs;
|
||||
}
|
||||
}else{
|
||||
sp = lemp->startRule->lhs;
|
||||
}
|
||||
@ -1305,21 +1319,7 @@ static struct config **basisend = 0; /* End of list of basis configs */
|
||||
|
||||
/* Return a pointer to a new configuration */
|
||||
PRIVATE struct config *newconfig(void){
|
||||
struct config *newcfg;
|
||||
if( freelist==0 ){
|
||||
int i;
|
||||
int amt = 3;
|
||||
freelist = (struct config *)calloc( amt, sizeof(struct config) );
|
||||
if( freelist==0 ){
|
||||
fprintf(stderr,"Unable to allocate memory for a new configuration.");
|
||||
exit(1);
|
||||
}
|
||||
for(i=0; i<amt-1; i++) freelist[i].next = &freelist[i+1];
|
||||
freelist[amt-1].next = 0;
|
||||
}
|
||||
newcfg = freelist;
|
||||
freelist = freelist->next;
|
||||
return newcfg;
|
||||
return (struct config*)calloc(1, sizeof(struct config));
|
||||
}
|
||||
|
||||
/* The configuration "old" is no longer used */
|
||||
@ -1549,7 +1549,7 @@ static void handle_D_option(char *z){
|
||||
*z = 0;
|
||||
}
|
||||
|
||||
/* Remember the name of the output directory
|
||||
/* Rember the name of the output directory
|
||||
*/
|
||||
static char *outputDir = NULL;
|
||||
static void handle_d_option(char *z){
|
||||
@ -1912,7 +1912,7 @@ static char *merge(
|
||||
**
|
||||
** Return Value:
|
||||
** A pointer to the head of a sorted list containing the elements
|
||||
** orginally in list.
|
||||
** originally in list.
|
||||
**
|
||||
** Side effects:
|
||||
** The "next" pointers for elements in list are changed.
|
||||
@ -1957,8 +1957,12 @@ static FILE *errstream;
|
||||
static void errline(int n, int k, FILE *err)
|
||||
{
|
||||
int spcnt, i;
|
||||
if( g_argv[0] ) fprintf(err,"%s",g_argv[0]);
|
||||
spcnt = lemonStrlen(g_argv[0]) + 1;
|
||||
if( g_argv[0] ){
|
||||
fprintf(err,"%s",g_argv[0]);
|
||||
spcnt = lemonStrlen(g_argv[0]) + 1;
|
||||
}else{
|
||||
spcnt = 0;
|
||||
}
|
||||
for(i=1; i<n && g_argv[i]; i++){
|
||||
fprintf(err," %s",g_argv[i]);
|
||||
spcnt += lemonStrlen(g_argv[i])+1;
|
||||
@ -2739,7 +2743,7 @@ static void parseonetoken(struct pstate *psp)
|
||||
** in order to control their assigned integer number. The number for
|
||||
** each token is assigned when it is first seen. So by including
|
||||
**
|
||||
** %token ONE TWO THREE
|
||||
** %token ONE TWO THREE.
|
||||
**
|
||||
** early in the grammar file, that assigns small consecutive values
|
||||
** to each of the tokens ONE TWO and THREE.
|
||||
@ -3544,7 +3548,7 @@ void ReportOutput(struct lemon *lemp)
|
||||
}
|
||||
|
||||
/* Search for the file "name" which is in the same directory as
|
||||
** the exacutable */
|
||||
** the executable */
|
||||
PRIVATE char *pathsearch(char *argv0, char *name, int modemask)
|
||||
{
|
||||
const char *pathlist;
|
||||
@ -3602,7 +3606,9 @@ PRIVATE int compute_action(struct lemon *lemp, struct action *ap)
|
||||
/* Since a SHIFT is inherient after a prior REDUCE, convert any
|
||||
** SHIFTREDUCE action with a nonterminal on the LHS into a simple
|
||||
** REDUCE action: */
|
||||
if( ap->sp->index>=lemp->nterminal ){
|
||||
if( ap->sp->index>=lemp->nterminal
|
||||
&& (lemp->errsym==0 || ap->sp->index!=lemp->errsym->index)
|
||||
){
|
||||
act = lemp->minReduce + ap->x.rp->iRule;
|
||||
}else{
|
||||
act = lemp->minShiftReduce + ap->x.rp->iRule;
|
||||
@ -3899,7 +3905,7 @@ PRIVATE int translate_code(struct lemon *lemp, struct rule *rp){
|
||||
lhsdirect = 1;
|
||||
}else if( rp->rhsalias[0]==0 ){
|
||||
/* The left-most RHS symbol has no value. LHS direct is ok. But
|
||||
** we have to call the distructor on the RHS symbol first. */
|
||||
** we have to call the destructor on the RHS symbol first. */
|
||||
lhsdirect = 1;
|
||||
if( has_destructor(rp->rhs[0],lemp) ){
|
||||
append_str(0,0,0,0);
|
||||
@ -4121,7 +4127,7 @@ void print_stack_union(
|
||||
int *plineno, /* Pointer to the line number */
|
||||
int mhflag /* True if generating makeheaders output */
|
||||
){
|
||||
int lineno = *plineno; /* The line number of the output */
|
||||
int lineno; /* The line number of the output */
|
||||
char **types; /* A hash table of datatypes */
|
||||
int arraysize; /* Size of the "types" array */
|
||||
int maxdtlength; /* Maximum length of any ".datatype" field. */
|
||||
@ -4883,7 +4889,7 @@ void ReportTable(
|
||||
** yyRuleInfoNRhs[].
|
||||
**
|
||||
** Note: This code depends on the fact that rules are number
|
||||
** sequentually beginning with 0.
|
||||
** sequentially beginning with 0.
|
||||
*/
|
||||
for(i=0, rp=lemp->rule; rp; rp=rp->next, i++){
|
||||
fprintf(out," %4d, /* (%d) ", rp->lhs->index, i);
|
||||
@ -5371,7 +5377,8 @@ int Strsafe_insert(const char *data)
|
||||
newnp->from = &(array.ht[h]);
|
||||
array.ht[h] = newnp;
|
||||
}
|
||||
free(x1a->tbl);
|
||||
/* free(x1a->tbl); // This program was originally for 16-bit machines.
|
||||
** Don't worry about freeing memory on modern platforms. */
|
||||
*x1a = array;
|
||||
}
|
||||
/* Insert the new data */
|
||||
@ -5539,7 +5546,9 @@ int Symbol_insert(struct symbol *data, const char *key)
|
||||
newnp->from = &(array.ht[h]);
|
||||
array.ht[h] = newnp;
|
||||
}
|
||||
free(x2a->tbl);
|
||||
/* free(x2a->tbl); // This program was originally written for 16-bit
|
||||
** machines. Don't worry about freeing this trivial amount of memory
|
||||
** on modern platforms. Just leak it. */
|
||||
*x2a = array;
|
||||
}
|
||||
/* Insert the new data */
|
||||
@ -5875,7 +5884,9 @@ int Configtable_insert(struct config *data)
|
||||
newnp->from = &(array.ht[h]);
|
||||
array.ht[h] = newnp;
|
||||
}
|
||||
free(x4a->tbl);
|
||||
/* free(x4a->tbl); // This code was originall written for 16-bit machines.
|
||||
** on modern machines, don't worry about freeing this trival amount of
|
||||
** memory. */
|
||||
*x4a = array;
|
||||
}
|
||||
/* Insert the new data */
|
||||
|
||||
Reference in New Issue
Block a user