[antlr-interest] ANTLR ANTLR Grammar

shmuel siegel antlr at shmuelhome.mine.nu
Thu Sep 16 17:40:26 PDT 2010


  On 9/17/2010 2:09 AM, Zachary Palmer wrote:
> Hello all,
>
> I just tried to use the ANTLR grammar for ANTLR v3 which appears here:
> http://www.antlr.org/grammar/ANTLR
>
> I tried building it in ANTLR v3.1.3 and got the following messages:
>
> warning(105): /resources/grammar/ANTLRv3.g:93:9: no lexer rule
> corresponding to token: DOC_COMMENT
>    |--->  :   DOC_COMMENT?
>
> warning(105): /resources/grammar/ANTLRv3.g:248:6: no lexer rule
> corresponding to token: SEMPRED
>    |--->  |   SEMPRED ( g='=>' ->  GATED_SEMPRED[$g] | ->  SEMPRED )
>
> warning(105): /resources/grammar/ANTLRv3.g:157:4: no lexer rule
> corresponding to token: DOC_COMMENT
>    |--->  :    DOC_COMMENT?
>
> warning(105): /resources/grammar/ANTLRv3.g:354:22: no lexer rule
> corresponding to token: SEMPRED
>    |--->  :    (rew+='->' preds+=SEMPRED predicated+=rewrite_alternative)*
>
> warning(200): /resources/grammar/ANTLRv3.g:472:5: Decision can match
> input such as "' ''$''A''N''T''L''R'' ''s''r''c'' ''"''\\''\'''"''
> ''0'..'9'" using multiple alternatives: 1, 2
> As a result, alternative(s) 2 were disabled for that input
>    |--->  (    ' $ANTLR ' SRC // src directive
>
> I looked through the grammar and the messages seem to be correct:
> DOC_COMMENT is defined as a special token and not as a lexical
> terminal.  Anyone have any suggestions as to what I should do about
> this?  I want to write some utilities to analyze the grammar I've
> written and doing so by walking over an AST of the grammar seemed to be
> the most promising choice.
>
> Thanks,
>
> Zach
The token warnings are exactly that. They are warnings. Even though 
there aren't any lexer rules by these names the lexer can produce these 
tokens. DOC_COMMENT is a special case of ML_COMMENT and SEMPRED is a 
special case of ACTION. The ambiguous rule is probably okay; the 
alternative picked is probably the one that you want. In other words, 
these warnings can be ignored for your purpose.



More information about the antlr-interest mailing list