RE: Precompiled grammars and Start-up Actions
[email protected] (Ken LaCrosse) Thu, 17 Apr 2003 12:04:18 -0700 (PDT)
| Newsgroups | perl.recdescent |
|---|---|
| Message-ID | <[email protected]> |
Or you could simply have a "reinitialize" start rule whose only purpose is to reset whatever variables you need to initialize. After calling that start rule you could then call the "regular" start rule to parse your data. I've done that in a couple of different grammars and it works great. "Orton, Yves" <[email protected]> wrote:> 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 ------------------------- Ken LaCrosse [email protected] [email protected]