[antlr-interest] Recursive rule invocation

Jeroen van Schagen jeroen.v.schagen at gmail.com
Sat Aug 29 03:57:36 PDT 2009


Can somebody please tell me what is recursive about the
*markupStatement*production in the following grammar? The problem
disappears when I remove
the expression NT symbol from argument, but this is required for my
language. Is it solvable without having to enable backtracking?
*markupStatement: markup+ expression ';' *
* **| markup+ regularStatement ';' *
* **| markup+ embedding ';'*
* **| markup+ ';' *
* **;*

where..

markup: IDCON attributes arguments?
-> ^( MARKUP IDCON attributes arguments? ) ;
attributes: attribute*
-> ^( ATTRIBUTES attribute* );
attribute: '#' IDCON // ID attribute
| '.' IDCON // Class attribute
| '$' IDCON // Name attribute
| ':' IDCON // Type attribute
| '@' NATCON // Width attribute
| '@' NATCON '%' NATCON // Width-height attribute
;

arguments: '(' argument? ( ',' argument )* ')' ;

*argument:** **expression*
* **| IDCON '=' expression ;*

expression: ( IDCON | NATCON | TEXT | SYMBOLCON
| '[' expression? ( ',' expression )* ']' // List
| '{' keyValuePair? ( ',' keyValuePair )* '}' // Record
) ( '+' expression | '.' IDCON )* ;
keyValuePair: IDCON ':' expression ;

regularStatement:    'echo' expression ';' ;

embedding: PRETEXT embed textTail ;
embed: markup* expression ;
textTail: POSTTEXT | MIDTEXT embed textTail ;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090829/d2e48f1b/attachment.html 


More information about the antlr-interest mailing list