[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Declaring a local variable in re-entrant C parser
From: |
Michael Moser |
Subject: |
Re: Declaring a local variable in re-entrant C parser |
Date: |
Wed, 23 Jan 2013 17:17:20 +0200 |
This is a non issue: the problem can be solved by adding state variables to
a structure that is passed as additional parameter to parsing function.
Please disregard my previous email
Is it possible to declare variable in a re-entrant parser ?
>
> Normally this is not an issue with non recursive parser; one can add
> global variable into the
> code with %{ .. %} ; initialization of variable can be added by
> %initial-action { .. }
>
> but adding new non global variables can't be done with for recursive
> parser.
> %initial-action can't be used for that purpose.
>
> Meanwhile I managed to work around by means of magic sed; the re-entrant
> parser has the comment
> /* The lookahead symbol */ at the start of the parser function.
>
> sed -e "s/\/\* The lookahead symbol\. \*\//$CODE/" pars.c >pars.txt.temp
> mv -f pars.txt.temp pars.c
>
> This solution is ugly and also adds dependency on the template used.
>
> Is is possible to add a directive similar to initial-action that adds
> declaration as is to the start of the parser function ?
>
>
>
>
>
>