From 3a9ac1951af770bda262a192a76fa427e291678a Mon Sep 17 00:00:00 2001 From: Steven Knight Date: Fri, 22 Oct 2004 22:22:44 +0000 Subject: Support .lex and .yacc file suffixes. (Matthew Doar) --- src/CHANGES.txt | 4 ++++ src/engine/SCons/Tool/lex.py | 1 + src/engine/SCons/Tool/yacc.py | 2 ++ test/LEX.py | 15 ++++++++++++++- test/YACC.py | 15 ++++++++++++++- 5 files changed, 35 insertions(+), 2 deletions(-) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 9845e85..4cfc71c 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -25,6 +25,10 @@ RELEASE 0.97 - XXX - Add a set of canned PathOption validators: PathExists (the default), PathIsFile, PathIsDir and PathIsDirCreate. + From Matthew Doar: + + - Add support for .lex and .yacc file suffixes for Lex and Yacc files. + From Eric Frias: - Huge performance improvement: wrap the tuples representing an diff --git a/src/engine/SCons/Tool/lex.py b/src/engine/SCons/Tool/lex.py index 18acbbd..4a17fae 100644 --- a/src/engine/SCons/Tool/lex.py +++ b/src/engine/SCons/Tool/lex.py @@ -42,6 +42,7 @@ def generate(env): c_file, cxx_file = SCons.Tool.createCFileBuilders(env) c_file.add_action('.l', SCons.Defaults.LexAction) + c_file.add_action('.lex', SCons.Defaults.LexAction) cxx_file.add_action('.ll', SCons.Defaults.LexAction) env['LEX'] = env.Detect('flex') or 'lex' diff --git a/src/engine/SCons/Tool/yacc.py b/src/engine/SCons/Tool/yacc.py index ff3f040..2c93b7c 100644 --- a/src/engine/SCons/Tool/yacc.py +++ b/src/engine/SCons/Tool/yacc.py @@ -61,8 +61,10 @@ def generate(env): c_file, cxx_file = SCons.Tool.createCFileBuilders(env) c_file.add_action('.y', SCons.Defaults.YaccAction) + c_file.add_action('.yacc', SCons.Defaults.YaccAction) cxx_file.add_action('.yy', SCons.Defaults.YaccAction) c_file.add_emitter('.y', yEmitter) + c_file.add_emitter('.yacc', yEmitter) cxx_file.add_emitter('.yy', yyEmitter) env['YACC'] = env.Detect('bison') or 'yacc' diff --git a/test/LEX.py b/test/LEX.py index 90549bd..3f596fb 100644 --- a/test/LEX.py +++ b/test/LEX.py @@ -51,6 +51,7 @@ sys.exit(0) test.write('SConstruct', """ env = Environment(LEX = r'%s mylex.py', tools=['default', 'lex']) env.Program(target = 'aaa', source = 'aaa.l') +env.Program(target = 'bbb', source = 'bbb.lex') """ % python) test.write('aaa.l', r""" @@ -64,9 +65,21 @@ main(int argc, char *argv[]) } """) -test.run(arguments = 'aaa' + _exe, stderr = None) +test.write('bbb.lex', r""" +int +main(int argc, char *argv[]) +{ + argv[argc++] = "--"; + printf("LEX\n"); + printf("bbb.lex\n"); + exit (0); +} +""") + +test.run(arguments = '.', stderr = None) test.run(program = test.workpath('aaa' + _exe), stdout = "mylex.py\naaa.l\n") +test.run(program = test.workpath('bbb' + _exe), stdout = "mylex.py\nbbb.lex\n") diff --git a/test/YACC.py b/test/YACC.py index 13203ff..062e4bc 100644 --- a/test/YACC.py +++ b/test/YACC.py @@ -66,6 +66,7 @@ sys.exit(0) test.write('SConstruct', """ env = Environment(YACC = r'%s myyacc.py', tools=['default', 'yacc']) env.Program(target = 'aaa', source = 'aaa.y') +env.Program(target = 'bbb', source = 'bbb.yacc') """ % python) test.write('aaa.y', r""" @@ -79,9 +80,21 @@ main(int argc, char *argv[]) } """) -test.run(arguments = 'aaa' + _exe, stderr = None) +test.write('bbb.yacc', r""" +int +main(int argc, char *argv[]) +{ + argv[argc++] = "--"; + printf("YACC\n"); + printf("bbb.yacc\n"); + exit (0); +} +""") + +test.run(arguments = '.', stderr = None) test.run(program = test.workpath('aaa' + _exe), stdout = "myyacc.py\naaa.y\n") +test.run(program = test.workpath('bbb' + _exe), stdout = "myyacc.py\nbbb.yacc\n") -- cgit v0.12