in reply to Parse::RecDescent Grammar Questions

Second try :)

Seems to me that this rules:

keylist: '{' <leftop: string /[,;]/ string> '}' association: '{' <leftop: key_value /[,;]/ key_value> '}'

will match only keylists and associations of length==2. Should not they be:

keylist: '{' <leftop: string (/[,;]/ string>)(s?) '}' association: '{' <leftop: key_value (/[,;]/ key_value>)(s?) '}'

to match groups of any length?

Rule One: Do not act incautiously when confronting a little bald wrinkly smiling man.

Replies are listed 'Best First'.
Re^2: Parse::RecDescent Grammar Questions
by ikegami (Patriarch) on May 20, 2008 at 20:53 UTC

    No.

    <leftop: key_value /[,;]/ key_value>

    is equivalent to

    ( key_value (/[,;]/ key_value)(s?) { [ $item[1], @{$item[2]} ] } )

    The "(s?)" is already built in.