help-bison
[Top][All Lists]
Advanced

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

Re: reentrant parser - how?


From: Hans Aberg
Subject: Re: reentrant parser - how?
Date: Sun, 8 May 2005 11:54:09 +0200

At 23:26 +0200 2005/05/04, Carsten Krueger wrote:
can anybody tell me how this lexer-parser-combination would look if it
is a reentrant parser?

I recall Paul Eggert said that the Bison generated parser, which he wrote, now is fully pure. If you have some data to be passed to the parser, that should be done via the arguments to yyparse, and there are some macros for doing that; see the Bison manual. If yyparse needs some local data, then there might not be support for doing that right now. Then you need to figure out how to make the Flex generated lexer to become pure; for that, check in the Help-Flex list <address@hidden>.

---------------lexer.l-------------------------------
%option yylineno
%option case-insensitive

%{
  #include "parser.tab.h"
  /* hier C-includes*/
%}

%%
.        { return LINE;
         }
%%

int yywrap(){ return 1; /* 1: beendet lex */ }

---------------lexer.l-------------------------------

---------------parser.y------------------------------
%{
  /* hier C-includes*/
%}

%token LINE

%%

PROGRAM : LINE { /* meine C-Anweisung */ }

%%

int yyerror (char const *s)
{
  exit(1);
  return 0;
}

---------------parser.y------------------------------

---------------main.c--------------------------------
extern int yyparse();

int main()
{
  /* YYIN = file_descriptor_1; */
  yyparse();
  /* reset_parser - ?????????????? */

  /* YYIN = file_descriptor_2; */
  /* yyparse();  */
  return 0;
}
---------------main.c--------------------------------

--------------make.sh--------------------------------
#!/bin/bash
bison -d parser.y
flex lexer.l

gcc -c parser.tab.c
gcc -c lex.yy.c
gcc -c main.c

gcc -o main parser.tab.o lex.yy.o main.o
--------------make.sh--------------------------------






reply via email to

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