@aengelberg: made some progress this weekend with my instaparse project! https://github.com/adzerk-oss/zerkdown
it's a work in progress of course
it does a braindead parsing of clojure maps/vectors
https://github.com/adzerk-oss/zerkdown/blob/master/src/adzerk/zerkdown/grammar.ebnf
feedback appreciated :simple_smile:
@micha this project is very cool
Does your ebnf allow [{]
?
not in a :CLJ
or :VEC
block
["{"]
would be ok though
<VEC-CHAR> = !(LSB | RSB | DQ) ANY-CHAR
looks like it would allow mismatched map delimiters inside it
oh interesting
yeah it's ambiguous
!(LSB | RSB | STRING | MAP) ANY-CHAR
would be nice there
then it would still allow mismatched quotes and delimiters because strings and maps don't successfully parse :simple_smile:
hmm
maybe (!(LSB | RSB | LCB | RCB | DQ) ANY-CHAR) | STRING | CLJ
yeah
i will try that
i am planning to do the recursion from clojure btw
i will parse one level of indentation, then for each :BLOCK
call insta again on the body
it seems like it will be straightforward, i hope
cool
Just make sure instaparse Failures are returned / shortcircuited properly :simple_smile:
how do you mean?
if a "sub-parse" returns a failure, then what?
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:
ah right
what did you mean before about strings and maps not successfully parsing?
negative lookahead = make sure this thing does not successfully parse
!STRING x
means no "complete well-formed strings" allowed, but you probably wanted "no double-quotes of any kind really"
and then you can add in | STRING
to allow well-formed strings
oh i see
i actually don't care about double quotes
i just don't want well formed strings, because those can legitimately contain {}[] etc
i'm not trying to fully parse the clojure data, i just need to know where it ends
i send it as a string and use clojure.core/read-string
on it later
that's fair, but if [{]}]
is allowed it's not exactly obvious where it ends :simple_smile:
haha yes
very interesting
anyway I don't think it's super hard to make the delimiters correct. (!(LSB | RSB | LCB | RCB | DQ) ANY-CHAR) | STRING | CLJ
That basically says "no double-quotes, UNLESS there is a well formed string"
yes that's awesome
testing was pretty easy to do, by configuring with different start rules
yeah. just don't forget negative testing :simple_smile:
ah right
yeah i didn't think of that
really cool idea. what is the intended use case for zerkdown?
well i want to use it for just about everything!
mostly for websites
but i can imagine using it for literate programming and things like that
but for making webapps it's really nice to have a "prose" syntax you can customize for your use case
like normally you have like
# My Title
that compiles down to
<h1>My Title</h1>
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>>
or even more complex things with behavior and everything, like forms and buttons