Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Since I wrote PPI, I probably have struggled against more anti-BNF things that most. So here's a few.

1. Source Filters
use Acme::Buffy; BuFFy BUFfy bufFy Buffy...
You can't handle source filters in BNF for obvious reasons.

2. BEGIN blocks

You can't (code) parse Perl without also executing it.
BEGIN { die if is_christmas($today); }
That code is legal Perl every day of the year except for Christmas, when it is not legal Perl code.

3. Cannot be parsed when isolated
use Some 'function'; function 'foo', 'bar';
That code could mean either function('foo'), 'bar' or function( 'foo', 'bar' ) depending on what is in the Some module.

If isn't installed on your machine, how are you to know.

PPI does what it does using more evil than Perl itself, and certainly more heuristics. It makes up for it's guesses by promising that what it writes out is ALWAYS character for character identical to what it read in, unless you change something.

So if it has a problem, it won't break as long as you don't change that part of the tree.

There's probably more reasons, but for me those are the big three.

In reply to Re^3: Perl not BNF-able?? by adamk
in thread Perl not BNF-able?? by anonymized user 468275

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

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2021-09-17 13:43 GMT
Find Nodes?
    Voting Booth?

    No recent polls found