is encoded in article.pg as follows:
:- [pg]. article :- name(FileName, "article.pl"), open(FileName,write,Stream), sigma_pg(pg(f,[f,g],[ [(f(0) -> zero), (f(s(n)) -> g(s(n))*f(n))], [(g(0) -> zero),(g(s(n)) -> suc(g(n)))] ]),Stream), close(Stream).
Predicate article create the parser in article.pl. This parser is called by the predicate phrase_pg/3. Here is a run for this example :
bash-2.03$ sicstus SICStus 3.8.3 (sparc-solaris-5.7): Mon May 8 14:25:09 MET DST 2000 Licensed to info.univ-angers.fr | ?- ['article.pg']. {consulting /home/info/helios/stephan/public_html/Research/GRAMMAIRES/PG/PROGRAMMATION/SICSTUS/article.pg...} {consulting /home/info/helios/stephan/public_html/Research/GRAMMAIRES/PG/PROGRAMMATION/SICSTUS/pg.pl...} {loading /opt/SICStus-3.8.3/lib/sicstus-3.8.3/library/lists.po...} {module lists imported into user} {loaded /opt/SICStus-3.8.3/lib/sicstus-3.8.3/library/lists.po in module lists, 10 msec 20472 bytes} {consulted /home/info/helios/stephan/public_html/Research/GRAMMAIRES/PG/PROGRAMMATION/SICSTUS/pg.pl in module user, 30 msec 31312 bytes} {consulted /home/info/helios/stephan/public_html/Research/GRAMMAIRES/PG/PROGRAMMATION/SICSTUS/article.pg in module user, 30 msec 32344 bytes} yes | ?- article. yes | ?- [article]. {consulting /home/info/helios/stephan/public_html/Research/GRAMMAIRES/PG/PROGRAMMATION/SICSTUS/article.pl...} {consulted /home/info/helios/stephan/public_html/Research/GRAMMAIRES/PG/PROGRAMMATION/SICSTUS/article.pl in module user, 0 msec 416 bytes} yes | ?- phrase_pg(suc(zero)*zero,f,[s(0)]). yes | ?-The tracing PG grammars compilor .
:- [pg_with_trace]. article_with_trace :- name(FileName, "article_with_trace.pl"), open(FileName,write,Stream), sigma_pg(pg(f,[f,g],[ [(f(0) -> zero), (f(s(n)) -> g(s(n))*f(n))], [(g(0) -> zero),(g(s(n)) -> suc(g(n)))] ]),Stream), close(Stream).
Predicate article_with_trace create the parser in article_with_trace.pl. This parser is called by the predicate phrase_pg/4. Here is a run for this example :
bash-2.03$ sicstus SICStus 3.8.3 (sparc-solaris-5.7): Mon May 8 14:25:09 MET DST 2000 Licensed to info.univ-angers.fr | ?- ['article_with_trace.pg']. {consulting /home/info/helios/stephan/public_html/Research/GRAMMAIRES/PG/PROGRAMMATION/SICSTUS/article_with_trace.pg...} {consulting /home/info/helios/stephan/public_html/Research/GRAMMAIRES/PG/PROGRAMMATION/SICSTUS/pg_with_trace.pl...} {loading /opt/SICStus-3.8.3/lib/sicstus-3.8.3/library/lists.po...} {module lists imported into user} {loaded /opt/SICStus-3.8.3/lib/sicstus-3.8.3/library/lists.po in module lists, 0 msec 20472 bytes} {consulted /home/info/helios/stephan/public_html/Research/GRAMMAIRES/PG/PROGRAMMATION/SICSTUS/pg_with_trace.pl in module user, 30 msec 36752 bytes} {consulted /home/info/helios/stephan/public_html/Research/GRAMMAIRES/PG/PROGRAMMATION/SICSTUS/article_with_trace.pg in module user, 40 msec 37904 bytes} yes | ?- article_with_trace. yes | ?- [article_with_trace]. {consulting /home/info/helios/stephan/public_html/Research/GRAMMAIRES/PG/PROGRAMMATION/SICSTUS/article_with_trace.pl...} {consulted /home/info/helios/stephan/public_html/Research/GRAMMAIRES/PG/PROGRAMMATION/SICSTUS/article_with_trace.pl in module user, 0 msec 1160 bytes} yes | ?- phrase_pg(suc(zero)*zero,f,[s(0)],user_output). g*f suc(g)*f suc(zero)*f suc(zero)*zero yes | ?-Another example