Skip to content

Commit

Permalink
before re-engineering
Browse files Browse the repository at this point in the history
  • Loading branch information
grammarware committed Jan 4, 2013
1 parent 5f2739d commit e7dad39
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
20 changes: 20 additions & 0 deletions shared/rascal/src/transform/NegotiatedXBGF.rsc
Expand Up @@ -97,6 +97,26 @@ public tuple[Problem,Advice,BGFGrammar] attemptTransform(XBGFSequence xbgf, BGFG
return <noproblem(),noadvice(),normalise(g1)>;
}

tuple[Problem,Advice,BGFGrammar] runAbridge(BGFProduction prod, grammar(rs, ps))
{
if (production(_,x,nonterminal(x)) !:= prod)
return
<
error("Production <prod> cannot be abridged."),
adviseDetouredProd(prod,ps), // NOT IMPLEMENTED YET
grammar(rs,ps)
>;
if (!inProds(prod,ps))
return
<
error("Production <prod> not found."),
setadvice("Consider the nonterminal <prod.lhs> already abridged.",[]),
grammar(rs,ps)
>;
return <noproblem(),noadvice(),grammar(rs, ps - prod)>;
}


tuple[Problem,Advice,BGFGrammar] runRenameN(str x, str y, grammar(rs, ps))
{
ns = allNs(ps);
Expand Down
7 changes: 0 additions & 7 deletions shared/rascal/src/transform/XBGF.rsc
Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions shared/rascal/src/transform/library/Util.rsc
Expand Up @@ -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));

0 comments on commit e7dad39

Please sign in to comment.