Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Yes, the context-free idea isn't a logical necessity for expressing in BNF, because that alone can be conquered by expressing the different context types as alternative BNF definitions.
How so? Could you give a BNF snippet that would express how to generate a forward declaration of a subroutine that matches the signature of the actual subroutine definition?
Rather, the most compelling arguments that have been made in reply here come from those perl syntax elements which overpower the nearby context, such as (amongst other examples given by various people) the e-regexp modifier.
The /e regexp modifier? In which way does that "overpower" nearby context? Couldn't that construct be parsed with the following BNF snippet:
non-a-slash: # string that doesn't contain a non escaped slash SUBSTITION: non-eval-substition | eval-substitution non-eval-substitution: 's' '/' not-a-slash '/' not-a-slash '/' non-e-modifiers +(*) eval-substitution: 's' '/' not-a-slash '/' slashless-code '/' e-modifiers( +*) non-e-modifiers: 'x' | 's' | 'm' | 'g' | 'x' | 'i' e-modifiers: 'e' | non-e-modifiers
Assuming you could create BNF for Perl code (and then you can create BNF for Perl code that doesn't contain a slash).

Grammars expressed in BNF can be parsed with recursive decent parsers (which do not have a fixed lookahead) - and if you can create a parser for all other Perl constructs, I can parse the difference between s/// and s///e.


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

Title:
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 How to display code and escape characters are good places to start.
Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (7)
As of 2024-03-28 18:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found