in reply to Simple Parsing of JavaScript function names using Parse-RecDescent
One way I could do this is by flattening this multi-dimensional array that gets returned into one array - or by doing it in the grammar (which is probably more efficient)? If someone knows how to do either (both would be great for learning) that would be awesome.
I've changed the output code to do this
which produces these results on the array structure that is returned to me.foreach my $parsedValue (@$refParsedValues) { print Dumper($parsedValue) if ($parsedValue); }
What we really wanted was an array that printed like this:Compile Time: 0.3 seconds ---------------------------------------------------------------------- +-- $VAR1 = [ '', '' ]; $VAR1 = [ '', '' ]; $VAR1 = [ 'funct1', '', '' ]; $VAR1 = [ '', '' ]; $VAR1 = [ '', [ '', [ 'funct2a', 'funct2b', '' ], '' ], '' ]; $VAR1 = 'funct3'; $VAR1 = 'funct4'; $VAR1 = 'funct5'; $VAR1 = 'funct6'; $VAR1 = 'funct7'; ---------------------------------------------------------------------- +-- Parse Time: 1.1 seconds Total Time: 1.4 seconds
$VAR1 = 'funct1'; $VAR1 = 'funct2a'; $VAR1 = 'funct2b'; $VAR1 = 'funct3'; $VAR1 = 'funct4'; $VAR1 = 'funct5'; $VAR1 = 'funct6'; $VAR1 = 'funct7';
|
|---|