Re: [Cgdb-devel] Mac OS X 10.5 cgdb Patches
Brought to you by:
bobbybrasko,
crouchingturbo
From: Kyle M. <ma...@gm...> - 2009-07-23 07:44:24
|
On Jul 22, 2009, at 19:13, Bob Rossi wrote: >>>> Additionally, Mac OS X commonly uses files with >>>> extensions .cp, .m, .mm and .M. These files are not currently >>>> colorized by the cgdb tokenizer. The C tokenizer does a very good >>>> job >>>> with these (.cp = C++, .m = Objective-C, .mm/.M = Objective-C+ >>>> +). A >>>> simple patch to tokenizer.c allows the C tokenizer to colorize >>>> these. >>>> The patch is attached to cgdb bug 2806868 here: >>>> >>>> https://sourceforge.net/tracker/?func=detail&aid=2806868&group_id=72581&atid=534974 >> >> What about the ".cp" extension? That's a normal C++ file? Please >> add >> the .cp extension to the list of extensions handled by the existing >> lexer -- ".cp" is a commonly used C++ extension in a variety of open >> source file projects. > > OK, I will do this. > >>> I can show you what to do if you want. It's mostly just a flex >>> scanner >>> under the hood. All you really need to do is enumerate all the >>> keywords. >> >> Sure, I'll be happy to create a flex scanner since it will be >> basically a >> copy of the C/C++ one that's already there plus recognition of the >> few >> special Objective-C keywords/types that are added and '#import'. The >> existing C/C++ scanner already does 99% of what it needs to do for >> Objective-C/Objective-C++ sources. >> >> Just point me to the code. > > OK, I will, give me some time to refresh my memory and I'll give you > some good instructions. Okay, I've attached a patch that adds a new lexer for Objective-C/ Objective-C++ files. The attached patch (lexer-patch.gz) is against revision 929 (the latest on trunk) of the cgdb subversion repository (and can be applied with patch -p1 to a checkout of http://cgdb.svn.sourceforge.net/svnroot/cgdb/cgdb/trunk) . The patch also includes the addition of ".cp" to the c_extensions list and includes the C-specific enhancements I added for objclexer.l as a patch to the C lexer as well: * Now recognizes hexadecimal integer literals * Now recognizes \octal and \xHEX character constants as literals ('\x55' '\012') * Now recognizes 'NULL' as a literal * Now recognizes false and true as literals (they are defined as the two boolean literals in the standard) not keywords. * Now recognizes integer suffixes and optional minus sign as part of the number literal * Now recognizes floating point constant literals * Now recognizes the leading 'L' as part of the literal for wide character and wide string literals And tokenizer-driver.c was updated as well to support 'objc' as a lexer name. It builds, runs and highlights properly for me. Other than the new objclexer.l file (which is about 80% the same as clexer.l), the changes are pretty minor. Kyle |