accessing elements of parse tree

[email protected] (Adaoui Mark)
Newsgroups perl.recdescent
Message-ID <[email protected]>
Hi All Happy New year,
I am trying to access parts of the parse tree, created by autotree, though i
am having some difficulty.
The specific part that i am having problems is accessing the contents of the
hash __DIRECTIVE2__, i understand (correct me if i am wrong) that within the
list the last element of a rule can be accessed on its own as it is a
terminal (i.e all the parts under namedNumber in this instance shown below).
Though __DIRECTIVE2__ is a nested hash? Because it is an intermediate rule,
how do i access this?
     
bless( {
                   'ident' => bless( {
                                       '__VALUE__' => 'cardFailState'
                                     }, 'ident' ),
                   'type' => bless( {
                                      'namedNumber' => bless( {
 
'__STRING1__' => '(',
 
'__STRING2__' => ')',
                                                                'ident' =>
bless( {
 
'__VALUE__' => 'raise'
 
}, 'ident' ),
                                                                'number' =>
bless( {
 
'__VALUE__' => '1'
 
}, 'number' ),
 
'__DIRECTIVE1__' => 1,
                                                                '__RULE__'
=> 'namedNumber'
                                                              },
'namedNumber' ),
                                      '__DIRECTIVE1__' => 1,
                                      '__RULE__' => 'type',
                                      '__STRING1__' => 'ENUMERATED',
                                      '__DIRECTIVE2__' => [
                                                            bless( {
 
'__STRING1__' => '(',
 
'__STRING2__' => ')',
                                                                     'ident'
=> bless( {
 
'__VALUE__' => 'clear'
 
}, 'ident' ),
 
'number' => bless( {
 
'__VALUE__' => '0'
 
}, 'number' ),
 
'__DIRECTIVE1__' => 1,
 
'__RULE__' => 'namedNumber'
                                                                   },
'namedNumber' ),
 
$VAR1->[0]{'type'}{'namedNumber'}
                                                          ],
                                      '__STRING2__' => '{',
                                      '__PATTERN1__' => ',',
                                      '__STRING3__' => '}'
                                    }, 'type' ),
                   '__DIRECTIVE1__' => 1,
                   '__RULE__' => 'namedType'
                 }, 'namedType' )
        ];

i have tried to assign it to an array, then using a foreach loop to access
all of the elements therein, here is a sample:
	
my @array = $aType->{sequence}{__DIRECTIVE2__};
   foreach $elem (@array){
	print $elem;
   }

should i be assigning the contents to a my %hash or @array, then using the
my in the loop as above, or am i completely of          track? any help is
greatly appreciated.

thanx mark
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.