mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-23 20:42:24 +00:00
Lemon update 2010-02-14 00:48:50 on branch lemon-update-2010
- Added -T option, to specify a template filename on the command line. The default is still "lempar.c", though. (user: icculus)
This commit is contained in:
parent
7e8b9219a8
commit
a656bb4f72
1 changed files with 26 additions and 0 deletions
|
@ -1446,6 +1446,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)
|
||||
|
@ -1464,6 +1472,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."},
|
||||
|
@ -3147,6 +3156,23 @@ struct lemon *lemp;
|
|||
char *cp;
|
||||
Boolean tpltnameinbuf;
|
||||
|
||||
/* 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);
|
||||
|
|
Loading…
Reference in a new issue