[m-users.] Correct use of pragma source_file and #N directives together ?

Zoltan Somogyi zoltan.somogyi at runbox.com
Wed Aug 17 07:57:05 AEST 2022


2022-08-17 07:34 GMT+10:00 "Sean Charles (emacstheviking)" <objitsu at gmail.com>:
> Hi, I am trying to complete my literate programming tool by having it intersperse the above mentioned directives into the generated source, but having read section "19.6 Source file name" until I glazed over, I just cannot fathom my obvious error!
> I have two small markdown files, which when rendered without the --mercury-lines option, an option to my program, stitch together and run just fine:

> main(!IO) :-
> :- pragma source_file("mtest2.md").
> #7
>     io.format("Yay\n", [], !IO),
> :- pragma source_file("mtest2.md").
> #8
>     io.format("Yay once again\n", [], !IO),
> :- pragma source_file("mtest.md").
> #19
>     io.format("-- line counter test--\n", [], !IO),
> :- pragma source_file("mtest.md").
> #20
>     io.format("this is the final and\n", [], !IO),
> :- pragma source_file("mtest.md").
> #21
>     io.format("last word\n", [], !IO).

Source file directives, like other directives, may not occur in the middle
of clauses, or in the middle of other directives. You get errors about
the code above because it tries to put source_file directives into the middle
of a clause.

Zoltan.


More information about the users mailing list