[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Declaring a local variable in re-entrant C parser
From: |
Michael Moser |
Subject: |
Declaring a local variable in re-entrant C parser |
Date: |
Wed, 23 Jan 2013 17:06:14 +0200 |
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 ?
- Declaring a local variable in re-entrant C parser,
Michael Moser <=