Hi,

I also thought about doing this. I guess it really depends on the 
Parser, if it has state associated it needs to be resetted. Since a 
grammer can contain arbitrary member definitions of a parser it also 
really depends on the grammar at hand.

But I guess you are wondering about the internal state that a parser 
always has, i.e. in Java the BaseRecognizer class. I am not sure about 
that, but I am also interested in a definitive answer. Yet my 
performance tests have shown that creating these objects a new is not 
expensive not regarding the generated GC load though. If an application 
is already at a tight memory state one wants to avoid creating new 
objects as far as possible.

Best,
Paul

Chris Lambrou schrieb:
> Hi all,
>
> Is there any reason why I should consider recycling lexers and parsers 
> in preference to creating new instances on demand?
>
> For example, should I consider doing this:
>
>     existingLexer.Reser();
>     existingLexer.CharStream = charStream;
>
> instead of this:
>
>     new MyGrammarLexer(charStream);
>
>
> And should I do this:
>
>     existingParser.Reset();
>     existingParser.TokenStream = tokenStream
>
> instead of this:
>
>     new MyGrammarParser(tokenStream)
>
>
> Are parsers and lexers especially heavyweight at all?  If the answer 
> depends on the context, then I should point out that I'm using the C# 
> runtime, and parsing many different input strings.
>
>
> Thanks,
>
> Chris
>
>
> ------------------------------------------------------------------------
>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: 
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>   


-- 
Paul Bouché
Voice: +49 30 590080-1284
 
Nokia Siemens Networks GmbH & Co. KG, An den Treptowers 1, 12435 Berlin, Germany
Sitz der Gesellschaft: München / Registered office: Munich
Registergericht: München / Commercial registry: Munich, HRA 88537
WEEE-Reg.-Nr.: DE 52984304

Persönlich haftende Gesellschafterin / General Partner: Nokia Siemens Networks 
Management GmbH
Geschäftsleitung / Board of Directors: Lydia Sommer, Olaf Horsthemke
Vorsitzender des Aufsichtsrats / Chairman of supervisory board: Lauri Kivinen
Sitz der Gesellschaft: München / Registered office: Munich
Registergericht: München / Commercial registry: Munich, HRB 163416


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~----------~----~----~----~------~----~------~--~---

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

Reply via email to