[m-users.] DCG-s in Mercury
Julien Fischer
jfischer at opturion.com
Sat Apr 24 21:53:09 AEST 2021
Hi Sean,
On Sat, 24 Apr 2021, Sean Charles (emacstheviking) wrote:
> Is there anywhere to be found a short, concise example of how to
> create a DCG rule, just so I can see some examples of the mode
> declarations, mine are not going to be used as generators, just as a
> lever and a parser/AST builder. I use phrase_from_file/3 in SWI
> Prolog, and the debugger means I can step through any rules that
> aren’t doing what I think. So far in mercury I have not even worked
> out how to start calling the head rule, if you call it that.
Have a look at samples/calculator.m in the Mercury distribution.
It contains an example of a parser for simple aritmetic expressions
implemented using DCGs.
Julien.
More information about the users
mailing list