<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hi Tomas,<div class=""><br class=""></div><div class="">Thanks for the heads up! I have been reading the calculator.m sample code from the ROTD build I have. Yes, things are different in Mercury land than Prolog land here and there. I spent a lot of blood, sweat and tears getting the lever and the AST builder to where they are. I was furloughed for 8 months and every day for about six hours I moved it all long.</div><div class=""><br class=""></div><div class="">The master plan is here : <a href="http://felt-lang.com" class="">http://felt-lang.com</a>.  ////certainly not a new idea but never done by me before. That site is written in my language, and all done with PHP which I hated but PHP was and still is ubiquitous. I then tried to write a v2.0 in Haskell, C, OCaml but always in my mind I knew it had to be Prolog, but recently I hit some issues with modules and multifile/1 etc and so, having first played with Mercury(!) in 2019 I decided that this is it, death or glory, the code gets ported or bust,</div><div class=""><br class=""></div><div class="">I —WILL- finish the job. Wether its CPS style or DCG or a hand-rolled DFA/FSM with CPS thrown in, whatever it takes.</div><div class=""><br class=""></div><div class="">Thanks.</div><div class="">Sean.</div><div class=""><br class=""></div><div class=""><div><br class=""><blockquote type="cite" class=""><div class="">On 24 Apr 2021, at 10:56, Tomas By <<a href="mailto:tomas@basun.net" class="">tomas@basun.net</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">On Sat, 24 Apr 2021 11:33:31 +0200, Sean Charles (emacstheviking) wrote:<br class=""><blockquote type="cite" class="">[...] now I have two sets of DCG rules to port from SWI Prolog and I<br class="">just don’t know where to start. [...]<br class=""></blockquote><br class=""><br class="">There are a couple of problems: partical data structures and<br class="">nondeterminism. If the DCG is for a formal language (ie programming<br class="">code) then it is better to rewrite the parser, for example using<br class="">`continuation passing' (I think it's called).<br class=""><br class="">To implement a DCG in Mercury you need to have solutions/2 at the top,<br class="">and then make all the `grammar rules' nondet. Constructing the output<br class="">holistically, as is/was common in DCGs, does not work (unless it has<br class="">been added in the twenty years or so since I tried it).<br class=""><br class="">But to begin with you can just remove all the output parameters from<br class="">the DCG, and then look at that problem after the parsing works.<br class=""><br class="">There are some minor advantages compared to Prolog, e.g. you can write<br class="">Kleene operators (star, plus, question mark) to make things<br class="">prettier. This has been discussed here before I believe.<br class=""><br class="">/Tomas<br class=""></div></div></blockquote></div><br class=""></div></body></html>