[antlr-interest] Wiki Markup
    ttest 
    ttest at gmx.de
       
    Wed Apr 20 14:59:38 PDT 2005
    
    
  
Hi,
I'm trying to parse a wiki like markup language and to translate that to
HTML. At the moment I'm defining my grammar and therefore I'm trying to get
together my parser and lexer rules.
One point I don't understand is how to decide whether something is a lexer
rule or a parser rule.
Lets say my markup is something like:
blabla, bla blablabla. blabla [[bold:blablabla]] bla bal.
and I want to convert that to:
blabla, bla blablabla. blabla <b>blablabla</b> bla bal.
What would my rules look like?
Here's what I've got so far but somehow I'm stuck with this.
/*
 * Parser
 */
 
class MarkupParser extends Parser;
markup
	:	(	element
		|	Text
		)*
	;
element
	:	ElementBegin elementName ':' elementAttributes ElementEnd
	;
elementName
	:	"bold"
	|	"italic"
	|	"headline"
	;
elementAttributes
	:	elementAttributeValue ('|' elementAttributeValue)*
	;
elementAttributeValue
	:	('a'..'z'|'A'..'Z')+
	;
/*
 * Lexer
 */
class MarkupLexer extends Lexer;
ElementBegin
	:	"[["
	;
ElementEnd
	:	"]]"
	;
Text
	:	('a'..'z'|'A'..'Z'|' '|'\n'|'\r')+
	;
Any help or suggestions are appreciated:
Thanks!
	Christian
    
    
More information about the antlr-interest
mailing list