Author Topic: How to configure tagging to ignore weird macros while lexing?  (Read 3128 times)

chrisant

  • Senior Community Member
  • Posts: 1410
  • Hero Points: 131
First, I don't have control over how the source files are managed in the project I work on (I am but one out of 2000+ people working on hundreds of thousands of files, I try, but I don't have enough clout :'().

So I'm looking for some help configuring Slick to be more forgiving about the weird things other people do.  I tried a few searchs in the forums for things like "tagging lexer" but didn't manage to find an answer.

For example, there is a header file like this:
Code: [Select]
#pragma once
interface ISomeInterface;
WEIRD_MACRO_THAT_BEGINS_NAMESPACE
enum SomeType
{
    sometypeValue1,
    sometypeValue2,
};
WEIRD_MACRO_THAT_ENDS_NAMESPACE

Slick says that "sometypeValue1" (etc) is not tagged.  If I put a semicolon after the two weird macros, then Slick tags the enum values (but it doesn't compile anymore).  If I replace the weird macros with the (much fewer) characters they resolve to, then I get beaten senseless with broken keyboards wielded by mobs of fanatical developers.

How can I customize the tagging lexer to ignore certain weird macros?  There are about 30 weird macros that I'd like it to just completely ignore while tagging files.

Graeme

  • Senior Community Member
  • Posts: 2638
  • Hero Points: 330
Re: How to configure tagging to ignore weird macros while lexing?
« Reply #1 on: May 14, 2008, 11:39:04 am »
That's what the C/C++ preprocessing settings are for - options -> languages -> C/C++ preprocessing.  There's some predefined ones  - a few for Microsoft, several hundred for boost!

For some reason if you add WEIRD_MACRO_THAT_ENDS_NAMESPACE and define it as // hello with no RETURN after it, it doesn't work and the tagging still fails to find sometypeValue1  - but if I add a RETURN after // hello, the tagging finds sometypeValue1 correctly.  Seems like a bug to me because it's not obvious that a RETURN is required.  #undef of WEIRD... doesn't work either - not sure if it should.

Graeme

Edit : I was experimenting a bit more with this RETURN problem and now I find I can't reproduce it.  The RETURN is no longer required  - even leaving the macro expansion completely blank works, which was the first thing I tried.
« Last Edit: May 14, 2008, 12:03:35 pm by Graeme »

chrisant

  • Senior Community Member
  • Posts: 1410
  • Hero Points: 131
Re: How to configure tagging to ignore weird macros while lexing?
« Reply #2 on: May 14, 2008, 04:59:53 pm »
Awesome, thanks, Graeme (HP++).
And thanks, SlickTeam!, this is the whiz-bang approach that I wasn't even going to ask for. 8)