On Tue, Nov 9, 2010 at 1:26 PM, David Wigg <[email protected]> wrote: > I updated the CPP_parser from Antlr1 to Antlr2. Ramin Zaghi has done a > great job to convert that to run under Antlr3. However, we do still > have a problem with understanding one particular piece of code. > > This is in an include file, iosfwd (1998). shown below. The line in question > is > for (_N = 0; !eq(*_U, _E(0)); ++_U) > and I would like to know what _E(0) is in order to able to parse it > properly. It must be something that returns a value (like a pointer?). > It looks to me like very early C code for a typecast but a later > version (2007) of iosfwd has something similar, "_Elem()", in that > position so I suppose it can't be a typecast. > Is it a function? It can't be a class because a class doesn't return a value. > > I hope some C++ expert can help. If so, it would be a great help if > he/she could quote chapter and verse from Stroustrup's book (Third > Edition, or indeed any other) as well since that would help to get our > C++ grammar file correct.. > > Thanks. > > David Wigg
<code snipped> _E(0) is either a) a "function style cast" (when _E is a type with no constructors) or b) a constructor call (when _E is a type with constructors). So, in the case you're asking for, an _E of value 0 is constructed as part of a search for the end of a null terminated string of _Es. And the same syntax can be used whether _E is a simple type or (say) a class type. HTH Stuart Dootson 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.
