-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
simple wiki concrete syntax for wikimania
git-svn-id: https://slps.svn.sourceforge.net/svnroot/slps@1107 ab42f6e0-554d-0410-b580-99e487e6eeb2
- Loading branch information
1 parent
f3ffbcf
commit 90c6693
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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")) |