[plt-scheme] abstracting parsers
At Fri, 7 May 2004 19:31:13 -0600, Scott Owens wrote:
> > I noticed that I've started writing too many rules like this one:
> >
> > (hex [(A) $1]
> > [(B) $1]
> > ...
> > [(ZERO) $1]
> > [(ONE) $1]
> > ...)
> >
> > and would rather write:
> >
> > (same-as hex
> > ZERO ONE TWO THREE FOUR FIVE SIX SEVEN EIGHT NINE A B C D E F)
> >
> > but can't define a same-as macro here.. I need to write some parser++
> > syntax that includes same-as.
>
> Firstly, this sort of thing is usually handled in the lexer, so make sure you
> actually need it in the parser.
He's writing a parser for the http rfc. From what I can tell of the
spec, there's no way to get around lexemes-as-bytes. It has things like
OCTET* in productions.
Robby