diff options
author | CamVan Nguyen <ctnguyen@us.ibm.com> | 2012-02-08 10:05:23 -0600 |
---|---|---|
committer | A. Patrick Williams III <iawillia@us.ibm.com> | 2012-02-09 15:50:31 -0600 |
commit | f321a3690c449b13cbda06bae1f3de59cb774d94 (patch) | |
tree | 4614bfafd4f158a4acde2eed23399a040d237804 /src/usr/hwpf/ifcompiler | |
parent | e5739c657fe8368f8addae0fad3c018aa6b10dfb (diff) | |
download | blackbird-hostboot-f321a3690c449b13cbda06bae1f3de59cb774d94.tar.gz blackbird-hostboot-f321a3690c449b13cbda06bae1f3de59cb774d94.zip |
SCOM Initfile - Ability to #include common scom initfile defines
Change-Id: If6b345a6f771579ccb687538f9c790f5875f564c
Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/651
Tested-by: Jenkins Server
Reviewed-by: Douglas R. Gilbert <dgilbert@us.ibm.com>
Reviewed-by: MIKE J. JONES <mjjones@us.ibm.com>
Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src/usr/hwpf/ifcompiler')
-rwxr-xr-x | src/usr/hwpf/ifcompiler/initCompiler.lex | 46 |
1 files changed, 45 insertions, 1 deletions
diff --git a/src/usr/hwpf/ifcompiler/initCompiler.lex b/src/usr/hwpf/ifcompiler/initCompiler.lex index e1c2116ec..174a51550 100755 --- a/src/usr/hwpf/ifcompiler/initCompiler.lex +++ b/src/usr/hwpf/ifcompiler/initCompiler.lex @@ -27,6 +27,7 @@ // camvanng 11/16/11 Support system & target attributes // camvanng 12/12/11 Support multiple address ranges within a SCOM address // camvanng 01/20/12 Support for using a range of indexes for array attributes +// camvanng 02/07/12 Ability to #include common scom initfile defines // End Change Log *********************************************************************************/ /** * @file initCompiler.lex @@ -69,6 +70,10 @@ std::string g_scomname; // dg02 extern int yyline; +#define MAX_INCLUDE_DEPTH 10 +YY_BUFFER_STATE include_stack[MAX_INCLUDE_DEPTH]; +int include_stack_num = 0; + %} @@ -104,6 +109,7 @@ MULTI_DIGIT [0-9]+ %x target %x attribute %x array +%x incl %% @@ -112,7 +118,17 @@ MULTI_DIGIT [0-9]+ \$Id:.*\n ++yyline; /* toss this - read by initCompiler.C */ /* Special end-of-file character. */ -<<EOF>> { return 0; } +<<EOF>> { + if (--include_stack_num < 0) + { + return 0; + } + else + { + yy_delete_buffer(YY_CURRENT_BUFFER); + yy_switch_to_buffer(include_stack[include_stack_num]); + } + } SyntaxVersion return INIT_VERSION; @@ -130,6 +146,34 @@ Versions BEGIN(fnames); return INIT_VERSIONS; } +include { BEGIN(incl); } +<incl>[ \t]* /* Eat up whitespace */ +<incl>[^ \t\n]+ { /* Got the include file name */ + /*printf("include file %s\n", yytext);*/ + if ( include_stack_num >= MAX_INCLUDE_DEPTH ) + { + lex_err("Includes nested too deeply"); + exit( 1 ); + } + + /* Save current input buffer */ + include_stack[include_stack_num++] = + YY_CURRENT_BUFFER; + + /* Switch input buffer */ + yyin = fopen( yytext, "r" ); + if (NULL == yyin) + { + oss.str(""); + oss << "Cannot open file: " << yytext; + lex_err(oss.str().c_str()); + exit(1); + } + yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE)); + + BEGIN(INITIAL); + } + define { return INIT_DEFINE;} |