RE: Precompiled grammars and Start-up Actions
[email protected] ("Orton, Yves") Thu, 17 Apr 2003 11:11:18 +0100
| Newsgroups | perl.recdescent |
|---|---|
| Message-ID | <71B318898201D311845C0008C75DAD1C08960962@defra1ex2> |
> I hacked around this problem by explicitly resetting the
> array after each
> parser run (@Yet::Another::Grammar::array=(); ), but that's rather
> hackerish..
You use a specific rule to start the parse right?
What I would do is rename that rule and then create a new start rule to
initilize what needs to be initialized and then call the real start rule. Ie
if it was "start_rule" then
<<'EOF_GRAMMAR'
start_rule: { @Yet::Another::Grammar::array=(); 1}
_start_rule
_start_rule: .....
EOF_GRAMMAR
You might have to tweak a few things to get this to work out, but its
definately the apporach I would take.
HTH
Yves