[m-users.] Free and Ground in the same error line?

Sean Charles (emacstheviking) objitsu at gmail.com
Mon Oct 30 23:05:35 AEDT 2023


Yes. I remember the first time I built Mercury, as it built I scoured all the examples to see what gems where lurking, having come from a largish Prolog project where I'd used SWI-Prolog to do some term rewriting, I thought I might have the same options and sure enough...yes, it will take some effort but it would make a good project.

I am using 22.01.6, and looking down into mercury_term_lexer.m, the list of returned token types doesn't include comments, not that I could see, so it might be harder scanning for documentation but given that the '%' being first on the line is the trigger I am sure a workaround could be done. The mmc-doc tool locates the predicate being asked for and then backtracks up the file to find the nearest comment block, for example

➜  mmc-doc git:(modules-renamed) ✗ mdoc io close_output
    % Closes an open text output stream.
    % This will throw an io.error exception if an I/O error occurs.
    %
:- pred close_output(io.text_output_stream::in, io::di, io::uo) is det.

So the files author would have to have stuck to convention regarding commenting. You have the option of course of manually extracting a comment, then using read_term() as well, which is probably easier. I do something similar with my transpiler in that the AST contains everything I saw, comments included, and then you can pick your way through stuff like where functions are defined, used, anything not used, variables declared etc etc.

It would be a fun exercise for sure, but for me, I am rammed out on stuff to be done at the moment.

:)



> On 30 Oct 2023, at 10:53, Volker Wysk <post at volker-wysk.de> wrote:
> 
> Am Samstag, dem 28.10.2023 um 16:59 +0100 schrieb Sean Charles
> (emacstheviking):
>>> On 28 Oct 2023, at 16:53, Tomas By <tomas at basun.net> wrote:
>>> 
>>> On Sat, 28 Oct 2023 17:29:13 +0200, Sean Charles (emacstheviking) wrote:
>>>> I've also been contemplating making a command line tool out of the
>>>> term-rewriting example code
>>> 
>>> This is a good idea, it is very easy in Mercury, with the token &
>>> parser libraries.
>> 
>> The file I played with was 'expand_term.m' in the samples folder. Perhaps
>> I might try to tinker with it and find a little job for it in this
>> evenings hack session on my transpiler... this might be the red pill
>> though......
> 
> Wow! This looks really powerful. It looks like it would be easy to parse and
> do something with Mercury source code. For instance, make a pretty printer
> for interface documentation. Or internationalization. Or gather
> statistics...
> 
> Cheers
> Volker
> _______________________________________________
> users mailing list
> users at lists.mercurylang.org <mailto:users at lists.mercurylang.org>
> https://lists.mercurylang.org/listinfo/users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurylang.org/archives/users/attachments/20231030/1e7c880e/attachment.html>


More information about the users mailing list