Skip to content

Commit

Permalink
reimplement unchain mutation in Rascal
Browse files Browse the repository at this point in the history
  • Loading branch information
grammarware committed Jan 17, 2013
1 parent 5e81ccc commit fdb3297
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
2 changes: 0 additions & 2 deletions shared/rascal/src/mutate/DeYaccify.rsc
Expand Up @@ -2,8 +2,6 @@
module mutate::DeYaccify

import syntax::BGF;
import transform::library::Util;
import transform::library::Yacc;

// NB: the deyaccification mutation works on horizontal productions,
// while the deyaccification transformation works on vertical ones!!!
Expand Down
18 changes: 18 additions & 0 deletions shared/rascal/src/mutate/InlineChains.rsc
@@ -0,0 +1,18 @@
@contributor{Vadim Zaytsev - vadim@grammarware.net - SWAT, CWI}
module mutate::InlineChains

import IO;
import syntax::BGF;
import export::BNF;

public BGFGrammar unchain_m(BGFGrammar g)
{
ps = g.prods;
for (tp:production(_,_,nonterminal(chained)) <- [p | p:production(_,_,nonterminal(x)) <- g.prods])
{
myprods = [bp | bp:production(_,chained,_) <- ps];
if ([production(_,_,rhs)] := myprods)
ps = ps + production(tp.label,tp.lhs,rhs) - myprods - tp;
}
return grammar(g.roots,ps);
}

0 comments on commit fdb3297

Please sign in to comment.