It's funny that you mentioned this because I dealt with this issue last week. See JMD, Markdown, and a brief overview of analysis and compilers . I am working on a true Markdown analyzer and I tried it with ANTLR.
There are several ways you can handle this.
-, :
BLOCK_QUOTE : '>' (' ' | '\t')? ;
, , .
- , , :
@members {
int quoteDepth = 0;
}
BLOCK_QUOTE : '\n' (q+='>' (' ' | '\t')?)+
{ if ($q.size() > quoteDepth)
else if ($q.size() < quoteDepth
quoteDepth = $q.size(); }
, . .
, Markdown , .
, , , , , . ( ) The Definitive ANTLR Reference: .
ANTLR . , , .