in reply to Re: Package variables and Parse::RecDescent
in thread Package variables and Parse::RecDescent

Hmm, so even though my grammar is in the same block as $checksyntax, by the time it is used the scope of $checksyntax is gone? So I'll have to make it global, hohum.
C.
  • Comment on Re: Re: Package variables and Parse::RecDescent

Replies are listed 'Best First'.
Re3: Package variables and Parse::RecDescent
by Hofmator (Curate) on Jan 08, 2003 at 08:46 UTC
    The problem is that your grammar might look to you like a piece of code but is in fact just a string. You could move the definition of that string to any prior place in your program, it doesn't make any difference to Parse::RecDescent (P::RD).

    Your grammar (the string) is taken apart into pieces (parsed) in P::RD and then the code to do the actual work is produced - outside your lexical scope. So apparently it can't access any lexical variables in this scope. The documenation of P::RD says to that:

    The action executes within a special namespace belonging to the active parser, so care must be taken in correctly qualifying variable names

    -- Hofmator