[plt-scheme] abstracting parsers

From: Scott Owens (sowens at cs.utah.edu)
Date: Fri May 7 19:05:15 EDT 2004

That is not directly possible.  The same grammar can define multiple parsers 
by using multiple start non-terminals, but grammars cannot use non-terminals 
from other grammars.  You could define your own syntactic abstraction for 
parsers that expands into the `parser' form.

-Scott

On Friday 07 May 2004 04:50 pm, Daniel Silva wrote:
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
> 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.