[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: reentrant flex, bison glue
From: |
John W. Millaway |
Subject: |
Re: reentrant flex, bison glue |
Date: |
Tue, 12 Mar 2002 09:01:56 -0800 (PST) |
> John> If bison passes values to flex, the only way for these values to
> John> be available to the user in a reentrant scanner is for the
> John> values to be saved in the scanner state.
>
> This is what I don't understand. Could you detail this part please?
> I fail to understand why the scanner would want to save its arguments
> in a structure.
>
> John> I say "guts" but they really go in the same place that 'yyleng'
> John> goes.
>
> I don't understand either why yyleng would be saved, it's merely a
> local variable of yylex, but this is not my business, you certainly
> have motivations I don't know.
In non-reentrant flex, yyleng was never a local variable. It is an extern
global variable. It is accessible from the parser, and also from "helper"
functions that are used in flex actions. The reentrant API doesn't want to
restrict access to yyleng to within yylex() only.
Some code might clear it all up. Here's what NON-rentrant flex might generate
(not EXACTLY, of course):
int yyleng;
char * yytext;
a_lot_more_globals;
int yylex() {
...
}
And here's what reentrant flex might generate:
struct yyglobals {
int leng_r;
char* text_r;
a_lot_more_globals;
};
#define yytext (G->yytext_r)
int yylex( struct yyglobals* G){
...
}
The values yylval, and yylloc are "special" in that they aren't technically
flex variables -- they are generated by bison. But they are meant to be
accessed by the user from within the scanner, just like the other flex
variables. So it makes sense to present them to the user in the same manner as
the other variables.
__________________________________________________
Do You Yahoo!?
Try FREE Yahoo! Mail - the world's greatest free email!
http://mail.yahoo.com/
- reentrant flex, bison glue, John W. Millaway, 2002/03/07
- Re: reentrant flex, bison glue, Akim Demaille, 2002/03/11
- Re: reentrant flex, bison glue, John W. Millaway, 2002/03/11
- Re: reentrant flex, bison glue, Akim Demaille, 2002/03/12
- Re: reentrant flex, bison glue,
John W. Millaway <=
- Re: reentrant flex, bison glue, Akim Demaille, 2002/03/12
- Re: reentrant flex, bison glue, John W. Millaway, 2002/03/13
- Re: reentrant flex, bison glue, Akim Demaille, 2002/03/13
- Re: reentrant flex, bison glue, John W. Millaway, 2002/03/13
- Re: reentrant flex, bison glue, Akim Demaille, 2002/03/14
- Re: reentrant flex, bison glue, John W. Millaway, 2002/03/14
- Re: reentrant flex, bison glue, Akim Demaille, 2002/03/18
- Re: reentrant flex, bison glue, John W. Millaway, 2002/03/18
- Re: reentrant flex, bison glue, Akim Demaille, 2002/03/18
- Re: reentrant flex, bison glue, John W. Millaway, 2002/03/18