Re: Autotree and repeated expressions
[email protected] ("Philip Coombes")
| Newsgroups | perl.recdescent |
|---|---|
| Message-ID | <[email protected]> |
Thanks Yves. I'd considered doing that but decided that I couldn't be
bothered to write extra parser classes for firstval etc. I'd forgotten that
you can still write actions in autotrees so this is an option I may use.
Another thing I've since discovered is that I can define the rule like
func: 'concat' '(' rvalue(2 /,/) ')'
which provides the two rvalues in the __DIRECTIVEn__ member. It looks uglier
but is possibly more extensible as I don't have to write new rules for each
parameter.
What I'd ideally like is something like
func: 'concat' '(' rvalue<as:parm1> ',' rvalue<as:parm2> ')'
where the parameters are accessible as parm1 and parm2 in the 'item' hash
for normal parsers and as named members in the blessed has for autotrees. It
would save all the digging around in the internals of the hash to try and
figure out what's where. I'm not sure if you can already do this or not, if
you can I've missed it somewhere.
Cheers,
Phil,
----- Original Message -----
From: "Orton, Yves" <[email protected]>
To: "'Philip Coombes'" <[email protected]>; <[email protected]>
Sent: Monday, March 11, 2002 10:49 AM
Subject: RE: Autotree and repeated expressions
> > In simple terms, if I am using autotree to build an OO parse
> > tree and I have
> > a rule of the form
> >
> > func: 'concat' '(' rvalue ',' rvalue ')'
> >
> > how do I access the second rvalue from the blessed object. I
> > can only see one in there.
>
> I _think_ the way to do this is to rework your grammer
>
> func: 'concat' '(' firstval ',' secondval ')'
> firstval :rvalue
> secondval:rvalue
>
> Usually though when I use autotrees i tend to end up having my terminals
> stubbed like:
>
> firstval :rvalue {$return=$item[1]; 1}
> secondval:rvalue {$return=$item[1]; 1}
>
> ANyway, just my $.02
>
> Yves
>
>