[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to read an understand the bison report file ?
From: |
Akim Demaille |
Subject: |
Re: How to read an understand the bison report file ? |
Date: |
Wed, 27 Jun 2012 08:44:27 +0200 |
Le 27 juin 2012 à 08:00, Akim Demaille a écrit :
> For instance, you have:
>
> state 88
>
> 1 t_comment_or_whitespace: . T_WHITESPACE
> 2 | . T_COMMENT
> 3 plain_comment_or_whitespace: . t_comment_or_whitespace
> 4 | . plain_comment_or_whitespace
> t_comment_or_whitespace
> 5 t_comment_or_whitespaces: . [T_BOOLEAN_OR]
> 6 | . plain_comment_or_whitespace
> 90 boolean_or_expr: boolean_or_expr . t_comment_or_whitespaces T_BOOLEAN_OR
> t_comment_or_whitespaces boolean_and_expr
> 91 conditional_expression: boolean_or_expr . [T_CLOSE_TAG, T_AS,
> T_WHITESPACE, T_COMMENT, T_LOGICAL_AND, T_LOGICAL_OR, T_LOGICAL_XOR,
> T_DOUBLE_ARROW, "+= (T_PLUS_EQUAL)", "-= (T_MINUS_EQUAL)", "*=
> (T_MUL_EQUAL)", "/= (T_DIV_EQUAL)", ".= (T_CONCAT_EQUAL)", "%=
> (T_MOD_EQUAL)", "&= (T_AND_EQUAL)", "|= (T_OR_EQUAL)", "^= (T_XOR_EQUAL)",
> "<<= (T_SL_EQUAL)", ">>= (T_SR_EQUAL)", '}', ':', ',', ')', ']', '?', '=',
> ';']
>
> T_WHITESPACE shift, and go to state 1
> T_COMMENT shift, and go to state 2
>
> T_WHITESPACE [reduce using rule 91 (conditional_expression)]
> T_COMMENT [reduce using rule 91 (conditional_expression)]
> T_BOOLEAN_OR reduce using rule 5 (t_comment_or_whitespaces)
> $default reduce using rule 91 (conditional_expression)
>
> t_comment_or_whitespace go to state 3
> plain_comment_or_whitespace go to state 4
> t_comment_or_whitespaces go to state 169
>
> which means that Bison does not know whether to reduce or to shift
> when a whitespace or a comment arrives after a boolean_or_expr.
Actually I realize that I answered without paying too much
attention to your grammar, and in the present case, always
shifting is not the right answer, nor is always-reducing:
> 90 boolean_or_expr: boolean_or_expr . t_comment_or_whitespaces T_BOOLEAN_OR
> t_comment_or_whitespaces boolean_and_expr
> 91 conditional_expression: boolean_or_expr . [T_WHITESPACE, T_COMMENT, …]
There is no way to know whether _after_ the whitespace/comment
there is a T_BOOLEAN_OR. Your grammar is not LR(1), not even
LR(k) as there can be as many whitespace/comment as you
want after boolean_or_expr, and before the token that will
help deciding whether to chose rule 90 (T_BOOLEAN_OR) or rule 91
(otherwise).
Either you need to completely change the way you handle the
spaces/comments, or you have to use GLR, as Hans suggested.
- How to read an understand the bison report file ?, Timothy Madden, 2012/06/26
- Re: How to read an understand the bison report file ?, Hans Aberg, 2012/06/26
- Re: How to read an understand the bison report file ?, Akim Demaille, 2012/06/27
- Re: How to read an understand the bison report file ?,
Akim Demaille <=
- Re: How to read an understand the bison report file ?, Timothy Madden, 2012/06/27
- Re: How to read an understand the bison report file ?, Vincent Zweije, 2012/06/27
- Re: How to read an understand the bison report file ?, Hans Aberg, 2012/06/27
- Re: How to read an understand the bison report file ?, Akim Demaille, 2012/06/28
- Re: How to read an understand the bison report file ?, Timothy Madden, 2012/06/28
- Re: How to read an understand the bison report file ?, Akim Demaille, 2012/06/28
- Re: How to read and understand the bison report file ?, Timothy Madden, 2012/06/28
- Re: How to read and understand the bison report file ?, Akim Demaille, 2012/06/28