[antlr-interest] ANTLR grammar processing returns strange warnings

Yann Gauteron ygauteron at gmail.com
Wed May 20 09:00:19 PDT 2009


Hi everyone,

I noticed something weird. If I take the same file TestKO.g than the
one I sent this morning and I processed it again this afternoon, ANTLR
did not return any warnings! Weird I said.

I'll keep the advice of Jim in case the problem appeared again. This
timeout "thing" can be one possible cause of such sporadic problem.
I'll keep you informed if the problem appears again and if it is
solved with the parameter of Jim.

Michael, I put the EOF in the main rule. Thanks for the advice. :-)

Gerald, many thanks for your analyzis. However, I can not understand
why ID_ETHERTYPE can conflict with T_MACADDR.
ID_ETHERTYPE          // DOCSIS 1.1: TLV [22|23].10.3
  : 'EtherType';

T_MACADDR       // MAC address ("00:11:22:33:44:55")
  : S_HEX S_HEX ':' S_HEX S_HEX ':' S_HEX S_HEX ':' S_HEX S_HEX ':'
S_HEX S_HEX ':' S_HEX S_HEX;

fragment S_HEX
  : ('0'..'9' | 'a'..'f' | 'A'..'F');

As far as I understand ANTLR grammar writing, ID_ETHERTYPE can only
match the exact string 'EtherType'. 'E' would not be a valid
ID_ETHERTYPE token. T_MACADDR could only match MAC addresses in the
"classic" form (two hex digits separated with a colon). Here again 'E'
could not be considered as a valid T_MACADDR (as well as 'EtherType'
which is not a valid T_MACADDR token). This was the reason why I was
not able to understand why it would have been any ambiguity in my
ANTLR grammar. If my understanding of ANTLR grammar/behaviour is
incorrect, don't hesitate to correct me! It would avoid me to go
deeper in a wrong direction and to be more effective with ANTLR.

Anyway, I was now able to process my grammar file. I'll continue
writing the grammar to integrate the missing IDs and rules.

Thanks for your help and your answers!
Y.


More information about the antlr-interest mailing list