Fork me on GitHub
#instaparse
<
2015-08-17
>
micha14:08:46

@aengelberg: made some progress this weekend with my instaparse project! https://github.com/adzerk-oss/zerkdown

micha14:08:28

it's a work in progress of course

micha14:08:54

it does a braindead parsing of clojure maps/vectors

micha14:08:39

feedback appreciated simple_smile

aengelberg20:08:21

@micha this project is very cool

aengelberg20:08:44

Does your ebnf allow [{]?

micha20:08:15

not in a :CLJ or :VEC block

micha20:08:31

["{"] would be ok though

aengelberg20:08:05

<VEC-CHAR> = !(LSB | RSB | DQ) ANY-CHAR looks like it would allow mismatched map delimiters inside it

micha20:08:32

oh interesting

micha20:08:52

yeah it's ambiguous

micha20:08:24

!(LSB | RSB | STRING | MAP) ANY-CHAR would be nice there

aengelberg20:08:00

then it would still allow mismatched quotes and delimiters because strings and maps don't successfully parse simple_smile

aengelberg20:08:17

maybe (!(LSB | RSB | LCB | RCB | DQ) ANY-CHAR) | STRING | CLJ

micha20:08:42

i will try that

micha20:08:54

i am planning to do the recursion from clojure btw

micha20:08:24

i will parse one level of indentation, then for each :BLOCK call insta again on the body

micha20:08:10

it seems like it will be straightforward, i hope

aengelberg20:08:03

Just make sure instaparse Failures are returned / shortcircuited properly simple_smile

micha20:08:28

how do you mean?

aengelberg20:08:51

if a "sub-parse" returns a failure, then what?

aengelberg20:08:43

I imagine it will be most idiomatic to call insta/parse again within the transformer. But my point is, if a parse failure arises (malformed zerkdown) within that, you will need to propagate that error properly simple_smile

micha20:08:38

what did you mean before about strings and maps not successfully parsing?

aengelberg20:08:43

negative lookahead = make sure this thing does not successfully parse

aengelberg20:08:11

!STRING x means no "complete well-formed strings" allowed, but you probably wanted "no double-quotes of any kind really"

aengelberg20:08:24

and then you can add in | STRING to allow well-formed strings

micha20:08:51

i actually don't care about double quotes

micha20:08:10

i just don't want well formed strings, because those can legitimately contain {}[] etc

micha20:08:39

i'm not trying to fully parse the clojure data, i just need to know where it ends

micha20:08:59

i send it as a string and use clojure.core/read-string on it later

aengelberg20:08:20

that's fair, but if [{]}] is allowed it's not exactly obvious where it ends simple_smile

micha20:08:21

very interesting

aengelberg20:08:29

anyway I don't think it's super hard to make the delimiters correct. (!(LSB | RSB | LCB | RCB | DQ) ANY-CHAR) | STRING | CLJ

aengelberg20:08:40

That basically says "no double-quotes, UNLESS there is a well formed string"

micha20:08:08

yes that's awesome

micha20:08:36

testing was pretty easy to do, by configuring with different start rules

aengelberg20:08:55

yeah. just don't forget negative testing simple_smile

micha20:08:19

yeah i didn't think of that

aengelberg20:08:13

really cool idea. what is the intended use case for zerkdown?

micha21:08:56

well i want to use it for just about everything!

micha21:08:02

mostly for websites

micha21:08:14

but i can imagine using it for literate programming and things like that

micha21:08:52

but for making webapps it's really nice to have a "prose" syntax you can customize for your use case

micha21:08:37

like normally you have like

# My Title
that compiles down to
<h1>My Title</h1>

micha21:08:21

but what if you need something like

<h1>My Title <small>The Best Thing Ever</small></h1>
i want to be able to just define a new inline tag for that, like
# My Title <<The Best Thing Ever>>

micha21:08:38

or even more complex things with behavior and everything, like forms and buttons