I’m trying to parse some Ruby code from C#… I just want to scrape out
the class/module names and the methods defined for each.
Assuming I first throw away comments and string literals, I figured a
couple of regular expressions to pull out the class and method names
would do the trick.
But then I realized I need to handle the possibility of nested classes
(and knowing which methods belong to the inner class, and which ones
belong the outer class), and my code got real complicated real fast.
Some googling didn’t reveal much to me, but I’m hoping someone will know
of a well-known algorithm or regular expressions that will help me out?
Again, I just need to know the classes defined in a file and the methods
that go with them. No need for 100% perfection, just something that
will work across 80% of the Ruby files out there.