Bug in the default yecc prologue file

Frej Drejhammar <>
Mon Jun 7 12:38:57 CEST 2004


Hi!

There is a bug in the default yecc prologue file
(lib/parsetools/include/yeccpre.hrl) as supplied by R9C-[01]. If
parse_and_scan/1 of the generated parser is used, the parser will
always report a parse failure when the lexer reports end of file. This
occurs even if the input is a complete root symbol.

The following one line patch corrects this bug, attached is also a
yecc grammar demonstrating the bug (run bug:bug/0).

Cheers,
Frej

--- yeccpre_orig.hrl    2004-06-04 23:03:27.000000000 +0200
+++ yeccpre.hrl 2004-06-04 23:05:34.000000000 +0200
@@ -61,7 +61,7 @@
 yeccpars1([], {M, F, A}, State, States, Vstack) ->
     case catch apply(M, F, A) of
         {eof, Endline} ->
-            {error, {Endline, ?THIS_MODULE, "end_of_file"}};
+           yeccpars1([], false, State, States, Vstack);
         {error, Descriptor, _Endline} ->
             {error, Descriptor};
         {'EXIT', Reason} ->

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: bug.yrl
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20040607/7bd11404/attachment.ksh>


More information about the erlang-questions mailing list