feed

Jan  18  Introduction by Chris Poirier • in Announcementspermalink

So, RCC is my attempt to write an LR compiler compiler.  I’m doing a consumer-oriented database system and I need several languages to control the system.  Last June (2007), I had a look around for an existing tool I could use, and wasn’t happy with the options.  My requirements were fairly simple:

  • I needed to be able to generate a parser in (at least) Ruby and Objective-C
  • I needed the parser to produce reasonable-quality error messages
  • I needed the generator to have good documentation or readable code, so I could figure out how to use it (and how to fix it, should need arise)
  • I didn’t want to have to do a lot of math to get my grammar to work with the generator

Anyway, after several frustrating days with existing systems, I decided to write my own.  I figured it would take at most a month, and that I could live with that investment.  So, naturally, it’s seven months later and I’m about ready to release it. 

D’oh!

Of course, RCC (short for Ruby Compiler Compiler — hey, I poured all my creativity into the code :-P ) has grown a bit since I started it.  It now generates your lexer and AST, as well as the parser, and includes facilities to do simple AST transformations during construction (to reduce the amount of stuff you have to do to it after).  The system also includes a grammar interpreter that explains exactly how your grammar deals with a particular source file, and why.  This should make debugging grammars a lot easier.

Finally, the biggest feature (it sure as hell took the most time!) is the error recovery system, which attempts to figure out what the programmer had intended to type whenever an error is encountered, so error messages more reliably direct the user to the real problem.

In terms of status, I’m presently working on a pre-release refactoring of the RCC code base.  The biggest aspect of this is a redesign of the grammar description language, which used to look a bit like yacc, and doesn’t any more (some of the assumptions I started with are no longer helpful).  During development, the grammar was loaded by an ad hoc parser I wrote for the purpose.  It was rather ugly, and didn’t produce the friendliest of error messages.  The new grammar is being parsed by RCC’s grammar interpreter, so you get all the benefits of the error recovery and automated help systems.  Yay!

More soon . . . .  :-)

Related Links

in Announcements:
on site:

Discussion: No comments

Jump to comment form | comments rss | trackback uri

Leave a comment

Markdown: The kinds of formatting markup you'd use in an email will probably work here. For more details on what you can do, check out the Markdown docs.

What of these number is prime? 10, 11, 18, 22 (required)


Site copyright 2007-2008 Chris Poirier.       Powered by Wordpress.       Entries RSS Comments RSS Validate Log in