Conversation
| SPC = #'\\ '+ | ||
| APPLY = #'^[^@\\ ][^}\\ ]+' | ||
| " | ||
| )) |
There was a problem hiding this comment.
@Odie I think that you might want to give instaparse a try.
There was a problem hiding this comment.
Well, I think mustache is sufficiently simple to deal with by hand. (Famous last words?)
Instaparse is really fantastic, but my last impression of it was “really magical, but maybe somewhat slow”. It might have been due to an ambiguous grammar that caused it to try going down two separate paths of the grammar tree though.
Anyway, since there are no complicated grammatical structures, and mustache is already fully spec’ed out, I’ll try seeing it through the rest of the way.
| (:require [hopen.renderer.xf :as rxf] | ||
| [instaparse.core :as insta])) | ||
|
|
||
| (declare parse) |
There was a problem hiding this comment.
Can be avoided if the render function can be defined after the parser.
Usually, the declare is only used when there is a cross recursion between 2 functions defined at the root level.
| (declare parse) | ||
|
|
||
| ;; TODO test case | ||
| (defn render |
There was a problem hiding this comment.
I would suggest to let the user do his own composition between the renderers and the parsers.
If this function is here just for testing, it makes sense to move it to the test namespace.
| STR = #'[^{}]+' | ||
| SILLYSTR = OBK SILLY CBK | ||
| OBK = '{' | ||
| CBK = '}' |
There was a problem hiding this comment.
I would suggest using non-abbreviated names or less abbreviated names, to ensure that anybody can easily read the source code.
OPEN_BLOCK, CLOSE_BLOCK for example.
There was a problem hiding this comment.
As a side note: the casing (upper-case / lower-case) does not matter for instaparse.
| FN = FNNAME APPLIES* | ||
| APPLIES = SPC | FCTX | APPLY | ||
| FNNAME = #'[a-zA-Z0-9\\-]+' | ||
| SPC = #'\\ '+ |
|
@hylisd So far, so good. I am impressed by the small size of the code. More tests would be needed, to parse different kind of forms in the templates. |
# Conflicts: # test/hopen/runner.cljs
This is a basic implementation about silli-j.