[mercury-users] DCG and get_token_list
Sergio Rafael Trindade Marques
l16447 at alunos.uevora.pt
Wed Mar 31 01:05:55 AEST 2004
Ralph Becket wrote:
>S?rgio Rafael Trindade Marques, Saturday, 27 March 2004:
>
>
>>Hi,
>>I'm implementing a prolog compiler at the university,
>>I've used lexer__get_token_list to get the token and implmented in
>>DCG a grammer I had for my subset of prolog.
>>
>>
>
>Why not use the parser module in the standard library? This parses a
>superset of Prolog and returns a term structure, which is exactly what
>you're looking for.
>
>
>
>>I don't know how to consume the tokens, can someone help me?
>>I also need to build a tree, in prolog would simply be:
>>
>>head( h(C1,C2) ) --> c1(C1) , c2(C2)
>>c1(C) --> [I], {integer(I), C=I}
>>...
>>
>>How do I do this in mercury?
>>
>>
>
>DCGs work the same way in Mercury as in Prolog.
>
>But, really, use parser.m unless you want to write your own parser as a
>learning exercise.
>
>-- 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
>--------------------------------------------------------------------------
>
>.
>
>
>
Thanks for helping me. Your help was very useful. :)
Sergio
--------------------------------------------------------------------------
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