[mercury-users] Parsing grammars using DCG

Douglas Michael Auclair dauclair at hotmail.com
Sun Jan 13 02:51:36 AEDT 2002


Dear all,

Thank you for your replies to my previous post, re: Emacs, a_solution!

I'm working on a parser for grammars following BNF -- my code is (lifted 
directly from Bratko's /Prolog: Programming for Artificial Intelligence/, 
chapter 21):

...
:- pred move(list(string), list(string)).
:- mode move(di, in) is semidet.

:- pred step(list(string), list(string)).
:- mode step(di, in) is semidet.
...

move --> step.
move --> step, move.

step --> [ "up" ].
step --> [ "down" ].


I've got the modes wrong here (DCG is a bit magical to me right now) ... 
what I intend is to slurp in a file of this language and return a parse tree 
(and, eventually, attach meaning to the parse nodes, e.g. "up" directs a 
robot arm up 1 cm; "down", down 1 cm).  A bit lost here, what corrections do 
I need to make, or what references/tutorials do I need to study to learn 
about coverting files to input tokens and assigning proper mode declarations 
for DCG over streams/lists/strings?

A propos, is there a way to direct the maillist to send posts to my email 
addr?

Sincerely,
Doug Auclair

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp.
--------------------------------------------------------------------------
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