This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-02-13
Channels
- # aleph (3)
- # announcements (2)
- # aws (48)
- # babashka (93)
- # beginners (101)
- # bristol-clojurians (1)
- # cider (3)
- # clj-kondo (17)
- # cljdoc (1)
- # cljsrn (3)
- # clojure (208)
- # clojure-dev (2)
- # clojure-europe (19)
- # clojure-italy (18)
- # clojure-losangeles (16)
- # clojure-nl (8)
- # clojure-spec (21)
- # clojure-sweden (8)
- # clojure-uk (57)
- # clojuredesign-podcast (6)
- # clojurescript (10)
- # code-reviews (6)
- # core-typed (1)
- # cryogen (7)
- # cursive (38)
- # datomic (34)
- # duct (13)
- # emacs (13)
- # fulcro (16)
- # funcool (2)
- # graalvm (1)
- # lambdaisland (5)
- # luminus (8)
- # lumo (1)
- # malli (2)
- # off-topic (12)
- # pathom (9)
- # re-frame (13)
- # reagent (11)
- # ring (3)
- # shadow-cljs (15)
- # sql (19)
- # tools-deps (61)
- # xtdb (23)
Thank you for your talk last night @borkdude! Nice to hear the background story of all the things you have created π Great job!
@borkdude when you wrote edamame did you consider using an instaparse parser? I'm considering this now, but I wonder if there might be problems with Graalvm
I'm trying to write a php parser π
The prototype can be slow
Also edamame misses some cases
π I am not worried
Actually it doesn't miss anything, but it doesn't give me enough information
e.g.`(edamame/parse-string "(((" {:all true})` doesn't tell me how many brackets are open
π I am not worried
I'm worried that I spend too much time on a parser that I will never use, but good point anyway
what is an example of what you are trying to parse? are you parsing html, or clojure code or a mix?
fooo <?php (if (> 1 10000) ?> 1 is not bigger than 1000 <? ?> 1 is smaller than 10000 <?php ) ?>
the basics are simple. The tricky part is when you have to count open brackets etc
Does edamame give a lazy sequence?
Because given the "performance first", the biggest performance hit is reading strings π
If you have a big template you just want to flush stuff
you don't need a lazy sequence per say, you can just use a read-next from the stream
kind of construction
yes sorry that's what I mean. Does edamame have that?
but not in the public API. you can just use it like it's used in sci / babashka though, they use it
This could be useful for tooling. For example, at Chlorine I'm currently using rewrite-cljs
to be able to parse Clojure code and detect "blocks and top-blocks" but it can be slow...
ah cool good to know
I'm looking for an input stream here https://github.com/borkdude/edamame/blob/master/src/edamame/impl/parser.cljc
note that edamame only parses clojure code, I don't know what stuff you are parsing outside the templating things
hmmm ok than it doesn't work
everything outside of <?php ?> tags can be anything
and between as well
@jeroenvandijk take a look here: https://github.com/borkdude/sci/blob/aca20d1d85b9c02b0c39157963b14e6fea185ad1/src/sci/impl/interpreter.cljc#L551
> than it doesn't work yeah, that's why I suggested forking edamame so you can just skip until the first templating part, etc, make tweaks
ah awesome, that looks useful
alternatively you can use edamame within your own parser. when you first parse until after the first <?php
in your own parsing logic and then invoke edamame on the same reader, etc, that should also maybe work
That's my current implementation. It becomes difficult with nested sexpressions and tags
so simple cases work, but when you start doing things like <? (if foo ?> a <? (if bar ?> that <? )) ?>
it becomes more difficult. You also need to count the brackets for proper error messages. My current approach is to collect the string and evaluate after the closing ?>. The parser for this is so big that my repl didn't like it. So I thought maybe i should try instaparse π
Maybe I should use instaparse to collect the tags and the rest with edamame for the proof of concept
I'll try that
haha thanks
Probably a better idea indeed
But that has other downsides
I'll not give up yet
fwiw bootleg does html templating as a CLI using sci: https://github.com/retrogradeorbit/bootleg
I'll have a look. Thanks!
bootleg doesn't really do that php escapey thing itself. If you were using bootleg you would do that in a template, like a selmer template, which bootleg supports
Ah thanks for confirming @retrogradeorbit
Did you build the bootleg templating to be super performant or is it more a convenience tool exploiting the quick boot time of Graalvm?
it is very performant but that was not an aim. Startup time was essential, though.
I built it because I wanted to build static websites. I appraised all the existing (mostly JS) static site builders and was frustrated by their complexity.
They all wanted me to learn a whole bunch of things particular to their framework. I didn't want to learn anything new. So I thought, if only I had a command line tool that would just take hiccup and render it as html. That's most of what I need.
It was also a project for me to experiment with the technology stack. To combine graal native images with @borkdude s sci project and put it through its paces.
If you do end up using it and the source of your site is open source then I would love to expand the example section.
I know of a few people using it but for commercial sites and they are unwilling to opensource their code.
I might use it when I have some time and enough motivation to get off my jekyll thing
Thanks for explaining @retrogradeorbit
I might also do my personal website in it, since it's just a single html file which I edit manually (last update 3 years ago)
Oh the other motivation was to combine markup. So I had a site template already done by a designer. Html and CSS and some JS. And I had expanded his JS (jquery)
so its good at letting you mash together a bunch of different formats, styles, templates and glue it all together
Ok I have something working. I've written it in a true php spaghetti code style as well https://gist.github.com/jeroenvandijk/fb4cafb5022cead538cde1c7c6e39c4d π
I've added a case that is currently not catched by Sci. https://github.com/borkdude/sci/pull/265/files Thinking about it a bit more validation the AST before running it might make more sense?
ok cool, fixed it i think