help-flex
[Top][All Lists]
Advanced

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

Re: pure_parser & reentrant lexer


From: Maciej A. Patelczyk
Subject: Re: pure_parser & reentrant lexer
Date: Sat, 7 Aug 2004 22:07:22 +0200
User-agent: Mutt/1.5.4i

On Fri, 6 Aug 2004, Bruce Lilly wrote:

> Maciej A. Patelczyk wrote:
> > Hello
> > 
> > I'm trying to write reentrant lexer and parser. Of course
> > i have a problem.
> > 
> > Flex - 2.5.31
> > Bison - 1.875a
> [...]
> > So, it doesn't work. Don't know why. Don't know where.
> > 
> > I need help. Maybe some examples (must be flex+bison) or
> > links ?
> 
> The calling convention for the reentrant lexical analyzer is different
> from the non-reentrant one.
> 
> Example at http://users.erols.com/blilly/mparse

Thanks.

But i still can't make it right. I put the lines

/* flex 2.5.31 and later needs this */
#define yyg ((struct yyguts_t *)yyscanner)

to my scanner.l file (wow...).

According to info pages (flex/bison) '%option bison-bridge reentrant'
in flex file and option '%pure_parser' in bison file makes yylval private 
variable (and makes other changes). So the declaration of yylex becomes
(parser.tab.c)
# define YYLEX yylex (&yylval, YYLEX_PARAM)

The declaration of yylval is 'YYSTYPE yylval' (in parser.tab.c in
yyparse). In lex.yy.c declaration of yylex is like this
extern int yylex \
       (YYSTYPE * yylval_param ,yyscan_t yyscanner);

#define YY_DECL int yylex \
       (YYSTYPE * yylval_param , yyscan_t yyscanner)


Now compiler reports:

address@hidden:~/tmp/mybis/3$ gcc -Wall -o test parser.tab.c
parser.tab.c: In function `yyparse':
parser.tab.c:762: error: parse error before "struct"
parser.tab.c:927: warning: passing arg 1 of `yylex' from incompatible
pointer type
parser.tab.c:965: error: incompatible types in assignment
parser.tab.c:1195: warning: passing arg 2 of `yydestruct' from
incompatible pointer type
parser.tab.c:1242: error: incompatible types in assignment

lines
762: YYSTYPE yylval;
927: yychar = YYLEX;
1242: *++yyvsp = yylval;

all in yyparse function


Still don't know what i'm doing wrong.

-- 
                maf




reply via email to

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