Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
I'm only vaguely familiar with parse::recdescent, but I'll try to give some general hints.
* Is it necessarily possible to reverse the data through the grammar to get the command line?
No. At least, for most grammars there are multiple variations of code that will end up as the same syntax tree / data structure. IOW if the original input is unambiguous, you should be able to reverse it into something equivalent but not necessarily character-for-character the same. If the input is ambiguous you'll have more problems.

* or is this only possible for special grammars?
I think in theory it would be possible to re-generate equivalent source data for any parse tree, given unambiguous grammar and input, but I'm not sure that parse::recdescent makes it easy (or even possible) to do that given only the grammar and the output data.

Looking at your code it doesn't seem *that* difficult to come up with something to handle your cases, though you may have to deal with some duplication of grammar rules.

In reply to Re: Reversible parsing (with Parse::RecDescent?) by Joost
in thread Reversible parsing (with Parse::RecDescent?) by goibhniu

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

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others about the Monastery: (10)
    As of 2018-02-22 13:56 GMT
    Find Nodes?
      Voting Booth?
      When it is dark outside I am happiest to see ...

      Results (293 votes). Check out past polls.