/*;-*-C-*-;
-** Copyright (c) Massachusetts Institute of Technology 1994-1998.
-** All Rights Reserved.
-** Unpublished rights reserved under the copyright laws of
-** the United States.
+** Splint - annotation-assisted static program checker
+** Copyright (C) 1994-2001 University of Virginia,
+** Massachusetts Institute of Technology
**
-** THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
-** OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
+** This program is free software; you can redistribute it and/or modify it
+** under the terms of the GNU General Public License as published by the
+** Free Software Foundation; either version 2 of the License, or (at your
+** option) any later version.
+**
+** This program is distributed in the hope that it will be useful, but
+** WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** General Public License for more details.
+**
+** The GNU General Public License is available from http://www.gnu.org/ or
+** the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+** MA 02111-1307, USA.
**
-** This code is distributed freely and may be used freely under the
-** following conditions:
-**
-** 1. This notice may not be removed or altered.
+** For information on lclint: lclint-request@cs.virginia.edu
+** To report a bug: lclint-bug@cs.virginia.edu
+** For more information: http://www.splint.org
+*/
+/*
+** cscanner.l
**
-** 2. Works derived from this code are not distributed for
-** commercial gain without explicit permission from MIT
-** (for permission contact lclint-request@sds.lcs.mit.edu).
+** Flex lexer for C.
+** Based on a C lexer by Nate Osgood
+** from hacrat@catfish.lcs.mit.edu Mon Jun 14 13:06:32 1993
*/
/*
- * Modified by Herbert 08/19/97:
- * - added #include for IBM's OS/2 compiler.
- * - fixed weird bug with lookup of tmp files (OS/2 and MSDOS only).
- */
-
+** Modified by Herbert 08/19/97:
+** - added #include for IBM's OS/2 compiler.
+** - fixed weird bug with lookup of tmp files (OS/2 and MSDOS only).
+*/
/*
- * Modified by Mike Smith
- * Corrected missing 'line' in scanf() calls in handleSpecial().
- * Without this, I get an error when LCLint hits a '#line' directive
- * in the pre-pre-processed source files. For safety, I have made these
- * conditional on OS2 and MSDOS because I don't understand why noone else
- * has seen this problem.
- *
- * Modified by Mike Smith, 4th June 1997
- * Finally resolved the #line problem. The scanf() calls have been fixed to
- * allow the following #line forms:-
- *
- * #line 123 "filename"
- * #line 123
- * # 123 "filename"
- * # 123
- *
- * The last two are generated by the GNU pre-processor, apparently
- */
+** Modified by Mike Smith
+** Corrected missing 'line' in scanf() calls in handleSpecial().
+** Without this, I get an error when LCLint hits a '#line' directive
+** in the pre-pre-processed source files. For safety, I have made these
+** conditional on OS2 and MSDOS because I don't understand why noone else
+** has seen this problem.
+**
+** Modified by Mike Smith, 4th June 1997
+** Finally resolved the #line problem. The scanf() calls have been fixed to
+** allow the following #line forms:-
+**
+** #line 123 "filename"
+** #line 123
+** # 123 "filename"
+** # 123
+**
+** The last two are generated by the GNU pre-processor, apparently
+*/
Digit [0-9]
Letter [a-zA-Z_$]
ULSuffix ({U}{L}|{L}{U})
%{
-/*
-** based on original C lexer by Nate Osgood
-** from hacrat@catfish.lcs.mit.edu Mon Jun 14 13:06:32 1993
-**
-*/
-
# include "lclintMacros.nf"
+# if defined(OS2) && defined(__IBMC__)
+ /* needed for isatty()... */
+# include <io.h>
+# else
# include <unistd.h>
+# endif
+
# include "basic.h"
# include "cgrammar.h"
# include "fileIdList.h"
# include "portab.h"
-# if defined(OS2) && defined(__IBMC__)
- /* needed for isatty()... */
-# include <io.h>
-# endif
-
static bool lastWasString = FALSE;
static char savechar = '\0';
if (processMacro ())
{
+ DPRINTF (("Here we are: %s", context_unparse ()));
+
if (context_inIterDef ())
{
RETURN_TOK (LLMACROITER);
static bool handleSpecial (char *yyt)
{
char *l = mstring_create (MAX_NAME_LENGTH);
- static bool reportcpp = FALSE;
int lineno = 0;
char c;
char *ol;
mstring_free (ol);
return FALSE;
} else {
- if (!reportcpp)
- {
-
- } else {
- llbug (message ("File contains preprocessor command: #%s",
- cstring_fromChars (ol)));
- reportcpp = TRUE;
- }
+ voptgenerror
+ (FLG_UNRECOGDIRECTIVE,
+ message ("Unrecognized pre-processor directive: #%s",
+ cstring_fromChars (ol)),
+ g_currentloc);
}
sfree (ol);
- return TRUE;
+ return FALSE; /* evans 2001-12-30: was: TRUE; */
}
sfree (ol);
}
else
{
+ /*
+ ** Will be handled by handleLlSpecial
+ */
+
cstring_free (id);
return FALSE;
}
if (c >= '0' && c <= '7') {
tval = (int) c - (int) '0';
+ } else if (c == 'U' || c == 'L' || c == 'u' || c == 'l') {
+ index++;
+ while (yytext[index] != '\0') {
+ if (c == 'U' || c == 'L' || c == 'u' || c == 'l') {
+ ;
+ } else {
+ voptgenerror
+ (FLG_SYNTAX,
+ message ("Invalid character (%c) following specifier in octal constant: %s",
+ c, cstring_fromChars (yytext)),
+ g_currentloc);
+ }
+ index++;
+ }
+
+ break;
} else {
voptgenerror
(FLG_SYNTAX,