[antlr-interest] [C target] INPUT -> TOKENS->AST ->MyAST problems
Юрушкин Михаил
yurushkin at rambler.ru
Thu Oct 22 15:52:39 PDT 2009
I know, you don't like be already))
Excuse me for my annoyance, but currently it's very important for me to
understand some antlr features.
I have my own AST (on C++)... I use C target, because there are no another
ways.
At first I didn't use AST building... but it was difficult to support
different problems...
Currently I think to do the following: create AST and convert this AST to
my own...
But I have a problem with TREE PARSER GRAMMAR.
!!!FIRST SITUATION!!!
rule [returns MySuperNode res]
:
^ a=ruleA, b=ruleB, c=ruleC,... z=ruleZ TOKEN1
{ res = f(a.res, b.res, c.res, ..., z.res); };
a, b, c, ..., z - subtries OF MY TREE, pointers.
If at the end of rule the exaption is occured (at the matching of the
token), rule will report an error and return.
AND ALL POINTERS WILL BE FORGOTTEN. Is there standard method for C target,
to survive from memory leaks??
Use auto_ptr's?
!!!SECOND SITUATION!!!
rule [returns MySuperNode res]
:
^ a=ruleA, b=ruleB, c=ruleC,... z=ruleZ // without TOKEN1
{ res = f(a.res, b.res, c.res, ..., z.res); };
If at the end of rule the exaption is occured (at the matching of the
ruleC), BUT HASEXCEPTION() will be equal FALSE!!! because error was
processed in rileZ... And
"{ res = f(a.res, b.res, c.res, ..., z.res); };" will be processed with
z.res=GARBAGE.
SOO... HOW CAN I DISCARD ACTION PROCESSING IF ERROR WAS FIRED IN CHILD
SUBTREE??
thank u =)
--
Best regards,
Michael
More information about the antlr-interest
mailing list