fmod PRINT-PN is
  inc PL-PRINT .
  inc META-PETRI .
 
  vars pntlT occsT ridT t occT preOccsT postOccsT iOccsT oOccsT bOccsT : Term .
  vars  ptl otl pntl : TermList .
  var mod : Module .
  var str : String .

**** Assume occsT reflects used initial marking

  op exportPNet2pn : Module Term -> String .
  eq exportPNet2pn(mod, 'pnet[pntlT,occsT]) =
        printOPlaces(mod, "initial=",occsT2occTL(occsT)) +
        printPNTransTL(mod,pntlT2pntTL(pntlT)) .

**** an xnet or tkb
  eq exportPNet2pn(mod,pntlT) = printPNTransTL(mod,pntlT2pntTL(pntlT)) [ owise ] .   

****  eq exportPNet2pn(mod,t) = "" [ owise ] .   **** not a pnet


  op printOPlaces : Module String TermList  -> String .
  eq printOPlaces(mod, str, empty) = "" .
  eq printOPlaces(mod, str, (occT, otl)) =
       str + occ2label(mod,occT) + "\n" + printOPlaces(mod, str, otl) .

  op printPNTransTL :  Module TermList -> String .
  op printPNTrans : Module Term -> String .

  eq printPNTransTL(mod,empty) = "" .
  eq printPNTransTL(mod,(t, pntl)) =
      printPNTrans(mod,t) + printPNTransTL(mod,pntl) .

  eq printPNTrans(mod,'pnTrans[ridT, iOccsT, oOccsT, bOccsT]) =
   "\n-------------------------\n" +
   "transition=" + printRidTAll(ridT) + "\n\n" +
    printOPlaces(mod,"input=",(occsT2occTL(iOccsT), occsT2occTL(bOccsT)))
         + "\n\n" +
    printOPlaces(mod,"output=",(occsT2occTL(oOccsT), occsT2occTL(bOccsT)))
         + "\n\n"  .

  eq printPNTrans(mod,t) = "" [owise] .  **** not a pntrans


endfm
