[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug going to 1.875
From: |
rosing |
Subject: |
bug going to 1.875 |
Date: |
Wed, 19 Feb 2003 17:38:50 -0700 |
Hi,
The following program, when run through a previous version of bison
worked fine, but after compiling it with 1.875 generates code that has
an error in it. I can fix it for now by compiling with -U__GNUC_MINOR__.
I'm not sure what the previous version was.
The offending code is the cpp section in
<start fragment>
/*----------------------------------------------------.
| yyerrlab1 -- error raised explicitly by an action. |
`----------------------------------------------------*/
yyerrlab1:
/* Suppress GCC warning that yyerrlab1 is unused when no action
invokes YYERROR. */
#if defined (__GNUC_MINOR__) && 2093 <= (__GNUC__ * 1000 + __GNUC_MINOR__)
__attribute__ ((__unused__))
#endif
goto yyerrlab2;
<end fragment>
Thanks,
Matt
--------------------------------------------
%{
#include <stdlib.h>
#include "slip.h"
/*#define YYSTYPE SlipNode**/
#define YYDEBUG 1
extern int exp_mode;
%}
%union{
struct slip_node_tp *ref;
int op;
}
%type <ref> program stmt_list phrase_list_opt phrase_empty phrase_list
exp bexpr base pri_exp
%type <op> dot_sep_opt sep_opt range eq comp shift mult add string integer ident
%token INTEGER
%token STRING
%token IDENT
%token RANGE
%token RANGEPLUS
%token AND
%token OR
%token NOTEQ
%token LE
%token GE
%token LSHIFT
%token RSHIFT
%token ISEQ
%token ARROW
%token EXPTERM
%token COMMA
%token LSLIP
%token LB
%token DCOLON
%% /* Grammar rules and actions follow. */
/*phraselist*/
program: stmt_list {global_slip = $1;};
/*phrase_list*/
stmt_list: {phrase_fix_pre();} phrase_list_opt
{
$$ = phrase_fix_pop();
}
;
phrase_list_opt: phrase_empty{$$=$1;}|phrase_list{$$=$1;};
phrase_empty:{$$=0; phrase_fix_push_phrase(slip_list(0));};
/*twoslip*/
phrase_list:
exp sep_opt
{
phrase_fix_push_phrase($1);
phrase_fix_push_op((enum phrase_op)(int)$2);
}
| phrase_list exp sep_opt
{
phrase_fix_push_phrase($2);
phrase_fix_push_op((enum phrase_op)(int)$3);
}
| '{' stmt_list '}' dot_sep_opt
{
phrase_fix_push_phrase(slip_list(slip_scope($2)));
phrase_fix_push_op((enum phrase_op)(int)$4);
}
| phrase_list '{' stmt_list '}' dot_sep_opt
{
phrase_fix_push_phrase(slip_list(slip_scope($3)));
phrase_fix_push_op((enum phrase_op)(int)$5);
}
| LB stmt_list '}' sep_opt
{
phrase_fix_push_phrase((slip_list($2)));
phrase_fix_push_op((enum phrase_op)(int)$4);
}
| phrase_list LB stmt_list '}' sep_opt
{
phrase_fix_push_phrase((slip_list($3)));
phrase_fix_push_op((enum phrase_op)(int)$5);
}
;
/*int*/
dot_sep_opt: {$$=semi_op;}
|'.' {$$=comma_op;}
|COMMA {$$=comma_op;}
|DCOLON {$$=dcolon_op;}
|';' {$$=semi_op;}
|'#' {$$=pound_op;}
;
/*int*/
sep_opt: {$$=comma_op;}
|'.' {$$=comma_op;}
|COMMA {$$=comma_op;}
|DCOLON {$$=dcolon_op;}
|';' {$$=semi_op;}
|'#' {$$=pound_op;}
;
/*phraseexpr*/
exp: {exp_mode=1;expr_fix_pre();} op_list bexpr EXPTERM
{$$=expr_fix_post();exp_mode=0;};
bexpr: base
| base op_plus
| base op_plus bexpr
;
base: pri_exp {expr_fix_push_base($1);};
pri_exp: integer { $$=(SlipNode*)(slip_int((int)$1));}
| ident { $$=(SlipNode*)(slip_ident((int)$1));}
| '@' ident {$$=(SlipNode*)(slip_keyword((int)$2));}
| string { $$=(SlipNode*)(slip_string((int)$1));}
| '(' exp ')' {$$=$2; exp_mode=1;}
| pri_exp '(' stmt_list ')' { $$=slip_bin($1, op_call, $3);exp_mode=1;}
| pri_exp '[' stmt_list ']' { $$=slip_bin($1, op_array,$3);exp_mode=1;}
| '[' stmt_list ']'
{
/*$$=slip_unary( op_data, $2);*/
$$ = slip_list($2);
exp_mode=1;
}
| LSLIP stmt_list ')' { $$=slip_list($2); exp_mode=1;}
| pri_exp '.' ident
{
$$=slip_bin($1, op_dot,slip_list(slip_ident((int)$3)));exp_mode=1;
}
| pri_exp ARROW ident
{
$$=slip_bin($1, op_arrow,slip_list(slip_ident((int)$3)));exp_mode=1;
}
| '`' ident {$$=slip_quote(slip_int((int)$2));}
;
op: range {expr_fix_push_op((enum op)(int)$1);}
| eq {expr_fix_push_op((enum op)(int)$1);}
| comp {expr_fix_push_op((enum op)(int)$1);}
| shift {expr_fix_push_op((enum op)(int)$1);}
| add {expr_fix_push_op((enum op)(int)$1);}
| mult {expr_fix_push_op((enum op)(int)$1);}
| ':' {expr_fix_push_op(op_colon);}
| '=' {expr_fix_push_op(op_eq);}
| OR {expr_fix_push_op(op_dbar);}
| AND {expr_fix_push_op(op_dampersand);}
| '|' {expr_fix_push_op(op_bar);}
| '^' {expr_fix_push_op(op_hat);}
| '&' {expr_fix_push_op(op_ampersand);}
| '!' {expr_fix_push_op(op_bang);}
/* | '.' {expr_fix_push_op(op_dot);}*/
;
op_list: | op_list op ;
op_plus: op | op_plus op;
range: RANGE {$$=op_ddot;}
| RANGEPLUS {$$=op_ddotplus;}
;
eq: ISEQ {$$=op_eqeq;}
| NOTEQ {$$=op_bangeq;};
comp: '<' {$$=op_left;}
| LE {$$=op_lefteq;}
| '>' {$$=op_right;}
| GE {$$=op_righteq;};
shift: LSHIFT {$$=op_dleft;}
| RSHIFT {$$=op_dright;};
add: '+' {$$=op_plus;}
| '-' {$$=op_minus;};
mult: '*' {$$=op_star;}
| '/' {$$=op_slash;};
string: STRING {$$=last_string;};
integer: INTEGER {$$=last_int;};
ident: IDENT {$$=last_ident;};
%%
void yyerror (const char *s) { /* called by yyparse on error */
char c;
int i=0;
while( cp[i]!='\n' && cp[i]!=0)
i++;
c = cp[i];
cp[i] = 0;
printf ("%s, line %d: %s\n", s,source_line,cp);
was_parse_err = 1;
cp[i] = c;
}
- bug going to 1.875,
rosing <=