# -*- coding: utf-8 -*- # Damien Riquet (d.riquet@gmail.com) # WTFPL Licence # December, 2012 # SConstruct file to compile a compiler # Here, we use Flex and Bison to do this # Scons knows flex as lex and bison as yacc (older versions) # This file has been designed to compile the Flex/Bison example written by Timo Bingmann # It can be found here: http://panthema.net/2007/flex-bison-cpp-example/ # 0) Build environment # -------------------- env = Environment() # Add a Bison (yacc) flag so that it creates an header file (parser.h) env.Append(YACCFLAGS='--defines=parser.h') # g++ compile flags env.Append(CXXFLAGS="-W -Wall -Wextra -ansi -g") # List of source files needed for the final compilation sources = ["driver.cc", "exprtest.cc"] # 1) Generate C++ files from lexer and analyzer files # -------------------- # We use here the CXXFile class that uses flex or bison accordingly to the source file sources += env.CXXFile(source='scanner.ll') sources += env.CXXFile(source='parser.yy') # 2) Build the application thanks to Program class # -------------------- env.Program("exprtest", sources)