<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, 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!<div class="">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:</div><div class=""><br class=""></div><div class=""><div class=""><font face="Menlo" class="">➜ mercury-mlpt git:(master) ✗ mlpt --append-duplicates mtest.md mtest2.md </font></div><div class=""><font face="Menlo" class="">Walking trail starting from: <<*>></font></div><div class=""><font face="Menlo" class="">! ensuring output path: .</font></div><div class=""><font face="Menlo" class="">> write:<<*>> ./test.m in progress.</font></div></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" class="">:- module test.<br class="">:- interface.<br class="">:- import_module io.<br class="">:- pred main(io::di, io::uo) is det.<br class=""><br class="">:- implementation.<br class="">:- import_module list.<br class=""><br class="">% following is defined in the other file!<br class="">main(!IO) :-<br class=""> io.format("Yay\n", [], !IO),<br class=""> io.format("Yay once again\n", [], !IO),<br class=""> io.format("-- line counter test--\n", [], !IO),<br class=""> io.format("this is the final and\n", [], !IO),<br class=""> io.format("last word\n", [], !IO).<br class=""></font><br class=""></div><div class="">The two markdown files are here, apologies in advance for the length of this post but I am trying to be concise:</div><div class=""><br class=""></div><div class=""><b class="">---- mtest.md</b></div><div class=""><font face="Menlo" class=""># Testing pragma source file<br class=""><br class="">```prolog <<*>> test.m<br class="">:- module test.<br class="">:- interface.<br class="">:- import_module io.<br class="">:- pred main(io::di, io::uo) is det.<br class=""><br class="">:- implementation.<br class="">:- import_module list.<br class=""><br class="">% following is defined in the other file!<br class=""><<main>><br class="">```<br class=""><br class="">so now we can define the main file BUT the definition is in another file!<br class=""><br class="">~~~ <<content>><br class="">io.format("-- line counter test--\n", [], !IO),<br class="">io.format("this is the final and\n", [], !IO),<br class="">io.format("last word\n", [], !IO).<br class="">~~~<br class=""><br class="">ALL DONE. THE END.</font></div><div class=""><b class="">----</b></div><div class=""><br class=""></div><div class="">and the second file:</div><div class=""><br class=""></div><div class=""><b class="">---- mtest2.md</b></div><div class=""><font face="Menlo" class=""># Main defined in here<br class=""><br class="">To make sure it can pull out stuff across files<br class=""><br class="">~~~{.prolog} <<main>><br class="">main(!IO) :-<br class=""> io.format("Yay\n", [], !IO),<br class=""> io.format("Yay once again\n", [], !IO),<br class=""> <<content>><br class="">~~~<br class=""><br class="">The <<content>> section is back in the other file.</font></div><div class=""><b class="">----</b></div><div class=""><br class=""></div><div class="">When I re-render with the --mercury-lines flag, the final output looks like this but it point blank compiles with lots of errors!</div><div class=""><br class=""></div><div class=""><b class="">---- output with compiler directives ----</b></div><div class=""><font face="Menlo" class="">:- module test.<br class="">:- pragma source_file("mtest.md").<br class="">#5<br class="">:- interface.<br class="">:- pragma source_file("mtest.md").<br class="">#6<br class="">:- import_module io.<br class="">:- pragma source_file("mtest.md").<br class="">#7<br class="">:- pred main(io::di, io::uo) is det.<br class="">:- pragma source_file("mtest.md").<br class="">#8<br class=""><br class="">:- pragma source_file("mtest.md").<br class="">#9<br class="">:- implementation.<br class="">:- pragma source_file("mtest.md").<br class="">#10<br class="">:- import_module list.<br class="">:- pragma source_file("mtest.md").<br class="">#11<br class=""><br class="">:- pragma source_file("mtest.md").<br class="">#12<br class="">% following is defined in the other file!<br class="">:- pragma source_file("mtest2.md").<br class="">#6<br class="">main(!IO) :-<br class="">:- pragma source_file("mtest2.md").<br class="">#7<br class=""> io.format("Yay\n", [], !IO),<br class="">:- pragma source_file("mtest2.md").<br class="">#8<br class=""> io.format("Yay once again\n", [], !IO),<br class="">:- pragma source_file("mtest.md").<br class="">#19<br class=""> io.format("-- line counter test--\n", [], !IO),<br class="">:- pragma source_file("mtest.md").<br class="">#20<br class=""> io.format("this is the final and\n", [], !IO),<br class="">:- pragma source_file("mtest.md").<br class="">#21<br class=""> io.format("last word\n", [], !IO).<br class=""><br class=""></font></div><div class=""><b class="">----</b></div><div class=""><br class=""></div><div class="">and the accompanying error output from the compiler:</div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" class="">➜ mercury-mlpt git:(master) ✗ mmc test.m<br class="">mtest.md:007: Error: no clauses for predicate `main'/2.<br class="">mtest2.md:007: Syntax error at token ':-': operator precedence error.<br class="">mtest2.md:008: Syntax error at token ':-': operator precedence error.<br class="">mtest2.md:009: Syntax error at token ':-': operator precedence error.<br class="">mtest2.md:020: Syntax error at token ':-': operator precedence error.<br class="">mtest2.md:021: Error: module qualifier in definition does not match preceding<br class="">mtest2.md:021: `:- module' declaration.<br class="">mtest2.md:021: Syntax error at token ':-': operator precedence error.</font></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">I manually commented out the pragma source_file() directives in test.m, to leave only the first one, and it does compile. I don't understand why these errors are happening as the documentation says that it 'is a good idea'....' but it doesn't really say what the restrictions are on the use of the pragma and the line directive, not to the point where it was clear to me anyway. I can see that there are probably too many and they are upsetting the compilers parsing but I don't know why.</div><div class=""><br class=""></div><div class="">This is the last option I have to implement before initial GitHub release and I didn't think it would be this tricky! :D The tool is working well, I am already using it for my ongoing transpiler IDE project.</div><div class=""><br class=""></div><div class="">Thanks,</div><div class="">Sean.</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div></body></html>