[antlr-interest] Problem with C target output on example C grammar

Kamil Burzynski nopik at data.pl
Wed Apr 2 11:33:39 PDT 2008


Hello,

>> As you see, only last scope (C) was initialized.

> OK - will look at that.

Thanks.

> On the smart pointer thing, I did not realize (as I don't use smart
> pointers) that they were passed around using a reference that was not
> nullable, but I was looking at supporting boost for the C++ stuff, so
> I guess it would have fallen out of the trying. I will look into that,
> but I am still thinking that the answer is that it is better not to
> initialize the return value.

Yeah, when I look at generated code, in my trivial examples it is not
necessary to initialize this value at all. I do not know if there is
possibility that in more complex example it is safe..
I was also thinking about default constructor, like:
  int i = int();
which in C++ guarantees to initialize plain types to 0 (or to your values in case of
custom classes). This would work with smart pointers and 99% of other
classes (and structs?) as well. However, with complex classes copying of
the resulting object may be problematic and unexpected.
Anyway, this do not work in C, unfortunately :)

> Incidentally, rather than passing things up and down the rules, you
> might find i easier to create helper classes in higher up scopes.

Yes, I was trying to do so, too. This is why I reported the second error
about multiple scopes :D

-- 
Best regards from
Kamil Burzynski



More information about the antlr-interest mailing list