Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Parse::RecDescent: how does work?

by sundialsvc4 (Abbot)
on Feb 07, 2013 at 14:28 UTC ( #1017668=note: print w/replies, xml ) Need Help??


in reply to Parse::RecDescent: how does <matchrule:> work?

Question #1 is ... what do you want?   (No, seriously.)   What interpretation of these three strings do you want to be “correct?”   Are they three distinct cases, or examples of the same one?

The interpretation that I guess you probably want is that there are only three tokens of interest:   '{', '}', <ident>.   The grammar, in quasi-BNF syntax, would then become:

<statement> ::= <ident> | '{' <statement>+ '}' ; <ident> ::= /[A-Za-z0-9]/ ;

This would be a simple left-tail recursive case.   But I am sure that my syntax is not actually sufficient for your needs, because if it were, you would scarcely need a parser with which to solve it.

Please provide a full representative example of the type of data you need to parse, and we’ll help you write the proper grammar-mojo.   It does take practice.

Replies are listed 'Best First'.
Re^2: Parse::RecDescent: how does <matchrule:> work?
by 7stud (Deacon) on Feb 08, 2013 at 03:41 UTC

    Please provide a full representative example of the type of data you need to parse, and we’ll help you write the proper grammar-mojo. It does take practice.

    The sample text and my finished grammar are over here.