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 19:26:41 +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;
    
    Yeah I saw that label and couldn't decide for a goto. My thought then
    was "maybe YYERROR just does the right thing (what else is
    yyexhaustedlab good for) - if not Jose will correct me :P".

heh :)
    
    > Then again, this relies on bison's internals, so it may be problematic.
    > Maybe this is something to ask for in address@hidden?
    
    Hard to believe that we are the first users who try to deal with a OOM
    situation in a parser ;) Not much time now, but will ask there if no one
    else here knows an answer.
    
Thanks.



reply via email to

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