[mercury-users] lexing and parsing in Mercury

Ralph Becket rbeck at microsoft.com
Mon Apr 23 21:16:51 AEST 2001


> read book => "read accomplished"
> open door => "open accomplished"
> open jar  => "open accomplished"
> open sesame => "open does not accept the sesame object"
> play piano => "play does not accept the piano object... in fact play
> 	      does not exist'
> add_verb_object('play','piano').
> play piano => "play accomplished"

An alternative to Fergus' suggestion is to use the lex and moose
modules in the extras distribution which do the same sort of thing as
the standard lex and yacc tools.

lex allows you to specify a set of token name/regular expression pairs
and will parse input into tokens for you.

moose lets you define a grammar over those tokens and decide what
processing should occur at various points.

I'm afraid I haven't got time right now to come up with an example, but
it would be good to get feedback on how well these tools work :)

Cheers,

Ralph
--------------------------------------------------------------------------
mercury-users mailing list
post:  mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the users mailing list