bison-patches
[Top][All Lists]
Advanced

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

Re: Interactive parsing with Bison


From: Bob Rossi
Subject: Re: Interactive parsing with Bison
Date: Fri, 23 Jun 2006 16:40:05 -0400
User-agent: Mutt/1.5.11

On Fri, Jun 23, 2006 at 03:34:17PM -0500, Satya wrote:
> >This sounds like it would be really easy to do with my push parser patch.
> 
> What is it? can you tell me more about this patch?

I'm working on a push parser patch. It has been posted to this list
already. I'm currently waiting on the FSF to get the assignment papers
to me. I'm pretty confident from talking with the maintainers that it
will eventually be excepted.

Basically, it allows bison to generate a parser that parses 1 token at a
time. You feed it the tokens one at a time, and it updates the parser
until you've parsed everything. Here's a simple example:

int
main (void)
{
  void *ctx = yypvarsinit ();
  FILE *fp;
  int val = 1;
  fp= fopen("1.dat", "r");
  yyparse (ctx);
  do {
    if(val != 0)
     set_yychar (ctx, yylex(fp));
    yyparse(ctx);
    val = get_yyresult (ctx);
    if(val == 1)
      fprintf(stderr,"\nSyntax error");
  } while (val!=0);
  fclose(fp);

  fprintf(stderr, "\n");
  return 0;
}

Bob Rossi




reply via email to

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