Hi Folks,

I have a recursive production and I want to return an array of the all the tokens matched by 'primitive'.

(The complete grammar is rather large so I'm posting just a snippet.)

vvalue: primitive vector_sep(?) vvalue | primitive vector_sep(?)

In an attempt to see the data structure being produced, I tried this:

vvalue: primitive vector_sep(?) vvalue { \@item } | primitive vector_sep(?) { \@item }

Which according to Data:Dumper, produces the structure below from "2,3 5 7,11,13 17".

[ 'vvalue', '2', [ ',' ], [ 'vvalue', '3', [], [ 'vvalue', '5', [], [ 'vvalue', '7', [ ',' ], [ 'vvalue', '11', [ ',' ], [ 'vvalue', '13', [], [ 'vvalue', '17', [], $VAR1->[6]{'value'}[3][3][3][3][3 +][3] ], $VAR1->[6]{'value'}[3][3][3][3][3] ], $VAR1->[6]{'value'}[3][3][3][3] ], $VAR1->[6]{'value'}[3][3][3] ], $VAR1->[6]{'value'}[3][3] ], $VAR1->[6]{'value'}[3] ], $VAR1->[6]{'value'} ],

What I'd like to receive back is [2,3,5,7,11,13,17].

Can someone point me in the right direction?

Cheers,

-J


In reply to capturing part of a recursive Parse::RecDescent production by Dogma

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.