[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Reductions during Bison error handling
From: |
Hans Aberg |
Subject: |
Re: Reductions during Bison error handling |
Date: |
Thu, 23 May 2002 16:17:58 +0200 |
At 18:01 -0700 2002/05/22, Paul Eggert wrote:
>I like the latter idea. I have the following suggestions for minor
>improvements. First, let's keep that redundant 'goto yyerrlab1;', as
>it is in keeping with the style of that code (as a state machine).
>There are several redundant gotos but I think they're all OK.
I don't know about errors, but I noticed that when I wrote my C++ skeleton
file, merging the various stacks into a single one, I had to move around
the code a bit, and as a consequence, some "goto"'s disappeared.
>Third, all other things being equal I prefer "<" to ">" since it
>causes textual order to reflect numeric order.
If all things are equal, that is. But they rarely are. In math, typically
the semantically more significant (to the human reader's cognition)
quantity should be on the LHS.
So Paul H's code looks exactly as I would want it to be in this respect. :-)
I can elaborate: The code
(1) yyn = yypact[yystate] + YYTERROR;
(2) if (yyn != YYFLAG + YYTERROR
&& yyn >= 0 && yyn <= YYLAST && yycheck[yyn] == YYTERROR
&& yytable[yyn] > 0)
conveys the intuition to me that at (1) the important quantity yyn is
assigned; then, a (2), a series of tests on this quantity is conducted in
order to pin it down. I figure that if one has a mental image of the
underlying algorithm, this is how would perceive it.
>Last, and perhaps most controversially, in this case it's a bit clearer
>to put the test in the while-expression rather than to use while(1) ...
>if (test) break;.
One should be aware of that long statements in the "for" and "while" heads
decreases legibility.
Hans Aberg
- Re: Reductions during Bison error handling, (continued)
- Re: Reductions during Bison error handling, Richard Stallman, 2002/05/21
- Re: Reductions during Bison error handling, Hans Aberg, 2002/05/21
- Re: Reductions during Bison error handling, Richard Stallman, 2002/05/23
- Re: Reductions during Bison error handling, Akim Demaille, 2002/05/24
- Re: Reductions during Bison error handling, Hans Aberg, 2002/05/24
- Re: Reductions during Bison error handling, Paul Eggert, 2002/05/21
- Re: Reductions during Bison error handling, Paul Hilfinger, 2002/05/21
- Re: Reductions during Bison error handling, Paul Eggert, 2002/05/22
- Re: Reductions during Bison error handling, Paul Hilfinger, 2002/05/22
- Re: Reductions during Bison error handling, Akim Demaille, 2002/05/23
- Re: Reductions during Bison error handling,
Hans Aberg <=
- Re: Reductions during Bison error handling, Richard Stallman, 2002/05/23
- Re: Reductions during Bison error handling, Paul Hilfinger, 2002/05/23
- Re: Reductions during Bison error handling, Richard Stallman, 2002/05/25
- Re: Reductions during Bison error handling, Mike Castle, 2002/05/23
Re: Reductions during Bison error handling, Paul Eggert, 2002/05/20
Re: Reductions during Bison error handling, Paul Hilfinger, 2002/05/13
Re: Reductions during Bison error handling, Paul Hilfinger, 2002/05/21