Main Page   Alphabetical List   Compound List   File List   Compound Members   File Members  

shift.c

Go to the documentation of this file.
00001 /*
00002 ** LCLint - annotation-assisted static program checker
00003 ** Copyright (C) 1994-2000 University of Virginia,
00004 **         Massachusetts Institute of Technology
00005 **
00006 ** This program is free software; you can redistribute it and/or modify it
00007 ** under the terms of the GNU General Public License as published by the
00008 ** Free Software Foundation; either version 2 of the License, or (at your
00009 ** option) any later version.
00010 ** 
00011 ** This program is distributed in the hope that it will be useful, but
00012 ** WITHOUT ANY WARRANTY; without even the implied warranty of
00013 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 ** General Public License for more details.
00015 ** 
00016 ** The GNU General Public License is available from http://www.gnu.org/ or
00017 ** the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00018 ** MA 02111-1307, USA.
00019 **
00020 ** For information on lclint: lclint-request@cs.virginia.edu
00021 ** To report a bug: lclint-bug@cs.virginia.edu
00022 ** For more information: http://lclint.cs.virginia.edu
00023 */
00024 
00025 /*
00026 ** shift.c
00027 **
00028 ** Larch shift sequence manager
00029 **
00030 **      Tokens are sent by the parser to this module.  Here they are saved
00031 **      for awhile in a stack, and delivered on demand during reduce actions.
00032 **      The coordination between what the parser sends here and what reduce
00033 **      consumes here must be maintained by the programmer.
00034 **
00035 */
00036 
00037 # include "lclintMacros.nf"
00038 # include "llbasic.h"
00039 # include "shift.h"
00040 
00041 /*@constant static int SHIFTMAX;@*/
00042 # define SHIFTMAX 200
00043 
00044 static o_ltoken Shifts[SHIFTMAX];
00045 static int shiftIndex;
00046 
00047 static bool Parsing_LSLinit = TRUE;
00048 
00049 static bool
00050 LSLGenIsEmptyShiftStack (void)
00051 {
00052   return (shiftIndex == 0);
00053 }
00054 
00055 void LSLGenShift (ltoken tok)
00056 {
00057   if (shiftIndex < SHIFTMAX)
00058     {
00059       Shifts[shiftIndex] = ltoken_copy (tok);
00060       shiftIndex++;
00061     }
00062   else
00063     {
00064       llbuglit ("LSLGenShift: needs MoreMem ()");
00065     }
00066 }
00067 
00068 extern void
00069 LSLGenShiftOnly (/*@only@*/ ltoken tok)
00070 {
00071   if (shiftIndex < SHIFTMAX)
00072     {
00073       Shifts[shiftIndex] = tok;
00074       shiftIndex++;
00075     }
00076   else
00077     {
00078       llbugexitlit ("LSLGenShift: needs MoreMem ()");
00079     }
00080 }
00081 
00082 extern ltoken
00083 LSLGenTopPopShiftStack (void)
00084 {
00085   if (LSLGenIsEmptyShiftStack ())
00086     {
00087       lclfatalbug ("LSLGenTopPopShiftStack: Empty stack");
00088     }
00089 
00090   /*@-retalias@*/
00091   return Shifts[--shiftIndex];
00092   /*@=retalias@*/
00093 }
00094 
00095 void
00096 LSLGenInit (bool LSLParse)
00097 {
00098   Parsing_LSLinit = LSLParse;
00099 }
00100 

Generated at Fri Nov 3 18:57:43 2000 for LCLint by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000