"Eric M. Ludlam" <eric@...>
on Wed, 18 November 2009 (18:59 EST)] wrote:
>> I have recently started using CEDET with boost and have narrowed down a
>> parsing "problem."
>> The problem is that #ifdef pre-parsing is not evaluating correctly.
>> An example of this type of statement is as follows:
>> #if defined(BOOST_NO_MEMBER_TEMPLATES) && !defined(BOOST_MSVC6_MEMBER_TEMPLATES)
> Hi Brian,
> Your assessment is correct. The preprocessor in CEDET for C doesn't
> do much for complex expressions. It's been in there for a couple years,
> and you're the first person to notice. :)
Yeah. Not often that I'm the first to notice stuff.
> The reason is that it isn't really a very simple problem. We are
> deep in the lexical analyzer, and suddenly we need a lexical analyzer to
> solve this problem. Right now we just have a bit of a short cut for the
> simple case of a single expression.
Indeed it is not a very simple problem.
> Ideally, we'd use the lexical analyzer and a parser to solve the
> problem, except we are trying to do a single pass lexical analysis,
> instead of the tradition 2 pass that gcc and most other compilers employ.
> If you'd like to take a crack at this problem in
> semantic-c-do-lex-if, I expect that the solution is to change the regex
> in semantic-lex-c-if to exclude the expression, and to extract it 'by
> hand' in semantic-c-do-lex-if where it could then be evaluated. If you
> don't have time, hopefully I can examine this more after Thanksgiving.
I started by looking at that function into how to handle this and realized that
it was anything but trivial. I'm not exactly a fluent (e)lisp developer but
I've been looking for something to sink my teeth into for some time.
I also looked at hideif.el (in emacs/lisp/progmodes) which gave another good
start, but then started noticing that it would take some time to deal with
anything besides the #if (defined(X) && defined(Y)) || defined(Z). But even
that required some parsing. I'll give it a go and let you know if I find
anything that will work. (of course, if I _actually_ do (which may be a
stretch) you'll be welcome to use/throw away as you see fit.
> If your patch is over 10 lines long or so, I'll also need a release
> so your changes can be included in Emacs.
No doubt the solution that I was thinking about would have been way over 10
lines. But maybe I'm not thinking about the correct approach. If I get
something working, than I'll send you what I do and we'll figure out the
paperwork if/when I do.
> Also, if it helps, you can disable
> semantic-c-obey-conditional-section-parsing-flag to just go with the
> 'whatever' approach. :)
I may have to do just that in the short term.
Of course I also noticed that the following is also not quite right, but this
is a result of my looking at the first problem and is not really that much of a
problem for me right now:
In this case both a(), and b() are parsed. Again not an issue for me and is
obviously a sibling of the first issue.
I'll keep working in my spare time to see if I can find a way to work with more
complex preprocessor statements.
PS: Thanks again for your awesome set of tools.
PPS: How'd the pumpkin toss go?