From: Eric Mahurin Date: 2005-10-14T12:05:46+09:00 Subject: [ANN] grammar-0.5 Well, I'm finally doing a release of my grammar package: http://rubyforge.org/projects/grammar/ I also released cursor-0.9 to go along with it: http://rubyforge.org/projects/cursor/ Here are some of the features of it: * BNF-like grammar written directly in Ruby (by overriding +, |, *, &, ~, etc operators) * lexer and parser grammars are specified in exactly the same way - one parses characters and the other tokens * can write a lexer-free parser * may define tokens however is appropriate * variety of Cursor options for connecting lexer to parser * can put lexer and parser in different threads * defaults to one character/token lookahead, but can extend to arbitrary lookahead where needed * autogenerates flattened code by using a macro-like facility * ruby actions easily specified in blocks * lots of convienent Grammar methods to combine and manipulate grammars TODO: * error reporting needs work. File/line/column numbers is needed * Cursor::Producer (multithreaded lexer cursor) needs some love. It doesn't have a very robut interface. * various small API changes. need more examples to see what would be good to have. * better testing. only have partial random testing. I also have to samples that you can look at: - tcl interpreter: a complete tcl parser (no lexer needed) and interpreter written in under 150 lines of ruby code. The example fact.tcl shows a recursive proc being defined and used in tcl. - infix 2 postfix expression converter: shows a lexer and parser and how they can be multi-threaded. converts an infix expression into a postfix expression (looks like Joy) returned in a simple array. __________________________________ Yahoo! Mail - PC Magazine Editors' Choice 2005 http://mail.yahoo.com