mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: update lemon version (#1768)
- upstream fixes: minor compiler warnings, style changes
This commit is contained in:
@ -22,17 +22,13 @@
|
|||||||
** The following is the concatenation of all %include directives from the
|
** The following is the concatenation of all %include directives from the
|
||||||
** input grammar file:
|
** input grammar file:
|
||||||
*/
|
*/
|
||||||
#include <stdio.h>
|
|
||||||
#include <assert.h>
|
|
||||||
/************ Begin %include sections from the grammar ************************/
|
/************ Begin %include sections from the grammar ************************/
|
||||||
%%
|
%%
|
||||||
/**************** End of %include directives **********************************/
|
/**************** End of %include directives **********************************/
|
||||||
/* These constants specify the various numeric values for terminal symbols
|
/* These constants specify the various numeric values for terminal symbols.
|
||||||
** in a format understandable to "makeheaders". This section is blank unless
|
***************** Begin token definitions *************************************/
|
||||||
** "lemon" is run with the "-m" command-line option.
|
|
||||||
***************** Begin makeheaders token definitions *************************/
|
|
||||||
%%
|
%%
|
||||||
/**************** End makeheaders token definitions ***************************/
|
/**************** End token definitions ***************************************/
|
||||||
|
|
||||||
/* The next sections is a series of control #defines.
|
/* The next sections is a series of control #defines.
|
||||||
** various aspects of the generated parser.
|
** various aspects of the generated parser.
|
||||||
@ -93,8 +89,7 @@
|
|||||||
/************* End control #defines *******************************************/
|
/************* End control #defines *******************************************/
|
||||||
#define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])))
|
#define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])))
|
||||||
|
|
||||||
/* Default linkage for exposed parser routines is global
|
/* Default linkage for exposed parser routines is global */
|
||||||
*/
|
|
||||||
#ifndef YYFUNCAPI
|
#ifndef YYFUNCAPI
|
||||||
# define YYFUNCAPI
|
# define YYFUNCAPI
|
||||||
#endif
|
#endif
|
||||||
@ -235,6 +230,7 @@ typedef struct yyParser yyParser;
|
|||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <assert.h>
|
||||||
static FILE *yyTraceFILE = 0;
|
static FILE *yyTraceFILE = 0;
|
||||||
static char *yyTracePrompt = 0;
|
static char *yyTracePrompt = 0;
|
||||||
#endif /* NDEBUG */
|
#endif /* NDEBUG */
|
||||||
@ -575,7 +571,7 @@ static YYACTIONTYPE yy_find_shift_action(
|
|||||||
#endif /* YYWILDCARD */
|
#endif /* YYWILDCARD */
|
||||||
return yy_default[stateno];
|
return yy_default[stateno];
|
||||||
}else{
|
}else{
|
||||||
assert( i>=0 && i<sizeof(yy_action)/sizeof(yy_action[0]) );
|
assert( i>=0 && i<(int)(sizeof(yy_action)/sizeof(yy_action[0])) );
|
||||||
return yy_action[i];
|
return yy_action[i];
|
||||||
}
|
}
|
||||||
}while(1);
|
}while(1);
|
||||||
@ -734,8 +730,9 @@ static YYACTIONTYPE yy_reduce(
|
|||||||
(void)yyLookahead;
|
(void)yyLookahead;
|
||||||
(void)yyLookaheadToken;
|
(void)yyLookaheadToken;
|
||||||
yymsp = yypParser->yytos;
|
yymsp = yypParser->yytos;
|
||||||
|
assert( yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) );
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
if( yyTraceFILE && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){
|
if( yyTraceFILE ){
|
||||||
yysize = yyRuleInfoNRhs[yyruleno];
|
yysize = yyRuleInfoNRhs[yyruleno];
|
||||||
if( yysize ){
|
if( yysize ){
|
||||||
fprintf(yyTraceFILE, "%sReduce %d [%s]%s, pop back to state %d.\n",
|
fprintf(yyTraceFILE, "%sReduce %d [%s]%s, pop back to state %d.\n",
|
||||||
|
|||||||
@ -1,11 +1,10 @@
|
|||||||
--- lempar.c.orig 2020-07-09 14:55:42.000000000 +0200
|
--- lempar.c.orig 2020-11-05 19:44:09.412097759 +0100
|
||||||
+++ lempar.c 2020-07-10 11:04:51.991472607 +0200
|
+++ lempar.c 2020-11-06 09:03:57.932738075 +0100
|
||||||
@@ -93,6 +93,12 @@
|
@@ -89,6 +89,11 @@
|
||||||
/************* End control #defines *******************************************/
|
/************* End control #defines *******************************************/
|
||||||
#define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])))
|
#define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])))
|
||||||
|
|
||||||
+/* Default linkage for exposed parser routines is global
|
+/* Default linkage for exposed parser routines is global */
|
||||||
+*/
|
|
||||||
+#ifndef YYFUNCAPI
|
+#ifndef YYFUNCAPI
|
||||||
+# define YYFUNCAPI
|
+# define YYFUNCAPI
|
||||||
+#endif
|
+#endif
|
||||||
@ -13,7 +12,7 @@
|
|||||||
/* Define the yytestcase() macro to be a no-op if is not already defined
|
/* Define the yytestcase() macro to be a no-op if is not already defined
|
||||||
** otherwise.
|
** otherwise.
|
||||||
**
|
**
|
||||||
@@ -251,6 +257,7 @@
|
@@ -248,6 +253,7 @@
|
||||||
** Outputs:
|
** Outputs:
|
||||||
** None.
|
** None.
|
||||||
*/
|
*/
|
||||||
@ -21,7 +20,7 @@
|
|||||||
void ParseTrace(FILE *TraceFILE, char *zTracePrompt){
|
void ParseTrace(FILE *TraceFILE, char *zTracePrompt){
|
||||||
yyTraceFILE = TraceFILE;
|
yyTraceFILE = TraceFILE;
|
||||||
yyTracePrompt = zTracePrompt;
|
yyTracePrompt = zTracePrompt;
|
||||||
@@ -320,6 +327,7 @@
|
@@ -317,6 +323,7 @@
|
||||||
|
|
||||||
/* Initialize a new parser that has already been allocated.
|
/* Initialize a new parser that has already been allocated.
|
||||||
*/
|
*/
|
||||||
@ -29,7 +28,7 @@
|
|||||||
void ParseInit(void *yypRawParser ParseCTX_PDECL){
|
void ParseInit(void *yypRawParser ParseCTX_PDECL){
|
||||||
yyParser *yypParser = (yyParser*)yypRawParser;
|
yyParser *yypParser = (yyParser*)yypRawParser;
|
||||||
ParseCTX_STORE
|
ParseCTX_STORE
|
||||||
@@ -359,6 +367,7 @@
|
@@ -356,6 +363,7 @@
|
||||||
** A pointer to a parser. This pointer is used in subsequent calls
|
** A pointer to a parser. This pointer is used in subsequent calls
|
||||||
** to Parse and ParseFree.
|
** to Parse and ParseFree.
|
||||||
*/
|
*/
|
||||||
@ -37,7 +36,7 @@
|
|||||||
void *ParseAlloc(void *(*mallocProc)(YYMALLOCARGTYPE) ParseCTX_PDECL){
|
void *ParseAlloc(void *(*mallocProc)(YYMALLOCARGTYPE) ParseCTX_PDECL){
|
||||||
yyParser *yypParser;
|
yyParser *yypParser;
|
||||||
yypParser = (yyParser*)(*mallocProc)( (YYMALLOCARGTYPE)sizeof(yyParser) );
|
yypParser = (yyParser*)(*mallocProc)( (YYMALLOCARGTYPE)sizeof(yyParser) );
|
||||||
@@ -427,6 +436,7 @@
|
@@ -424,6 +432,7 @@
|
||||||
/*
|
/*
|
||||||
** Clear all secondary memory allocations from the parser
|
** Clear all secondary memory allocations from the parser
|
||||||
*/
|
*/
|
||||||
@ -45,7 +44,7 @@
|
|||||||
void ParseFinalize(void *p){
|
void ParseFinalize(void *p){
|
||||||
yyParser *pParser = (yyParser*)p;
|
yyParser *pParser = (yyParser*)p;
|
||||||
while( pParser->yytos>pParser->yystack ) yy_pop_parser_stack(pParser);
|
while( pParser->yytos>pParser->yystack ) yy_pop_parser_stack(pParser);
|
||||||
@@ -444,6 +454,7 @@
|
@@ -441,6 +450,7 @@
|
||||||
** is defined in a %include section of the input grammar) then it is
|
** is defined in a %include section of the input grammar) then it is
|
||||||
** assumed that the input pointer is never NULL.
|
** assumed that the input pointer is never NULL.
|
||||||
*/
|
*/
|
||||||
@ -53,7 +52,7 @@
|
|||||||
void ParseFree(
|
void ParseFree(
|
||||||
void *p, /* The parser to be deleted */
|
void *p, /* The parser to be deleted */
|
||||||
void (*freeProc)(void*) /* Function used to reclaim memory */
|
void (*freeProc)(void*) /* Function used to reclaim memory */
|
||||||
@@ -460,6 +471,7 @@
|
@@ -457,6 +467,7 @@
|
||||||
** Return the peak depth of the stack for a parser.
|
** Return the peak depth of the stack for a parser.
|
||||||
*/
|
*/
|
||||||
#ifdef YYTRACKMAXSTACKDEPTH
|
#ifdef YYTRACKMAXSTACKDEPTH
|
||||||
@ -61,7 +60,7 @@
|
|||||||
int ParseStackPeak(void *p){
|
int ParseStackPeak(void *p){
|
||||||
yyParser *pParser = (yyParser*)p;
|
yyParser *pParser = (yyParser*)p;
|
||||||
return pParser->yyhwm;
|
return pParser->yyhwm;
|
||||||
@@ -484,6 +496,7 @@
|
@@ -481,6 +492,7 @@
|
||||||
** Return the number of missed state/lookahead combinations.
|
** Return the number of missed state/lookahead combinations.
|
||||||
*/
|
*/
|
||||||
#if defined(YYCOVERAGE)
|
#if defined(YYCOVERAGE)
|
||||||
@ -69,7 +68,7 @@
|
|||||||
int ParseCoverage(FILE *out){
|
int ParseCoverage(FILE *out){
|
||||||
int stateno, iLookAhead, i;
|
int stateno, iLookAhead, i;
|
||||||
int nMissed = 0;
|
int nMissed = 0;
|
||||||
@@ -891,6 +904,7 @@
|
@@ -889,6 +901,7 @@
|
||||||
** Outputs:
|
** Outputs:
|
||||||
** None.
|
** None.
|
||||||
*/
|
*/
|
||||||
@ -77,7 +76,7 @@
|
|||||||
void Parse(
|
void Parse(
|
||||||
void *yyp, /* The parser */
|
void *yyp, /* The parser */
|
||||||
int yymajor, /* The major token code number */
|
int yymajor, /* The major token code number */
|
||||||
@@ -1065,6 +1079,7 @@
|
@@ -1063,6 +1076,7 @@
|
||||||
** Return the fallback token corresponding to canonical token iToken, or
|
** Return the fallback token corresponding to canonical token iToken, or
|
||||||
** 0 if iToken has no fallback.
|
** 0 if iToken has no fallback.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
/* https://sqlite.org/src/artifact/600a58b9
|
/*
|
||||||
* Artifact 600a58b9d1b8ec5419373982428e927ca208826edacb91ca42ab94514d006039:
|
* https://www.sqlite.org/src/artifact/70eedc31
|
||||||
* File tool/lemon.c part of check-in [951d22b7] at 2020-07-03
|
* Artifact 70eedc31614a58fe31a71025c17ebd1502a6ce9cfef0ed5e33acb0b5b737b291:
|
||||||
|
* File tool/lemon.c part of check-in [4591ee03] at 2020-09-21
|
||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
** This file contains all sources (including headers) to the LEMON
|
** This file contains all sources (including headers) to the LEMON
|
||||||
@ -430,7 +431,7 @@ struct lemon {
|
|||||||
int printPreprocessed; /* Show preprocessor output on stdout */
|
int printPreprocessed; /* Show preprocessor output on stdout */
|
||||||
int has_fallback; /* True if any %fallback is seen in the grammar */
|
int has_fallback; /* True if any %fallback is seen in the grammar */
|
||||||
int nolinenosflag; /* True if #line statements should not be printed */
|
int nolinenosflag; /* True if #line statements should not be printed */
|
||||||
int linkage; /* 1 if %static provided (use static linkage) */
|
int linkage; /* True if %static provided (use static linkage) */
|
||||||
char *argv0; /* Name of the program */
|
char *argv0; /* Name of the program */
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1614,14 +1615,14 @@ static struct rule *Rule_merge(struct rule *pA, struct rule *pB){
|
|||||||
** Sort a list of rules in order of increasing iRule value
|
** Sort a list of rules in order of increasing iRule value
|
||||||
*/
|
*/
|
||||||
static struct rule *Rule_sort(struct rule *rp){
|
static struct rule *Rule_sort(struct rule *rp){
|
||||||
int i;
|
unsigned int i;
|
||||||
struct rule *pNext;
|
struct rule *pNext;
|
||||||
struct rule *x[32];
|
struct rule *x[32];
|
||||||
memset(x, 0, sizeof(x));
|
memset(x, 0, sizeof(x));
|
||||||
while( rp ){
|
while( rp ){
|
||||||
pNext = rp->next;
|
pNext = rp->next;
|
||||||
rp->next = 0;
|
rp->next = 0;
|
||||||
for(i=0; i<sizeof(x)/sizeof(x[0]) && x[i]; i++){
|
for(i=0; i<sizeof(x)/sizeof(x[0])-1 && x[i]; i++){
|
||||||
rp = Rule_merge(x[i], rp);
|
rp = Rule_merge(x[i], rp);
|
||||||
x[i] = 0;
|
x[i] = 0;
|
||||||
}
|
}
|
||||||
@ -1648,8 +1649,7 @@ static void stats_line(const char *zLabel, int iValue){
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* The main program. Parse the command line and do it... */
|
/* The main program. Parse the command line and do it... */
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv){
|
||||||
{
|
|
||||||
static int version = 0;
|
static int version = 0;
|
||||||
static int rpflag = 0;
|
static int rpflag = 0;
|
||||||
static int basisflag = 0;
|
static int basisflag = 0;
|
||||||
@ -1693,6 +1693,7 @@ int main(int argc, char **argv)
|
|||||||
struct lemon lem;
|
struct lemon lem;
|
||||||
struct rule *rp;
|
struct rule *rp;
|
||||||
|
|
||||||
|
(void)argc;
|
||||||
OptInit(argv,options,stderr);
|
OptInit(argv,options,stderr);
|
||||||
if( version ){
|
if( version ){
|
||||||
printf("Lemon version 1.0\n");
|
printf("Lemon version 1.0\n");
|
||||||
@ -2291,7 +2292,7 @@ static void parseonetoken(struct pstate *psp)
|
|||||||
psp->firstrule = psp->lastrule = 0;
|
psp->firstrule = psp->lastrule = 0;
|
||||||
psp->gp->nrule = 0;
|
psp->gp->nrule = 0;
|
||||||
psp->gp->linkage = 0;
|
psp->gp->linkage = 0;
|
||||||
/* Fall thru to next case */
|
/* fall through */
|
||||||
case WAITING_FOR_DECL_OR_RULE:
|
case WAITING_FOR_DECL_OR_RULE:
|
||||||
if( x[0]=='%' ){
|
if( x[0]=='%' ){
|
||||||
psp->state = WAITING_FOR_DECL_KEYWORD;
|
psp->state = WAITING_FOR_DECL_KEYWORD;
|
||||||
@ -2451,7 +2452,7 @@ static void parseonetoken(struct pstate *psp)
|
|||||||
psp->alias[psp->nrhs] = 0;
|
psp->alias[psp->nrhs] = 0;
|
||||||
psp->nrhs++;
|
psp->nrhs++;
|
||||||
}
|
}
|
||||||
}else if( (x[0]=='|' || x[0]=='/') && psp->nrhs>0 ){
|
}else if( (x[0]=='|' || x[0]=='/') && psp->nrhs>0 && ISUPPER(x[1]) ){
|
||||||
struct symbol *msp = psp->rhs[psp->nrhs-1];
|
struct symbol *msp = psp->rhs[psp->nrhs-1];
|
||||||
if( msp->type!=MULTITERMINAL ){
|
if( msp->type!=MULTITERMINAL ){
|
||||||
struct symbol *origsp = msp;
|
struct symbol *origsp = msp;
|
||||||
@ -2668,8 +2669,10 @@ static void parseonetoken(struct pstate *psp)
|
|||||||
}
|
}
|
||||||
nOld = lemonStrlen(zOld);
|
nOld = lemonStrlen(zOld);
|
||||||
n = nOld + nNew + 20;
|
n = nOld + nNew + 20;
|
||||||
addLineMacro = !psp->gp->nolinenosflag && psp->insertLineMacro &&
|
addLineMacro = !psp->gp->nolinenosflag
|
||||||
(psp->decllinenoslot==0 || psp->decllinenoslot[0]!=0);
|
&& psp->insertLineMacro
|
||||||
|
&& psp->tokenlineno>1
|
||||||
|
&& (psp->decllinenoslot==0 || psp->decllinenoslot[0]!=0);
|
||||||
if( addLineMacro ){
|
if( addLineMacro ){
|
||||||
for(z=psp->filename, nBack=0; *z; z++){
|
for(z=psp->filename, nBack=0; *z; z++){
|
||||||
if( *z=='\\' ) nBack++;
|
if( *z=='\\' ) nBack++;
|
||||||
@ -3545,8 +3548,8 @@ void ReportOutput(struct lemon *lemp)
|
|||||||
PRIVATE char *pathsearch(char *argv0, char *name, int modemask)
|
PRIVATE char *pathsearch(char *argv0, char *name, int modemask)
|
||||||
{
|
{
|
||||||
const char *pathlist;
|
const char *pathlist;
|
||||||
char *pathbufptr;
|
char *pathbufptr = 0;
|
||||||
char *pathbuf;
|
char *pathbuf = 0;
|
||||||
char *path,*cp;
|
char *path,*cp;
|
||||||
char c;
|
char c;
|
||||||
|
|
||||||
@ -3580,8 +3583,8 @@ PRIVATE char *pathsearch(char *argv0, char *name, int modemask)
|
|||||||
else pathbuf = &cp[1];
|
else pathbuf = &cp[1];
|
||||||
if( access(path,modemask)==0 ) break;
|
if( access(path,modemask)==0 ) break;
|
||||||
}
|
}
|
||||||
free(pathbufptr);
|
|
||||||
}
|
}
|
||||||
|
free(pathbufptr);
|
||||||
}
|
}
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
@ -3647,6 +3650,16 @@ PRIVATE void tplt_xfer(char *name, FILE *in, FILE *out, int *lineno)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Skip forward past the header of the template file to the first "%%"
|
||||||
|
*/
|
||||||
|
PRIVATE void tplt_skip_header(FILE *in, int *lineno)
|
||||||
|
{
|
||||||
|
char line[LINESIZE];
|
||||||
|
while( fgets(line,LINESIZE,in) && (line[0]!='%' || line[1]!='%') ){
|
||||||
|
(*lineno)++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* The next function finds the template file and opens it, returning
|
/* The next function finds the template file and opens it, returning
|
||||||
** a pointer to the opened file. */
|
** a pointer to the opened file. */
|
||||||
PRIVATE FILE *tplt_open(struct lemon *lemp)
|
PRIVATE FILE *tplt_open(struct lemon *lemp)
|
||||||
@ -3655,6 +3668,7 @@ PRIVATE FILE *tplt_open(struct lemon *lemp)
|
|||||||
char buf[1000];
|
char buf[1000];
|
||||||
FILE *in;
|
FILE *in;
|
||||||
char *tpltname;
|
char *tpltname;
|
||||||
|
char *toFree = 0;
|
||||||
char *cp;
|
char *cp;
|
||||||
|
|
||||||
/* first, see if user specified a template filename on the command line. */
|
/* first, see if user specified a template filename on the command line. */
|
||||||
@ -3686,7 +3700,7 @@ PRIVATE FILE *tplt_open(struct lemon *lemp)
|
|||||||
}else if( access(templatename,004)==0 ){
|
}else if( access(templatename,004)==0 ){
|
||||||
tpltname = templatename;
|
tpltname = templatename;
|
||||||
}else{
|
}else{
|
||||||
tpltname = pathsearch(lemp->argv0,templatename,0);
|
toFree = tpltname = pathsearch(lemp->argv0,templatename,0);
|
||||||
}
|
}
|
||||||
if( tpltname==0 ){
|
if( tpltname==0 ){
|
||||||
fprintf(stderr,"Can't find the parser driver template file \"%s\".\n",
|
fprintf(stderr,"Can't find the parser driver template file \"%s\".\n",
|
||||||
@ -3696,10 +3710,10 @@ PRIVATE FILE *tplt_open(struct lemon *lemp)
|
|||||||
}
|
}
|
||||||
in = fopen(tpltname,"rb");
|
in = fopen(tpltname,"rb");
|
||||||
if( in==0 ){
|
if( in==0 ){
|
||||||
fprintf(stderr,"Can't open the template file \"%s\".\n",templatename);
|
fprintf(stderr,"Can't open the template file \"%s\".\n",tpltname);
|
||||||
lemp->errorcnt++;
|
lemp->errorcnt++;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
free(toFree);
|
||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4317,6 +4331,7 @@ void ReportTable(
|
|||||||
int mnTknOfst, mxTknOfst;
|
int mnTknOfst, mxTknOfst;
|
||||||
int mnNtOfst, mxNtOfst;
|
int mnNtOfst, mxNtOfst;
|
||||||
struct axset *ax;
|
struct axset *ax;
|
||||||
|
char *prefix;
|
||||||
|
|
||||||
lemp->minShiftReduce = lemp->nstate;
|
lemp->minShiftReduce = lemp->nstate;
|
||||||
lemp->errAction = lemp->minShiftReduce + lemp->nrule;
|
lemp->errAction = lemp->minShiftReduce + lemp->nrule;
|
||||||
@ -4405,7 +4420,26 @@ void ReportTable(
|
|||||||
fprintf(sql, "COMMIT;\n");
|
fprintf(sql, "COMMIT;\n");
|
||||||
}
|
}
|
||||||
lineno = 1;
|
lineno = 1;
|
||||||
tplt_xfer(lemp->name,in,out,&lineno);
|
|
||||||
|
fprintf(out,
|
||||||
|
"/* This file is automatically generated by Lemon from input grammar\n"
|
||||||
|
"** source file \"%s\". */\n", lemp->filename); lineno += 2;
|
||||||
|
|
||||||
|
/* The first %include directive begins with a C-language comment,
|
||||||
|
** then skip over the header comment of the template file
|
||||||
|
*/
|
||||||
|
if( lemp->include==0 ) lemp->include = "";
|
||||||
|
for(i=0; ISSPACE(lemp->include[i]); i++){
|
||||||
|
if( lemp->include[i]=='\n' ){
|
||||||
|
lemp->include += i+1;
|
||||||
|
i = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if( lemp->include[0]=='/' ){
|
||||||
|
tplt_skip_header(in,&lineno);
|
||||||
|
}else{
|
||||||
|
tplt_xfer(lemp->name,in,out,&lineno);
|
||||||
|
}
|
||||||
|
|
||||||
/* Generate the include code, if any */
|
/* Generate the include code, if any */
|
||||||
tplt_print(out,lemp,lemp->include,&lineno);
|
tplt_print(out,lemp,lemp->include,&lineno);
|
||||||
@ -4417,17 +4451,18 @@ void ReportTable(
|
|||||||
tplt_xfer(lemp->name,in,out,&lineno);
|
tplt_xfer(lemp->name,in,out,&lineno);
|
||||||
|
|
||||||
/* Generate #defines for all tokens */
|
/* Generate #defines for all tokens */
|
||||||
|
if( lemp->tokenprefix ) prefix = lemp->tokenprefix;
|
||||||
|
else prefix = "";
|
||||||
if( mhflag ){
|
if( mhflag ){
|
||||||
const char *prefix;
|
|
||||||
fprintf(out,"#if INTERFACE\n"); lineno++;
|
fprintf(out,"#if INTERFACE\n"); lineno++;
|
||||||
if( lemp->tokenprefix ) prefix = lemp->tokenprefix;
|
}else{
|
||||||
else prefix = "";
|
fprintf(out,"#ifndef %s%s\n", prefix, lemp->symbols[1]->name);
|
||||||
for(i=1; i<lemp->nterminal; i++){
|
|
||||||
fprintf(out,"#define %s%-30s %2d\n",prefix,lemp->symbols[i]->name,i);
|
|
||||||
lineno++;
|
|
||||||
}
|
|
||||||
fprintf(out,"#endif\n"); lineno++;
|
|
||||||
}
|
}
|
||||||
|
for(i=1; i<lemp->nterminal; i++){
|
||||||
|
fprintf(out,"#define %s%-30s %2d\n",prefix,lemp->symbols[i]->name,i);
|
||||||
|
lineno++;
|
||||||
|
}
|
||||||
|
fprintf(out,"#endif\n"); lineno++;
|
||||||
tplt_xfer(lemp->name,in,out,&lineno);
|
tplt_xfer(lemp->name,in,out,&lineno);
|
||||||
|
|
||||||
/* Generate the defines */
|
/* Generate the defines */
|
||||||
|
|||||||
@ -1,14 +1,14 @@
|
|||||||
--- lemon.c.orig 2020-07-09 14:54:53.871102972 +0200
|
--- lemon.c.orig 2020-11-05 19:43:43.780141575 +0100
|
||||||
+++ lemon.c 2020-07-10 12:01:05.488791973 +0200
|
+++ lemon.c 2020-11-05 19:59:41.022505205 +0100
|
||||||
@@ -426,6 +426,7 @@
|
@@ -426,6 +426,7 @@
|
||||||
int printPreprocessed; /* Show preprocessor output on stdout */
|
int printPreprocessed; /* Show preprocessor output on stdout */
|
||||||
int has_fallback; /* True if any %fallback is seen in the grammar */
|
int has_fallback; /* True if any %fallback is seen in the grammar */
|
||||||
int nolinenosflag; /* True if #line statements should not be printed */
|
int nolinenosflag; /* True if #line statements should not be printed */
|
||||||
+ int linkage; /* 1 if %static provided (use static linkage) */
|
+ int linkage; /* True if %static provided (use static linkage) */
|
||||||
char *argv0; /* Name of the program */
|
char *argv0; /* Name of the program */
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1555,6 +1556,24 @@
|
@@ -1555,6 +1560,24 @@
|
||||||
lemon_strcpy(outputDir, z);
|
lemon_strcpy(outputDir, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,7 +33,7 @@
|
|||||||
static char *user_templatename = NULL;
|
static char *user_templatename = NULL;
|
||||||
static void handle_T_option(char *z){
|
static void handle_T_option(char *z){
|
||||||
user_templatename = (char *) malloc( lemonStrlen(z)+1 );
|
user_templatename = (char *) malloc( lemonStrlen(z)+1 );
|
||||||
@@ -1644,6 +1663,7 @@
|
@@ -1643,6 +1666,7 @@
|
||||||
{OPT_FLAG, "c", (char*)&compress, "Don't compress the action table."},
|
{OPT_FLAG, "c", (char*)&compress, "Don't compress the action table."},
|
||||||
{OPT_FSTR, "d", (char*)&handle_d_option, "Output directory. Default '.'"},
|
{OPT_FSTR, "d", (char*)&handle_d_option, "Output directory. Default '.'"},
|
||||||
{OPT_FSTR, "D", (char*)handle_D_option, "Define an %ifdef macro."},
|
{OPT_FSTR, "D", (char*)handle_D_option, "Define an %ifdef macro."},
|
||||||
@ -41,15 +41,15 @@
|
|||||||
{OPT_FLAG, "E", (char*)&printPP, "Print input file after preprocessing."},
|
{OPT_FLAG, "E", (char*)&printPP, "Print input file after preprocessing."},
|
||||||
{OPT_FSTR, "f", 0, "Ignored. (Placeholder for -f compiler options.)"},
|
{OPT_FSTR, "f", 0, "Ignored. (Placeholder for -f compiler options.)"},
|
||||||
{OPT_FLAG, "g", (char*)&rpflag, "Print grammar without actions."},
|
{OPT_FLAG, "g", (char*)&rpflag, "Print grammar without actions."},
|
||||||
@@ -2266,6 +2286,7 @@
|
@@ -2266,6 +2290,7 @@
|
||||||
psp->preccounter = 0;
|
psp->preccounter = 0;
|
||||||
psp->firstrule = psp->lastrule = 0;
|
psp->firstrule = psp->lastrule = 0;
|
||||||
psp->gp->nrule = 0;
|
psp->gp->nrule = 0;
|
||||||
+ psp->gp->linkage = 0;
|
+ psp->gp->linkage = 0;
|
||||||
/* Fall thru to next case */
|
/* fall through */
|
||||||
case WAITING_FOR_DECL_OR_RULE:
|
case WAITING_FOR_DECL_OR_RULE:
|
||||||
if( x[0]=='%' ){
|
if( x[0]=='%' ){
|
||||||
@@ -2551,6 +2572,11 @@
|
@@ -2551,6 +2576,11 @@
|
||||||
psp->state = WAITING_FOR_WILDCARD_ID;
|
psp->state = WAITING_FOR_WILDCARD_ID;
|
||||||
}else if( strcmp(x,"token_class")==0 ){
|
}else if( strcmp(x,"token_class")==0 ){
|
||||||
psp->state = WAITING_FOR_CLASS_ID;
|
psp->state = WAITING_FOR_CLASS_ID;
|
||||||
@ -61,7 +61,7 @@
|
|||||||
}else{
|
}else{
|
||||||
ErrorMsg(psp->filename,psp->tokenlineno,
|
ErrorMsg(psp->filename,psp->tokenlineno,
|
||||||
"Unknown declaration keyword: \"%%%s\".",x);
|
"Unknown declaration keyword: \"%%%s\".",x);
|
||||||
@@ -4297,7 +4323,7 @@
|
@@ -4311,7 +4341,7 @@
|
||||||
|
|
||||||
in = tplt_open(lemp);
|
in = tplt_open(lemp);
|
||||||
if( in==0 ) return;
|
if( in==0 ) return;
|
||||||
@ -70,7 +70,7 @@
|
|||||||
if( out==0 ){
|
if( out==0 ){
|
||||||
fclose(in);
|
fclose(in);
|
||||||
return;
|
return;
|
||||||
@@ -4401,6 +4427,9 @@
|
@@ -4435,6 +4465,9 @@
|
||||||
tplt_xfer(lemp->name,in,out,&lineno);
|
tplt_xfer(lemp->name,in,out,&lineno);
|
||||||
|
|
||||||
/* Generate the defines */
|
/* Generate the defines */
|
||||||
|
|||||||
Reference in New Issue
Block a user