This should be very easy to do with Dacorbi Pattern Search. Let me show you how. Let me start with a before/after shot of a sample header, which you'll see to the right (the after shot is obtained by pressing Replace All):
Before

After

There is no need to write complicated parsing code. Dacorbi Pattern Search handles that part for you. All you have to do is create a series of Search / Replace rules using Dacorbi Patterns (you can then save it for further use). Basically, you tell it:
- When you find something like 0xFFFF change it to &HFFFF
- When you find something like #define Add(a, b) a+b, change it to Macro Add(a, b) = a + b
- etc.
The rules all works concurrently. Here, I have just 8 rules, and you can see just one of them in the screenshot. You will want to gradually add to it (community project anyone?). Here is the list of all 8 rules in this example: (they all have the "Pass Once" box checkmarked; also some lines have a carriage return in the Replace box, but you can't see it in the representation below):
---------------- Pattern 1 of 8 ----------------
Find
const {ConstantName} = {Value};
Replace With
%{ConstantName} = {Value}
---------------- Pattern 2 of 8 ----------------
Find
const {DataType} {ConstantName} = {Value};
Replace With
macro {ConstantName} = {Value}
---------------- Pattern 3 of 8 ----------------
Find
//
Replace With
'
---------------- Pattern 4 of 8 ----------------
Find
/* {Comment} */
Replace With
---------------- Pattern 5 of 8 ----------------
Find
#define {Constant} {"\r\n"}
Replace With
%{Constant} = 1
---------------- Pattern 6 of 8 ----------------
Find
#define {MacroName} {Value} {"\r\n"}
Replace With
Macro {MacroName} = {Value}
---------------- Pattern 7 of 8 ----------------
Find
#define {MacroName}({Params}) {Value} {"\r\n"}
Replace With
Macro {MacroName}({Params}) = {Value}
---------------- Pattern 8 of 8 ----------------
Find
{HexPrefix:"0x"}{HexNumber:"[0-9A-F]+"}
Replace With
&H{HexNumber}
Leave a comment: