Does this make the ANTLR problem any simpler?
- d.
---------- Forwarded message ---------- From: Tim Starling tstarling@wikimedia.org Date: 17 Feb 2008 06:19 Subject: [Wikitech-l] Preprocessor syntax in ABNF To: wikitech-l@lists.wikimedia.org
Just a fun little project for my Sunday afternoon:
http://www.mediawiki.org/wiki/Preprocessor_ABNF
Turns out the production rules are pretty simple. The magic is in the disambiguation. An EBNF representation of the whole of MediaWiki wikitext, if such a thing is possible, would only go a small way towards specifying the language.
-- Tim Starling
_______________________________________________ Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
On 2/17/08, David Gerard dgerard@gmail.com wrote:
Does this make the ANTLR problem any simpler?
No. But it's interesting.
This line:
wikitext-L2 = heading / wikitext-L3 / *wikitext-L2
must be incorrect, right? It's just infinitely recursive on the third alternative?
One thing I really notice comparing ABNF and ANTLR is this kind of thing:
comment = "<!--" literal "-->"
ABNF apparently doesn't distinguish lexing and parsing. In ANTLR, if you specified a rule like that, it would generate lexer tokens for the "<!--" and "-->" and possibly break all kinds of near-misses. For example "<!-blah" seems to become unparseable. So you end up with workarounds like this:
HTML_COMMENT: (('<!--') => '<!--' .* ('-->' | EOF) { $channel=HIDDEN; }) | '<' { $type=LT; };
(not that that quite works, but...)
Steve
wikitext-l@lists.wikimedia.org