Skip to content

Commit

Permalink
simple wiki concrete syntax for wikimania
Browse files Browse the repository at this point in the history
git-svn-id: https://slps.svn.sourceforge.net/svnroot/slps@1107 ab42f6e0-554d-0410-b580-99e487e6eeb2
  • Loading branch information
grammarware committed Aug 6, 2011
1 parent f3ffbcf commit 90c6693
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions topics/grammars/wiki/simple/MediaWiki.rsc
@@ -0,0 +1,54 @@
module MediaWiki

syntax WikiText = WikiSymbol*;

syntax WikiSymbol
= MWWord w
| WikiLink wl;

syntax WikiLink
= simple: "[[" PageName destination "]]"
| barred: "[[" PageName destination "|" MWWord+ description "]]"
;

lexical MWWord
= ![\ \t\n\r\[\]]+ !>> ![\ \t\n\r\[\]]
;

// http://en.wikipedia.org/wiki/Wikipedia:Naming_conventions_(technical_restrictions)#Forbidden_characters
lexical PageName
= ![#\<\>\[\]|{}\t\n\r]+ !>> ![#\<\>\[\]|{}\t\n\r]
;

layout MediaWiki = [\ \t\n\r]* !>> [\ \t\n\r];

// needed if you want to run an eclipse editor
public WikiText parsewikitext(str i, loc s){return parse(#WikiText, i, s);}
// import util::IDE;
// import MediaWiki;
// registerLanguage("MediaWiki","wiki",parsewikitext);
// registerContributions("MediaWiki",{popup(menu("ANTLR",[edit("transform", ppWT)]))});


public str ppWT((WikiText)`<WikiSymbol* wss>`)
{
return "<for(ws <- wss){><ppWS(ws)><}>";
}

public str ppWS((WikiSymbol)`<MWWord w>`)
{
return "<w>";
}

public str ppWS((WikiSymbol)`<WikiLink wl>`)
{
if ( wl.prod.def.name == "simple" )
return "[[<wl.destination>]]";
else
return "[[<wl.description>|<wl.destination>]]";
}

// import MediaWiki;
// parse(#WikiText,|project://wiki/src/test.wiki|)
// parse(#WikiText,"some [[Wiki]] text")
// ppWT(parse(#WikiText,"some [[Wiki]] text"))

0 comments on commit 90c6693

Please sign in to comment.