[Top][All Lists]

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

Re: push parser

From: Bob Rossi
Subject: Re: push parser
Date: Mon, 18 Dec 2006 10:32:10 -0500
User-agent: Mutt/1.5.12-2006-07-14

On Mon, Dec 18, 2006 at 03:48:55AM -0500, Joel E. Denny wrote:
> On Fri, 15 Dec 2006, Joel E. Denny wrote:
> > 3. Why don't we "Initialize the default location before parsing starts" 
> > for push parsers?  Also, %initial-action does not play well with the 
> > location passed to yypush_parse.  If @$ is set in %initial-action, @$ 
> > overwrites the location of every token.  %initial-action ought to be 
> > performed only the first time yypush_parse is called and each time the 
> > parse starts over; that would be consistent with how it works for yyparse.  
> > Moreover, the location passed to yypush_parse ought to be assigned to 
> > yylloc only when it's time to read a token (where YYLEX is invoked).  
> > Otherwise, @$ in %initial-action and it clobber each other.  I'm guessing 
> > $$ has the same problem and solution.  I haven't fixed any of this.
> Attached is a rather large patch that I believe fixes all the above... and 
> does a lot more.  I have not yet committed it.
> Here's a short description of this patch:
> For push mode, I've defined a yyparse that effectively wraps yypush_parse.  
> Push parsers can now be either pure (you must declare %pure-parser) or 
> impure.  Now, if you trick the test suite into using push.c and 
> effectively declaring %push-parser wherever it currently uses yacc.c, the 
> entire test suite still passes make maintainer-check... except for some 
> push-specific debugging output.

I don't understand. Why would we want impure push parsers?
I noticed that you changed the calc tests to only call yyparse,
shouldn't we be testing the yypush_parse function still?

When I apply your patch, I get in this prototype,
  int gdbmi_push_parse (gdbmi_pstate *yyps);
this no longer allows me to work with the push parser they way I used
to. Here is the main loop in my gdbmi code,

  ctx = gdbmi_pstate_new ();
  do {
    /* As an example, the reading here is to simulate what would happen in an
     * asychronous execution mode, where the data read externally was passed
     * into the parsing function.  */
    data_read = fgets (data, SIZE-2, fd);

    /* If a line is available, then it can be sent to the lexer and parser,
     * otherwise, wait for more input. */
    if (data_read)
      int pattern;
      gdbmi__scan_string (strdup (data_read));

      while ((pattern = gdbmi_lex ()) != 0)
        int val;
        val = gdbmi_push_parse (ctx, pattern, NULL, NULL);
        if (val == YYPUSH_MORE) /* OK, needs more */
        } else if (val == 0) /* Parser is done, this shouldn't happen */
          *parse_failed = 1;
        else { /* Error */
          *parse_failed = 1;
  } while (data_read);

And some other magic. How am I now supposed to pass into
gdbmi_push_parse the token that I just got back from gdbmi_lex?

Bob Rossi

reply via email to

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