[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: parser improvement suggestion

From: asmwarrior
Subject: Re: parser improvement suggestion
Date: Thu, 09 Jun 2011 09:42:04 +0800
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20081209 Thunderbird/ Mnenhy/

On 2011-6-8 15:52, Jean-Marc Saffroy wrote:
Mostly, I think you need to use the "recursive decent parser", so you create a
lot of functions like:
With the approach you suggest, is it still possible to parse things like

#ifdef foo
class foo {
class bar {
Yes, currently, codeblocks' parser can handle this kind of preprocessor directive. But there are some limitations.
#if Const Expression
It need to do Const expression calculation and Macro expansion. Mostly, it need a Macro symbol table look-up. and note that each translation unit should have its own symbol table, so this is a time consuming work.

Current way, we just simplified this, if a symbol is not found, we just set if to "0", so we can always take a conditional preprocessor branch, although it is not 100% correct branch.

ctags has the same way to handle conditional preprocessor directives.
Global felt quite mature to me the last 10 years I used it. :)

Well, I'd admit that if your code is very complex (contains a lot of c++ template and template partial specialization), It is hard to parse them. This time, a full compiler front end can solve the issue, but a full compiler is always running slowly.:-) Clang compiler has an index feature, but gcc currently doesn't have such feature.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]