Support pragma comments.

This commit is contained in:
steve 2002-02-15 05:20:58 +00:00
parent 0964dd99c5
commit ba8465abd2
2 changed files with 28 additions and 3 deletions

View File

@ -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]+
<CCOMMENT>\n { istack->lineno += 1; ECHO; }
<CCOMMENT>"*/" { 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; }
<PCOMENT>. { ECHO; }
<PCOMENT>\n { istack->lineno += 1; ECHO; }
<PCOMENT>"*)" { BEGIN(comment_enter); ECHO; }
/* Strings do not contain macros or preprocessor directives. */
\" { comment_enter = YY_START; BEGIN(CSTRING); ECHO; }
<CSTRING>\\\" { yymore(); }

View File

@ -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); }
<LCOMMENT>. { yymore(); }
<LCOMMENT>\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); }
<CCOMMENT>. { yymore(); }
<CCOMMENT>\n { yylloc.first_line += 1; yymore(); }
<CCOMMENT>"*/" { 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); }
<PCOMMENT>. { yymore(); }
<PCOMMENT>\n { yylloc.first_line += 1; yymore(); }
<PCOMMENT>"*)" { BEGIN(comment_enter); }
"<<" { return K_LS; }
">>" { return K_RS; }
"<=" { return K_LE; }