[plt-scheme] abstracting parsers

From: Daniel Silva (dansilva at lynx.dac.neu.edu)
Date: Fri May 7 18:50:12 EDT 2004

I'm working on a message parser for some protocol defined in an RFC.
Parts of those messages (some non-terminals) are defined in other RFCs.
It would be nice to be able to refer to non-terminals from other grammars.
Is this possible?

For example, something like:

;; RFC 2396 defines Uniform Resource Identifiers (URIs)

(require (prefix rfc2396: (lib "RFC2396.ss"
                               "IETF" "RFCs")))

(parser 
  (grammar
     ...
     (Request-Line [(Method SP Request-URI SP HTTP-Version CRLF)
                    (make-request-line $1 $3 $5)])

     (Request-URI [(ASTERISK) $1]
                  [(rfc2396:absolute-uri) $1]
                  [(rfc2396:abs_path) $1]
                  [(rfc2396:authority) $1])

     ...))



Posted on the users mailing list.