instaparse

If you're not trampolining your parser, why bother getting up in the morning?
aengelberg 2016-08-29T00:05:49.000063Z

@seylerius This approach handles a variety of potential characters before the tags, at the expense of speed, since it parses every single character on the header line to get around regex greediness.

(def headlines
  (insta/parser
   "<S> = token (ows token)*
    <token> = section / content
    section = h (ows content)*
    h = ows stars <#'\\s+'> (todo <#'\\s+'>)? title
    <title> = (#'.'+ ws-line? tags) / #'.+'
    stars = #'^\\*+'
    todo = #'TODO|DONE'
    tags = <':'> (tag <':'>)+ ws
    <tag> = #'[a-zA-Z0-9_@]+'
    <ws> = <#'[\r\n\\s]+'>
    <ws-line> = <#'[^\r\n\\S]+'>
    <ows> = <#'\\s*'>
    <content> = #'^([^*].*)?'"))

seylerius 2016-08-29T00:08:47.000064Z

Probably be an uncommon usage, but technically legal, @aengelberg. Probably ought to do something like this. Hmmm.

seylerius 2016-08-29T00:14:20.000065Z

Yeah, that works. Definitely going to need the follow-up concatenation I was planning on.

seylerius 2016-08-29T01:19:34.000067Z

Okay, another puzzle for ya, @aengelberg. In this latest push, why isn't priority getting picked up? I've cleaned up some of the names and added an overall parse function that takes a string, to simplify testing.

seylerius 2016-08-29T01:20:21.000068Z

(parse (slurp "<http://sample.org|sample.org>")) should work for testing.

seylerius 2016-08-29T01:20:35.000069Z

(Thanks a ton for the help, BTW)

seylerius 2016-08-29T01:25:52.000070Z

A priority is defined as a letter preceded by a pound sign, in square brackets. [#A] or [#z], for example.

seylerius 2016-08-29T01:39:52.000071Z

Lol, whoops. Reversed my pound sign and bracket

seylerius 2016-08-29T03:52:13.000072Z

@aengelberg: Can you help me figure out why the parsed sample is not registering as compliant hiccup to insta/transform?

seylerius 2016-08-29T04:29:09.000073Z

Okay, I see that it's looking for a root node. Tried to unhide the document node, but it's not showing up.

aengelberg 2016-08-29T04:29:51.000074Z

@seylerius lemme take a look

seylerius 2016-08-29T04:30:11.000075Z

Thanks.

aengelberg 2016-08-29T04:32:45.000076Z

@seylerius what's the repro case?

seylerius 2016-08-29T04:33:41.000077Z

(parse (slurp "<http://sample.org|sample.org>")) returns a seq, not a vector with a root node.

aengelberg 2016-08-29T04:34:13.000078Z

looks like function reducing doesn't exist

aengelberg 2016-08-29T04:34:45.000079Z

CompilerException java.lang.RuntimeException: Unable to resolve symbol: reducing in this context

seylerius 2016-08-29T04:36:52.000080Z

Cleared that up.

seylerius 2016-08-29T04:36:57.000081Z

Thanks

seylerius 2016-08-29T04:37:57.000082Z

Still isn't giving me a root node, though.

seylerius 2016-08-29T04:39:02.000083Z

([:author..., rather than [:document [:author...

aengelberg 2016-08-29T04:41:04.000084Z

interesting. transforming on a sequence should work. I think you may have found a bug in instaparse.

aengelberg 2016-08-29T04:41:32.000085Z

The fact that there's a string in the uppermost level is what's throwing it off.

seylerius 2016-08-29T04:43:23.000086Z

Fascinating

seylerius 2016-08-29T04:46:21.000087Z

@aengelberg: Maybe make strings pass straight through transform?

aengelberg 2016-08-29T04:46:22.000088Z

I can confirm that's a bug

aengelberg 2016-08-29T04:46:28.000090Z

Yeah, that's what I'm about to do.

seylerius 2016-08-29T04:46:32.000091Z

Awesome

aengelberg 2016-08-29T05:11:35.000092Z

@seylerius https://github.com/Engelberg/instaparse/pull/145

aengelberg 2016-08-29T05:19:55.000096Z

oops, didn't link properly... edited

seylerius 2016-08-29T05:29:00.000097Z

Downloaded, testing.

seylerius 2016-08-29T05:29:08.000098Z

It works! Thanks, @aengelberg!

seylerius 2016-08-29T18:30:06.000099Z

@aengelberg: Yep, that worked perfectly. What's the release schedule on that, out of curiosity?

seylerius 2016-08-29T18:33:07.000100Z

In the meantime, I'm moving on to adding additional parsers (drawers, blocks, footnotes, lists, tables, to name a few).

aengelberg 2016-08-29T18:56:11.000101Z

@seylerius For instaparse we prefer to merge fixes, bump version numbers / changelogs, and deploy to clojars all at once. And only my dad has the power to do the last part. So whenever he gets around to doing that is when I'd expect to see the latest version. Should be sometime today.

seylerius 2016-08-29T19:08:51.000102Z

Shiny. Looking forward to it. Also, shiny that y'all are a father-son team. Be cool if one of my kids coded with me (after I have some).

aengelberg 2016-08-29T19:31:34.000103Z

Thanks. It's fun! You may enjoy the Clojure/west 2014 instaparse talk, which provides some backstory on the collaboration

seylerius 2016-08-29T19:42:17.000104Z

Awesome. I'll check it out