[mercury-users] Mercury grammar definition

Bakos Gábor aborgabor at gmail.com
Sun Jul 1 08:39:27 AEST 2012


   Still a newbie... I was trying to implement an LL(*) parser to the
Mercury language, based on this
reference, although I have some problems, could you help me understand?
(Maybe I was looking at the wrong page.)
 - The comments are not defined anywhere, (I guess it was handled by
referring to ISO Prolog), could you confirm, that those are the % single
line, and non-nesting /*, */ comments (and there is no more)?
 - Do the comments act as a whitespace? (I guess yes, but as comments
not mentioned anywhere, this might be just an implementation choice.)
 - How could be the built-in , be distinguished from the argument's
comma? (I tried to define the arguments as simple terms, but the
precedence rules make it not working for the basic hello world program.
See: https://gist.github.com/3025801 you can open it with AntlrWorks for
syntax highlight, and navigation. When I tried to defined as simple left
associative terms separated by comma, there were ambiguity errors
because of the other alternative.)
 - Are the unary +, - operators have to correct specifier? I thought it
would be fy instead of fx.
 - The 950 precedence fxy parts seems to be not separated, maybe there
is a mandatory whitespace there? (With fxy there is an ambiguity error
there in my attempt.)
 - I think the . has also double meaning, but maybe I do misunderstand
main(!IO) :-
io.write_string("Hello, ", !IO),
io.write_string("World!", !IO),
io.nl(!IO). %this dot seems to have different role from the ones
following io.
Thanks, gabor

PS.: I have a simpler grammar with builder for eclipse working more or
less, but without a proper grammar the error reports are really awful,
practically useless.

mercury-users mailing list
Post messages to:       mercury-users at csse.unimelb.edu.au
Administrative Queries: owner-mercury-users at csse.unimelb.edu.au
Subscriptions:          mercury-users-request at csse.unimelb.edu.au

More information about the users mailing list