It is because you are trying to do things while you parse - another reason to 
build a tree and THEN operate on the tree.

Catch does not need a type in the C target, you can just use:

r:
  Ddddddd
;
catch() { }

(assuming 3.2 of ANTLR).

The other thing you might do is break up your rule list so that exceptions in 
them do not drop out the whole rule, which is what happens in all targets 
unless you structure the rules a little. Break things down in to smaller units. 
The function call overhead (which may not even occur because of inlining) is 
very small in C.

Jim

> -----Original Message-----
> From: [email protected] [mailto:antlr-interest-
> [email protected]] On Behalf Of Ìèõàèë Þðóøêèí
> Sent: Monday, October 19, 2009 2:37 AM
> To: [email protected]
> Subject: [antlr-interest] [c target] memory leaks during error recovery
> 
> Good day,
> I have the rule
> 
> myRule[returns Type1 res] :
>  rule1, rule2, rule3, rule4... ruleN { res = f($rule1, $rule2,..., ,
> $ruleN) }
>  ;
> 
> it's all ok.
> BUT if ruleN will fire exception, rule1, rule2.. rule(N-1) subtrees
> will
> be forgotten!!!
> How can I manage such situations?? can you write me right code for such
> rule, that gives answer on my question?
> thanks
> 
> PS: I tried to use "catch" attribute .. but it needs errorCode. It's
> not
> good, because there're may be different errors.
> 
> --
> Best regards,
> Michael
> 
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-
> email-address




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

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to