diff --git a/ivlpp/lexor.lex b/ivlpp/lexor.lex index 77220c8ef..9a0b0be70 100644 --- a/ivlpp/lexor.lex +++ b/ivlpp/lexor.lex @@ -1,7 +1,7 @@ %{ /* - * Copyright (c) 1999 Stephen Williams (steve@icarus.com) + * Copyright (c) 1999-2002 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: lexor.lex,v 1.29 2002/01/06 04:51:31 steve Exp $" +#ident "$Id: lexor.lex,v 1.30 2002/02/15 05:20:58 steve Exp $" #endif # include "config.h" @@ -89,6 +89,7 @@ static int comment_enter = 0; %x PPINCLUDE %x PPDEFINE %x CCOMMENT +%x PCOMENT %x CSTRING %x ERROR_LINE @@ -111,6 +112,15 @@ W [ \t\b\f]+ \n { istack->lineno += 1; ECHO; } "*/" { BEGIN(comment_enter); ECHO; } + /* Detect and pass multiline pragma comments. As with C-style + comments, pragma comments are passed through, and CPP directives + contained within are ignored. */ + +"(*" { comment_enter = YY_START; BEGIN(PCOMENT); ECHO; } +. { ECHO; } +\n { istack->lineno += 1; ECHO; } +"*)" { BEGIN(comment_enter); ECHO; } + /* Strings do not contain macros or preprocessor directives. */ \" { comment_enter = YY_START; BEGIN(CSTRING); ECHO; } \\\" { yymore(); } diff --git a/lexor.lex b/lexor.lex index 9984bc5e2..2027f8269 100644 --- a/lexor.lex +++ b/lexor.lex @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: lexor.lex,v 1.68 2001/12/29 19:00:13 steve Exp $" +#ident "$Id: lexor.lex,v 1.69 2002/02/15 05:20:58 steve Exp $" #endif # include "config.h" @@ -95,6 +95,7 @@ static int comment_enter; %} %x CCOMMENT +%x PCOMMENT %x LCOMMENT %x CSTRING %s UDPTABLE @@ -110,15 +111,29 @@ W [ \t\b\f\r]+ [ \t\b\f\r] { ; } \n { yylloc.first_line += 1; } + /* C++ style comments start with / / and run to the ene of the + current line. These are very easy to handle. */ + "//".* { comment_enter = YY_START; BEGIN(LCOMMENT); } . { yymore(); } \n { yylloc.first_line += 1; BEGIN(comment_enter); } + + /* The contents of C-style comments are ignored, like white space. */ + "/*" { comment_enter = YY_START; BEGIN(CCOMMENT); } . { yymore(); } \n { yylloc.first_line += 1; yymore(); } "*/" { BEGIN(comment_enter); } + /* Pragma comments are very similar to C-style comments, except that + they are allowed to carry tool-specific pragma strings. */ + +"(*" { comment_enter = YY_START; BEGIN(PCOMMENT); } +. { yymore(); } +\n { yylloc.first_line += 1; yymore(); } +"*)" { BEGIN(comment_enter); } + "<<" { return K_LS; } ">>" { return K_RS; } "<=" { return K_LE; }