Closed enebo closed 5 years ago
Thanks Tom! This looks great 🍻
I'm going to look into following up with wrapping the implementation-specific nodes with a ActionviewPrecompiler::ASTParser::Node
class. I'm also interested in supporting ripper or whitequark/parser as a third backend, but I'd love to keep this without dependencies beyond ActionView.
Got a working JRuby test for CI https://github.com/jhawthorn/actionview_precompiler/runs/125774749 🎉
@jhawthorn If ripper works then that is a good way to reduce the dependencies. If it is fast enough then it would be a single back end. My motivation was to see how different the two APIs are...the drift is substantial although I think supportable.
@jhawthorn I'm curious, why do you want to avoid the dependency on whitequark/parser? (given that ActionView itself already has many dependencies)
I think the parser
gem would provide a robust and easy-to-use API, portable across both Ruby implementations and versions.
Currently, RubyVM::AbstractSyntaxTree
is in a rather unclear state: https://bugs.ruby-lang.org/issues/14844, and the current code would need yet another backend for supporting other Ruby implementations or older MRI versions (if desired).
ripper
would also be a more portable alternative, although with a less convenient API than the parser
gem.
👍 I'm open to using ripper.
I originally did write this using parser
, and it's unfortunately way too slow for how I'd like to use this.
@jhawthorn Makes sense, thanks for replying.
As a ruby core developer who has used RubyVM::AST
, ripper
and parser
, I personally prefer parser
, but think that either of those gems is a significantly better option than RubyVM::AST
which could change and/or be dropped in any version of Ruby. So, please don't depend on RubyVM::
in production code, we will not shield you from pain if such features are dropped/changed.
RubyVM one. Mostly this starts to abstract the differences into an ast_parser helper which can be included.
Another future experiment is to see how possible it would be to swap out both of these to using something like Ripper.