peg-trees and you

Posted by s.f. on June 11, 2009

Recently at work, I needed to parse ugly data files from an ancient classified-ads database that a predecessor devoted an entire Ruby application to. While painstakingly building regexes, I remembered looking at Treetop a few months ago.

Treetop is a Ruby library for writing Parsing expression grammars. PEGs are another way of constructing grammars and could be thought of as super-regexes: they don’t allow left-lookup or ambiguity in the parse tree, making them not so useful for natural language but killer for computer languages. Around 40 lines of code and 7 rules took the place of what the original author devoted dedicated tempfiles and regex arrow code to.

That being said, PEGs are conceptually harder to get grips on, and Treetop’s documentation is not entirely clear on some hangups you might find. Most of which you can solve using the excellent mailing list, but I know I wished during the past few days that I could get it summed up for me.
Continue reading…

Io gathering speed

Posted by s.f. on January 07, 2008

_why had a neat post on Io today, showing off a cool introspection+meta trick that I wasn’t aware of. And since it’s _why, the Io mailing list has shown another flurry of activity, which I’m hoping will snowball into another group of fresh users, to eventually reach that goal of “1.0″..

Interestingly enough, Io was the language I learned right after Ruby, for much the same reason: trying to get a good grip on concurrency in simulation environments, after too much exposure to UnrealScript.
 (And along those lines, Thunder and Lightning still stands as the only major game project using Io as a scripting language).