[cfe-dev] [PATCH]: Parsing for C++ classes
Chris Lattner
clattner at apple.com
Tue Jun 24 11:11:01 PDT 2008
On Jun 24, 2008, at 11:07 AM, Argiris Kirtzidis wrote:
> Chris Lattner wrote:
>>
>> + /// LexedMethodStacks - During parsing of a top (non-nested) C++
>> class, its
>> + /// inline method definitions and the inline method definitions
>> of its nested
>> + /// classes are lexed and stored here.
>> + /// A new lexed methods stack is pushed for local classes in
>> inline methods.
>> + std::stack< std::stack<LexedMethod> > LexedMethodStacks;
>>
>> Out of curiousity, why use a std::stack instead of std::deque or
>> std::vector?
>
> About the outer stack, it's the last "MethodTokensForOneClass"
> pushed that is going to be used for adding lexed methods, so a stack
> seems appropriate.
Ok
> About the inner stack, there won't be a difference whether it's a
> stack, list or deque, although std::vector might not be as
> appropriate since there's no need to have LexedMethods in contiguous
> memory.
> Since a std::stack was already brought in for the outer stack, I
> figured I could use it again to avoid bringing in an additional
> container.
std::stack is actually not a container, it is an adaptor that wraps
std::deque (by default).
>> These really push one 'nested class' worth of methods, right? It
>> might be better to name these "PushClassStack" or something.
>
> Ok to both suggestions.
> Just a sidenote, I think these containers and methods will need
> refactoring to accomodate other types of "delayed parsing", like
> default parameters. So they are subject to change; probably a new
> class will be added for all this.
Makes sense, using a new struct (even with one member) is even better
than a typedef!
>> In Parser::ConsumeAndStoreUntil, do you think it would make sense
>> to specialize it for T=r_brace, or do you expect other clients?
>
> This method calls itself recursively for braces and parentheses.
Ok!
-Chris
More information about the cfe-dev
mailing list