in reply to Parse::RecDescent question

First of all, you need to tell PRD that you have a line-oriented syntax rather than a whitespace separated syntax. Otherwise, newlines will be swallowed between tokens arbitrarily. And then all you really have is a command and its args:
grammar: line(s?) /\z/ { $item[1] } line: <skip:[ \t]+> command arg(s?) "\n" { [$item[2], $item[3]] } command: /\w+/ arg: <perl_quotelike>
That should get you started. If you have more questions, the Parse::RecDescent mailing list can be accessed via http://lists.perl.org.

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.


update:My PRD coding skills may be a bit rusty, and I didn't have time to test this code. Hopefully, if you can't get it to work, it'll at least be a model to start debugging from.
update2:OK, this works:
grammar: line(s?) /\z/ { $item[1] } line: <skip:'[ \t]*'> command arg(s?) "\n" { [$item[2], @{$item[3]}] } command: /\w+/ arg: /\w+/ | <perl_quotelike> { $item[1][2] }
the problem is that "perl_quotelike" doesn't match a bareword! So you have to have either barewords or quoted words.

Replies are listed 'Best First'.
Re: Re: Parse::RecDescent question
by linux454 (Pilgrim) on Dec 12, 2003 at 16:29 UTC
    Unfortunately, that doesn't work.
    The following is the output that I recieved:

    | grammar |Trying rule: [grammar] | | grammar | |"TestDirective | | |"true"\nNoValDirect +ive | | |"test"\n" | grammar |Trying production: [line /\z/] | | grammar |Trying repeated subrule: [line] | | line |Trying rule: [line] | | line |Trying production: [] | | line |>>Matched production: []<< | | line |>>Matched rule<< (return value: | | |[line]) | | line |(consumed: []) | | grammar |>>Matched repeated subrule: [line]<< | | |(1 times) | | grammar |Trying terminal: [/\z/] | | grammar |<<Didn't match terminal>> | | grammar |<<Didn't match rule>> |

    Note: Sorry for the formatting it just doesn't translate well
Re: &bull;Re: Parse::RecDescent question
by linux454 (Pilgrim) on Dec 12, 2003 at 20:40 UTC
    Yep, update2 works.

    Thank you so very much, merlyn.
    I greatly appreciate your time and effort.