[DGD] Search and replace with parse_string?

Felix A. Croes felix at dworkin.nl
Fri Jul 23 23:17:25 CEST 2010


Krister Svanlund <krister.svanlund at gmail.com> wrote:

> Continuing on the same theme! I've written this grammar that works for
> a color string (such as "RED!") but not for a movement string such as
> "<5" or "^". Movement strings only gives a nil return value and the
> "showthis" function is never called.
>
> mod   = /[!_]/
> move  = /[v<>\^]/
> word  = /[A-Z]+/
> nr    = /[0-9]+/
> color : word
> color : color mod
> movem : move ?showthis
> movem : movem nr

The first production rule defines the start symbol for the grammar,
which in this case is 'color'.  'movem' cannot be reached from there.

Regards,
Felix Croes



More information about the DGD mailing list