Re: Passing parameters to a parser

[email protected] (Marcel Grunauer)
Newsgroups perl.recdescent
Message-ID <B8E260AE.F03%[email protected]>
Am 4/16/02 3:36 PM schrieb "Vsevolod Buzinov" unter <[email protected]>:

> Parse::RecDescent is much help for my task, but what gets me into trouble is
> that I can't see a way to pass any parameters to a parser except to make them
> global variables.

 perldoc Parse::RecDescent

       Arguments can also be passed to the start rule, simply by
       appending them to the argument list with which the start
       rule is called (after the "line number" parameter). For
       example, given:

               $parser = new Parse::RecDescent ( $grammar );

               $parser->data($text, 1, "str", 2, \@arr);

               #             ^^^^^  ^  ^^^^^^^^^^^^^^^
               #               |    |         |
               # TEXT TO BE PARSED  |         |
               # STARTING LINE NUMBER         |
               # ELEMENTS OF @arg WHICH IS PASSED TO RULE data

       then within the productions of the rule `data', the array
       `@arg' will contain `("str", 2, \@arr)'.

.... If that's what you mean.

Marcel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.