Fork me on GitHub
#instaparse
<
2016-08-29
>
aengelberg00:08:49

@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> = #'[[email protected]]+'
    <ws> = <#'[\r\n\\s]+'>
    <ws-line> = <#'[^\r\n\\S]+'>
    <ows> = <#'\\s*'>
    <content> = #'^([^*].*)?'"))

seylerius00:08:47

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

seylerius00:08:20

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

seylerius01:08:34

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.

seylerius01:08:21

(parse (slurp "")) should work for testing.

seylerius01:08:35

(Thanks a ton for the help, BTW)

seylerius01:08:52

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

seylerius01:08:52

Lol, whoops. Reversed my pound sign and bracket

seylerius03:08:13

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

seylerius04:08:09

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

aengelberg04:08:45

@seylerius what's the repro case?

seylerius04:08:41

(parse (slurp "")) returns a seq, not a vector with a root node.

aengelberg04:08:13

looks like function reducing doesn't exist

aengelberg04:08:45

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

seylerius04:08:52

Cleared that up.

seylerius04:08:57

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

seylerius04:08:02

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

aengelberg04:08:04

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

aengelberg04:08:32

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

seylerius04:08:21

@aengelberg: Maybe make strings pass straight through transform?

aengelberg04:08:22

I can confirm that's a bug

aengelberg04:08:28

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

aengelberg05:08:55

oops, didn't link properly... edited

seylerius05:08:00

Downloaded, testing.

seylerius05:08:08

It works! Thanks, @aengelberg!

seylerius18:08:06

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

seylerius18:08:07

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

aengelberg18:08:11

@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.

seylerius19:08:51

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).

aengelberg19:08:34

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

seylerius19:08:17

Awesome. I'll check it out