parsing - How to compile yacc/bison with multiple files? -


i'd adjust yacc-parser of kconfig-libs (/<path-to-kconfig>/libs/parser). i'm having problems resolving various symbols, variables, functions, tokens, etc. guess problem is, compiling not files of kconfig-parser included. here's do:

lex lconf.l bison -d -y ./yconf.y  gcc -o yconf y.tab.c 

i error messages like:

./yconf.y 499:44: error: >>rootmenu<< not declared (first use in function) rootmenu.prompt = menu_add_prompt(p_menu, rootmenu, null);                                           ^  ./yconf.y:576:2: error: »zconfnerrs« not declared (first use in function) zconfnerrs++; ^  ./yconf.y:546:3: error: »zconfnerrs« not declared (first use in function) zconfnerrs++; ^ 

there more files (.c , .h) in directory of parser, (i guess) need included compiler-process: hconf.c, lconf.c util.c symbol.c menu.c expr.c confdata.c, lkc.h lkc_proto.h (but in sourcecode there specific #include commands)

i'm using code straight out-of-the-box. when use makefile in directory compiles without problems, doing manually shown above doesn't seem work. unfortunately makefile looks rather cryptic me - since i'm not makefile-pro - it's not easy did.

thanks advises, "pass" these files, compiling can done.

kind regards

[edit:] sources of kconfiglib, can found @ http://ymorin.is-a-geek.org/projects/kconfig-frontends. sources of parser located here: /<path-to-kconfig>/libs/parser

these build problems have little bison or flex. similar problems occur time try build complex software project without using project's build system.

so simple answer kconfig-frontends project built using autotools, means expected execute

./configure [options] 

in top-level directory in order create makefiles needed build project.

as usual, git repository doesn't include configure script. rather, necessary create script (and other necessary configuration files) using autotools.

if using release tarballs, won't need figure out how generate configure script, because is included in tarballs. have fewer problems build.

as aside, source management not simple problem , there many contrasting opinions how it. 1 of problems is quite common inject modifications source files during build process, example in order configure platform-specific defaults. example, take line:

rootmenu.prompt = menu_add_prompt(p_menu, rootmenu, null); 

found in conf_parse function towards bottom of yconf.y. here, rootmenu expected (i believe) string containing file path root menu; file path installation-specific, not defined anywhere in source. instead, injected in makefile, contain line like:

cppflags = -drootmenu="\"$(root_menu)\"" -dconfig_=\"$(config_prefix)\" ... 

(it's more complicated that; i'm simplifying process considerably. line in libs/parser/makefile.am , you'll find relevant in libs/parser/makefile after run ./configure @ top level.)

make passes cppflags -- is, c preprocessor flags -- c compiler when needs build object file. (there many such predefined variables; can find list in documentation make.) , gcc (and other c compilers) interpret -dmacro=value mean "predefine macro value before preprocessing these source files".

the consequence have macros definitions not visible anywhere in source files, unless consider input files automake part of source. unless know these macros, can't compile files without using bundled build system.

the above standard issue c/c++ source distributions. other problem have have been avoided (i think) common.

both flex , bison come option change prefix yy in generated code else. need if have more 1 parser or scanner in project; otherwise there clash of global symbols yylex or (in case) yynerrs. kconfig project uses prefix zconf, symbol zconfnerrs global variable parser increments each time reports syntax error. work, need set prefix when generate parser bison , scanner flex.

the prefix can set in command-line option, or can set in bison , flex source files. magic macros described above, using command-line option makes setting less visible. moreover, generated code won't compile , won't link if prefixes not set expected value. consequently, prefer set prefix in source file, not shares opinion, including, apparently, author(s) of package you're trying build.

i found settings in top-level configure file:

am_lflags="-l -p zconf" am_yflags="-t -l -p zconf" 

these settings used create lflags (flex flags) , yflags (bison "yacc" flags) variables makefile. (they're easy find if know you're looking for, that's no excuse.)

for it's worth, have put setting source files:

  /* flex (.l) file: */ %option prefix="zconf"    /* bison (.y) file: */ %define api.prefix "zconf" 

the other command-line options less critical, although can set in source file if desired.

i have no idea why -l/-l flags used: cause bison/flex omit #line directives link generated files source line numbers in .y/.l files; without these directives, debugging more painful. bison -t flag causes bison include code "tracing" parse, although still have set global variable yydebug (or zconfdebug in case) non-zero value in order traces produced. using -t highly recommended because costs little , simplifies debugging, project should build fine without it.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -