Related articles |
---|
Parsing C++ manowar@sauropod.engin.umich.edu (1996-11-15) |
Re: Parsing C++ graham.hughes@resnet.ucsb.edu (Graham Hughes) (1996-11-18) |
Re: Parsing C++ nagle@netcom.com (1996-11-18) |
Re: Parsing C++ jsgray@acm.org (Jan Gray) (1996-11-19) |
Re: Parsing C++ jlilley@empathy.com (1996-12-03) |
Re: Parsing C++ dlmoore@ix.netcom.com (David L Moore) (1996-12-07) |
Re: Parsing C++ jlilley@empathy.com (1996-12-09) |
Re: Parsing C++ jlilley@empathy.com (1996-12-09) |
Re: Parsing C++ fjh@mundook.cs.mu.OZ.AU (1996-12-10) |
Re: Parsing C++ davidb@datalytics.com (1996-12-18) |
From: | jlilley@empathy.com (John Lilley) |
Newsgroups: | comp.lang.c++.moderated,comp.compilers |
Date: | 9 Dec 1996 00:07:03 -0500 |
Organization: | Empathy Software |
References: | 96-11-102 96-12-029 96-12-052 |
Keywords: | C++, parse |
dlmoore@ix.netcom.com says...
>One interesting thing about C++ is the "injection" rule which says that
>a method defined in a class is compiled as if it immediately followed
>the
>class:
>
> int foo;
> class A {
> void bar()
> {
> foo x;
> }
> enum foo {bar,bletch};
> };
This is not entirely correct. You are not allowed to change the
meaning of an identifier to a type after usage of the identifier has
been encountered. I think you can count on being able to parser
(recognize) the code in one pass, but at least some additional symbol
table management must be done after the entire class is seen. I don't
know what most compilers do, but it seems that the easiest approach is
to collect the list of tokens for a method body, and then reparse it
later.
On a slightly different subject, I know that the MSVC++ compiler, when
processing a template definition, simply squirrels away the token
list. For example:
template <class T> class A { foo bar blat adksljas 234 };
Will compile, but an instantiation of the template will produce
errors.
John Lilley
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.