CODE:
from CppHeaderParser import CppHeader
code = """
struct Struct
{
#define DOUBLE(var) \
((var) * 2)
UINT32 var;
};
"""
cppheader = CppHeader(code, argType="string")
print "1. Executed successfully"
fd = open(<INSERT FILE NAME FOR CODE ABOVE HERE>)
code = "".join(fd.readlines())
fd.close()
cppheader = CppHeader(code, argType="string")
print "2. Executed successfully"
OUTPUT:
1. Executed successfully
Traceback (most recent call last):
File "C:\eclipse_wa_python\t4\parser.py", line 18, in <module>
cppheader = CppHeader(code, argType="string")
File "C:\Python27\lib\site-packages\CppHeaderParser\CppHeaderParser.py", line 2122, in __init__
% (self.headerFileName, tok.lineno, tok.value, " ".join(self.nameStack)))
CppHeaderParser.CppHeaderParser.CppParseError: Not able to parse on line 5 evaluating ";"
Error around: ( ( var ) * 2 ) UINT32 var
Sorry, this one works for me. Do you have white space after the \ in the #define? Can you attach a .cpp file in case there is something copied over in a copy/paste
By .cpp I mean .h. I tried as a string and as a file. Unix format and dos format. There has to be some extra char in there somewhere
header crashing module
Does not work for me on Win 7 and AIX 5.3. Python 2.7.3. I thought it had something to do with the join but you know best.
Versions:
CppHeaderParser = Head
ply = 3.4
CODE:
from CppHeaderParser import CppHeader
code = """
struct Struct
{
#define DOUBLE(var) \ ((var) * 2)
UINT32 var;
};
"""
cppheader = CppHeader(code, argType="string")
print "1. Executed successfully"
cppheader = CppHeader("test.h")
print "2. Executed successfully"
OUTPUT:
1. Executed successfully
Traceback (most recent call last):
File "C:\eclipse_wa_python\t4\parser.py", line 14, in <module>
cppheader = CppHeader("test.h")
File "C:\Python27\lib\site-packages\CppHeaderParser\CppHeaderParser.py", line 2122, in __init__
% (self.headerFileName, tok.lineno, tok.value, " ".join(self.nameStack)))
CppHeaderParser.CppHeaderParser.CppParseError: Not able to parse test.h on line 5 evaluating ";"
Error around: ( ( var ) * 2 ) UINT32 var
Oh. No extra characters. From my testing, it has something to do with the nested parenthesis on the second line of the #define.
Fixed in commit 95:859cf19a5981
Issue was the #define had whitespace in front of it
AIX, I am very curious what you are using this library for. I love to hear what people use it for if you could tell me.