-
Notifications
You must be signed in to change notification settings - Fork 17
Open
Description
It might be ambitious, but I'm trying to parse /usr/include/math.h (on OS X)
Here's what I have so far:
f = '/usr/include/math.h'
prep = C::Preprocessor.new
# XXX: bug #4
prep.pwd = File.expand_path('.')
source = prep.preprocess_file(f)
# XXX: there seem to still be some '#' lines, which cause Cast to choke
source.gsub!(/(^\#.+)/, '')
begin
ast = C.parse(source)
rescue C::ParseError => e
p e
# XXX: feature request #3
line_num = e.message.match(/\d*/)[0].to_i
puts source.lines.to_a[line_num-1]
endThe output of which is:
#<C::ParseError: 32:0: parse error on LPAREN (LPAREN)>
inline __attribute__ ((__always_inline__)) int __inline_isfinitel(long double);
So my guess is Cast doesn't support __attribute__, which I understand is not part of the C spec, but unfortunately is somewhat common in actual code. Description here: http://gcc.gnu.org/onlinedocs/gcc/Attribute-Syntax.html with all its infelicities.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels