dissect.cstruct
dissect.cstruct copied to clipboard
add support for const pointer array ```const char* arr[]```
Hello Together,
the dissect.cstruct is a real big deal to parse c files. For const *char i encounter the error, that const is unsupported. Following example:
from dissect.cstruct import cstruct
cdef = """
const char* pArrChr[] = {
"myStr1", /**< comment */
"myStr2", /**< comment */
"myStr3"
};
"""
cs = cstruct()
cs.load(cdef)
Following output:
File "/home/ubuntu/Desktop/dissect.cstruct/dissect/cstruct/cstruct.py", line 268, in load
TokenParser(self, \*\*kwargs).parse(definition)
File "/home/ubuntu/Desktop/dissect.cstruct/dissect/cstruct/parser.py", line 470, in parse
raise ParserError(f"line {self._lineno(token)}: unexpected token {token!r}")
dissect.cstruct.exceptions.ParserError: line 2: unexpected token <Token.IDENTIFIER value='const'>
Thanks again for your support.
BR, Andreas
Hey Andreas, while it would be really nice to support this, unfortunately the current parser is a little too inflexible to easily add support for this syntax. But I'll leave the ticket open for future reference!