From 72c8897d13340228de1174e67b54de147e57cd7a Mon Sep 17 00:00:00 2001 From: steve Date: Wed, 26 Apr 2000 01:35:26 +0000 Subject: [PATCH] Handling mixing of defines within ifdef/endif. --- ivlpp/lexor.lex | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/ivlpp/lexor.lex b/ivlpp/lexor.lex index 8e8215542..7c6964505 100644 --- a/ivlpp/lexor.lex +++ b/ivlpp/lexor.lex @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: lexor.lex,v 1.17 2000/03/29 04:36:42 steve Exp $" +#ident "$Id: lexor.lex,v 1.18 2000/04/26 01:35:26 steve Exp $" #endif # include @@ -116,14 +116,23 @@ W [ \t\b\f]+ that follows it. when the directive ends, the do_include function performs the include operation. */ -^{W}?`include { BEGIN(PPINCLUDE); } +^{W}?`include { yy_push_state(PPINCLUDE); } \"[^\"]*\" { include_filename(); } [ \t\b\f] { ; } -\n { istack->lineno += 1; BEGIN(0); do_include(); } -<> { istack->lineno += 1; BEGIN(0); do_include(); } + /* Catch single-line comments that share the line with an include + directive. And while I'm at it, I might as well preserve the + comment in the output stream. */ + +"//".* { ECHO; } + + /* These finish the include directive (EOF or EOL) so I revert the + lexor state and execute the inclusion. */ + +\n { istack->lineno += 1; yy_pop_state(); do_include(); } +<> { istack->lineno += 1; yy_pop_state(); do_include(); } /* Detect the define directive, and match the name. Match any @@ -131,7 +140,7 @@ W [ \t\b\f]+ directive and the name, go into PPDEFINE mode and prepare to collect the defined value. */ -`define{W}[a-zA-Z][a-zA-Z0-9_]*{W}? { BEGIN(PPDEFINE); def_start(); } +`define{W}[a-zA-Z][a-zA-Z0-9_]*{W}? { yy_push_state(PPDEFINE); def_start(); } .* { do_define(); } @@ -139,14 +148,14 @@ W [ \t\b\f]+ def_finish(); istack->lineno += 1; fputc('\n', yyout); - BEGIN(0); + yy_pop_state(); } <> { def_finish(); istack->lineno += 1; fputc('\n', yyout); - BEGIN(0); + yy_pop_state(); } `undef{W}[a-zA-Z][a-zA-Z0-9_]*{W}?.* { def_undefine(); }