[antlr-interest] Simple ASP-like grammar

Dimitrios Kolovos dskolovos at gmail.com
Wed Nov 30 01:21:38 PST 2005


I have found a working solution in case someone faces the same issue 
sometime later. Thanks for your replies!

AnyTextBlock
    :
    (
    '\0' .. '\u00FF'
    {
        if (LA(1) == '%' && LA(2) == ']'){
            break;
        }
        else if (LA(1) == '[' && LA(2) == '%'){
            break;
        }
    }
    )+
    ;

Cheers,
Dimitrios

Rob Greene wrote:

>On 11/29/05, Dimitrios Kolovos <dskolovos at gmail.com> wrote:
>  
>
>>The grammar I have developed is compiled without errors or warnings.
>>However the parser returns the whole text as a single child of the root
>>AST node. I have tried to find similar grammars on the web but no luck.
>>    
>>
>
>I'm going to punt. Being the newbie, take this with a grain of salt...
>I've read that ANTLR's lexer is greedy. I'd guess that once it enters
>either of the antText or tagged rule, there's nothing to make it exit.
>I'm not sure if the answer is to define the "[%" and "%]" in the lexer
>or to exclude them from the AnyTextBlock.
>
>Hope that leads to something...
>-Rob
>
>  
>


More information about the antlr-interest mailing list