(Stolen from http://www.scifac.ru.ac.za/coco/ )
Coco/R combines the functionality of the well-known UNIX tools lex and yacc , to form an extremely easy to use compiler generator that generates recursive descent parsers, their associated scanners, and (in some versions) a driver program, from attributed grammars (written using EBNF syntax with attributes and semantic actions) which conform to the restrictions imposed by LL(1) parsing (rather than LALR parsing, as allowed by yacc ). The user has to add modules for symbol table handling, optimization, and code generation in order to get a running compiler. Coco/R can also be used to construct other syntax-based applications that have less of a “compiler” flavour.
Coco/R(uby) is a port of Coco/R to ruby and generates pure ruby parsers and scanners. This version of Coco/R is not related to Mark Probert’s version ( http://raa.ruby-lang.org/list.rhtml?name=coco-rb ).
This version of Coco/R generates pure ruby. Mark’s version generates C for ruby extensions. If you find this version too slow, you might want to check out Mark’s. If however, you need pure ruby or can’t deploy where there is a C compiler, you finally have an LL solution.
Q: Size of Grammar
Is there a limit to the size of the grammar that one can use with Coco/R(uby)?
I’ve been trying to generate a parser for the Accel EDA ASCII file format, and it’s reporting the following error:
– SymTab fatal error
– too many symbols
Stack Trace = ./Tab.rb:327:in
Any suggestions, aside from simplifying the grammar (which is something that I’d love to do, were it actually all that feasible)?
There are 3 constants in Tab.rb. The important one, as far as I can find is MaxSetNr, which defaults to 128. This should be sufficient for most little languages, but probably bogs terribly under big grammars. Feel free to tweak this value as you see fit.