mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-30 19:03:16 +03:00
Added -T option, to specify a template filename on the command line.
The default is still "lempar.c", though. FossilOrigin-Name: e6cbe1e5ee80db282a41951b805b7bd8b13adf28
This commit is contained in:
26
tool/lemon.c
26
tool/lemon.c
@ -1429,6 +1429,14 @@ static void handle_D_option(char *z){
|
||||
*z = 0;
|
||||
}
|
||||
|
||||
static char *user_templatename = NULL;
|
||||
static void handle_T_option(char *z){
|
||||
user_templatename = malloc( lemonStrlen(z)+1 );
|
||||
if( user_templatename==0 ){
|
||||
memory_error();
|
||||
}
|
||||
strcpy(user_templatename, z);
|
||||
}
|
||||
|
||||
/* The main program. Parse the command line and do it... */
|
||||
int main(argc,argv)
|
||||
@ -1447,6 +1455,7 @@ char **argv;
|
||||
{OPT_FLAG, "b", (char*)&basisflag, "Print only the basis in report."},
|
||||
{OPT_FLAG, "c", (char*)&compress, "Don't compress the action table."},
|
||||
{OPT_FSTR, "D", (char*)handle_D_option, "Define an %ifdef macro."},
|
||||
{OPT_FSTR, "T", (char*)handle_T_option, "Specify a template file."},
|
||||
{OPT_FLAG, "g", (char*)&rpflag, "Print grammar without actions."},
|
||||
{OPT_FLAG, "m", (char*)&mhflag, "Output a makeheaders compatible file."},
|
||||
{OPT_FLAG, "l", (char*)&nolinenosflag, "Do not print #line statements."},
|
||||
@ -3112,6 +3121,23 @@ struct lemon *lemp;
|
||||
char *tpltname;
|
||||
char *cp;
|
||||
|
||||
/* first, see if user specified a template filename on the command line. */
|
||||
if (user_templatename != 0) {
|
||||
if( access(user_templatename,004)==-1 ){
|
||||
fprintf(stderr,"Can't find the parser driver template file \"%s\".\n",
|
||||
user_templatename);
|
||||
lemp->errorcnt++;
|
||||
return 0;
|
||||
}
|
||||
in = fopen(user_templatename,"rb");
|
||||
if( in==0 ){
|
||||
fprintf(stderr,"Can't open the template file \"%s\".\n",user_templatename);
|
||||
lemp->errorcnt++;
|
||||
return 0;
|
||||
}
|
||||
return in;
|
||||
}
|
||||
|
||||
cp = strrchr(lemp->filename,'.');
|
||||
if( cp ){
|
||||
sprintf(buf,"%.*s.lt",(int)(cp-lemp->filename),lemp->filename);
|
||||
|
Reference in New Issue
Block a user