Merge "put SpecialMovepageAfterMove hook after success message output"
[mediawiki.git] / resources / mediawiki / mediawiki.jqueryMsg.peg
blobe059ed1d9e489d52685592a4b86730b6b258eb1e
1 /* PEG grammar for a subset of wikitext, useful in the MediaWiki frontend */
3 start
4   = e:expression* { return e.length > 1 ? [ "CONCAT" ].concat(e) : e[0]; }
6 expression
7   = template
8   / link
9   / extlink
10   / replacement
11   / literal
13 paramExpression
14   = template
15   / link
16   / extlink
17   / replacement
18   / literalWithoutBar
20 template
21   = "{{" t:templateContents "}}" { return t; }
23 templateContents
24   = twr:templateWithReplacement p:templateParam* { return twr.concat(p) }
25   / twr:templateWithOutReplacement p:templateParam* { return twr.concat(p) }
26   / t:templateName p:templateParam* { return p.length ? [ t, p ] : [ t ] }
28 templateWithReplacement
29   = t:templateName ":" r:replacement { return [ t, r ] }
31 templateWithOutReplacement
32   = t:templateName ":" p:paramExpression { return [ t, p ] }
34 templateParam
35   = "|" e:paramExpression* { return e.length > 1 ? [ "CONCAT" ].concat(e) : e[0]; }
37 templateName
38   = tn:[A-Za-z_]+ { return tn.join('').toUpperCase() }
40 link
41   = "[[" w:expression "]]" { return [ 'WLINK', w ]; }
43 extlink
44   = "[" url:url whitespace text:expression "]" { return [ 'LINK', url, text ] }
46 url
47   = url:[^ ]+ { return url.join(''); }
49 whitespace
50   = [ ]+
52 replacement
53   = '$' digits:digits { return [ 'REPLACE', parseInt( digits, 10 ) - 1 ] }
55 digits
56   = [0-9]+
58 literal
59   = lit:escapedOrRegularLiteral+ { return lit.join(''); }
61 literalWithoutBar
62   = lit:escapedOrLiteralWithoutBar+ { return lit.join(''); }
64 escapedOrRegularLiteral
65   = escapedLiteral
66   / regularLiteral
68 escapedOrLiteralWithoutBar
69   = escapedLiteral
70   / regularLiteralWithoutBar
72 escapedLiteral
73   = "\\" escaped:. { return escaped; }
75 regularLiteral
76   = [^{}\[\]$\\]
78 regularLiteralWithoutBar
79   = [^{}\[\]$\\|]