Glen Starchman sent the following bits through the ether: > With something like that, it might not be too far of a stretch to > create a Ruby equivalant of the kjParser project (the Python parser > generator). One of the the most recent crazy things I've done is to try to rewrite the Ruby parser/lexer in Perl using the Parse::Yapp module. The module allows yacc-like grammars and is fairly fast. I had a simple Ruby parser in Perl up in about two hours. The tricky bit is the lexer (see that lovely yylex routine) and the lexer state (lex_state), which is sometimes set in the grammar actions. Hence, you need to look at the actions ;-) Summary: it's entirely possible to implement a parser for Ruby from Ruby's parse.c. If you start simple, you get a simple parser which can only parse simple code. By slowly hacking on the lexer, you can add more and more features. A complete parser? Bet you I never get there, but getting most of the way is pretty good. Leon ps so why do you think I'm writing a Ruby parser in Perl? ;-) -- ... And tomorrow will be like today, only more so