4 ms·
Why not just write a ruby to JS transpiler? I imagine the yacc grammar could be translated to jison (http://zaach.github.io/jison/ http://zaach.github.io/jison
by niggler 14y ago
Why not just write a ruby to JS transpiler? I imagine the yacc grammar could be translated to jison (http://zaach.github.io/jison/ http://zaach.github.io/jison/) , and it's really easy to grab those script tags (e.g. https://github.com/Niggler/scriptify.js/blob/master/scriptify.js https://github.com/Niggler/scriptify.js/blob/master/scriptif...)
- vidarh 14y agoLast time I looked, which admittedly was one of the 1.8.x versions of Ruby, the bison grammar for MRI was 6000-7000 lines including thousands of lines of C code that included a lot of state tracking for the parser to handle the more obnoxious parts of the grammar... Hopefully that's improved in 2.0... Or maybe the Rubinius or jRuby parsers might be better starting points (haven't looked at either)
- stormbrew 14y agoNope, it's still incredibly awful. Most of those thousands of lines aren't actually the grammer but the hand-written, full of exceptions, lexer. It has, if anything, gotten even worse thanks to allowing method selectors (the '.') to be placed on the next line, and the (key: value) syntax for hash args. And all working active ports of Ruby use either the MRI lexer/parser verbatim or a mostly direct port of it. The JRuby port has the good graces to at least break the thousands of lines of lexing out into a few basic functions based on the first char of the token rather than leaving it in a giant switch statement, though.