[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: pure bison and YYPARSE_PARAM
From: |
Tim Van Holder |
Subject: |
Re: pure bison and YYPARSE_PARAM |
Date: |
Mon, 26 Jan 2004 16:19:16 +0100 |
> Hi all,
>
> Using flex and bison in a pure context.
>
> Flex generates yylex/2 lval as first arg and lloc as second
>
> Specifying pure-parser in *.y file yields proper yylex calling.
>
> However the flex example calles bison as
>
> yyparse( Lexer )
>
> Where lexer is the datastructure allocated by yylex_init
> containing the state
> of the lex parser.
>
> However yyparse generally has NO arguments EXCEPT if
> YYPARSE_PARAM e.a. is
> used.
>
> However the info for bison states that his define is depreciated ...
>
> What is then the alternative to pass the lexer to the bison parser ?
In newer bison, use
%parse-param {my_parse_context_t* my_parse_context}
%lex-param {my_lex_context_t* my_lex_context}
(one such entry per parameter to pass).
[[Info Nodes: {Parser Function}, {Pure Calling}]]
%parse-param also causes the same args to be added to yyerror() calls,
which answers your other question ('yyerror and pure parsers').
[[Info Node: {Error Reporting}]]
But note that there is a bug in bison 1.875 that breaks the use of
%lex-param (for the above example, bison would generate
#define YYLEX yylex(, my_lex_context)
(unless yyloc & co were also being added).