[antlr-interest] [BUG] 3.0b4 no complaint on parser reference to lexical fragment
Kay Roepke
kroepke at classdump.org
Sun Nov 12 17:16:26 PST 2006
On 13. Nov 2006, at 1:21 , John B. Brodie wrote:
> i have declared C to be a fragment, doesn't fragment mean "part
> of" ? aren't
> fragments meant to be internal to the lexer. does it make sense
> for C to be an
> internal "part of" one token and then be the whole of (via set
> token type) of
> another token ?
I didn't mean the "token C" but the "token type C". I could do the
following:
fragment
C : 'c'
;
B : 'b' ('a' { $type = C;})?
and it would be perfectly legal (and maybe even sensible...;))
>> Throwing an error here would mean that you couldn't reference any
>> tokens from
>> a @tokens section, for instance.
>
> (i am not aware of a @tokens section, to you mean tokens{...} (no
> @) ?)
yes, t'was a typo
> sounds like an unfortunate mixing of functionality between fragment
> and the
> tokens{...} section
fragment only means that it will not be directly called from
nextToken (and certain
stuff isn't done in a fragment rule, but that's for optimization only).
It is still a lexer rule and still produces an entry in the token
vocabulary, thus its
token type can be used and referred to in parsers.
cheers,
-k
--
Kay Röpke
http://classdump.org/
More information about the antlr-interest
mailing list