[antlr-interest] Wiki Markup Like Grammar Example

Eric Webb eric at collectivegenius.net
Sun Feb 28 16:44:19 PST 2010


I am working on a note taking language (think wiki markup, but somewhat 
more specialized), and I am trying to use Antlr 3.2 to parse and create 
an AST of the content/structure.

Does anyone have any sample wiki (or similar) grammar that works in 
Antlr 3.2?  I found this:

http://dirkriehle.com/publications/2008/wiki-creole/

which is for Creole 1.0 (with is meant to be a standard Wiki markup 
language).  Unfortunately, it doesn't work for me.

Thanks in advance.

cheers,
eric


** More Information for the Interested **


I have a working grammar that can parse document sections and 
paragraphs, for example:

    *section 1
    ---

    this is a paragraph in the section

    section 1.1
    ---

    nested sections!

    ---
    ---
    *


It works great (after a bit of trial and error and reading The 
Definitive ANTLR Reference and giving gUnit a spin).  Now, I am trying 
to start supporting other standard wiki type things in my grammar, like:

Lists:

  * this is a list item
  * this is another list item

Formatting:

this is **bold**!
this is //italic//.

The problem is, my grammar for the the sections/paragraphs above is 
"word" based (ie: I create WORD tokens with the lexer), while the Creole 
example tokenizes the stream into character tokens to be able to 
identify the list, formatting, and other delimiters.

I am hoping for a working example that shows some best practices for a 
language like wiki markup before I go about re-structuring my grammar to 
support these other things (which I think I need to do).

Or, if I am totally misguided, let me know that too.

cheers,
eric



More information about the antlr-interest mailing list