Open mohawk2 opened 10 years ago
I'd put it in a base class Inline::Parse for the 3 parsers. I don't think it needs to go in Inline::C.
It's really just a debugging thing, I think. Only a tiny bit of the C is parsed.
I'd like it available to use not for debugging, but for assisting with easing FFI. And I'd argue it's not a general Inline::Parse thing because it's only parsing C, and Inline::C already does that.
In other words, I am proposing that the internal API that already exists would be slightly modified and exposed to the outside world. So instead of:
$parser->code($code); # puts data in $parser->{data}{function} etc
it would be:
$data = $parser->code($code); # similar structure but passed as data
By the way, should Inline::C::get_types be changed to use one of https://metacpan.org/pod/ExtUtils::XSBuilder or https://metacpan.org/pod/distribution/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm ? We could also look to collaborate or steal ideas from these guys.
It may be overkill, but maybe looking at the API of MarpaX::Languages::C::AST might be useful.
E.g.:
And possibly specifying which parser to use: