]> andersk Git - splint.git/blobdiff - src/mtgrammar.y
Added test case for sizeof bug fix.
[splint.git] / src / mtgrammar.y
index 5a5861211d14773a52ddc40254a81757f387b40d..11f91fbb7cd6e32030e4ceadcda7b9d692528851 100644 (file)
@@ -1,20 +1,25 @@
 /*;-*-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-2002 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.
-**
-**     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).
+** For information on splint: splint@cs.virginia.edu
+** To report a bug: splint-bug@cs.virginia.edu
+** For more information: http://www.splint.org
 */
 /*
 ** mtgrammar.y
 %{
 
 # include "bison.reset"
-# include "lclintMacros.nf"
+# include "splintMacros.nf"
 # include "llbasic.h"
 
-# ifndef __LCLINT__
+# ifndef S_SPLINT_S
 extern ctype mtscanner_lookupType (mttok p_tok) /*@modifies p_tok@*/ ;
 # endif
 
@@ -37,9 +42,10 @@ extern ctype mtscanner_lookupType (mttok p_tok) /*@modifies p_tok@*/ ;
     # include "mtscanner.h"
   */
 
-static /*@exits@*/ void mterror (char *);
+static /*@noreturn@*/ void mterror (char *);
 
 /*@-noparams@*/ /* Can't list params since YYSTYPE isn't defined yet. */
+extern int mtlex () ;
 static void yyprint (/*FILE *p_file, int p_type, YYSTYPE p_value */);
 /*@=noparams@*/
 
@@ -74,11 +80,12 @@ static void yyprint (/*FILE *p_file, int p_type, YYSTYPE p_value */);
   mtTransferAction mttransferaction;
   mtLoseReferenceList mtlosereferencelist;
   mtLoseReference mtlosereference;
-
+  pointers pointers;
   /*@only@*/ cstringList cstringlist;
   ctype ctyp;
   /*@only@*/ qtype qtyp;
-  int count;
+  qual qual;
+  qualList quals;
 }
 
 /* Don't forget to enter all tokens in mtscanner.c */
@@ -111,11 +118,11 @@ static void yyprint (/*FILE *p_file, int p_type, YYSTYPE p_value */);
 
 %token <tok> MT_CHAR MT_INT MT_FLOAT MT_DOUBLE MT_VOID  MT_ANYTYPE MT_INTEGRALTYPE MT_UNSIGNEDINTEGRALTYPE
 %token <tok> MT_SIGNEDINTEGRALTYPE 
-%token <tok> MT_CONST MT_VOLATILE
+%token <tok> MT_CONST MT_VOLATILE MT_RESTRICT
 %token <tok> MT_STRINGLIT
 %token <tok> MT_IDENT
 
-%type <count> pointers
+%type <pointers> pointers
 %type <ctyp> optType typeSpecifier typeName abstractDecl abstractDeclBase 
 %type <qtyp> typeExpression
 %type <qtyp> completeType completeTypeAux optCompleteType
@@ -142,7 +149,8 @@ static void yyprint (/*FILE *p_file, int p_type, YYSTYPE p_value */);
 %type <mtdecl> declarationNode
 %type <mtpieces> declarationPieces
 %type <tok> valueChoice
-
+%type <quals> innerModsList
+%type <qual> innerMods
 
 %start file
 
@@ -226,18 +234,19 @@ abstractDecl
  | pointers abstractDeclBase { $$ = ctype_adjustPointers ($1, $2); }
 
 pointers
- : MT_STAR { $$ = 1; }
- | MT_STAR innerModsList { $$ = 1; }
- | MT_STAR pointers { $$ = 1 + $2; }
- | MT_STAR innerModsList pointers { $$ = 1 + $3; }
+ : MT_STAR { $$ = pointers_createMt ($1); }
+ | MT_STAR innerModsList { $$ = pointers_createModsMt ($1, $2); }
+ | MT_STAR pointers { $$ = pointers_extend (pointers_createMt ($1), $2); }
+ | MT_STAR innerModsList pointers { $$ = pointers_extend (pointers_createModsMt ($1, $2), $3); }
 
 innerMods
- : MT_CONST    { /* ignored for now */; }
- | MT_VOLATILE { ; }
+ : MT_CONST    { $$ = qual_createConst (); }
+ | MT_VOLATILE { $$ = qual_createVolatile (); }
+ | MT_RESTRICT { $$ = qual_createRestrict (); }
 
 innerModsList
- : innerMods { ; }
- | innerModsList innerMods { ; }
+ : innerMods { $$ = qualList_single ($1); }
+ | innerModsList innerMods { $$ = qualList_add ($1, $2); }
 
 abstractDeclBase
  : MT_LPAREN abstractDecl MT_RPAREN { $$ = ctype_expectFunction ($2); }
This page took 0.080979 seconds and 4 git commands to generate.