[antlr-interest] Parsing problem in C++
stuart.dootson at gmail.com
Tue Nov 9 16:41:54 PST 2010
On Tue, Nov 9, 2010 at 1:26 PM, David Wigg <wiggjd at bcs.org.uk> 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..
> David Wigg
_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
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
More information about the antlr-interest