AntlrGrammarXWiki
Last modified by Thomas Mortagne on 2017/03/24 12:26
ANTLR Grammar for XWiki syntax
This is part of the new XWiki rendering component work. I need to write an ANTLR grammar for XWiki.
This is where I'm at now but it's not working fine. For example it doesn't recognize {macro/}:
grammar xwiki;
document : block+
;
block : section
| paragraph
;
paragraph : sentence NEWLINE
;
section : SECTIONTITLE WS sentence NEWLINE
;
sentence : elementBlock (WS elementBlock)*
;
elementBlock : macro
| word
;
macro : '{' ID (':' macroParams)? '/}'
;
macroParams : macroParam ('|' macroParam)*
;
macroParam : ID '=' ID
;
word : boldWord
| italicWord
| underlineWord
| WORD
;
boldWord : '*' WORD '*'
;
italicWord : '~~' WORD '~~'
;
underlineWord : '__' WORD '__'
;
SECTIONTITLE : '1.1.1.1.1.1'
| '1.1.1.1.1'
| '1.1.1.1'
| '1.1.1'
| '1.1'
| '1'
;
WS : (' '|'\t')+
;
NEWLINE : '\r'? '\n'
;
WORD : ~('\n'|'\r'|' '|'\t'|'{')+
;
ID : LETTER (LETTER | DIGIT)*
;
fragment LETTER : 'a'..'z' | 'A'..'Z';
fragment DIGIT : '0'..'9';