i just realized i should move thi sout of the runtime...forgot token
was in there. I can move it so we can all avoid this last minute
runtime change! Sorry...hang on for the removal...
Ter
On May 1, 2008, at 10:57 AM, Micheal J wrote:
> Hi,
>
>>> On May 1, 2008, at 10:02 AM, Johannes Luber wrote:
>>>
>>>> Hi!
>>>>
>>>> I've noticed following new addition to the Token class:
>>>>
>>>> public static final Set legalOptions =
>>>> new HashSet() {
>>>> {
>>>> add(defaultOption);
>>>> }
>>>> };
>>>>
>>>> Can someone explain me, what that code snippet actually does? It
>>>> looks like that a new HashSet is created and that the variable
>>>> defaultOption is added, but that's a guess as I have never
>> seen such
>>>> syntax before. Am I right?
>>>>
>>>
>>> The {...} is a ctor for the unnamed anon inner class. weird, eh?
>>>
>>> Ter
>>>
>>
>> And what for do you intend to use this inner class for? C#
>> doesn't have a direct equivalent.
>>
>> Johannes
>
>
> This translates to something like:
>
> ... class Token
> {
> ...
>
> static readonly IDictionary<string,string> legalOptions;
>
> ...
>
> static Token()
> {
> legalOptions = new Dictionary<string,string>();
> legalOptions.Add(defaultOption, defaultOption);
> }
>
> ...
> }
>
> Notes:
>
> 1. C# has no built-in Set type so you may use a list or dictionary
> etc. I
> prefer a dictionary as it is faster to search (for set membership
> tests).
> Just use same value for key and value.
>
> 2. The static ctor simulates the actions of the anonymous inner class
>
> 3. If you prefer, you may build a set type for C# (or reuse one from a
> BSD-compatible library)
>
>
> Micheal
>
> -----------------------
> The best way to contact me is via the list/forum. My time is very
> limited.
>
> _______________________________________________
> antlr-dev mailing list
> [email protected]
> http://www.antlr.org:8080/mailman/listinfo/antlr-dev
_______________________________________________
antlr-dev mailing list
[email protected]
http://www.antlr.org:8080/mailman/listinfo/antlr-dev