Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Parse::RecDescent: how does <matchrule:> 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.


Comment on Re: Parse::RecDescent: how does <matchrule:> work?
Download Code
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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1017668]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (8)
As of 2014-12-18 03:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (41 votes), past polls