astexplorer icon indicating copy to clipboard operation
astexplorer copied to clipboard

Adding Ruby parser

Open peter-leonov opened this issue 6 years ago • 4 comments

Hi guys,

Thanks for the inspiring and useful project! Learning babel transformations with it is a pure joy 👍

Are you interested in adding a Ruby parser? I've developed ruby-parser.js (live demo) for fun in pure JavaScript. It can also be of use to someone learning Ruby. I'm fine with making a PR if you find it interesting.

peter-leonov avatar Feb 28 '18 17:02 peter-leonov

In general yes, though the output of the parser doesn't seem to be suited very well for astexplorer. Nodes are usually objects with types.

fkling avatar Mar 07 '18 05:03 fkling

IMHO, converting S-expressions to node is a quite easy task. Are there any other requirements you see as a must?

peter-leonov avatar Mar 07 '18 08:03 peter-leonov

One thing that people find most useful is the fact that we can highlight the corresponding source text of a node and "focus" the corresponding code when moving the cursor around in the source text.

To do this we need to know a node's start and end index in the source text string.

fkling avatar Mar 07 '18 13:03 fkling

True, I find it awesome too :) As far as I remember the AST part of my ruby parser lacks location information, but the lexer does store token locations. So it wouldn't be that hard to make AST part location aware too. Will check it out.

Thanks for a quick and informative reply!

peter-leonov avatar Mar 09 '18 13:03 peter-leonov