c++ - Parsing C Header Files -
c++ - Parsing C Header Files -
i have c header file have precompiled using gcc -e
flag, , trying parse using lex , yacc; however, getting hung on typedef'd variables.
for example:
typedef unsigned long ulong; ulong = 5;
will throw syntax error @ sec line's ulong.
i have tried redefine part of grammar (found here) http://www.quut.com/c/ansi-c-grammar-y.html, under type_specifer
replacing type_name
identifier
, create multiple s/r , r/r errors unable fix.
are there other approaches recommend? or different approach @ precompiling together?
in code link too: http://www.quut.com/c/ansi-c-grammar-y.html,
look @ bottom: see function
int check_type(void) { /* * pseudo code --- should check * * if (yytext == type_name) * homecoming type_name; * * homecoming identifier; */ /* * homecoming identifier */ homecoming identifier; }
you need write code identifies weather sequence (yytest, yytext+yylength] identifier or type_name. means in parser need build construction parse code function can identifier in structure.
pre-populate construction default types char/int/short/long/float/double etc. other types need add together parse input.
c++ c yacc lex
Comments
Post a Comment