Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??


I have a kind of a backup solution that requires parsing for certain case (mysql insert statement).

Currently this is implemented with Parse::RecDescent as it took me some while to get feet wet with its grammars. But the parser seems to be the performance bottleneck so recently I decided to try the brand new Marpa::XS and it cracked my nut head to make it work for me.

I am still very sure it should be the right tool for the case but just see no any (simple) explanation on how to turn the single line of input into the data structure ( arrayref of arrayrefs ). E. g.,:

INSERT INTO `tehtable` ( `field00`, `field01` ) VALUES ( 123, `abcd\'e +fgh` );
into arrayref like this:
[ [ qw/field00 field01/ ], [ 123, 'abcd\'efgh' ] ]

I can see the Marpa::HTML code but it's not that explanarory yet to me since it's about much more complicated than what I need, e. g. it does use that mysterious BNF stuff that I'm very unsure I will need for that particular task.

Marpa's 'Calculator' example isn't useful for me neither because it takes input token by token. Does it mean to me that I need to split my INSERT statement by myself for Marpa's input?

I have also tried with SQL::Translator but it seems to parse only the database schemas, e. g., CREATE TABLE only. Am I wrong on that?

Thank you.

In reply to Marpa::XS for SQL INSERTs? by petr999

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
    Domain Nodelet?
    and the web crawler heard nothing...

    How do I use this?Last hourOther CB clients
    Other Users?
    Others imbibing at the Monastery: (2)
    As of 2024-07-23 21:41 GMT
    Find Nodes?
      Voting Booth?

      No recent polls found

      erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.