[antlr-interest] ANTLR 3: XML Parsing tutorial

Oliver Zeigermann oliver.zeigermann at gmail.com
Sun Dec 24 03:41:34 PST 2006


Hi Mark!

2006/12/24, Mark Mandel <mark.mandel at gmail.com>:
> Hey,
>
> (Quick prefix with a ANTLR newbie disclaimer)
>
> Quick question for you all:
>
> Looking at:
> http://www.antlr.org/wiki/display/ANTLR3/1.+Lexer
>
> The rule in question is:
> WS  : (' '|'\r'|'\t'|'\u000C'|'\n') {channel=99;}
>     ;
>
> 2 questions on the statement made on this rule:
>
> (1)
> 'The rule WS is special as it recognizes all white spaces, but does
> not pass it to the next stage, the token parser, because we don't care
> about white spaces.'
>
> Any reason why a $channel=HIDDEN was not used (I realise this is the
> same, but, I would have thought it would make more sense to a new
> user?)

$channel=HIDDEN would actually be better I guess.

> (2)
> Sending the token to channel 99 is ANTLR's way of saying that.
> '0'..'9' is a short form of saying (0|1|2|3|4|5|6|7|8|9) and 'a'..'z'
> respectively for the characters from a to z.'
>
> Is it just me, or does this sentence not make any sense?

Does not make sense to me neither. However, if you include the
sentence directly before that:

"The rule WS is special as it recognizes all white spaces, but does
not pass it to the next stage, the token parser, because we don't care
about white spaces."

Does it make sense?

> >From what I've been reading, sending the token to chennel 99 is ANTLRs
> way of saying, 'please ignore this token, because we do not care about
> it at this time'.  Am I wrong?

That's right and may be a better phrasing.

Anyway, it is a Wiki. If things do not sound clear, you are free and
welcome to make them better :)

Cheers

Oliver


More information about the antlr-interest mailing list