From: Clifford Heath Date: 2008-01-28T19:34:57+09:00 Subject: Re: Treetop parser (or PEG in general?) questions Phrogz wrote: > require 'rubygems' > require 'treetop' > > Treetop.load "t1.treetop" > @parser = T1Parser.new > @root = @parser.parse( "Hi 123\n\n" ) Just a tip: Treetop now uses my Polyglot gem, which hooks require, so that instead of calling "Treetop.load 't1.treetop'", you can just say: require 'treetop' require 't1' If the .rb file is found first, that'll be loaded, if not, treetop will compile 't1.treetop' (or 't1.tt', whichever you use). In my CQL parser, I have a file cql.rb, which does the require 'treetop' and require 'CQLParser', and also uses Polyglot to define a CQL load function, so if you have a file "model.cql", you can just: require 'cql' require 'model' and the model.cql file is compiled by the CQL parser (which itself is created dynamically by Treetop if needed). Cute stuff. Clifford Heath.