poke-devel
[Top][All Lists]
Advanced

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

Re: [PATCH 1/3] Remove include xalloc.h from libpoke/pkl-env.c


From: Jose E. Marchesi
Subject: Re: [PATCH 1/3] Remove include xalloc.h from libpoke/pkl-env.c
Date: Sat, 16 May 2020 18:46:24 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Hi Tim.

    diff --git a/libpoke/pkl-tab.y b/libpoke/pkl-tab.y
    index 23c1fd8a..9ef6519e 100644
    --- a/libpoke/pkl-tab.y
    +++ b/libpoke/pkl-tab.y
    @@ -414,6 +414,8 @@ pushlevel:
          %empty
                {
                       pkl_parser->env = pkl_env_push_frame (pkl_parser->env);
    +                  if (!pkl_parser->env)
    +                    YYERROR;
                     }
             ;

The yyparse function (in this case pkl_tab_parse) should return 2 in
case of memory exhaustion:

 -- Function: int yyparse (void)
     The value returned by ‘yyparse’ is 0 if parsing was successful
     (return is due to end-of-input).

     The value is 1 if parsing failed because of invalid input, i.e.,
     input that contains a syntax error or that causes ‘YYABORT’ to be
     invoked.

     The value is 2 if parsing failed due to memory exhaustion.

Both YYERROR and YYABORT make yyparse to return 1.  The difference
betweent the two is that YYABORT returns immediately, whereas YYERROR
initiates syntax error recovery, executing rule destructors and the
like.

I don't think we sould use YYERROR for out-of-memory conditions.
First, because it makes yyparse to return 1, not 2.
Second, because it is not a syntax error condition.

Looking at bison internals, this will probably work:

  goto yyexhaustedlab;

Then again, this relies on bison's internals, so it may be problematic.
Maybe this is something to ask for in address@hidden?



reply via email to

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