Reputation: 5545
whitequark recently gave an accurate answer about how to get a ruby AST : the answer is Ripper, included in standard Ruby library.
However, I played a little with Ripper, but I have not find a documentation about the content/structure of the AST itself.
So my question is : where can I find a concise documentation about Ripper sexp output ?
Upvotes: 4
Views: 414
Reputation: 23071
No explicit documentation on Ripper exists, as Ripper is just an interface to MRI's yacc/bison parser. You can read the source, through; all the identifiers mentioned with %type <node>
may appear in Ripper's sexps.
The MRI sources aren't an easy read, through, and I'd recommend determining the structure by trial and error: it may actually be faster that way.
You may be interested in this article, through, and also YARD uses some code based on Ripper. While that's not exactly what you need (i.e. the docs), these links contain some useful clues.
Upvotes: 2