$B!y(B10000$B1_J,L5NA!y(B

2005-04-13 Thread info
$B"#"#"#!V(B1$B1_!WJ,L5NA%]%$%s%HB#Dh%-%c%s%Z!<%se$2$^$9!*(B

$B"!(B1$B1_L5NA%]%$%s%H$H?7$7$$=P2q$$(BGET$B!*"*"*"*(B 
http://awg.qsv20.com/?springg

$B!zL5NA$GAjEvM7$Y$^$9$N$G@'Hs$*;n$72<$5$$$M"v(B
$B!z;HMQ$7$F$_$F!V$3$l$O!*!W$H;W$C$FD:$$$?J}$N$_!VM-NA!W$X$*?J$_2<$5$$!#(B



___
Help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison


Conflicts shift/reduction

2005-04-13 Thread Eduardo Robles Elvira
Hello everybody !

I'm developing an Interpreter with flex & bison. The grammatical parser (with 
bison) part is mostly working; the problem is that there are a few problems I 
have yet to solve;

Normally bison tells me:
lea.y: conflicts: 2 shift/reduce, 4 reduce/reduce

I haven't found it to miswork even with that, so I don't think that it's 
problematic. Now I've been changing recursivity from left to right, and it 
has been a successful change, but one problem emerged, and is a 
shift/reduction conflict. When I turn this code:
<
elif_statement:
 '|' expr_bool cond_start
  sentence_list
  { $$ = TRelif_statement($2, $4); }
;

elif_statement_list:
 elif_statement_list elif_statement
  { $$ = TRelif_statement_list($2, $1); }
 | elif_statement
  { $$ = TRelif_statement_list($1, NULL); }
>
Into this other:
<
elif_statement:
 '|' expr_bool cond_start
  sentence_list
  { $$ = TRelif_statement($2, $4); }
;

elif_statement_list:
 elif_statement elif_statement_list
  { $$ = TRelif_statement_list($1, $2); }
 | elif_statement
  { $$ = TRelif_statement_list($1, NULL); }
>
This is the bison output:
lea.y: conflicts: 3 shift/reduce, 4 reduce/reduce
lea.y:475.11-476.57: warning: rule never reduced because of conflicts: 
elif_statement_list: elif_statement

How can I solve it ?

The other major problem is with my implementation of boolean expresions and 
plain expresions. It's convenient to me to separe both of them, because it's 
the right thing to do (TM).  But it happens that a boolean expression can 
also be considered a expression. right now, I have only this implemented (see 
the comment inside):
<
expr:
 INT_VAL
  { $$ = TRexpr_int($1); }
 // TODO: Sometimes a expr_bool can also be considered an expr,
 // for example when it reffers to a boolean variable, but if we
 // add here expr_bool, 91 reduce/reduce problems appear and
 // parsing becomes broken!
 | BOOL_VAL
  { $$ = TRexpr_expr_bool($1); }
>

The code for both of them, expr and expr_bool is large:
<
expr_bool:
 BOOL_VAL
  { $$ = TRexpr_bool_val($1); }
 | '(' expr_bool ')'
  { $$ = $2; }
 | struct_call
  { $$ = TRexpr_bool_struct($1); }
 | NOT_OP expr_bool %prec NEG
  { $$ = TRexpr_bool_not($2); }
 | expr_bool AND_OP expr_bool
  { $$ = TRexpr_bool_log('&', $1, $3); }
 | expr_bool OR_OP expr_bool
  { $$ = TRexpr_bool_log('|', $1, $3); }
 | expr '=' expr
  { $$ = TRexpr_bool('=', $1, $3); }
 | expr '<' expr
  { $$ = TRexpr_bool('<', $1, $3); }
 | expr '>' expr
  { $$ = TRexpr_bool('>', $1, $3); }
 | expr LE_OP expr
  { $$ = TRexpr_bool('l', $1, $3); }
 | expr GE_OP expr
  { $$ = TRexpr_bool('g', $1, $3); }
 | expr NOT_EQ expr
  { $$ = TRexpr_bool('n', $1, $3); }
 | function_call
  { $$ = TRexpr_bool_fcall($1); }
;

expr:
 INT_VAL
  { $$ = TRexpr_int($1); }
 // TODO: Sometimes a expr_bool can also be considered an expr,
 // usually when it reffers to a boolean variable, but if we
 // add here expr_bool 91 reduce/reduce problems appear!
 | BOOL_VAL
  { $$ = TRexpr_expr_bool($1); }
 | FLOAT_VAL
  { $$ = TRexpr_float($1); }
 | STR_VAL
  { $$ = TRexpr_str($1); }
 | struct_call
  { $$ = TRexpr_struct($1); }
 | expr '+' expr
  { $$ = TRexpr('+', $1, $3); }
 | expr '-' expr
  { $$ = TRexpr('-', $1, $3); }
 | expr '*' expr
  { $$ = TRexpr('*', $1, $3); }
 | expr '/' expr
  { $$ = TRexpr('/', $1, $3); }
 | expr '%' expr
  { $$ = TRexpr('%', $1, $3); }
 | expr '^' expr
  { $$ = TRexpr('^', $1, $3); }
 | '-' expr %prec NEG
  { $$ = TRexpr('n', $2, NULL); }
 | '(' expr ')'
  { $$ = $2; }
 | function_call
  { $$ = TRexpr_fcall($1); }
;
>

You can see the whole code in the SVN repository: 
http://svn.berlios.de/viewcvs/lea/trunk/ . *Any* help is appreciated !


Thanks for your time,
  Edulix.


___
Help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison


Re: Conflicts shift/reduction

2005-04-13 Thread Hans Aberg
At 21:16 +0200 2005/04/13, Eduardo Robles Elvira wrote:
This is the bison output:
lea.y: conflicts: 3 shift/reduce, 4 reduce/reduce
lea.y:475.11-476.57: warning: rule never reduced because of conflicts:
elif_statement_list: elif_statement
How can I solve it ?
The standard attempt to resolve shift/reduce conflicts, is to use the 
--verbose option, and in the .output file, in the afflicted state and 
rules, put precedences of the tokens right before and after the ".". 
As the Bison manual says, a reduce/reduce conflict may indicate a 
serious problem with the grammar. If you are sure the grammar is OK, 
you might try the %glr option.
--
  Hans Aberg

___
Help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison


viewing parse tree

2005-04-13 Thread hz kto


Hi, all

I was wondering are there any tools out there that allow to view bison parse 
tree in graphics some sort of pseudo graphics, or any other way to help 
understand which branches of the parse tree depend on a particular grammar 
element. For example I want to find out all branches that might contain 
multiplication.

thanks in advance

Alex



___
Help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison


Fabrizio Gonzalez (2nd request)

2005-04-13 Thread FabrizioGonzalez
Fabrizio Gonzalez is still waiting to hear from you to join their mobile 
friends network.

Guess what? You now have 1 friend that have invited you to their mobile network!

These friend are waiting for you to accept:
Fabrizio Gonzalez


Click the link below to see your friend? photos and accept their invitations.

http://www.sms.ac/registration/[EMAIL PROTECTED]&InvitorNbrs=40182640;r=0&t=4

Don?t recognize the name above? Click the link above to learn more about the 
friend who invited you or to block future invitations.

SMS.ac,Inc.,7770 Regents Road,Suite 113-405, San Diego, CA 92122 USA



___
Help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison