version 1.25, 2004/06/21 09:05:16 |
version 1.35, 2012/12/17 07:20:45 |
|
|
* DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, |
* DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, |
* PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. |
* PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. |
* |
* |
* $OpenXM: OpenXM_contrib2/asir2000/parse/parse.y,v 1.24 2004/06/18 05:57:00 noro Exp $ |
* $OpenXM: OpenXM_contrib2/asir2000/parse/parse.y,v 1.34 2011/06/16 08:17:15 noro Exp $ |
*/ |
*/ |
%{ |
%{ |
#define malloc(x) GC_malloc(x) |
#define malloc(x) Risa_GC_malloc(x) |
#define realloc(x,y) GC_realloc(x,y) |
#define realloc(x,y) Risa_GC_realloc(x,y) |
#define free(x) GC_free(x) |
#define free(x) Risa_GC_free(x) |
|
|
#if defined(TOWNS) |
#if defined(TOWNS) |
#include <alloca.h> |
#include <alloca.h> |
Line 67 extern int gdef,mgdef,ldef; |
|
Line 67 extern int gdef,mgdef,ldef; |
|
extern SNODE parse_snode; |
extern SNODE parse_snode; |
extern int main_parser, allow_create_var; |
extern int main_parser, allow_create_var; |
|
|
int prresult; |
int prresult,saveresult; |
|
|
static int ind; |
static int ind; |
static FNODE t; |
static FNODE t; |
|
|
| CONTINUE tail |
| CONTINUE tail |
{ $$ = mksnode(0,S_CONTINUE); } |
{ $$ = mksnode(0,S_CONTINUE); } |
| RETURN tail |
| RETURN tail |
{ $$ = mksnode(1,S_RETURN,0); } |
{ $$ = mksnode(1,S_RETURN,NULLP); } |
| RETURN expr tail |
| RETURN expr tail |
{ $$ = mksnode(1,S_RETURN,$2); } |
{ $$ = mksnode(1,S_RETURN,$2); } |
| IF '(' node ')' stat |
| IF '(' node ')' stat |
{ $$ = mksnode(4,S_IFELSE,$1,$3,$5,0); $5?$$->ln=$5->ln:0; NOPR; } |
{ $$ = mksnode(4,S_IFELSE,$1,$3,$5,NULLP); $5?$$->ln=$5->ln:0; NOPR; } |
| IF '(' node ')' stat ELSE stat |
| IF '(' node ')' stat ELSE stat |
{ $$ = mksnode(4,S_IFELSE,$1,$3,$5,$7); $7?$$->ln=$7->ln:0; NOPR; } |
{ $$ = mksnode(4,S_IFELSE,$1,$3,$5,$7); $7?$$->ln=$7->ln:0; NOPR; } |
| FOR '(' node ';' node ';' node ')' stat |
| FOR '(' node ';' node ';' node ')' stat |
{ $$ = mksnode(5,S_FOR,$1,$3,$5?$5:ONENODE,$7,$9); $9?$$->ln=$9->ln:0; NOPR; } |
{ $$ = mksnode(5,S_FOR,$1,$3,$5?$5:ONENODE,$7,$9); $9?$$->ln=$9->ln:0; NOPR; } |
| WHILE '(' node ')' stat |
| WHILE '(' node ')' stat |
{ $$ = mksnode(5,S_FOR,$1,0,$3,0,$5); $5?$$->ln=$5->ln:0; NOPR; } |
{ $$ = mksnode(5,S_FOR,$1,NULLP,$3,NULLP,$5); $5?$$->ln=$5->ln:0; NOPR; } |
| DO stat WHILE '(' node ')' tail |
| DO stat WHILE '(' node ')' tail |
{ $$ = mksnode(3,S_DO,$1,$2,$5); } |
{ $$ = mksnode(3,S_DO,$1,$2,$5); NOPR; } |
| LCASE '(' node ')' ':' '=' expr tail |
| LCASE '(' node ')' ':' '=' expr tail |
{ $$ = mksnode(3,S_PFDEF,$1,$3,$7); NOPR; } |
{ $$ = mksnode(3,S_PFDEF,$1,$3,$7); NOPR; } |
| PFDEF LCASE '(' node ')' tail |
| PFDEF LCASE '(' node ')' tail |
{ $$ = mksnode(3,S_PFDEF,$2,$4,0); NOPR; } |
{ $$ = mksnode(3,S_PFDEF,$2,$4,NULLP); NOPR; } |
| FDEF LCASE { mkpvs($2); } '(' { ldef = 1; } node { ldef = -1; } ')' desc '{' stats '}' |
| FDEF LCASE { mkpvs($2); } '(' { ldef = 1; } node { ldef = -1; } ')' desc '{' stats '}' |
{ |
{ |
mkuf($2,asir_infile->name,$6, |
mkuf($2,asir_infile->name,$6, |
mksnode(1,S_CPLX,$11),$1,asir_infile->ln,$9,CUR_MODULE); |
mksnode(1,S_CPLX,$11),$1,asir_infile->ln,$9,CUR_MODULE); |
$$ = 0; NOPR; |
$$ = 0; NOPR; |
} |
} |
| MODDEF LCASE tail |
| MODDEF LCASE tail |
{ CUR_MODULE = mkmodule($2); MPVS = CUR_MODULE->pvs; $$ = 0; NOPR; } |
{ |
|
CUR_MODULE = mkmodule($2); |
|
MPVS = CUR_MODULE->pvs; |
|
$$ = mksnode(1,S_MODULE,CUR_MODULE); NOPR; |
|
} |
| MODEND tail |
| MODEND tail |
{ CUR_MODULE = 0; MPVS = 0; $$ = 0; NOPR; } |
{ CUR_MODULE = 0; MPVS = 0; $$ = mksnode(1,S_MODULE,NULLP); NOPR; } |
| error tail |
| error tail |
{ yyerrok; $$ = 0; } |
{ yyerrok; $$ = 0; } |
; |
; |
|
|
|
|
searchf(noargsysf,$1,&f); |
searchf(noargsysf,$1,&f); |
if ( f ) |
if ( f ) |
$$ = mkfnode(2,I_FUNC,f,0); |
$$ = mkfnode(2,I_FUNC,f,NULLP); |
else { |
else { |
searchc($1,&f); |
searchc($1,&f); |
if ( f ) |
if ( f ) |
$$ = mkfnode(2,I_FUNC,f,mkfnode(1,I_LIST,0)); |
$$ = mkfnode(2,I_FUNC,f,mkfnode(1,I_LIST,NULLP)); |
else { |
else { |
gen_searchf_searchonly($1,(FUNC *)&f); |
gen_searchf_searchonly($1,(FUNC *)&f); |
if ( f ) |
if ( f ) |
|
|
| LCASE '{' node '}' '(' node ')' |
| LCASE '{' node '}' '(' node ')' |
{ |
{ |
searchpf($1,(FUNC *)&val); |
searchpf($1,(FUNC *)&val); |
$$ = mkfnode(2,I_PFDERIV,val,mkfnode(1,I_LIST,$6),mkfnode(1,I_LIST,$3)); |
$$ = mkfnode(3,I_PFDERIV,val,mkfnode(1,I_LIST,$6),mkfnode(1,I_LIST,$3)); |
} |
} |
| GETOPT '(' rawstr ')' |
| GETOPT '(' rawstr ')' |
{ |
{ |
|
|
} |
} |
| GETOPT '(' ')' |
| GETOPT '(' ')' |
{ |
{ |
$$ = mkfnode(2,I_GETOPT,0); |
$$ = mkfnode(2,I_GETOPT,NULLP); |
} |
} |
| TIMER '(' expr ',' expr ',' expr ')' |
| TIMER '(' expr ',' expr ',' expr ')' |
{ |
{ |
|
|
searchf(parif,$3,(FUNC *)&val); |
searchf(parif,$3,(FUNC *)&val); |
if ( !val ) |
if ( !val ) |
mkparif($3,(FUNC *)&val); |
mkparif($3,(FUNC *)&val); |
$$ = mkfnode(2,I_FUNC,val,0); |
$$ = mkfnode(2,I_FUNC,val,NULLP); |
} |
} |
| PARIF '(' LCASE ',' node ')' |
| PARIF '(' LCASE ',' node ')' |
{ |
{ |
|
|
} |
} |
| '(' '*' expr ')' '(' node ')' |
| '(' '*' expr ')' '(' node ')' |
{ |
{ |
$$ = mkfnode(2,I_IFUNC,$3,mkfnode(1,I_LIST,$6)); |
$$ = mkfnode(2,I_IFUNC,$3,mkfnode(1,I_LIST,$6),NULLP); |
} |
} |
|
| '(' '*' expr ')' '(' node '|' optlist ')' |
|
{ |
|
$$ = mkfnode(3,I_IFUNC,$3,mkfnode(1,I_LIST,$6), |
|
mkfnode(1,I_LIST,$8)); |
|
} |
|
| UCASE '(' node ')' |
|
{ |
|
if ( main_parser || allow_create_var ) |
|
t = mkfnode(2,I_PVAR,makepvar($1),NULLP); |
|
else { |
|
ind = searchpvar($1); |
|
if ( ind == -1 ) { |
|
fprintf(stderr,"%s : no such variable.\n",$1); |
|
YYABORT; |
|
} else |
|
t = mkfnode(2,I_PVAR,ind,NULLP); |
|
} |
|
$$ = mkfnode(2,I_IFUNC,t,mkfnode(1,I_LIST,$3)); |
|
} |
| CAR '(' expr ')' |
| CAR '(' expr ')' |
{ $$ = mkfnode(1,I_CAR,$3); } |
{ $$ = mkfnode(1,I_CAR,$3); } |
| CDR '(' expr ')' |
| CDR '(' expr ')' |
|
|
| UCASE |
| UCASE |
{ |
{ |
if ( main_parser || allow_create_var ) |
if ( main_parser || allow_create_var ) |
$$ = mkfnode(2,I_PVAR,makepvar($1),0); |
$$ = mkfnode(2,I_PVAR,makepvar($1),NULLP); |
else { |
else { |
ind = searchpvar($1); |
ind = searchpvar($1); |
if ( ind == -1 ) { |
if ( ind == -1 ) { |
fprintf(stderr,"%s : no such variable.\n",$1); |
fprintf(stderr,"%s : no such variable.\n",$1); |
YYABORT; |
YYABORT; |
} else |
} else |
$$ = mkfnode(2,I_PVAR,ind,0); |
$$ = mkfnode(2,I_PVAR,ind,NULLP); |
} |
} |
} |
} |
| pexpr '[' expr ']' |
| pexpr '[' expr ']' |
|
|
expr : pexpr |
expr : pexpr |
{ $$ = $1; } |
{ $$ = $1; } |
| '(' STRUCT rawstr ')' pexpr |
| '(' STRUCT rawstr ')' pexpr |
{ $$ = mkfnode(3,I_CAST,structtoindex($3),$5,0); } |
{ $$ = mkfnode(3,I_CAST,structtoindex($3),$5,NULLP); } |
| expr '=' expr |
| expr '=' expr |
{ $$ = mkfnode(2,I_ASSPVAR,$1,$3); } |
{ $$ = mkfnode(2,I_ASSPVAR,$1,$3); } |
| expr BOPASS expr |
| expr BOPASS expr |
|
|
| expr AND expr |
| expr AND expr |
{ $$ = mkfnode(2,I_AND,$1,$3); } |
{ $$ = mkfnode(2,I_AND,$1,$3); } |
| FOP_NOT expr |
| FOP_NOT expr |
{ $$ = mkfnode(3,I_LOP,$1,$2,0); } |
{ $$ = mkfnode(3,I_LOP,$1,$2,NULLP); } |
| expr FOP_AND expr |
| expr FOP_AND expr |
{ $$ = mkfnode(3,I_LOP,$2,$1,$3); } |
{ $$ = mkfnode(3,I_LOP,$2,$1,$3); } |
| expr FOP_OR expr |
| expr FOP_OR expr |
|
|
{ $$ = mkfnode(1,I_NEWCOMP,(int)structtoindex($3)); } |
{ $$ = mkfnode(1,I_NEWCOMP,(int)structtoindex($3)); } |
| QUOTED '(' expr ')' |
| QUOTED '(' expr ')' |
{ MKQUOTE(quote,$3); $$ = mkfnode(1,I_FORMULA,(pointer)quote); } |
{ MKQUOTE(quote,$3); $$ = mkfnode(1,I_FORMULA,(pointer)quote); } |
|
| '[' node '|' expr ']' |
|
{ $$ = mkfnode(2,I_CONS,$2,$4); } |
| '`' expr |
| '`' expr |
{ MKQUOTE(quote,$2); $$ = mkfnode(1,I_FORMULA,(pointer)quote); } |
{ MKQUOTE(quote,$2); $$ = mkfnode(1,I_FORMULA,(pointer)quote); } |
; |
; |