%{
|
%{
|
/* arparse.y - Stange script language parser */
|
/* arparse.y - Stange script language parser */
|
|
|
/* Copyright 1992, 1993, 1995, 1997, 1999, 2002, 2003, 2007
|
/* Copyright 1992, 1993, 1995, 1997, 1999, 2002, 2003, 2007
|
Free Software Foundation, Inc.
|
Free Software Foundation, Inc.
|
|
|
This file is part of GNU Binutils.
|
This file is part of GNU Binutils.
|
|
|
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
the Free Software Foundation; either version 3 of the License, or
|
the Free Software Foundation; either version 3 of the License, or
|
(at your option) any later version.
|
(at your option) any later version.
|
|
|
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
GNU General Public License for more details.
|
GNU General Public License for more details.
|
|
|
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
|
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
|
MA 02110-1301, USA. */
|
MA 02110-1301, USA. */
|
|
|
|
|
/* Contributed by Steve Chamberlain
|
/* Contributed by Steve Chamberlain
|
sac@cygnus.com
|
sac@cygnus.com
|
|
|
*/
|
*/
|
#define DONTDECLARE_MALLOC
|
#define DONTDECLARE_MALLOC
|
#include "sysdep.h"
|
#include "sysdep.h"
|
#include "bfd.h"
|
#include "bfd.h"
|
#include "arsup.h"
|
#include "arsup.h"
|
extern int verbose;
|
extern int verbose;
|
extern int yylex (void);
|
extern int yylex (void);
|
static int yyerror (const char *);
|
static int yyerror (const char *);
|
%}
|
%}
|
|
|
%union {
|
%union {
|
char *name;
|
char *name;
|
struct list *list ;
|
struct list *list ;
|
|
|
};
|
};
|
|
|
%token NEWLINE
|
%token NEWLINE
|
%token VERBOSE
|
%token VERBOSE
|
%token FILENAME
|
%token FILENAME
|
%token ADDLIB
|
%token ADDLIB
|
%token LIST
|
%token LIST
|
%token ADDMOD
|
%token ADDMOD
|
%token CLEAR
|
%token CLEAR
|
%token CREATE
|
%token CREATE
|
%token DELETE
|
%token DELETE
|
%token DIRECTORY
|
%token DIRECTORY
|
%token END
|
%token END
|
%token EXTRACT
|
%token EXTRACT
|
%token FULLDIR
|
%token FULLDIR
|
%token HELP
|
%token HELP
|
%token QUIT
|
%token QUIT
|
%token REPLACE
|
%token REPLACE
|
%token SAVE
|
%token SAVE
|
%token OPEN
|
%token OPEN
|
|
|
%type modulelist
|
%type modulelist
|
%type modulename
|
%type modulename
|
%type optional_filename
|
%type optional_filename
|
%%
|
%%
|
|
|
start:
|
start:
|
{ prompt(); } session
|
{ prompt(); } session
|
;
|
;
|
|
|
session:
|
session:
|
session command_line
|
session command_line
|
|
|
|
|
;
|
;
|
|
|
command_line:
|
command_line:
|
command NEWLINE { prompt(); }
|
command NEWLINE { prompt(); }
|
;
|
;
|
|
|
command:
|
command:
|
open_command
|
open_command
|
| create_command
|
| create_command
|
| verbose_command
|
| verbose_command
|
| directory_command
|
| directory_command
|
| addlib_command
|
| addlib_command
|
| clear_command
|
| clear_command
|
| addmod_command
|
| addmod_command
|
| save_command
|
| save_command
|
| extract_command
|
| extract_command
|
| replace_command
|
| replace_command
|
| delete_command
|
| delete_command
|
| list_command
|
| list_command
|
| END { ar_end(); return 0; }
|
| END { ar_end(); return 0; }
|
| error
|
| error
|
| FILENAME { yyerror("foo"); }
|
| FILENAME { yyerror("foo"); }
|
|
|
|
|
;
|
;
|
|
|
|
|
extract_command:
|
extract_command:
|
EXTRACT modulename
|
EXTRACT modulename
|
{ ar_extract($2); }
|
{ ar_extract($2); }
|
;
|
;
|
|
|
replace_command:
|
replace_command:
|
REPLACE modulename
|
REPLACE modulename
|
{ ar_replace($2); }
|
{ ar_replace($2); }
|
;
|
;
|
|
|
clear_command:
|
clear_command:
|
CLEAR
|
CLEAR
|
{ ar_clear(); }
|
{ ar_clear(); }
|
;
|
;
|
|
|
delete_command:
|
delete_command:
|
DELETE modulename
|
DELETE modulename
|
{ ar_delete($2); }
|
{ ar_delete($2); }
|
;
|
;
|
addmod_command:
|
addmod_command:
|
ADDMOD modulename
|
ADDMOD modulename
|
{ ar_addmod($2); }
|
{ ar_addmod($2); }
|
;
|
;
|
|
|
list_command:
|
list_command:
|
LIST
|
LIST
|
{ ar_list(); }
|
{ ar_list(); }
|
;
|
;
|
|
|
save_command:
|
save_command:
|
SAVE
|
SAVE
|
{ ar_save(); }
|
{ ar_save(); }
|
;
|
;
|
|
|
|
|
|
|
open_command:
|
open_command:
|
OPEN FILENAME
|
OPEN FILENAME
|
{ ar_open($2,0); }
|
{ ar_open($2,0); }
|
;
|
;
|
|
|
create_command:
|
create_command:
|
CREATE FILENAME
|
CREATE FILENAME
|
{ ar_open($2,1); }
|
{ ar_open($2,1); }
|
;
|
;
|
|
|
|
|
addlib_command:
|
addlib_command:
|
ADDLIB FILENAME modulelist
|
ADDLIB FILENAME modulelist
|
{ ar_addlib($2,$3); }
|
{ ar_addlib($2,$3); }
|
;
|
;
|
directory_command:
|
directory_command:
|
DIRECTORY FILENAME modulelist optional_filename
|
DIRECTORY FILENAME modulelist optional_filename
|
{ ar_directory($2, $3, $4); }
|
{ ar_directory($2, $3, $4); }
|
;
|
;
|
|
|
|
|
|
|
optional_filename:
|
optional_filename:
|
FILENAME
|
FILENAME
|
{ $$ = $1; }
|
{ $$ = $1; }
|
| { $$ = 0; }
|
| { $$ = 0; }
|
;
|
;
|
|
|
modulelist:
|
modulelist:
|
'(' modulename ')'
|
'(' modulename ')'
|
{ $$ = $2; }
|
{ $$ = $2; }
|
|
|
|
|
{ $$ = 0; }
|
{ $$ = 0; }
|
;
|
;
|
|
|
modulename:
|
modulename:
|
modulename optcomma FILENAME
|
modulename optcomma FILENAME
|
{ struct list *n = (struct list *) malloc(sizeof(struct list));
|
{ struct list *n = (struct list *) malloc(sizeof(struct list));
|
n->next = $1;
|
n->next = $1;
|
n->name = $3;
|
n->name = $3;
|
$$ = n;
|
$$ = n;
|
}
|
}
|
| { $$ = 0; }
|
| { $$ = 0; }
|
;
|
;
|
|
|
|
|
optcomma:
|
optcomma:
|
','
|
','
|
|
|
|
|
;
|
;
|
|
|
|
|
verbose_command:
|
verbose_command:
|
VERBOSE
|
VERBOSE
|
{ verbose = !verbose; }
|
{ verbose = !verbose; }
|
;
|
;
|
|
|
|
|
%%
|
%%
|
|
|
static int
|
static int
|
yyerror (const char *x ATTRIBUTE_UNUSED)
|
yyerror (const char *x ATTRIBUTE_UNUSED)
|
{
|
{
|
extern int linenumber;
|
extern int linenumber;
|
|
|
printf (_("Syntax error in archive script, line %d\n"), linenumber + 1);
|
printf (_("Syntax error in archive script, line %d\n"), linenumber + 1);
|
return 0;
|
return 0;
|
}
|
}
|
|
|