[Scons-users] yacc vs bison

Pierre-Luc Boily pierreluc.boily at gmail.com
Tue Dec 10 22:35:47 EST 2019


Thx,

I ended up doing this :
def yaccing(env, source):
    """ Generate c file and header file from yacc file.  """
    if str(source).endswith('.y'):
        env['YACC'] = 'yacc'  # By default, scons use Bison tool for yaccing
file.  Change the tool for yacc
        return
env.CFile(target=env.create_target_name(env.get_filename(str(source))),
                         source=source)
    else:
        print(str(source) + ' is not a yacc file.')
        exit(1)

Regarding your comment about overwriting the FLAGS, I agree with you.  But I
do have a strange behavior, probably something I do not understand about
scons yet (or just another stupid mistake).  See my Sconscript : 

env['YACCFLAGS'] = ['-t', '-p', 'atc_co_', '-d']
env['LEXFLAGS'] = ['-Patc_co_']
env.lexing('atc_co_lex.l')
env.yaccing('atc_co_yacc.y')

env['YACCFLAGS'] = ['-t', '-p', 'atc_db_', '-d']
env['LEXFLAGS'] = ['-Patc_db_']
env.lexing('atc_db_lex.l')
env.yaccing('atc_db_yacc.y')

This gives this output :
flex -Patc_db_ -t atm_common/libdb/src/atc_co_lex.l >
build/atm_common/libdb/src/linux.x86.debug/atc_co_lex.c
yacc -t -p atc_db_ -d -o
build/atm_common/libdb/src/linux.x86.debug/atc_co_yacc.c
atm_common/libdb/src/atc_co_yacc.y
flex -Patc_db_ -t atm_common/libdb/src/atc_db_lex.l >
build/atm_common/libdb/src/linux.x86.debug/atc_db_lex.c
yacc -t -p atc_db_ -d -o
build/atm_common/libdb/src/linux.x86.debug/atc_db_yacc.c
atm_common/libdb/src/atc_db_yacc.y

As you can see only "atc_db_" is used as flags.  I think a workaround could
be to clone two environments, but I feel I do something wrong.




--
Sent from: http://scons.1086193.n5.nabble.com/Users-f16930.html


More information about the Scons-users mailing list