instaparse

If you're not trampolining your parser, why bother getting up in the morning?
sova-soars-the-sora 2020-02-27T16:22:23.006500Z

@mmeix it looks to me at first glance that you could make some rules span = <span> val </span> paragraph = <p> val </p> val = paragraph* | span* | val [editS: added stars to p and span in val]

sova-soars-the-sora 2020-02-27T16:22:39.006900Z

the last rule allows recursion, which can infinitely nest spans or p's

sova-soars-the-sora 2020-02-27T16:22:59.007400Z

notice how i defined the rigid components of the grammar on the right-hand side, with my variable, and how i use variable names only on the left-hand side.

mmeix 2020-02-27T16:27:30.007700Z

That looks like a good recipe. Thanks!

sova-soars-the-sora 2020-02-27T16:29:51.008400Z

@mmeix http://instaparse-live.matt.is/#/-M16TrdGzPQ0FFLRyCyd/v1

sova-soars-the-sora 2020-02-27T16:30:07.008800Z

i had to make sure it works before setting you out

sova-soars-the-sora 2020-02-27T16:30:33.009300Z

notice how there can be multiple valid parses with the recursion now.

sova-soars-the-sora 2020-02-27T16:32:47.010400Z

you'll probably need to be creative with the output to get rid of tags you don't need 😃 i forget exactly how we would delete unnecessary strings in the grammar itself, there's a way with rules i think, it might just be mathematical though lol

mmeix 2020-02-27T16:49:20.011100Z

Getting rid of tags is done by enclosing them with <…>

mmeix 2020-02-27T16:49:38.011500Z

Thanks for the gist!

mmeix 2020-02-27T16:51:52.013400Z

Now I’m thinking, if it would be possible to get a general solution without enumerating all possible tags (span, p , …). It would need to somehow remember the tag name until its closing cousin arrives

mmeix 2020-02-27T16:53:16.013800Z

Didn’t know http://instaparse-live.matt.is ! Great tool!

👍 1