diff --git a/ivlpp/lexor.lex b/ivlpp/lexor.lex index 5641befa5..6917e4dd9 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 */ #ifdef HAVE_CVS_IDENT -#ident "$Id: lexor.lex,v 1.47 2007/05/25 18:21:39 steve Exp $" +#ident "$Id: lexor.lex,v 1.48 2007/05/30 23:21:20 steve Exp $" #endif # include "config.h" @@ -118,11 +118,11 @@ static void ifdef_leave(void) if (strcmp(istack->path,cur->path) != 0) { fprintf(stderr, "%s:%u: warning: " "This `endif matches an ifdef in another file.\n", - istack->path, istack->lineno); + istack->path, istack->lineno+1); fprintf(stderr, "%s:%u: : " "This is the odd matched `ifdef.\n", - cur->path, cur->lineno); + cur->path, cur->lineno+1); } free(cur->path); @@ -316,7 +316,24 @@ W [ \t\b\f]+ yy_push_state(IFDEF_SUPR); } -`else { BEGIN(IFDEF_FALSE); } +`elsif{W}[a-zA-Z_][a-zA-Z0-9_$]* { + BEGIN(IFDEF_SUPR); + } +`elsif{W}[a-zA-Z_][a-zA-Z0-9_$]* { + char*name = strchr(yytext, '`'); + assert(name); + name += 6; + name += strspn(name, " \t\b\f"); + + if (is_defined(name)) { + BEGIN(IFDEF_TRUE); + } else { + BEGIN(IFDEF_FALSE); + } + } +`elsif{W}[a-zA-Z_][a-zA-Z0-9_$]* { } + +`else { BEGIN(IFDEF_SUPR); } `else { BEGIN(IFDEF_TRUE); } `else { } @@ -329,6 +346,42 @@ W [ \t\b\f]+ `endif { ifdef_leave(); yy_pop_state(); } +`ifdef { + fprintf(stderr, "%s:%u: `ifdef without a macro name - ignored.\n", + istack->path, istack->lineno+1); + error_count += 1; + } + +`ifndef { + fprintf(stderr, "%s:%u: `ifndef without a macro name - ignored.\n", + istack->path, istack->lineno+1); + error_count += 1; + } + +`elsif { + fprintf(stderr, "%s:%u: `elsif without a macro name - ignored.\n", + istack->path, istack->lineno+1); + error_count += 1; + } + +`elsif{W}[a-zA-Z_][a-zA-Z0-9_$]* { + fprintf(stderr, "%s:%u: `elsif without a matching `ifdef - ignored.\n", + istack->path, istack->lineno+1); + error_count += 1; + } + +`else { + fprintf(stderr, "%s:%u: `else without a matching `ifdef - ignored.\n", + istack->path, istack->lineno+1); + error_count += 1; + } + +`endif { + fprintf(stderr, "%s:%u: `endif without a matching `ifdef - ignored.\n", + istack->path, istack->lineno+1); + error_count += 1; + } + /* This pattern notices macros and arranges for them to be replaced. */ `[a-zA-Z][a-zA-Z0-9_$]* { def_match(); } @@ -766,7 +819,7 @@ static void lexor_done() ifdef_stack = cur->next; fprintf(stderr, "%s:%u: error: This `ifdef lacks an `endif.\n", - cur->path, cur->lineno); + cur->path, cur->lineno+1); free(cur->path); free(cur);