Skip to content

Commit

Permalink
PNF export made perfect
Browse files Browse the repository at this point in the history
  • Loading branch information
grammarware committed Jan 21, 2013
1 parent 50d58f1 commit e897435
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 69 deletions.
8 changes: 4 additions & 4 deletions shared/rascal/src/export/PNF.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public str ppnf(BGFProdList ps) = mapjoin(ppnf,ps,"\n");

public str ppnf(set[BGFProduction] ps) = mapjoin(ppnf,ps,"\n");

public str ppnf(BGFProduction p) = "<p.lhs> ::= <ppnftop(p.rhs)> ;";
public str ppnf(BGFProduction p) = "\\textit{<p.lhs>} ::= <ppnftop(p.rhs)> ;";

str ppnftop(sequence(BGFExprList es)) = "(<ppnf(es)>)";
default str ppnftop(BGFExpression e) = ppnf(e);
Expand All @@ -22,10 +22,10 @@ public str ppnf(empty()) = "\\false";
public str ppnf(val(string())) = "\\mathit{str}";
public str ppnf(val(integer())) = "\\mathit{int}";
public str ppnf(anything()) = "ANYTHING";
public str ppnf(terminal(str s)) = "\\t(<s>)";
public str ppnf(nonterminal(str s)) = "\\n(<s>)";
public str ppnf(terminal(str s)) = "\\te(\\textit{<s>})";
public str ppnf(nonterminal(str s)) = "\\n(\\textit{<s>})";
public str ppnf(selectable(s,e)) = "\\s(<s>,<ppnfost(e)>)";
public str ppnf(sequence(L)) = "(<ppnf(mapjoin(ppnf,es,", "))>)";
public str ppnf(sequence(L)) = "(<mapjoin(ppnf,L,", ")>)";
public str ppnf(choice(L)) = "\\dis([<mapjoin(ppnf,L,"; ")>])";
public str ppnf(allof(L)) = "\\con([<mapjoin(ppnf,L,"; ")>])";
public str ppnf(marked(e)) = "\\langle<ppnf(e)>\\rangle";
Expand Down
10 changes: 5 additions & 5 deletions shared/rascal/src/export/XBNF.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public str ppx(XBGFCommand::appear(BGFProduction p)) = "appear(<pp(p)>)";
public str ppx(XBGFCommand::bypass()) = "bypass()";
public str ppx(XBGFCommand::chain(BGFProduction p)) = "chain(<pp(p)>)";
public str ppx(XBGFCommand::clone(str x, str y, XBGFScope w)) = "clone(<x>,<y>,<pp(w)>)";
public str ppx(XBGFCommand::concatT(list[str] xs, str y, XBGFScope w)) = "concatT(<pp(xs)>,<y>,<pp(w)>)";
public str ppx(XBGFCommand::concatT(list[str] xs, str y, XBGFScope w)) = "concatT(\"<joinStrings(xs,"\"+\"")>\",\"<y>\",<pp(w)>)";
public str ppx(XBGFCommand::concretize(BGFProduction p)) = "concretize(<pp(p)>)";
public str ppx(XBGFCommand::deanonymize(BGFProduction p)) = "deanonymize(<pp(p)>)";
public str ppx(XBGFCommand::define(list[BGFProduction] ps)) = "define(<pp(ps)>)";
Expand Down Expand Up @@ -53,11 +53,11 @@ public str ppx(XBGFCommand::renameN(str x, str y)) = "renameN(<x>,<y>)";
public str ppx(XBGFCommand::renameS(str x, str y, XBGFScope w)) = "renameS(<x>,<y>,<pp(w)>)";
public str ppx(XBGFCommand::renameT(str x, str y)) = "renameT(<x>,<y>)";
public str ppx(XBGFCommand::replace(BGFExpression e1, BGFExpression e2, XBGFScope w)) = "replace(<pp(e1)>,<pp(e2)>,<pp(w)>)";
public str ppx(XBGFCommand::reroot(list[str] xs)) = "reroot(<pp(xs)>)";
public str ppx(XBGFCommand::reroot(list[str] xs)) = "reroot(<joinStrings(xs,",")>)";
public str ppx(XBGFCommand::splitN(str x, list[BGFProduction] ps, XBGFScope w)) = "splitN(<x>,<pp(ps)>,<pp(w)>)";
public str ppx(XBGFCommand::splitT(str x, list[str] ys, XBGFScope w)) = "splitT(<x>,<pp(ys)>,<pp(w)>)";
public str ppx(XBGFCommand::splitT(str x, list[str] ys, XBGFScope w)) = "splitT(\"<x>\",\"<joinStrings(ys,"\"+\"")>\",<pp(w)>)";
public str ppx(XBGFCommand::unchain(BGFProduction p)) = "unchain(<pp(p)>)";
public str ppx(XBGFCommand::undefine(list[str] xs)) = "undefine(<pp(xs)>)";
public str ppx(XBGFCommand::undefine(list[str] xs)) = "undefine(<joinStrings(xs,",")>)";
public str ppx(XBGFCommand::unfold(str x, XBGFScope w)) = "unfold(<x>,<pp(w)>)";
public str ppx(XBGFCommand::unite(str x, str y)) = "unite(<x>,<y>)";
public str ppx(XBGFCommand::unlabel(str x)) = "unlabel(<x>)";
Expand All @@ -78,4 +78,4 @@ str pp(XBGFScope::notinnt(str x)) = "notinnt(<x>)";
str pp(XBGFScope::comboscope(XBGFScope w1, XBGFScope w2)) = "comboscope(<pp(w1)>,<pp(w2)>)";
default str pp(XBGFScope smth) = "??<smth>??";

str pp(list[str] ss) = joinStrings(ss,",");
//str pp(list[str] ss) = joinStrings(ss,",");
121 changes: 61 additions & 60 deletions shared/rascal/src/export/XPNF.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -7,73 +7,74 @@ import syntax::XBGF;
import syntax::BGF;
import export::PNF;

public str ppxs(XBGFSequence xs) = mapjoin(ppx,xs,"\n");
public str ppxs(XBGFSequence xs) = "\\begin{align*}\n&<mapjoin(ppx,xs,"; \\\\\n&")>\n\\end{align*}";

public str ppx(XBGFCommand::abridge(BGFProduction p)) = "abridge(<ppnf(p)>)";
public str ppx(XBGFCommand::abstractize(BGFProduction p)) = "abstractize(<ppnf(p)>)";
public str ppx(XBGFCommand::addH(BGFProduction p)) = "addH(<ppnf(p)>)";
public str ppx(XBGFCommand::addV(BGFProduction p)) = "addV(<ppnf(p)>)";
public str ppx(XBGFCommand::anonymize(BGFProduction p)) = "anonymize(<ppnf(p)>)";
public str ppx(XBGFCommand::appear(BGFProduction p)) = "appear(<ppnf(p)>)";
public str ppx(XBGFCommand::bypass()) = "bypass()";
public str ppx(XBGFCommand::chain(BGFProduction p)) = "chain(<ppnf(p)>)";
public str ppx(XBGFCommand::clone(str x, str y, XBGFScope w)) = "clone(<x>,<y>,<pp(w)>)";
public str ppx(XBGFCommand::concatT(list[str] xs, str y, XBGFScope w)) = "concatT(<pp(xs)>,<y>,<pp(w)>)";
public str ppx(XBGFCommand::concretize(BGFProduction p)) = "concretize(<ppnf(p)>)";
public str ppx(XBGFCommand::deanonymize(BGFProduction p)) = "deanonymize(<ppnf(p)>)";
public str ppx(XBGFCommand::define(list[BGFProduction] ps)) = "define(<ppnf(ps)>)";
public str ppx(XBGFCommand::designate(BGFProduction p)) = "designate(<ppnf(p)>)";
public str ppx(XBGFCommand::detour(BGFProduction p)) = "detour(<ppnf(p)>)";
public str ppx(XBGFCommand::deyaccify(str x)) = "deyaccify(<x>)";
public str ppx(XBGFCommand::disappear(BGFProduction p)) = "disappear(<ppnf(p)>)";
public str ppx(XBGFCommand::distribute(XBGFScope w)) = "distribute(<pp(w)>)";
public str ppx(XBGFCommand::downgrade(BGFProduction p1, BGFProduction p2)) = "downgrade(<ppnf(p1)>,<ppnf(p2)>)";
public str ppx(XBGFCommand::eliminate(str x)) = "eliminate(<x>)";
public str ppx(XBGFCommand::equate(str x, str y)) = "equate(<x>,<y>)";
public str ppx(XBGFCommand::extract(BGFProduction p, XBGFScope w)) = "extract(<ppnf(p)>,<pp(w)>)";
public str ppx(XBGFCommand::factor(BGFExpression e1, BGFExpression e2, XBGFScope w)) = "factor(<ppnf(e1)>,<ppnf(e2)>,<pp(w)>)";
public str ppx(XBGFCommand::fold(str x, XBGFScope w)) = "fold(<x>,<pp(w)>)";
public str ppx(XBGFCommand::horizontal(XBGFScope w)) = "horizontal(<pp(w)>)";
public str ppx(XBGFCommand::importG(list[BGFProduction] ps)) = "importG(<ppnf(ps)>)";
public str ppx(XBGFCommand::inject(BGFProduction p)) = "inject(<ppnf(p)>)";
public str ppx(XBGFCommand::inline(str x)) = "inline(<x>)";
public str ppx(XBGFCommand::introduce(list[BGFProduction] ps)) = "introduce(<ppnf(ps)>)";
public str ppx(XBGFCommand::iterate(BGFProduction p)) = "iterate(<ppnf(p)>)";
public str ppx(XBGFCommand::lassoc(BGFProduction p)) = "lassoc(<ppnf(p)>)";
public str ppx(XBGFCommand::massage(BGFExpression e1, BGFExpression e2, XBGFScope w)) = "massage(<ppnf(e1)>,<ppnf(e2)>,<pp(w)>)";
public str ppx(XBGFCommand::narrow(BGFExpression e1, BGFExpression e2, XBGFScope w)) = "narrow(<ppnf(e1)>,<ppnf(e2)>,<pp(w)>)";
public str ppx(XBGFCommand::permute(BGFProduction p)) = "permute(<ppnf(p)>)";
public str ppx(XBGFCommand::project(BGFProduction p)) = "project(<ppnf(p)>)";
public str ppx(XBGFCommand::rassoc(BGFProduction p)) = "rassoc(<ppnf(p)>)";
public str ppx(XBGFCommand::redefine(list[BGFProduction] ps)) = "redefine(<ppnf(ps)>)";
public str ppx(XBGFCommand::removeH(BGFProduction p)) = "removeH(<ppnf(p)>)";
public str ppx(XBGFCommand::removeV(BGFProduction p)) = "removeV(<ppnf(p)>)";
public str ppx(XBGFCommand::renameL(str x, str y)) = "renameL(<x>,<y>)";
public str ppx(XBGFCommand::renameN(str x, str y)) = "renameN(<x>,<y>)";
public str ppx(XBGFCommand::renameS(str x, str y, XBGFScope w)) = "renameS(<x>,<y>,<pp(w)>)";
public str ppx(XBGFCommand::renameT(str x, str y)) = "renameT(<x>,<y>)";
public str ppx(XBGFCommand::replace(BGFExpression e1, BGFExpression e2, XBGFScope w)) = "replace(<ppnf(e1)>,<ppnf(e2)>,<pp(w)>)";
public str ppx(XBGFCommand::reroot(list[str] xs)) = "reroot(<pp(xs)>)";
public str ppx(XBGFCommand::splitN(str x, list[BGFProduction] ps, XBGFScope w)) = "splitN(<x>,<ppnf(ps)>,<pp(w)>)";
public str ppx(XBGFCommand::splitT(str x, list[str] ys, XBGFScope w)) = "splitT(<x>,<pp(ys)>,<pp(w)>)";
public str ppx(XBGFCommand::unchain(BGFProduction p)) = "unchain(<ppnf(p)>)";
public str ppx(XBGFCommand::undefine(list[str] xs)) = "undefine(<pp(xs)>)";
public str ppx(XBGFCommand::unfold(str x, XBGFScope w)) = "unfold(<x>,<pp(w)>)";
public str ppx(XBGFCommand::unite(str x, str y)) = "unite(<x>,<y>)";
public str ppx(XBGFCommand::unlabel(str x)) = "unlabel(<x>)";
public str ppx(XBGFCommand::upgrade(BGFProduction p1, BGFProduction p2)) = "upgrade(<ppnf(p1)>,<ppnf(p2)>)";
public str ppx(XBGFCommand::vertical(XBGFScope w)) = "vertical(<pp(w)>)";
public str ppx(XBGFCommand::widen(BGFExpression e1, BGFExpression e2, XBGFScope w)) = "widen(<ppnf(e1)>,<ppnf(e2)>,<pp(w)>)";
public str ppx(XBGFCommand::yaccify(list[BGFProduction] ps)) = "yaccify(<ppnf(ps)>)";
public str ppx(XBGFCommand::atomic(list[XBGFCommand] steps)) = "atomic(<pp(steps)>)";
public str ppx(XBGFCommand::strip(str a)) = "strip(<a>)";
public str ppx(XBGFCommand::abridge(BGFProduction p)) = "\\mathbf{abridge}(<ppnf(p)>)";
public str ppx(XBGFCommand::abstractize(BGFProduction p)) = "\\mathbf{abstractize}(<ppnf(p)>)";
public str ppx(XBGFCommand::addH(BGFProduction p)) = "\\mathbf{addH}(<ppnf(p)>)";
public str ppx(XBGFCommand::addV(BGFProduction p)) = "\\mathbf{addV}(<ppnf(p)>)";
public str ppx(XBGFCommand::anonymize(BGFProduction p)) = "\\mathbf{anonymize}(<ppnf(p)>)";
public str ppx(XBGFCommand::appear(BGFProduction p)) = "\\mathbf{appear}(<ppnf(p)>)";
public str ppx(XBGFCommand::bypass()) = "\\mathbf{bypass}()";
public str ppx(XBGFCommand::chain(BGFProduction p)) = "\\mathbf{chain}(<ppnf(p)>)";
public str ppx(XBGFCommand::clone(str x, str y, XBGFScope w)) = "\\mathbf{clone}(<x>,<y>,<pp(w)>)";
public str ppx(XBGFCommand::concatT(list[str] xs, str y, XBGFScope w)) = "\\mathbf{concatT}((<joinStrings(["\\te(<x>)" | x<-xs],",")>),\\te(<y>),<pp(w)>)";
public str ppx(XBGFCommand::concretize(BGFProduction p)) = "\\mathbf{concretize}(<ppnf(p)>)";
public str ppx(XBGFCommand::deanonymize(BGFProduction p)) = "\\mathbf{deanonymize}(<ppnf(p)>)";
public str ppx(XBGFCommand::define(list[BGFProduction] ps)) = "\\mathbf{define}(<ppnf(ps)>)";
public str ppx(XBGFCommand::designate(BGFProduction p)) = "\\mathbf{designate}(<ppnf(p)>)";
public str ppx(XBGFCommand::detour(BGFProduction p)) = "\\mathbf{detour}(<ppnf(p)>)";
public str ppx(XBGFCommand::deyaccify(str x)) = "\\mathbf{deyaccify}(<x>)";
public str ppx(XBGFCommand::disappear(BGFProduction p)) = "\\mathbf{disappear}(<ppnf(p)>)";
public str ppx(XBGFCommand::distribute(XBGFScope w)) = "\\mathbf{distribute}(<pp(w)>)";
public str ppx(XBGFCommand::downgrade(BGFProduction p1, BGFProduction p2)) = "\\mathbf{downgrade}(<ppnf(p1)>,<ppnf(p2)>)";
public str ppx(XBGFCommand::eliminate(str x)) = "\\mathbf{eliminate}(<x>)";
public str ppx(XBGFCommand::equate(str x, str y)) = "\\mathbf{equate}(<x>,<y>)";
public str ppx(XBGFCommand::extract(BGFProduction p, globally())) = "\\mathbf{extract}(<ppnf(p)>)";
public str ppx(XBGFCommand::extract(BGFProduction p, XBGFScope w)) = "\\mathbf{extract}(<ppnf(p)>,<pp(w)>)";
public str ppx(XBGFCommand::factor(BGFExpression e1, BGFExpression e2, XBGFScope w)) = "\\mathbf{factor}(<ppnf(e1)>,<ppnf(e2)>,<pp(w)>)";
public str ppx(XBGFCommand::fold(str x, XBGFScope w)) = "\\mathbf{fold}(<x>,<pp(w)>)";
public str ppx(XBGFCommand::horizontal(XBGFScope w)) = "\\mathbf{horizontal}(<pp(w)>)";
public str ppx(XBGFCommand::importG(list[BGFProduction] ps)) = "\\mathbf{importG}(<ppnf(ps)>)";
public str ppx(XBGFCommand::inject(BGFProduction p)) = "\\mathbf{inject}(<ppnf(p)>)";
public str ppx(XBGFCommand::inline(str x)) = "\\mathbf{inline}(\\textit{<x>})";
public str ppx(XBGFCommand::introduce(list[BGFProduction] ps)) = "\\mathbf{introduce}(<ppnf(ps)>)";
public str ppx(XBGFCommand::iterate(BGFProduction p)) = "\\mathbf{iterate}(<ppnf(p)>)";
public str ppx(XBGFCommand::lassoc(BGFProduction p)) = "\\mathbf{lassoc}(<ppnf(p)>)";
public str ppx(XBGFCommand::massage(BGFExpression e1, BGFExpression e2, XBGFScope w)) = "\\mathbf{massage}(<ppnf(e1)>,<ppnf(e2)>,<pp(w)>)";
public str ppx(XBGFCommand::narrow(BGFExpression e1, BGFExpression e2, XBGFScope w)) = "\\mathbf{narrow}(<ppnf(e1)>,<ppnf(e2)>,<pp(w)>)";
public str ppx(XBGFCommand::permute(BGFProduction p)) = "\\mathbf{permute}(<ppnf(p)>)";
public str ppx(XBGFCommand::project(BGFProduction p)) = "\\mathbf{project}(<ppnf(p)>)";
public str ppx(XBGFCommand::rassoc(BGFProduction p)) = "\\mathbf{rassoc}(<ppnf(p)>)";
public str ppx(XBGFCommand::redefine(list[BGFProduction] ps)) = "\\mathbf{redefine}(<ppnf(ps)>)";
public str ppx(XBGFCommand::removeH(BGFProduction p)) = "\\mathbf{removeH}(<ppnf(p)>)";
public str ppx(XBGFCommand::removeV(BGFProduction p)) = "\\mathbf{removeV}(<ppnf(p)>)";
public str ppx(XBGFCommand::renameL(str x, str y)) = "\\mathbf{renameL}(<x>,<y>)";
public str ppx(XBGFCommand::renameN(str x, str y)) = "\\mathbf{renameN}(\\textit{<x>},\\textit{<y>})";
public str ppx(XBGFCommand::renameS(str x, str y, XBGFScope w)) = "\\mathbf{renameS}(<x>,<y>,<pp(w)>)";
public str ppx(XBGFCommand::renameT(str x, str y)) = "\\mathbf{renameT}(<x>,<y>)";
public str ppx(XBGFCommand::replace(BGFExpression e1, BGFExpression e2, XBGFScope w)) = "\\mathbf{replace}(<ppnf(e1)>,<ppnf(e2)>,<pp(w)>)";
public str ppx(XBGFCommand::reroot(list[str] xs)) = "\\mathbf{reroot}(<pp(xs)>)";
public str ppx(XBGFCommand::splitN(str x, list[BGFProduction] ps, XBGFScope w)) = "\\mathbf{splitN}(<x>,<ppnf(ps)>,<pp(w)>)";
public str ppx(XBGFCommand::splitT(str x, list[str] ys, XBGFScope w)) = "\\mathbf{splitT}(\\te(<x>),(<joinStrings(["\\te(<y>)" | y<-ys],",")>),<pp(w)>)";
public str ppx(XBGFCommand::unchain(BGFProduction p)) = "\\mathbf{unchain}(<ppnf(p)>)";
public str ppx(XBGFCommand::undefine(list[str] xs)) = "\\mathbf{undefine}(<pp(xs)>)";
public str ppx(XBGFCommand::unfold(str x, XBGFScope w)) = "\\mathbf{unfold}(<x>,<pp(w)>)";
public str ppx(XBGFCommand::unite(str x, str y)) = "\\mathbf{unite}(\\textit{<x>},\\textit{<y>})";
public str ppx(XBGFCommand::unlabel(str x)) = "\\mathbf{unlabel}(<x>)";
public str ppx(XBGFCommand::upgrade(BGFProduction p1, BGFProduction p2)) = "\\mathbf{upgrade}(<ppnf(p1)>,<ppnf(p2)>)";
public str ppx(XBGFCommand::vertical(XBGFScope w)) = "\\mathbf{vertical}(<pp(w)>)";
public str ppx(XBGFCommand::widen(BGFExpression e1, BGFExpression e2, XBGFScope w)) = "\\mathbf{widen}(<ppnf(e1)>,<ppnf(e2)>,<pp(w)>)";
public str ppx(XBGFCommand::yaccify(list[BGFProduction] ps)) = "\\mathbf{yaccify}(<ppnf(ps)>)";
public str ppx(XBGFCommand::atomic(list[XBGFCommand] steps)) = "\\mathbf{atomic}(<pp(steps)>)";
public str ppx(XBGFCommand::strip(str a)) = "\\mathbf{strip}(<a>)";
public default str ppx(XBGFCommand smth) = "??<smth>??";
str pp(XBGFScope::globally()) = "globally()";
str pp(XBGFScope::nowhere()) = "nowhere()";
str pp(XBGFScope::inlabel(str l)) = "inlabel(<l>)";
str pp(XBGFScope::notinlabel(str l)) = "notinlabel(<l>)";
str pp(XBGFScope::innt(str x)) = "innt(<x>)";
str pp(XBGFScope::innt(str x)) = "\\textrm{in} \\n(\\textit{<x>})";
str pp(XBGFScope::notinnt(str x)) = "notinnt(<x>)";
str pp(XBGFScope::comboscope(XBGFScope w1, XBGFScope w2)) = "comboscope(<pp(w1)>,<pp(w2)>)";
default str pp(XBGFScope smth) = "??<smth>??";
Expand Down

0 comments on commit e897435

Please sign in to comment.