diff --git a/shared/rascal/src/transform/NegotiatedXBGF.rsc b/shared/rascal/src/transform/NegotiatedXBGF.rsc index f8c01d21..93803665 100644 --- a/shared/rascal/src/transform/NegotiatedXBGF.rsc +++ b/shared/rascal/src/transform/NegotiatedXBGF.rsc @@ -97,6 +97,26 @@ public tuple[Problem,Advice,BGFGrammar] attemptTransform(XBGFSequence xbgf, BGFG return ; } +tuple[Problem,Advice,BGFGrammar] runAbridge(BGFProduction prod, grammar(rs, ps)) +{ + if (production(_,x,nonterminal(x)) !:= prod) + return + < + error("Production cannot be abridged."), + adviseDetouredProd(prod,ps), // NOT IMPLEMENTED YET + grammar(rs,ps) + >; + if (!inProds(prod,ps)) + return + < + error("Production not found."), + setadvice("Consider the nonterminal already abridged.",[]), + grammar(rs,ps) + >; + return ; +} + + tuple[Problem,Advice,BGFGrammar] runRenameN(str x, str y, grammar(rs, ps)) { ns = allNs(ps); diff --git a/shared/rascal/src/transform/XBGF.rsc b/shared/rascal/src/transform/XBGF.rsc index a6fba815..eec22eb5 100644 --- a/shared/rascal/src/transform/XBGF.rsc +++ b/shared/rascal/src/transform/XBGF.rsc @@ -131,13 +131,6 @@ BGFGrammar runAddV(BGFProduction p1, grammar(rs, ps)) } } -bool inProds(BGFProduction p, []) = false; -bool inProds(BGFProduction p, list[BGFProduction] ps) -{ - if (eqP(normalise(p),normalise(ps[0]))) return true; - else return inProds(p,slice(ps,1,len(ps)-1)); -} - BGFGrammar runAnonymize(BGFProduction p1, grammar(rs, ps)) { p2 = unmark(p1); diff --git a/shared/rascal/src/transform/library/Util.rsc b/shared/rascal/src/transform/library/Util.rsc index be8f39f6..f6411361 100644 --- a/shared/rascal/src/transform/library/Util.rsc +++ b/shared/rascal/src/transform/library/Util.rsc @@ -143,3 +143,6 @@ public int levenshtein(str x, str y) } return prow[size(prow)-1]; } + +public bool inProds(BGFProduction p, []) = false; +public bool inProds(BGFProduction p, list[BGFProduction] ps) = eqP(normalise(p),normalise(ps[0])) || inProds(p,tail(ps));