bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: `YYERROR;' should not discard lookahead token


From: Paul Eggert
Subject: Re: `YYERROR;' should not discard lookahead token
Date: Mon, 3 Feb 2003 07:09:44 -0800 (PST)

> From: Akim Demaille <address@hidden>
> Date: Sun, 02 Feb 2003 11:31:59 +0100

> | 2002-11-24  Paul Eggert  <address@hidden>
> | 
> |     * data/yacc.c (yyerrlab1): Move this label down, so that the
> |     parser does not discard the lookahead token if the user code
> |     invokes YYERROR.  This change is required for POSIX conformance.
> 
> Is there any test related to this feature?

Sorry, no.

> (I'm reading the code as it is now, so maybe the context is no
> longer the same:

Yes, the context got munged by later changes, but then it partially
got munged back in the 2003-01-21 change.  So the basic idea is the
same now: yyerrlab1 used to be just before the previous if-statement
"if (yyerrstatus == 3) ..." that discards the lookahead token if we
just tried and failed to reuse it.

> I don't absolutely understand how the patch and the ChangeLog relate
> to each other, since, if I understand correctly, what you actually
> changed is the behavior of YYERROR when we are already in error
> mode.

POSIX says that the lookahead token is discarded only under the
following conditions:

 (1) When a syntax error is detected by the parser

 (2) no normal input symbols have been shifted since the preceding error
     was detected

 (3) the lookahead symbol is not an endmarker

The error in the old code was that its condition (1) was this:

 (1') When YYERROR is executed or when the parser detects a syntax error

This check is somewhat independent of whether the parser is in error
mode.  Error mode is when the parser has shifted over less than three
normal input symbols since the last error was detected (and when no
semantic action has executed the macro yyerrok in the meantime).




reply via email to

[Prev in Thread] Current Thread [Next in Thread]