"Walter Bright" <newshou...@digitalmars.com> wrote in message news:ia2duj$2j7...@digitalmars.com... > Nick Sabalausky wrote: >> Can't say I'm really familiar with Spirit. From a brief lookover, these >> are my impresions of the differences: >> >> Spirit: Grammar is embedded into your source code as actual C++ code. >> Goldie: Grammar is defined in a domain-specfic language. >> But either one could probably have a wrapper to work the other way. >> >> Spirit: Uses (abuses?) operator overloading (Although, apperently SpiritD >> doesn't inherit Spirit's operator overloading: >> http://www.sstk.co.uk/spiritd.php ) >> Goldie: Operator overloading isn't really applicable, because of using a >> DSL. >> >> As they stand, Spirit seems like it could be pretty handly for simple, >> quick little DSLs, ex, things for which Goldie might seem like overkill. >> But Goldie's interface could probably be improved to compete pretty well >> in those cases. OTOH, Goldie's approach (being based on GOLD) has a >> deliberate separation between grammar and parsing, which has it's own >> benefits; for instance, grammar definitions can be re-used for any >> purpose. >> >> > > Does Goldie have (like Spirit) a set of canned routines for things like > numeric literals?
No, but such things can easily be provided in the docs for simple copy-paste. For instance: DecimalLiteral = {Number} ({Number} | '_')* HexLiteral = '0' [xX] ({Number} | [ABCDEFabcdef_])+ Identifier = ('_' | {Letter}) ('_' | {AlphaNumeric})* {StringChar} = {Printable} - ["] StringLiteral = '"' ({StringChar} | '\' {Printable})* '"' All one would need to do to use those is copy-paste them into their grammar definition. Some sort of import mechanism could certainly be added though, to allow for selective import of pre-defined things like that. There are many pre-defined character sets though (and others can be manually-created, of course): http://www.devincook.com/goldparser/doc/grammars/character-sets.htm > > Can the D version of Goldie be turned into one file? Assuming just the library and not the included tools (many of which could be provided as part of the library, though), and not counting files generated for the static-style, then yes, but it would probably be a bit long.