Skip to content

Commit

Permalink
automated migration from XML-based XBGF to Rascal-based
Browse files Browse the repository at this point in the history
  • Loading branch information
grammarware committed Jan 17, 2013
1 parent 17f20b5 commit 994e208
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
4 changes: 2 additions & 2 deletions shared/rascal/src/export/BNF.rsc
Expand Up @@ -28,8 +28,8 @@ public str pp(terminal(str s)) = "\"<s>\"";
public str pp(nonterminal(str s)) = "<s>";
public str pp(selectable(s,e)) = "<s>::<ppost(e)>";
public str pp(sequence(L)) = "(<pp(L)>)";
public str pp(choice(L)) = "(<mapjoin(pp,es," | ")>)";
public str pp(allof(L)) = "(<mapjoin(pp,es," & ")>)";
public str pp(choice(L)) = "(<mapjoin(pp,L," | ")>)";
public str pp(allof(L)) = "(<mapjoin(pp,L," & ")>)";
public str pp(marked(e)) = "\<<pp(e)>\>";
public str pp(optional(e)) = "<pppre(e)>?";
public str pp(not(e)) = <ppost(e)>";
Expand Down
34 changes: 34 additions & 0 deletions shared/rascal/src/metarascal/XBGF2Rascal.rsc
@@ -0,0 +1,34 @@
@contributor{Vadim Zaytsev - vadim@grammarware.net - SWAT, CWI}
module metarascal::XBGF2Rascal

import String;
import IO;
import io::ReadBGF;
import io::ReadXBGF;
import export::XBNF;

public void main(list[str] args) = main(|cwd:///|+args[0]);

public void main(loc x)
{
xbgf = readXBGF(x);
writeFile(//|cwd:///Transformation.rsc|,
|project://slps/src/metarascal/Transformation.rsc|,
"@contributor{XBGF2Rascal}
'module Transformation // feel free to change that after moving the file
'
'import syntax::BGF;
'import syntax::XBGF;
'import transform::XBGF;
'import diff::GDT;
'
'BGFGrammar doTrafo(XBGFSequence x, BGFGrammar g)
' = transform([<for(step <- xbgf){>
' // <ppx(step)>
' <step>,<}>
' bypass()
' ],g);
'");
}

public void tst() = main(|home:///projects/slps/topics/island/csharp-ecma-334-1/adapt.using.xbgf|);

0 comments on commit 994e208

Please sign in to comment.