[mercury-users] using mercury for parsing/scanning

Fergus Henderson fjh at cs.mu.OZ.AU
Mon Dec 31 14:54:51 AEDT 2001


On 31-Dec-2001, Dave Slutzkin <dave_slutzkin at yahoo.com> wrote:
>  --- Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> > On 31-Dec-2001, Dave Slutzkin
> > <dave_slutzkin at yahoo.com> wrote:
> > > When using DCGs to scan character strings, is
> there an
> > > alternative to this:
> > > 
> > > keyword -->
> > >    ['K','E','Y','W','O','R','D']
> > 
> > You can use
> > 
> > 	keyword --> string("KEYWORD").
> > 
> > where string//1 can be defined as
> 
> <snipped code>
> 
> But surely this is inefficient?  Doing the conversino
> every time the predicate is called?

With the current Mercury implementation, yes, that will probably be
inefficient.

> Another question:
> 
> How do I write a char literal?  '@' works fine, but
> '.' or ',' gives me problems (they look like operators
> to the compiler).

Put them in parentheses, e.g.

	DotChar = ('.'),
	CommaChar = (','),
	...

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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