/* A Bison parser, made by GNU Bison 1.875.  */

/* Skeleton parser for Yacc-like parsing with Bison,
   Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software Foundation, Inc.

   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, 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.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place - Suite 330,
   Boston, MA 02111-1307, USA.  */

/* As a special exception, when this file is copied by Bison into a
   Bison output file, you may use that output file without restriction.
   This special exception was added by the Free Software Foundation
   in version 1.24 of Bison.  */

/* Written by Richard Stallman by simplifying the original so called
   ``semantic'' parser.  */

/* All symbols defined below should begin with yy or YY, to avoid
   infringing on user name space.  This should be done even for local
   variables, as they might otherwise be expanded by user macros.
   There are some unavoidable exceptions within include files to
   define necessary library symbols; they are noted "INFRINGES ON
   USER NAME SPACE" below.  */

/* Identify Bison output.  */
#define YYBISON 1

/* Skeleton name.  */
#define YYSKELETON_NAME "yacc.c"

/* Pure parsers.  */
#define YYPURE 0

/* Using locations.  */
#define YYLSP_NEEDED 0

/* If NAME_PREFIX is specified substitute the variables and functions
   names.  */
#define yyparse ribparse
#define yylex   riblex
#define yyerror riberror
#define yylval  riblval
#define yychar  ribchar
#define yydebug ribdebug
#define yynerrs ribnerrs


/* Tokens.  */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
   /* Put the tokens into the symbol table, so that GDB and other debuggers
      know about them.  */
   enum yytokentype {
     RIB_DECLARE = 258,
     RIB_FRAME_BEGIN = 259,
     RIB_FRAME_END = 260,
     RIB_WORLD_BEGIN = 261,
     RIB_WORLD_END = 262,
     RIB_FORMAT = 263,
     RIB_FRAME_ASPECT_RATIO = 264,
     RIB_SCREEN_WINDOW = 265,
     RIB_CROP_WINDOW = 266,
     RIB_PROJECTION = 267,
     RIB_CLIPPING = 268,
     RIB_CLIPPING_PLANE = 269,
     RIB_DEPTH_OF_FIELD = 270,
     RIB_SHUTTER = 271,
     RIB_PIXEL_VARIANCE = 272,
     RIB_PIXEL_SAMPLES = 273,
     RIB_PIXEL_FILTER = 274,
     RIB_EXPOSURE = 275,
     RIB_IMAGER = 276,
     RIB_QUANTIZE = 277,
     RIB_DISPLAY = 278,
     RIB_HIDER = 279,
     RIB_COLOR_SAMPLES = 280,
     RIB_RELATIVE_DETAIL = 281,
     RIB_OPTION = 282,
     RIB_ATTRIBUTE_BEGIN = 283,
     RIB_ATTRIBUTE_END = 284,
     RIB_COLOR = 285,
     RIB_OPACITY = 286,
     RIB_TEXTURE_COORDINATES = 287,
     RIB_LIGHT_SOURCE = 288,
     RIB_AREA_LIGHT_SOURCE = 289,
     RIB_ILLUMINATE = 290,
     RIB_SURFACE = 291,
     RIB_ATMOSPHERE = 292,
     RIB_INTERIOR = 293,
     RIB_EXTERIOR = 294,
     RIB_SHADING_RATE = 295,
     RIB_SHADING_INTERPOLATION = 296,
     RIB_MATTE = 297,
     RIB_BOUND = 298,
     RIB_DETAIL = 299,
     RIB_DETAIL_RANGE = 300,
     RIB_GEOMETRIC_APPROXIMATION = 301,
     RIB_GEOMETRIC_REPRESENTATION = 302,
     RIB_ORIENTATION = 303,
     RIB_REVERSE_ORIENTATION = 304,
     RIB_SIDES = 305,
     RIB_IDENTITY = 306,
     RIB_TRANSFORM = 307,
     RIB_CONCAT_TRANSFORM = 308,
     RIB_PERSPECTIVE = 309,
     RIB_TRANSLATE = 310,
     RIB_ROTATE = 311,
     RIB_SCALE = 312,
     RIB_SKEW = 313,
     RIB_DEFORMATION = 314,
     RIB_DISPLACEMENT = 315,
     RIB_COORDINATE_SYSTEM = 316,
     RIB_COORDINATE_SYS_TRANSFORM = 317,
     RIB_TRANSFORM_BEGIN = 318,
     RIB_TRANSFORM_END = 319,
     RIB_ATTRIBUTE = 320,
     RIB_POLYGON = 321,
     RIB_GENERAL_POLYGON = 322,
     RIB_POINTS_POLYGONS = 323,
     RIB_POINTS_GENERAL_POLYGONS = 324,
     RIB_BASIS = 325,
     RIB_PATCH = 326,
     RIB_PATCH_MESH = 327,
     RIB_NU_PATCH = 328,
     RIB_TRIM_CURVE = 329,
     RIB_SPHERE = 330,
     RIB_CONE = 331,
     RIB_CYLINDER = 332,
     RIB_HYPERBOLOID = 333,
     RIB_PARABOLOID = 334,
     RIB_DISK = 335,
     RIB_TORUS = 336,
     RIB_CURVES = 337,
     RIB_GEOMETRY = 338,
     RIB_POINTS = 339,
     RIB_SUBDIVISION_MESH = 340,
     RIB_BLOBBY = 341,
     RIB_PROCEDURAL = 342,
     RIB_SOLID_BEGIN = 343,
     RIB_SOLID_END = 344,
     RIB_OBJECT_BEGIN = 345,
     RIB_OBJECT_END = 346,
     RIB_OBJECT_INSTANCE = 347,
     RIB_MOTION_BEGIN = 348,
     RIB_MOTION_END = 349,
     RIB_MAKE_TEXTURE = 350,
     RIB_MAKE_BUMP = 351,
     RIB_MAKE_LAT_LONG_ENVIRONMENT = 352,
     RIB_MAKE_CUBE_FACE_ENVIRONMENT = 353,
     RIB_MAKE_SHADOW = 354,
     RIB_ARCHIVE_RECORD = 355,
     RIB_ERROR_HANDLER = 356,
     RIB_VERSION = 357,
     RIB_VERSION_STRING = 358,
     RIB_ARRAY_BEGIN = 359,
     RIB_ARRAY_END = 360,
     RIB_TEXT = 361,
     RIB_IDENTIFIER = 362,
     RIB_FLOAT = 363,
     RIB_STRUCTURE_COMMENT = 364
   };
#endif
#define RIB_DECLARE 258
#define RIB_FRAME_BEGIN 259
#define RIB_FRAME_END 260
#define RIB_WORLD_BEGIN 261
#define RIB_WORLD_END 262
#define RIB_FORMAT 263
#define RIB_FRAME_ASPECT_RATIO 264
#define RIB_SCREEN_WINDOW 265
#define RIB_CROP_WINDOW 266
#define RIB_PROJECTION 267
#define RIB_CLIPPING 268
#define RIB_CLIPPING_PLANE 269
#define RIB_DEPTH_OF_FIELD 270
#define RIB_SHUTTER 271
#define RIB_PIXEL_VARIANCE 272
#define RIB_PIXEL_SAMPLES 273
#define RIB_PIXEL_FILTER 274
#define RIB_EXPOSURE 275
#define RIB_IMAGER 276
#define RIB_QUANTIZE 277
#define RIB_DISPLAY 278
#define RIB_HIDER 279
#define RIB_COLOR_SAMPLES 280
#define RIB_RELATIVE_DETAIL 281
#define RIB_OPTION 282
#define RIB_ATTRIBUTE_BEGIN 283
#define RIB_ATTRIBUTE_END 284
#define RIB_COLOR 285
#define RIB_OPACITY 286
#define RIB_TEXTURE_COORDINATES 287
#define RIB_LIGHT_SOURCE 288
#define RIB_AREA_LIGHT_SOURCE 289
#define RIB_ILLUMINATE 290
#define RIB_SURFACE 291
#define RIB_ATMOSPHERE 292
#define RIB_INTERIOR 293
#define RIB_EXTERIOR 294
#define RIB_SHADING_RATE 295
#define RIB_SHADING_INTERPOLATION 296
#define RIB_MATTE 297
#define RIB_BOUND 298
#define RIB_DETAIL 299
#define RIB_DETAIL_RANGE 300
#define RIB_GEOMETRIC_APPROXIMATION 301
#define RIB_GEOMETRIC_REPRESENTATION 302
#define RIB_ORIENTATION 303
#define RIB_REVERSE_ORIENTATION 304
#define RIB_SIDES 305
#define RIB_IDENTITY 306
#define RIB_TRANSFORM 307
#define RIB_CONCAT_TRANSFORM 308
#define RIB_PERSPECTIVE 309
#define RIB_TRANSLATE 310
#define RIB_ROTATE 311
#define RIB_SCALE 312
#define RIB_SKEW 313
#define RIB_DEFORMATION 314
#define RIB_DISPLACEMENT 315
#define RIB_COORDINATE_SYSTEM 316
#define RIB_COORDINATE_SYS_TRANSFORM 317
#define RIB_TRANSFORM_BEGIN 318
#define RIB_TRANSFORM_END 319
#define RIB_ATTRIBUTE 320
#define RIB_POLYGON 321
#define RIB_GENERAL_POLYGON 322
#define RIB_POINTS_POLYGONS 323
#define RIB_POINTS_GENERAL_POLYGONS 324
#define RIB_BASIS 325
#define RIB_PATCH 326
#define RIB_PATCH_MESH 327
#define RIB_NU_PATCH 328
#define RIB_TRIM_CURVE 329
#define RIB_SPHERE 330
#define RIB_CONE 331
#define RIB_CYLINDER 332
#define RIB_HYPERBOLOID 333
#define RIB_PARABOLOID 334
#define RIB_DISK 335
#define RIB_TORUS 336
#define RIB_CURVES 337
#define RIB_GEOMETRY 338
#define RIB_POINTS 339
#define RIB_SUBDIVISION_MESH 340
#define RIB_BLOBBY 341
#define RIB_PROCEDURAL 342
#define RIB_SOLID_BEGIN 343
#define RIB_SOLID_END 344
#define RIB_OBJECT_BEGIN 345
#define RIB_OBJECT_END 346
#define RIB_OBJECT_INSTANCE 347
#define RIB_MOTION_BEGIN 348
#define RIB_MOTION_END 349
#define RIB_MAKE_TEXTURE 350
#define RIB_MAKE_BUMP 351
#define RIB_MAKE_LAT_LONG_ENVIRONMENT 352
#define RIB_MAKE_CUBE_FACE_ENVIRONMENT 353
#define RIB_MAKE_SHADOW 354
#define RIB_ARCHIVE_RECORD 355
#define RIB_ERROR_HANDLER 356
#define RIB_VERSION 357
#define RIB_VERSION_STRING 358
#define RIB_ARRAY_BEGIN 359
#define RIB_ARRAY_END 360
#define RIB_TEXT 361
#define RIB_IDENTIFIER 362
#define RIB_FLOAT 363
#define RIB_STRUCTURE_COMMENT 364




/* Copy the first part of user declarations.  */
#line 1 "rib.y"

//////////////////////////////////////////////////////////////////////
//
//                             Pixie
//
// Copyright © 1999 - 2003, Okan Arikan
//
// Contact: okan@cs.berkeley.edu
//
// This library 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 library 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.
// 
// You should have received a copy of the GNU General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
//
///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////
//
//  File				:	rib.y
//  Classes				:	-
//  Description			:	RIB bindings
//
////////////////////////////////////////////////////////////////////////
#undef alloca
#define	YYMAXDEPTH	100000

#include <math.h>
#include <string.h>
#include <stdarg.h>

#include "common/global.h"
#include "common/containers.h"
#include "ri.h"
#include "renderer.h"
#include "delayed.h"
#include "stats.h"
#include "rib.h"
#include "error.h"

// Some forward definitions
		int						riblex(void );				// Forward definition for stupid yacc
		void					riberror(char *,...);

// Types for the data encountered in the rib file
// Note that there's no type for integer as they are recovered from floats
typedef enum {
	RT_FLOAT,
	RT_TEXT,
	RT_STAR,
	RT_PL,
	RT_NULL
} ERIBType;

// Every command has an argument list composed of this type
typedef union {
	ERIBType	type;
	float		real;
	int			integer;
	char		*string;
} ERIBValue;

// Holds information about a parameter
typedef struct {
	char		*name;			// Name of the parameter
	ERIBType	type;			// Type of the parameter
	int			numItems;		// Number of items of type ERIBValue
	ERIBValue	*values;		// Points to the array of values for this parameter
	int			valuesStart;	// Index in the argument list where the parameter starts
} TParameter;

static	int					numConstant					=	0;		// The number of constant
static	int					numVertex					=	0;		// The number of vertices
static	int					numVarying					=	0;		// The number of varyings
static	int					numFaceVarying				=	0;		// The number of facevaryings
static	int					numUniform					=	0;		// The number of uniforms
static	CArray<RtPointer>	*lights						=	NULL;	// Number -> handle mapping for lights
static	CTrie<RtPointer>	*lightNames					=	NULL;	// Name -> handle mapping for lights
static	CArray<RtPointer>	*ribObjects					=	NULL;	// Number -> handle mapping for ribObjects
static	CArray<char *>		*allocatedStrings			=	NULL;	// Strings that have been allocated for the last command
static	void				(*callback)(const char *)	=	NULL;	// The callback function for the parser
static	ERIBValue			*args						=	NULL;
static	int					numArguments				=	0;
static	int					argumentStepSize			=	100000;
static	int					maxArgument					=	0;
static	int					numParameters				=	0;
static	int					maxParameter				=	0;
static	RtToken				*tokens						=	NULL;
static	RtPointer			*vals						=	NULL;
static	TParameter			*parameters					=	NULL;

		const char			*ribFile					=	NULL;	// The RIB file that we're parsing now
		int					ribLineno					=	-1;		// The line number in the rib file


#define	argCheck()															\
	if (numArguments == maxArgument) {										\
		ERIBValue	*tmp	=	new ERIBValue[maxArgument+argumentStepSize];\
																			\
		memcpy(tmp,args,numArguments*sizeof(ERIBValue));					\
																			\
		maxArgument			+=	argumentStepSize;							\
		argumentStepSize	*=	2;											\
																			\
		delete [] args;														\
		args				=	tmp;										\
	}

#define	paramCheck()														\
	if (numParameters == maxParameter) {									\
		RtToken		*tmpTokens		=	new RtToken[maxParameter+10];		\
		RtPointer	*tmpVals		=	new RtPointer[maxParameter+10];		\
		TParameter	*tmpParameters	=	new TParameter[maxParameter+10];	\
																			\
		memcpy(tmpTokens,		tokens,maxParameter*sizeof(RtToken));		\
		memcpy(tmpVals,			vals,maxParameter*sizeof(RtPointer));		\
		memcpy(tmpParameters,	parameters,maxParameter*sizeof(TParameter));\
																			\
		delete [] tokens;													\
		delete [] vals;														\
		delete [] parameters;												\
																			\
		tokens						=	tmpTokens;							\
		vals						=	tmpVals;							\
		parameters					=	tmpParameters;						\
																			\
		maxParameter				+=	10;									\
	}

#define	get(__n)		(args + __n)


// Some textual descriptions for the rib-ri parser

// Basis functions
const	char	*RI_BEZIERBASIS				=	"bezier";
const	char	*RI_BSPLINEBASIS			=	"b-spline";
const	char	*RI_POWERBASIS				=	"power";
const	char	*RI_CATMULLROMBASIS			=	"catmull-rom";
const	char	*RI_HERMITEBASIS			=	"hermite";

// Error handlers
const	char	*RI_ERRORIGNORE				=	"ignore";
const	char	*RI_ERRORPRINT				=	"print";
const	char	*RI_ERRORABORT				=	"abort";

// Predefined procedural handlers
const	char	*RI_PROCDELAYEDREADARCHIVE	=	"DelayedReadArchive";
const	char	*RI_PROCRUNPROGRAM			=	"RunProgram";
const	char	*RI_PROCDYNAMICLOAD			=	"DynamicLoad";

// Predefined error handlers
const	char	*RI_ERROR_IGNORE			=	"ignore";
const	char	*RI_ERROR_ABORT				=	"abort";
const	char	*RI_ERROR_PRINT				=	"print";

void	test();

///////////////////////////////////////////////////////////////////////
// Function				:	toLowerCase
// Description			:	Convert the argument to lowercase
// Return Value			:	Pointer to the argument
// Comments				:
// Date last edited		:	8/10/2001
static	char			*toLowerCase(char *s) {
	int	i;
	int	l	=	strlen(s);

	for (i=0;i<l;i++) {
		if ((s[i] >= 'A') && (s[i] <= 'Z'))
			s[i]	=	'a'+s[i]-'A';
	}

	return s;
}


///////////////////////////////////////////////////////////////////////
// Function				:	parameterListCheck
// Description			:	Count the number of variables inb the parameter list
// Return Value			:	TRUE if OK
// Comments				:	(This version is used by the primitives)
// Date last edited		:	8/10/2001
static	int		parameterListCheck() {
	int			i;
	CVariable	tmp;

	// Set the number of variables
	numConstant		=	0;
	numVertex		=	0;
	numVarying		=	0;
	numFaceVarying	=	0;
	numUniform		=	0;

	// For each parameter encountered
	for (i=0;i<numParameters;i++) {
		TParameter		*par	=	parameters+i;
		CVariable		*var	=	currentRenderer->retrieveVariable(par->name);
		EVariableClass	container;

		// Try to define the variable for later usage	
		if (var == NULL) {
			if (parseVariable(&tmp,NULL,par->name)) {
				container	=	tmp.container;

				var			=	currentRenderer->retrieveVariable(tmp.name);
				if (var == NULL) {
					var = currentRenderer->declareVariable(NULL,par->name);
				}
			}
		} else {
			container	=	var->container;
		}

		// Handle some irregular cases
		if (var == NULL) {
			// Special symbols
			if (strcmp(par->name,"Pz") == 0) {
				tmp.numFloats	=	1;
				tmp.numItems	=	1;
				tmp.entry		=	VARIABLE_P;
				strcpy(tmp.name,"Pz");
				tmp.type		=	TYPE_FLOAT;
				tmp.container	=	CONTAINER_VERTEX;
				tmp.usageMarker	=	PARAMETER_P;
				var				=	&tmp;
				container		=	var->container;
			} else if (strcmp(par->name,"Np") == 0) {
				tmp.numFloats	=	3;
				tmp.numItems	=	1;
				tmp.entry		=	VARIABLE_NG;
				strcpy(tmp.name,"Np");
				tmp.type		=	TYPE_NORMAL;
				tmp.container	=	CONTAINER_VERTEX;
				tmp.usageMarker	=	PARAMETER_NG;
				var				=	&tmp;
				container		=	var->container;
			} else if (strcmp(par->name,"Pw") == 0) {
				tmp.numFloats	=	4;
				tmp.numItems	=	1;
				tmp.entry		=	VARIABLE_P;
				strcpy(tmp.name,"Pw");
				tmp.type		=	TYPE_POINT;
				tmp.container	=	CONTAINER_VERTEX;
				tmp.usageMarker	=	PARAMETER_P;
				var				=	&tmp;
				container		=	var->container;
			}
		}	

		if (var == NULL)	{
			error(CODE_BADTOKEN,"Parameter \"%s\" is not declared\n",par->name);
			return FALSE;
		}

		if ((par->numItems % var->numFloats) != 0) {
			error(CODE_MISSINGDATA,"Invalid number of items for the parameter \"%s\" (expecting n*%d, found %d)\n",par->name,var->numFloats,par->numItems);
			return FALSE;
		}

		// Type checking
		if (var->type == TYPE_INTEGER) {
			if (par->type == RT_FLOAT) {
				int	j;

				for (j=0;j<par->numItems;j++) {
					par->values[j].integer	=	(int) par->values[j].real;
				}
			} else {
				error(CODE_RANGE,"Type mismatch for parameter \"%s\" (expecting integer, found string)\n",par->name);
				return	FALSE;
			}
		} else if (var->type == TYPE_STRING) {
			if (par->type != RT_TEXT) {
				error(CODE_RANGE,"Type mismatch for parameter \"%s\" (expecting string, found float)\n",par->name);
				return	FALSE;
			}
		} else {
			if (par->type != RT_FLOAT) {
				error(CODE_RANGE,"Type mismatch for parameter \"%s\" (expecting float, found string)\n",par->name);
				return	FALSE;
			}
		}

#define	SIZECHECK(dest)																		\
			if (dest == 0) {																\
				dest = (par->numItems / var->numFloats);									\
			} else {																		\
				if (dest != (par->numItems / var->numFloats)) {								\
					error(CODE_RANGE,"Invalid number of items for the parameter \"%s\" (expecting %d, found %d)\n",par->name,dest,par->numItems/var->numFloats);	\
					return FALSE;															\
				}																			\
			}

		switch(container) {
		case CONTAINER_UNIFORM:
			SIZECHECK(numUniform);
			break;
		case CONTAINER_VERTEX:
			SIZECHECK(numVertex);
			break;
		case CONTAINER_VARYING:
			SIZECHECK(numVarying);
			break;
		case CONTAINER_FACEVARYING:
			SIZECHECK(numFaceVarying);
			break;
		case CONTAINER_CONSTANT:
			SIZECHECK(numConstant);
			break;
		default:
			error(CODE_BUG,"Unknown container class in parameter list.\n");
			return FALSE;
			break;
		}

#undef SIZECHECK

	}

	return TRUE;
}

///////////////////////////////////////////////////////////////////////
// Function				:	getBasis
// Description			:	Get the basis matrix from a given text
// Return Value			:	TRUE if OK
// Comments				:
// Date last edited		:	8/20/2003
static	int		sizeCheck(int numExpVertex,int numExpVarying,int numExpFaceVarying,int numExpUniform) {
	if (numExpVarying == 0)		numExpVarying		=	numExpVertex;
	if (numExpVertex == 0)		numExpVertex		=	numExpVarying;
	if (numExpFaceVarying == 0)	numExpFaceVarying	=	numExpVertex;

	if (numConstant != 0) {
		if (numConstant != 1) {
			error(CODE_CONSISTENCY,"Unexpected number of constants (1 expected, %d found)\n",numVarying);
			return FALSE;
		}
	}

	if (numVertex != 0) {
		if (numExpVertex != numVertex) {
			error(CODE_CONSISTENCY,"Unexpected number of vertices (%d expected, %d found)\n",numExpVertex,numVertex);
			return FALSE;
		}
	}

	if (numVarying != 0) {
		if (numExpVarying != numVarying) {
			error(CODE_CONSISTENCY,"Unexpected number of varyings (%d expected, %d found)\n",numExpVarying,numVarying);
			return FALSE;
		}
	}

	if (numFaceVarying != 0) {
		if (numExpFaceVarying != numFaceVarying) {
			error(CODE_CONSISTENCY,"Unexpected number of facevaryings (%d expected, %d found)\n",numExpFaceVarying,numFaceVarying);
			return FALSE;
		}
	}

	if (numUniform != 0) {
		if (numExpUniform != numUniform) {
			error(CODE_CONSISTENCY,"Unexpected number of uniforms (%d expected, %d found)\n",numExpUniform,numUniform);
			return FALSE;
		}
	}

	return TRUE;
}

///////////////////////////////////////////////////////////////////////
// Function				:	getBasis
// Description			:	Get the basis matrix from a given text
// Return Value			:	TRUE if OK
// Comments				:
// Date last edited		:	8/10/2001
static	int		getBasis(RtBasis **a,char *n) {
	char	*name	=	toLowerCase(n);

	if (strcmp(name,RI_BEZIERBASIS) == 0)
		a[0]	=	&RiBezierBasis;
	else if (strcmp(name,RI_BSPLINEBASIS) == 0)
		a[0]	=	&RiBSplineBasis;
	else if (strcmp(name,RI_CATMULLROMBASIS) == 0)
		a[0]	=	&RiCatmullRomBasis;
	else if (strcmp(name,RI_HERMITEBASIS) == 0)
		a[0]	=	&RiHermiteBasis;
	else if (strcmp(name,RI_POWERBASIS) == 0)
		a[0]	=	&RiPowerBasis;
	else {
		error(CODE_BADTOKEN,"Unknown basis: \"%s\"\n",name);
		return	FALSE;
	}

	return	TRUE;
}

///////////////////////////////////////////////////////////////////////
// Function				:	getFilter
// Description			:	Get the filter from a given text
// Return Value			:	NULL if failed
// Comments				:
// Date last edited		:	8/10/2001
static	RtFilterFunc	getFilter(char *n) {
	char			*name	=	toLowerCase(n);
	RtFilterFunc	f		=	NULL;

	if (strcmp(name,RI_BOXFILTER) == 0) {
		f = RiBoxFilter;
	} else if (strcmp(name,RI_GAUSSIANFILTER) == 0) {
		f = RiGaussianFilter;
	} else if (strcmp(name,RI_TRIANGLEFILTER) == 0) {
		f = RiTriangleFilter;
	} else if (strcmp(name,RI_CATMULLROMFILTER) == 0) {
		f = RiCatmullRomFilter;
	} else if (strcmp(name,RI_SINCFILTER) == 0) {
		f = RiSincFilter;
	} else {
		error(CODE_BADTOKEN,"Filter \"%s\" not recognised\n",name);
	}

	return f;
}

///////////////////////////////////////////////////////////////////////
// Function				:	getError
// Description			:	Get the error handler from a given text
// Return Value			:	NULL if failed
// Comments				:
// Date last edited		:	8/10/2001
static	RtErrorHandler	getErrorHandler(char *n) {
	char			*name	=	toLowerCase(n);
	RtErrorHandler	f		=	NULL;

	if (strcmp(name,RI_ERRORIGNORE) == 0) {
		f = RiErrorPrint;
	} else if (strcmp(name,RI_ERRORPRINT) == 0) {
		f = RiErrorPrint;
	} else if (strcmp(name,RI_ERRORABORT) == 0) {
		f = RiErrorAbort;
	} else {
		error(CODE_BADTOKEN,"Error handler \"%s\" not recognised\n",name);
	}

	return f;
}




/* Enabling traces.  */
#ifndef YYDEBUG
# define YYDEBUG 0
#endif

/* Enabling verbose error messages.  */
#ifdef YYERROR_VERBOSE
# undef YYERROR_VERBOSE
# define YYERROR_VERBOSE 1
#else
# define YYERROR_VERBOSE 0
#endif

#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
#line 459 "rib.y"
typedef union ribval {
	float	real;
	char	string[512];
	int		integer;
} YYSTYPE;
/* Line 191 of yacc.c.  */
#line 767 "rib.cpp"
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
# define YYSTYPE_IS_TRIVIAL 1
#endif



/* Copy the second part of user declarations.  */


/* Line 214 of yacc.c.  */
#line 779 "rib.cpp"

#if ! defined (yyoverflow) || YYERROR_VERBOSE

/* The parser invokes alloca or malloc; define the necessary symbols.  */

# if YYSTACK_USE_ALLOCA
#  define YYSTACK_ALLOC alloca
# else
#  ifndef YYSTACK_USE_ALLOCA
#   if defined (alloca) || defined (_ALLOCA_H)
#    define YYSTACK_ALLOC alloca
#   else
#    ifdef __GNUC__
#     define YYSTACK_ALLOC __builtin_alloca
#    endif
#   endif
#  endif
# endif

# ifdef YYSTACK_ALLOC
   /* Pacify GCC's `empty if-body' warning. */
#  define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
# else
#  if defined (__STDC__) || defined (__cplusplus)
#   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
#   define YYSIZE_T size_t
#  endif
#  define YYSTACK_ALLOC malloc
#  define YYSTACK_FREE free
# endif
#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */


#if (! defined (yyoverflow) \
     && (! defined (__cplusplus) \
	 || (YYSTYPE_IS_TRIVIAL)))

/* A type that is properly aligned for any stack member.  */
union yyalloc
{
  short yyss;
  YYSTYPE yyvs;
  };

/* The size of the maximum gap between one aligned stack and the next.  */
# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)

/* The size of an array large to enough to hold all stacks, each with
   N elements.  */
# define YYSTACK_BYTES(N) \
     ((N) * (sizeof (short) + sizeof (YYSTYPE))				\
      + YYSTACK_GAP_MAXIMUM)

/* Copy COUNT objects from FROM to TO.  The source and destination do
   not overlap.  */
# ifndef YYCOPY
#  if 1 < __GNUC__
#   define YYCOPY(To, From, Count) \
      __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
#  else
#   define YYCOPY(To, From, Count)		\
      do					\
	{					\
	  register YYSIZE_T yyi;		\
	  for (yyi = 0; yyi < (Count); yyi++)	\
	    (To)[yyi] = (From)[yyi];		\
	}					\
      while (0)
#  endif
# endif

/* Relocate STACK from its old location to the new one.  The
   local variables YYSIZE and YYSTACKSIZE give the old and new number of
   elements in the stack, and YYPTR gives the new location of the
   stack.  Advance YYPTR to a properly aligned location for the next
   stack.  */
# define YYSTACK_RELOCATE(Stack)					\
    do									\
      {									\
	YYSIZE_T yynewbytes;						\
	YYCOPY (&yyptr->Stack, Stack, yysize);				\
	Stack = &yyptr->Stack;						\
	yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
	yyptr += yynewbytes / sizeof (*yyptr);				\
      }									\
    while (0)

#endif

#if defined (__STDC__) || defined (__cplusplus)
   typedef signed char yysigned_char;
#else
   typedef short yysigned_char;
#endif

/* YYFINAL -- State number of the termination state. */
#define YYFINAL  3
/* YYLAST -- Last index in YYTABLE.  */
#define YYLAST   665

/* YYNTOKENS -- Number of terminals. */
#define YYNTOKENS  110
/* YYNNTS -- Number of nonterminals. */
#define YYNNTS  15
/* YYNRULES -- Number of rules. */
#define YYNRULES  152
/* YYNRULES -- Number of states. */
#define YYNSTATES  639

/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */
#define YYUNDEFTOK  2
#define YYMAXUTOK   364

#define YYTRANSLATE(YYX) 						\
  ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)

/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX.  */
static const unsigned char yytranslate[] =
{
       0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
       5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
      15,    16,    17,    18,    19,    20,    21,    22,    23,    24,
      25,    26,    27,    28,    29,    30,    31,    32,    33,    34,
      35,    36,    37,    38,    39,    40,    41,    42,    43,    44,
      45,    46,    47,    48,    49,    50,    51,    52,    53,    54,
      55,    56,    57,    58,    59,    60,    61,    62,    63,    64,
      65,    66,    67,    68,    69,    70,    71,    72,    73,    74,
      75,    76,    77,    78,    79,    80,    81,    82,    83,    84,
      85,    86,    87,    88,    89,    90,    91,    92,    93,    94,
      95,    96,    97,    98,    99,   100,   101,   102,   103,   104,
     105,   106,   107,   108,   109
};

#if YYDEBUG
/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
   YYRHS.  */
static const unsigned short yyprhs[] =
{
       0,     0,     3,     5,     8,    10,    13,    15,    18,    20,
      24,    27,    29,    31,    35,    38,    42,    44,    47,    49,
      51,    54,    55,    58,    61,    64,    65,    67,    71,    73,
      76,    78,    80,    82,    87,    90,    96,   104,   110,   118,
     122,   126,   134,   139,   141,   145,   148,   152,   157,   161,
     165,   172,   178,   182,   185,   189,   192,   196,   198,   200,
     205,   210,   217,   224,   234,   246,   251,   256,   260,   265,
     269,   273,   277,   281,   285,   288,   291,   294,   304,   312,
     322,   330,   336,   344,   348,   351,   354,   356,   359,   361,
     381,   401,   404,   409,   414,   420,   429,   440,   444,   448,
     451,   454,   456,   458,   462,   465,   469,   474,   480,   486,
     509,   532,   572,   576,   584,   597,   608,   615,   624,   630,
     638,   645,   654,   664,   676,   683,   692,   698,   706,   714,
     724,   730,   733,   743,   749,   755,   759,   771,   774,   776,
     779,   781,   784,   787,   789,   799,   809,   817,   831,   836,
     839,   842,   845
};

/* YYRHS -- A `-1'-separated list of the rules' RHS. */
static const yysigned_char yyrhs[] =
{
     111,     0,    -1,   123,    -1,   112,   108,    -1,   108,    -1,
     113,   108,    -1,   108,    -1,   114,   106,    -1,   106,    -1,
     104,   113,   105,    -1,   104,   105,    -1,   115,    -1,   113,
      -1,   104,   112,   105,    -1,   104,   105,    -1,   104,   114,
     105,    -1,   106,    -1,   104,   105,    -1,   119,    -1,   118,
      -1,   122,   121,    -1,    -1,   106,   116,    -1,   106,   118,
      -1,   123,   124,    -1,    -1,   109,    -1,     3,   106,   106,
      -1,     4,    -1,     4,   108,    -1,     5,    -1,     6,    -1,
       7,    -1,     8,   108,   108,   108,    -1,     9,   108,    -1,
      10,   108,   108,   108,   108,    -1,    10,   104,   108,   108,
     108,   108,   105,    -1,    11,   108,   108,   108,   108,    -1,
      11,   104,   108,   108,   108,   108,   105,    -1,    12,   106,
     121,    -1,    13,   108,   108,    -1,    14,   108,   108,   108,
     108,   108,   108,    -1,    15,   108,   108,   108,    -1,    15,
      -1,    16,   108,   108,    -1,    17,   108,    -1,    18,   108,
     108,    -1,    19,   106,   108,   108,    -1,    20,   108,   108,
      -1,    21,   106,   121,    -1,    22,   106,   108,   108,   108,
     108,    -1,    23,   106,   106,   106,   121,    -1,    24,   106,
     121,    -1,    25,   116,    -1,    25,   115,   115,    -1,    26,
     108,    -1,    27,   106,   121,    -1,    28,    -1,    29,    -1,
      30,   108,   108,   108,    -1,    31,   108,   108,   108,    -1,
      30,   104,   108,   108,   108,   105,    -1,    31,   104,   108,
     108,   108,   105,    -1,    32,   108,   108,   108,   108,   108,
     108,   108,   108,    -1,    32,   104,   108,   108,   108,   108,
     108,   108,   108,   108,   105,    -1,    33,   106,   108,   121,
      -1,    33,   106,   106,   121,    -1,    33,   106,   121,    -1,
      34,   106,   108,   121,    -1,    35,   108,   108,    -1,    36,
     106,   121,    -1,    37,   106,   121,    -1,    38,   106,   121,
      -1,    39,   106,   121,    -1,    40,   108,    -1,    41,   106,
      -1,    42,   108,    -1,    43,   104,   108,   108,   108,   108,
     108,   108,   105,    -1,    43,   108,   108,   108,   108,   108,
     108,    -1,    44,   104,   108,   108,   108,   108,   108,   108,
     105,    -1,    44,   108,   108,   108,   108,   108,   108,    -1,
      45,   108,   108,   108,   108,    -1,    45,   104,   108,   108,
     108,   108,   105,    -1,    46,   106,   108,    -1,    47,   106,
      -1,    48,   106,    -1,    49,    -1,    50,   108,    -1,    51,
      -1,    52,   104,   108,   108,   108,   108,   108,   108,   108,
     108,   108,   108,   108,   108,   108,   108,   108,   108,   105,
      -1,    53,   104,   108,   108,   108,   108,   108,   108,   108,
     108,   108,   108,   108,   108,   108,   108,   108,   108,   105,
      -1,    54,   108,    -1,    55,   108,   108,   108,    -1,    57,
     108,   108,   108,    -1,    56,   108,   108,   108,   108,    -1,
      58,   108,   108,   108,   108,   108,   108,   108,    -1,    58,
     104,   108,   108,   108,   108,   108,   108,   108,   105,    -1,
      59,   106,   121,    -1,    60,   106,   121,    -1,    61,   106,
      -1,    62,   106,    -1,    63,    -1,    64,    -1,    65,   106,
     121,    -1,    66,   121,    -1,    67,   117,   121,    -1,    68,
     117,   117,   121,    -1,    69,   117,   117,   117,   121,    -1,
      70,   106,   108,   106,   108,    -1,    70,   104,   108,   108,
     108,   108,   108,   108,   108,   108,   108,   108,   108,   108,
     108,   108,   108,   108,   105,   108,   106,   108,    -1,    70,
     106,   108,   104,   108,   108,   108,   108,   108,   108,   108,
     108,   108,   108,   108,   108,   108,   108,   108,   108,   105,
     108,    -1,    70,   104,   108,   108,   108,   108,   108,   108,
     108,   108,   108,   108,   108,   108,   108,   108,   108,   108,
     105,   108,   104,   108,   108,   108,   108,   108,   108,   108,
     108,   108,   108,   108,   108,   108,   108,   108,   108,   105,
     108,    -1,    71,   106,   121,    -1,    72,   106,   108,   106,
     108,   106,   121,    -1,    73,   108,   108,   115,   108,   108,
     108,   108,   115,   108,   108,   121,    -1,    74,   115,   115,
     115,   115,   115,   115,   115,   115,   115,    -1,    75,   108,
     108,   108,   108,   121,    -1,    75,   104,   108,   108,   108,
     108,   105,   121,    -1,    76,   108,   108,   108,   121,    -1,
      76,   104,   108,   108,   108,   105,   121,    -1,    77,   108,
     108,   108,   108,   121,    -1,    77,   104,   108,   108,   108,
     108,   105,   121,    -1,    78,   108,   108,   108,   108,   108,
     108,   108,   121,    -1,    78,   104,   108,   108,   108,   108,
     108,   108,   108,   105,   121,    -1,    79,   108,   108,   108,
     108,   121,    -1,    79,   104,   108,   108,   108,   108,   105,
     121,    -1,    80,   108,   108,   108,   121,    -1,    80,   104,
     108,   108,   108,   105,   121,    -1,    81,   108,   108,   108,
     108,   108,   121,    -1,    81,   104,   108,   108,   108,   108,
     108,   105,   121,    -1,    82,   106,   117,   106,   121,    -1,
      84,   121,    -1,    85,   106,   117,   117,   120,   117,   117,
     115,   121,    -1,    85,   106,   117,   117,   121,    -1,    86,
     108,   115,   118,   121,    -1,    83,   106,   121,    -1,    87,
     106,   118,   104,   108,   108,   108,   108,   108,   108,   105,
      -1,    88,   106,    -1,    89,    -1,    90,   108,    -1,    91,
      -1,    92,   108,    -1,    93,   116,    -1,    94,    -1,    95,
     106,   106,   106,   106,   106,   108,   108,   121,    -1,    96,
     106,   106,   106,   106,   106,   108,   108,   121,    -1,    97,
     106,   106,   106,   108,   108,   121,    -1,    98,   106,   106,
     106,   106,   106,   106,   106,   108,   106,   108,   108,   121,
      -1,    99,   106,   106,   121,    -1,   101,   106,    -1,   102,
     108,    -1,   102,   103,    -1,     1,    -1
};

/* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
static const unsigned short yyrline[] =
{
       0,   581,   581,   584,   592,   601,   609,   617,   627,   637,
     644,   652,   657,   663,   670,   678,   685,   695,   699,   704,
     710,   715,   734,   746,   760,   770,   774,   781,   788,   793,
     799,   804,   809,   814,   822,   828,   837,   848,   857,   868,
     875,   882,   893,   901,   906,   913,   919,   926,   938,   945,
     955,   965,   974,   983,   997,  1012,  1018,  1027,  1032,  1037,
    1051,  1065,  1081,  1097,  1110,  1125,  1135,  1145,  1152,  1162,
    1171,  1178,  1185,  1192,  1199,  1205,  1211,  1217,  1239,  1259,
    1281,  1301,  1310,  1321,  1328,  1334,  1340,  1345,  1351,  1356,
    1398,  1440,  1446,  1454,  1462,  1471,  1483,  1497,  1504,  1511,
    1517,  1523,  1528,  1533,  1542,  1552,  1565,  1601,  1645,  1658,
    1707,  1756,  1835,  1861,  1937,  1971,  1995,  2009,  2025,  2038,
    2053,  2067,  2083,  2109,  2137,  2151,  2167,  2180,  2195,  2210,
    2227,  2273,  2283,  2321,  2349,  2358,  2367,  2436,  2442,  2447,
    2455,  2460,  2470,  2478,  2483,  2500,  2517,  2532,  2553,  2561,
    2571,  2576,  2581
};
#endif

#if YYDEBUG || YYERROR_VERBOSE
/* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
   First, the terminals, then, starting at YYNTOKENS, nonterminals. */
static const char *const yytname[] =
{
  "$end", "error", "$undefined", "RIB_DECLARE", "RIB_FRAME_BEGIN", 
  "RIB_FRAME_END", "RIB_WORLD_BEGIN", "RIB_WORLD_END", "RIB_FORMAT", 
  "RIB_FRAME_ASPECT_RATIO", "RIB_SCREEN_WINDOW", "RIB_CROP_WINDOW", 
  "RIB_PROJECTION", "RIB_CLIPPING", "RIB_CLIPPING_PLANE", 
  "RIB_DEPTH_OF_FIELD", "RIB_SHUTTER", "RIB_PIXEL_VARIANCE", 
  "RIB_PIXEL_SAMPLES", "RIB_PIXEL_FILTER", "RIB_EXPOSURE", "RIB_IMAGER", 
  "RIB_QUANTIZE", "RIB_DISPLAY", "RIB_HIDER", "RIB_COLOR_SAMPLES", 
  "RIB_RELATIVE_DETAIL", "RIB_OPTION", "RIB_ATTRIBUTE_BEGIN", 
  "RIB_ATTRIBUTE_END", "RIB_COLOR", "RIB_OPACITY", 
  "RIB_TEXTURE_COORDINATES", "RIB_LIGHT_SOURCE", "RIB_AREA_LIGHT_SOURCE", 
  "RIB_ILLUMINATE", "RIB_SURFACE", "RIB_ATMOSPHERE", "RIB_INTERIOR", 
  "RIB_EXTERIOR", "RIB_SHADING_RATE", "RIB_SHADING_INTERPOLATION", 
  "RIB_MATTE", "RIB_BOUND", "RIB_DETAIL", "RIB_DETAIL_RANGE", 
  "RIB_GEOMETRIC_APPROXIMATION", "RIB_GEOMETRIC_REPRESENTATION", 
  "RIB_ORIENTATION", "RIB_REVERSE_ORIENTATION", "RIB_SIDES", 
  "RIB_IDENTITY", "RIB_TRANSFORM", "RIB_CONCAT_TRANSFORM", 
  "RIB_PERSPECTIVE", "RIB_TRANSLATE", "RIB_ROTATE", "RIB_SCALE", 
  "RIB_SKEW", "RIB_DEFORMATION", "RIB_DISPLACEMENT", 
  "RIB_COORDINATE_SYSTEM", "RIB_COORDINATE_SYS_TRANSFORM", 
  "RIB_TRANSFORM_BEGIN", "RIB_TRANSFORM_END", "RIB_ATTRIBUTE", 
  "RIB_POLYGON", "RIB_GENERAL_POLYGON", "RIB_POINTS_POLYGONS", 
  "RIB_POINTS_GENERAL_POLYGONS", "RIB_BASIS", "RIB_PATCH", 
  "RIB_PATCH_MESH", "RIB_NU_PATCH", "RIB_TRIM_CURVE", "RIB_SPHERE", 
  "RIB_CONE", "RIB_CYLINDER", "RIB_HYPERBOLOID", "RIB_PARABOLOID", 
  "RIB_DISK", "RIB_TORUS", "RIB_CURVES", "RIB_GEOMETRY", "RIB_POINTS", 
  "RIB_SUBDIVISION_MESH", "RIB_BLOBBY", "RIB_PROCEDURAL", 
  "RIB_SOLID_BEGIN", "RIB_SOLID_END", "RIB_OBJECT_BEGIN", 
  "RIB_OBJECT_END", "RIB_OBJECT_INSTANCE", "RIB_MOTION_BEGIN", 
  "RIB_MOTION_END", "RIB_MAKE_TEXTURE", "RIB_MAKE_BUMP", 
  "RIB_MAKE_LAT_LONG_ENVIRONMENT", "RIB_MAKE_CUBE_FACE_ENVIRONMENT", 
  "RIB_MAKE_SHADOW", "RIB_ARCHIVE_RECORD", "RIB_ERROR_HANDLER", 
  "RIB_VERSION", "RIB_VERSION_STRING", "RIB_ARRAY_BEGIN", "RIB_ARRAY_END", 
  "RIB_TEXT", "RIB_IDENTIFIER", "RIB_FLOAT", "RIB_STRUCTURE_COMMENT", 
  "$accept", "start", "ribIntString", "ribFloatString", "ribTextString", 
  "ribFloatArray", "ribFloats", "ribIntArray", "ribTextArray", 
  "ribEmptyArray", "ribTexts", "ribPL", "ribParameter", "ribCommands", 
  "ribComm", 0
};
#endif

# ifdef YYPRINT
/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
   token YYLEX-NUM.  */
static const unsigned short yytoknum[] =
{
       0,   256,   257,   258,   259,   260,   261,   262,   263,   264,
     265,   266,   267,   268,   269,   270,   271,   272,   273,   274,
     275,   276,   277,   278,   279,   280,   281,   282,   283,   284,
     285,   286,   287,   288,   289,   290,   291,   292,   293,   294,
     295,   296,   297,   298,   299,   300,   301,   302,   303,   304,
     305,   306,   307,   308,   309,   310,   311,   312,   313,   314,
     315,   316,   317,   318,   319,   320,   321,   322,   323,   324,
     325,   326,   327,   328,   329,   330,   331,   332,   333,   334,
     335,   336,   337,   338,   339,   340,   341,   342,   343,   344,
     345,   346,   347,   348,   349,   350,   351,   352,   353,   354,
     355,   356,   357,   358,   359,   360,   361,   362,   363,   364
};
# endif

/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
static const unsigned char yyr1[] =
{
       0,   110,   111,   112,   112,   113,   113,   114,   114,   115,
     115,   116,   116,   117,   117,   118,   118,   119,   120,   120,
     121,   121,   122,   122,   123,   123,   124,   124,   124,   124,
     124,   124,   124,   124,   124,   124,   124,   124,   124,   124,
     124,   124,   124,   124,   124,   124,   124,   124,   124,   124,
     124,   124,   124,   124,   124,   124,   124,   124,   124,   124,
     124,   124,   124,   124,   124,   124,   124,   124,   124,   124,
     124,   124,   124,   124,   124,   124,   124,   124,   124,   124,
     124,   124,   124,   124,   124,   124,   124,   124,   124,   124,
     124,   124,   124,   124,   124,   124,   124,   124,   124,   124,
     124,   124,   124,   124,   124,   124,   124,   124,   124,   124,
     124,   124,   124,   124,   124,   124,   124,   124,   124,   124,
     124,   124,   124,   124,   124,   124,   124,   124,   124,   124,
     124,   124,   124,   124,   124,   124,   124,   124,   124,   124,
     124,   124,   124,   124,   124,   124,   124,   124,   124,   124,
     124,   124,   124
};

/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
static const unsigned char yyr2[] =
{
       0,     2,     1,     2,     1,     2,     1,     2,     1,     3,
       2,     1,     1,     3,     2,     3,     1,     2,     1,     1,
       2,     0,     2,     2,     2,     0,     1,     3,     1,     2,
       1,     1,     1,     4,     2,     5,     7,     5,     7,     3,
       3,     7,     4,     1,     3,     2,     3,     4,     3,     3,
       6,     5,     3,     2,     3,     2,     3,     1,     1,     4,
       4,     6,     6,     9,    11,     4,     4,     3,     4,     3,
       3,     3,     3,     3,     2,     2,     2,     9,     7,     9,
       7,     5,     7,     3,     2,     2,     1,     2,     1,    19,
      19,     2,     4,     4,     5,     8,    10,     3,     3,     2,
       2,     1,     1,     3,     2,     3,     4,     5,     5,    22,
      22,    39,     3,     7,    12,    10,     6,     8,     5,     7,
       6,     8,     9,    11,     6,     8,     5,     7,     7,     9,
       5,     2,     9,     5,     5,     3,    11,     2,     1,     2,
       1,     2,     2,     1,     9,     9,     7,    13,     4,     2,
       2,     2,     1
};

/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
   STATE-NUM when YYTABLE doesn't specify something else to do.  Zero
   means the default is an error.  */
static const unsigned char yydefact[] =
{
      25,     0,     0,     1,   152,     0,    28,    30,    31,    32,
       0,     0,     0,     0,     0,     0,     0,    43,     0,     0,
       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
      57,    58,     0,     0,     0,     0,     0,     0,     0,     0,
       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
       0,    86,     0,    88,     0,     0,     0,     0,     0,     0,
       0,     0,     0,     0,     0,   101,   102,     0,    21,     0,
       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
       0,     0,     0,     0,     0,     0,    21,     0,     0,     0,
       0,   138,     0,   140,     0,     0,   143,     0,     0,     0,
       0,     0,     0,     0,    26,    24,     0,    29,     0,    34,
       0,     0,     0,     0,    21,     0,     0,     0,     0,    45,
       0,     0,     0,    21,     0,     0,    21,     0,     6,    12,
      11,    53,    55,    21,     0,     0,     0,     0,     0,     0,
      21,     0,     0,    21,    21,    21,    21,    74,    75,    76,
       0,     0,     0,     0,     0,     0,     0,    84,    85,    87,
       0,     0,    91,     0,     0,     0,     0,     0,    21,    21,
      99,   100,    21,     0,   104,    21,     0,    21,     0,     0,
       0,     0,    21,     0,     0,     0,     0,     0,     0,     0,
       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
       0,    21,   131,     0,     0,     0,   137,   139,   141,    11,
     142,     0,     0,     0,     0,     0,   149,   151,   150,    27,
       0,     0,     0,     0,     0,    39,    40,     0,     0,    44,
      46,     0,    48,    49,     0,     0,    52,    10,     0,     5,
      54,    56,     0,     0,     0,     0,     0,     0,    21,    21,
      67,    21,    69,    70,    71,    72,    73,     0,     0,     0,
       0,     0,     0,    83,     0,     0,     0,     0,     0,     0,
       0,    97,    98,   103,     0,    16,    22,    23,    20,    14,
       4,     0,   105,    21,     0,     0,     0,   112,     0,     0,
       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
       0,     0,     0,     0,     0,     0,   135,     0,     0,     0,
       0,     0,     0,     0,     0,    21,    33,     0,     0,     0,
       0,     0,    42,    47,     0,    21,     9,     0,    59,     0,
      60,     0,     0,    16,    66,    65,    68,     0,     0,     0,
       0,     0,     0,     0,     0,    92,     0,    93,     0,     0,
       8,     0,    13,     3,   106,    21,     0,     0,     0,     0,
       0,     0,     0,     0,     0,    21,     0,     0,     0,     0,
       0,     0,     0,    21,     0,     0,    21,    21,    21,     0,
       0,     0,     0,     0,   148,     0,    35,     0,    37,     0,
       0,    51,     0,     0,     0,     0,     0,     0,     0,     0,
       0,    81,     0,     0,    94,     0,     0,    15,     7,   107,
       0,     0,   108,     0,     0,     0,     0,    21,     0,   118,
       0,    21,     0,     0,     0,    21,     0,   126,     0,     0,
     130,     0,    19,    18,     0,   133,   134,     0,     0,     0,
       0,     0,     0,     0,     0,    50,    61,    62,     0,     0,
       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
       0,    21,     0,     0,     0,   116,    21,     0,   120,     0,
       0,     0,   124,    21,     0,    21,    17,     0,     0,     0,
       0,    21,     0,    36,    38,    41,     0,     0,     0,    78,
       0,    80,    82,     0,     0,     0,     0,     0,     0,   113,
       0,     0,    21,   119,    21,     0,     0,    21,   127,     0,
     128,     0,     0,     0,     0,   146,     0,     0,     0,     0,
       0,     0,     0,     0,    95,     0,     0,     0,     0,   117,
     121,     0,    21,   125,    21,    21,     0,    21,    21,     0,
       0,    63,    77,    79,     0,     0,     0,     0,     0,     0,
       0,     0,   122,   129,   132,     0,   144,   145,     0,     0,
       0,     0,    96,     0,     0,     0,   115,    21,     0,     0,
      64,     0,     0,     0,     0,    21,   123,   136,     0,     0,
       0,     0,     0,   114,    21,     0,     0,     0,     0,   147,
       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
      89,    90,     0,     0,     0,     0,     0,     0,     0,     0,
     109,   110,     0,     0,     0,     0,     0,     0,     0,     0,
       0,     0,     0,     0,     0,     0,     0,     0,   111
};

/* YYDEFGOTO[NTERM-NUM]. */
static const short yydefgoto[] =
{
      -1,     1,   281,   129,   351,   209,   276,   177,   277,   433,
     434,   174,   175,     2,   105
};

/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
   STATE-NUM.  */
#define YYPACT_NINF -203
static const short yypact[] =
{
    -203,    22,   521,  -203,  -203,   -40,   -80,  -203,  -203,  -203,
     -37,   -30,   -89,   -87,   -22,   -20,   -11,    -9,     0,     3,
       4,     1,     5,     8,     9,    10,    11,   -84,    12,    15,
    -203,  -203,   -81,   -79,   -78,    16,    17,    18,    19,    21,
      23,    24,    20,    26,    25,   -73,   -71,   -70,    29,    30,
      31,  -203,    32,  -203,   -19,    14,    33,    34,    35,    36,
     -68,    39,    40,    41,    42,  -203,  -203,    43,    44,    47,
      47,    47,   -59,    48,    49,    45,    52,   -65,   -62,   -56,
     -54,   -51,   -49,   -48,    51,    53,    44,    54,    55,    56,
      58,  -203,    57,  -203,    60,   -84,  -203,    64,    65,    66,
      67,    68,    70,   -96,  -203,  -203,    72,  -203,    71,  -203,
      73,    74,    75,    76,    44,    77,    78,    79,    80,  -203,
      81,    82,    83,    44,    84,    87,    44,   -33,  -203,    86,
      52,  -203,  -203,    44,    88,    89,    90,    91,    92,    94,
     -98,    95,    96,    44,    44,    44,    44,  -203,  -203,  -203,
      97,    98,    99,   100,   101,   102,   103,  -203,  -203,  -203,
     104,   105,  -203,   106,   108,   109,   110,   111,    44,    44,
    -203,  -203,    44,   -95,  -203,    44,   -32,    44,    47,    47,
     112,   113,    44,   114,   115,    52,   116,   117,   118,   119,
     120,   121,   122,   123,   124,   126,   127,   128,   129,   131,
      47,    44,  -203,    47,    52,   -23,  -203,  -203,  -203,  -203,
    -203,   134,   135,   136,   138,   139,  -203,  -203,  -203,  -203,
     140,   141,   142,   143,   144,  -203,  -203,   145,   146,  -203,
    -203,   147,  -203,  -203,   148,   151,  -203,  -203,   -28,  -203,
    -203,  -203,   150,   152,   153,   156,   157,   158,   -90,    44,
    -203,    44,  -203,  -203,  -203,  -203,  -203,   159,   160,   161,
     162,   163,   164,  -203,   166,   167,   168,   169,   170,   171,
     172,  -203,  -203,  -203,   -38,  -203,  -203,  -203,  -203,  -203,
    -203,   -26,  -203,    44,    47,   173,   -15,  -203,   176,    52,
      52,   177,   178,   179,   180,   181,   182,   184,   185,   189,
     190,   191,   192,   193,   194,   197,  -203,    47,   -23,   198,
     155,   199,   200,   201,   202,    44,  -203,   203,   204,   205,
     206,   207,  -203,  -203,   208,    44,  -203,   209,  -203,   210,
    -203,   211,   212,   -39,  -203,  -203,  -203,   213,   214,   215,
     216,   217,   218,   219,   220,  -203,   221,  -203,   222,   223,
    -203,    -4,  -203,  -203,  -203,    44,   224,   225,   228,   229,
     230,    52,   232,   233,   234,    44,   236,   237,   238,   239,
     240,   241,   242,    44,   243,   244,    44,   -12,    44,   245,
     248,   249,   250,   251,  -203,   252,  -203,   253,  -203,   254,
     255,  -203,   259,   261,   260,   262,   263,   264,   265,   266,
     267,  -203,   268,   269,  -203,   270,   272,  -203,  -203,  -203,
     273,   274,  -203,   277,   278,    52,   279,    44,   280,  -203,
     281,    44,   282,   284,   286,    44,   290,  -203,   288,   289,
    -203,    -1,  -203,  -203,    47,  -203,  -203,   292,   295,   296,
     297,   298,   293,   301,   299,  -203,  -203,  -203,   302,   303,
     304,   305,   306,   307,   311,   309,   310,   313,   315,   316,
     318,    44,   319,    52,   314,  -203,    44,   323,  -203,   321,
     322,   326,  -203,    44,   324,    44,  -203,    47,   325,   327,
     329,    44,   328,  -203,  -203,  -203,   330,   331,   332,  -203,
     333,  -203,  -203,   334,   335,   336,   337,   338,   339,  -203,
     340,    52,    44,  -203,    44,   341,   343,    44,  -203,   349,
    -203,    52,   350,   351,   352,  -203,   355,   354,   356,   358,
     360,   359,   361,   362,  -203,   363,   364,    52,    52,  -203,
    -203,   365,    44,  -203,    44,    44,   367,    44,    44,   368,
     369,  -203,  -203,  -203,   370,   371,   375,   373,   374,   378,
      52,   382,  -203,  -203,  -203,   380,  -203,  -203,   377,   384,
     383,   386,  -203,   387,   388,   389,  -203,    44,   385,   390,
    -203,   391,   395,   396,   397,    44,  -203,  -203,   398,   399,
     400,   401,   402,  -203,    44,   403,   404,   405,   406,  -203,
     407,   408,   409,   410,   411,   412,   513,   516,   517,   518,
     519,   520,   523,   524,   525,   526,   530,   531,   532,   533,
    -203,  -203,   534,   535,    -8,   539,   537,   538,   540,   541,
    -203,  -203,   542,   543,   544,   545,   546,   547,   548,   549,
     550,   551,   552,   553,   554,   555,   559,   557,  -203
};

/* YYPGOTO[NTERM-NUM].  */
static const short yypgoto[] =
{
    -203,  -203,  -203,  -122,  -203,   -27,   -21,   -69,  -202,  -203,
    -203,   -82,  -203,  -203,  -203
};

/* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
   positive, shift that token.  If negative, reduce the rule which
   number is the opposite.  If zero, do what YYDEFACT says.
   If YYTABLE_NINF, syntax error.  */
#define YYTABLE_NINF -3
static const short yytable[] =
{
     130,   178,   179,   310,   202,   238,   131,   217,   248,   274,
     249,   275,   218,   128,   274,   110,   333,   112,   128,   111,
     127,   113,     3,   134,   128,   136,   138,   135,   107,   137,
     139,   150,   225,   152,   154,   151,   166,   153,   155,   186,
     167,   233,   188,   187,   236,   180,   189,   181,   190,   185,
     192,   241,   191,   194,   193,   196,   198,   195,   250,   197,
     199,   253,   254,   255,   256,   274,   106,   237,   350,   128,
     128,   108,   237,   279,   210,   128,   280,   326,   109,   352,
     239,   309,   353,   275,   114,   160,   271,   272,   115,   357,
     273,   358,   431,   278,   333,   282,   616,   116,   617,   117,
     287,   407,   408,   240,   476,   350,   378,   121,   118,   283,
     284,   119,   120,   122,   123,   124,   125,   126,   161,   306,
     132,   133,   140,   141,     0,   143,   142,   144,   147,   145,
     146,   305,   148,   149,   307,   156,   157,   158,     0,     0,
     159,   162,   163,   164,   165,   168,   169,   170,   171,   172,
     173,   176,   238,   184,   182,   183,   127,   200,   290,   201,
     203,     0,   205,   204,   206,   207,   334,   335,   208,   336,
     211,   212,   213,   214,   215,   432,   216,   308,   219,   220,
       0,   221,   222,   223,   224,   226,   227,   228,   229,   230,
     231,   232,   234,   235,   239,     0,   242,   243,   244,   245,
     246,   354,   247,   251,   252,   257,   258,   259,   260,   261,
     262,   263,   264,   265,   266,   355,   267,   268,   269,   270,
     285,   286,   288,   289,   291,   292,   293,   294,   295,   296,
     297,   298,   299,   384,   300,   301,   302,   303,   377,   304,
     311,   312,   313,   391,   314,   315,     0,     0,   316,   317,
     318,   319,   320,   321,   322,   323,   324,   325,   327,   379,
     328,   329,   360,   361,   330,   331,   332,   337,   338,   339,
     340,   341,   342,   409,   343,   344,   345,   346,   347,   348,
     349,   356,   359,   419,     0,   362,   363,   364,   365,   366,
     367,   427,   368,   369,   430,   435,   436,   370,   371,   372,
     373,   374,   375,   376,   350,   380,   381,   382,   383,     0,
       0,   385,   386,   387,   388,   389,   390,   392,   393,   394,
     395,   396,   397,   398,   399,   400,   401,   402,   403,   404,
     405,   406,   410,   411,   415,   465,   412,   413,   414,   468,
     416,   417,   418,   472,   420,   421,   422,   423,   424,   425,
     426,   428,   429,   437,   438,   439,     0,   441,   440,     0,
     442,   443,   444,   445,   446,   477,   447,     0,   448,     0,
     449,   450,   451,   452,   453,   454,   455,   456,   457,   499,
     458,   459,   460,   461,   503,   466,   462,   464,   463,   467,
     469,   508,   470,   510,   471,   473,   474,   475,   483,   515,
     478,   479,   480,     0,   482,   481,   484,   485,   511,     0,
     486,   487,   488,   489,   490,   491,   492,   493,   494,   502,
     529,   495,   530,   496,   497,   533,   498,   500,   504,   505,
     506,   507,   509,   512,   516,   513,   501,   514,   517,   518,
     519,   520,   521,   522,   523,   524,   525,   526,   527,   531,
     552,   532,   553,   554,   534,   556,   557,     0,   536,   537,
     538,   539,   540,   542,   541,   543,     0,   544,     0,   545,
     546,   547,   548,   551,   528,   555,   558,   559,   560,   561,
     562,   563,   564,   569,   535,   576,   565,   567,   568,   570,
     577,   571,     0,   583,   572,   573,   574,   575,   578,   579,
     549,   550,   589,   580,   581,   582,   584,   585,   586,   587,
     588,   590,   591,   592,   593,   594,   595,   596,   597,   598,
     599,    -2,     4,   566,     5,     6,     7,     8,     9,    10,
      11,    12,    13,    14,    15,    16,    17,    18,    19,    20,
      21,    22,    23,    24,    25,    26,    27,    28,    29,    30,
      31,    32,    33,    34,    35,    36,    37,    38,    39,    40,
      41,    42,    43,    44,    45,    46,    47,    48,    49,    50,
      51,    52,    53,    54,    55,    56,    57,    58,    59,    60,
      61,    62,    63,    64,    65,    66,    67,    68,    69,    70,
      71,    72,    73,    74,    75,    76,    77,    78,    79,    80,
      81,    82,    83,    84,    85,    86,    87,    88,    89,    90,
      91,    92,    93,    94,    95,    96,    97,    98,    99,   100,
     101,   600,   102,   103,   601,   602,   603,   604,   605,     0,
     104,   606,   607,   608,   609,   610,   611,   612,     0,     0,
       0,   613,   614,   615,   618,   619,   620,     0,   621,   622,
     623,   624,   625,   626,   627,   628,   629,   630,   631,   632,
     633,   634,   635,   636,   637,   638
};

static const short yycheck[] =
{
      27,    70,    71,   205,    86,   127,    27,   103,   106,   104,
     108,   106,   108,   108,   104,   104,   106,   104,   108,   108,
     104,   108,     0,   104,   108,   104,   104,   108,   108,   108,
     108,   104,   114,   104,   104,   108,   104,   108,   108,   104,
     108,   123,   104,   108,   126,   104,   108,   106,   104,    76,
     104,   133,   108,   104,   108,   104,   104,   108,   140,   108,
     108,   143,   144,   145,   146,   104,   106,   105,   106,   108,
     108,   108,   105,   105,    95,   108,   108,   105,   108,   105,
     108,   104,   108,   106,   106,   104,   168,   169,   108,   104,
     172,   106,   104,   175,   106,   177,   104,   108,   106,   108,
     182,   105,   106,   130,   105,   106,   308,   106,   108,   178,
     179,   108,   108,   108,   106,   106,   106,   106,   104,   201,
     108,   106,   106,   106,    -1,   106,   108,   106,   108,   106,
     106,   200,   106,   108,   203,   106,   106,   106,    -1,    -1,
     108,   108,   108,   108,   108,   106,   106,   106,   106,   106,
     106,   104,   274,   108,   106,   106,   104,   106,   185,   106,
     106,    -1,   106,   108,   106,   108,   248,   249,   108,   251,
     106,   106,   106,   106,   106,   377,   106,   204,   106,   108,
      -1,   108,   108,   108,   108,   108,   108,   108,   108,   108,
     108,   108,   108,   106,   108,    -1,   108,   108,   108,   108,
     108,   283,   108,   108,   108,   108,   108,   108,   108,   108,
     108,   108,   108,   108,   108,   284,   108,   108,   108,   108,
     108,   108,   108,   108,   108,   108,   108,   108,   108,   108,
     108,   108,   108,   315,   108,   108,   108,   108,   307,   108,
     106,   106,   106,   325,   106,   106,    -1,    -1,   108,   108,
     108,   108,   108,   108,   108,   108,   108,   106,   108,   104,
     108,   108,   289,   290,   108,   108,   108,   108,   108,   108,
     108,   108,   108,   355,   108,   108,   108,   108,   108,   108,
     108,   108,   106,   365,    -1,   108,   108,   108,   108,   108,
     108,   373,   108,   108,   376,   377,   378,   108,   108,   108,
     108,   108,   108,   106,   106,   106,   106,   106,   106,    -1,
      -1,   108,   108,   108,   108,   108,   108,   108,   108,   108,
     108,   108,   108,   108,   108,   108,   108,   108,   108,   108,
     108,   108,   108,   108,   361,   417,   108,   108,   108,   421,
     108,   108,   108,   425,   108,   108,   108,   108,   108,   108,
     108,   108,   108,   108,   106,   106,    -1,   106,   108,    -1,
     108,   108,   108,   108,   105,   434,   105,    -1,   108,    -1,
     108,   108,   108,   108,   108,   108,   108,   108,   108,   461,
     108,   108,   108,   106,   466,   105,   108,   108,   415,   108,
     108,   473,   108,   475,   108,   105,   108,   108,   105,   481,
     108,   106,   106,    -1,   106,   108,   105,   108,   477,    -1,
     108,   108,   108,   108,   108,   108,   105,   108,   108,   105,
     502,   108,   504,   108,   108,   507,   108,   108,   105,   108,
     108,   105,   108,   108,   106,   108,   463,   108,   108,   108,
     108,   108,   108,   108,   108,   108,   108,   108,   108,   108,
     532,   108,   534,   535,   105,   537,   538,    -1,   108,   108,
     108,   106,   108,   105,   108,   105,    -1,   108,    -1,   108,
     108,   108,   108,   108,   501,   108,   108,   108,   108,   108,
     105,   108,   108,   106,   511,   567,   108,   105,   108,   105,
     105,   108,    -1,   575,   108,   108,   108,   108,   108,   108,
     527,   528,   584,   108,   108,   108,   108,   108,   108,   108,
     108,   108,   108,   108,   108,   108,   108,   108,   108,   108,
     108,     0,     1,   550,     3,     4,     5,     6,     7,     8,
       9,    10,    11,    12,    13,    14,    15,    16,    17,    18,
      19,    20,    21,    22,    23,    24,    25,    26,    27,    28,
      29,    30,    31,    32,    33,    34,    35,    36,    37,    38,
      39,    40,    41,    42,    43,    44,    45,    46,    47,    48,
      49,    50,    51,    52,    53,    54,    55,    56,    57,    58,
      59,    60,    61,    62,    63,    64,    65,    66,    67,    68,
      69,    70,    71,    72,    73,    74,    75,    76,    77,    78,
      79,    80,    81,    82,    83,    84,    85,    86,    87,    88,
      89,    90,    91,    92,    93,    94,    95,    96,    97,    98,
      99,   108,   101,   102,   108,   108,   108,   108,   108,    -1,
     109,   108,   108,   108,   108,   105,   105,   105,    -1,    -1,
      -1,   108,   108,   108,   105,   108,   108,    -1,   108,   108,
     108,   108,   108,   108,   108,   108,   108,   108,   108,   108,
     108,   108,   108,   108,   105,   108
};

/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
   symbol of state STATE-NUM.  */
static const unsigned char yystos[] =
{
       0,   111,   123,     0,     1,     3,     4,     5,     6,     7,
       8,     9,    10,    11,    12,    13,    14,    15,    16,    17,
      18,    19,    20,    21,    22,    23,    24,    25,    26,    27,
      28,    29,    30,    31,    32,    33,    34,    35,    36,    37,
      38,    39,    40,    41,    42,    43,    44,    45,    46,    47,
      48,    49,    50,    51,    52,    53,    54,    55,    56,    57,
      58,    59,    60,    61,    62,    63,    64,    65,    66,    67,
      68,    69,    70,    71,    72,    73,    74,    75,    76,    77,
      78,    79,    80,    81,    82,    83,    84,    85,    86,    87,
      88,    89,    90,    91,    92,    93,    94,    95,    96,    97,
      98,    99,   101,   102,   109,   124,   106,   108,   108,   108,
     104,   108,   104,   108,   106,   108,   108,   108,   108,   108,
     108,   106,   108,   106,   106,   106,   106,   104,   108,   113,
     115,   116,   108,   106,   104,   108,   104,   108,   104,   108,
     106,   106,   108,   106,   106,   106,   106,   108,   106,   108,
     104,   108,   104,   108,   104,   108,   106,   106,   106,   108,
     104,   104,   108,   108,   108,   108,   104,   108,   106,   106,
     106,   106,   106,   106,   121,   122,   104,   117,   117,   117,
     104,   106,   106,   106,   108,   115,   104,   108,   104,   108,
     104,   108,   104,   108,   104,   108,   104,   108,   104,   108,
     106,   106,   121,   106,   108,   106,   106,   108,   108,   115,
     116,   106,   106,   106,   106,   106,   106,   103,   108,   106,
     108,   108,   108,   108,   108,   121,   108,   108,   108,   108,
     108,   108,   108,   121,   108,   106,   121,   105,   113,   108,
     115,   121,   108,   108,   108,   108,   108,   108,   106,   108,
     121,   108,   108,   121,   121,   121,   121,   108,   108,   108,
     108,   108,   108,   108,   108,   108,   108,   108,   108,   108,
     108,   121,   121,   121,   104,   106,   116,   118,   121,   105,
     108,   112,   121,   117,   117,   108,   108,   121,   108,   108,
     115,   108,   108,   108,   108,   108,   108,   108,   108,   108,
     108,   108,   108,   108,   108,   117,   121,   117,   115,   104,
     118,   106,   106,   106,   106,   106,   108,   108,   108,   108,
     108,   108,   108,   108,   108,   106,   105,   108,   108,   108,
     108,   108,   108,   106,   121,   121,   121,   108,   108,   108,
     108,   108,   108,   108,   108,   108,   108,   108,   108,   108,
     106,   114,   105,   108,   121,   117,   108,   104,   106,   106,
     115,   115,   108,   108,   108,   108,   108,   108,   108,   108,
     108,   108,   108,   108,   108,   108,   106,   117,   118,   104,
     106,   106,   106,   106,   121,   108,   108,   108,   108,   108,
     108,   121,   108,   108,   108,   108,   108,   108,   108,   108,
     108,   108,   108,   108,   108,   108,   108,   105,   106,   121,
     108,   108,   108,   108,   108,   115,   108,   108,   108,   121,
     108,   108,   108,   108,   108,   108,   108,   121,   108,   108,
     121,   104,   118,   119,   120,   121,   121,   108,   106,   106,
     108,   106,   108,   108,   108,   108,   105,   105,   108,   108,
     108,   108,   108,   108,   108,   108,   108,   108,   108,   108,
     108,   106,   108,   115,   108,   121,   105,   108,   121,   108,
     108,   108,   121,   105,   108,   108,   105,   117,   108,   106,
     106,   108,   106,   105,   105,   108,   108,   108,   108,   108,
     108,   108,   105,   108,   108,   108,   108,   108,   108,   121,
     108,   115,   105,   121,   105,   108,   108,   105,   121,   108,
     121,   117,   108,   108,   108,   121,   106,   108,   108,   108,
     108,   108,   108,   108,   108,   108,   108,   108,   115,   121,
     121,   108,   108,   121,   105,   115,   108,   108,   108,   106,
     108,   108,   105,   105,   108,   108,   108,   108,   108,   115,
     115,   108,   121,   121,   121,   108,   121,   121,   108,   108,
     108,   108,   105,   108,   108,   108,   115,   105,   108,   106,
     105,   108,   108,   108,   108,   108,   121,   105,   108,   108,
     108,   108,   108,   121,   108,   108,   108,   108,   108,   121,
     108,   108,   108,   108,   108,   108,   108,   108,   108,   108,
     108,   108,   108,   108,   108,   108,   108,   108,   108,   108,
     105,   105,   105,   108,   108,   108,   104,   106,   105,   108,
     108,   108,   108,   108,   108,   108,   108,   108,   108,   108,
     108,   108,   108,   108,   108,   108,   108,   105,   108
};

#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
# define YYSIZE_T __SIZE_TYPE__
#endif
#if ! defined (YYSIZE_T) && defined (size_t)
# define YYSIZE_T size_t
#endif
#if ! defined (YYSIZE_T)
# if defined (__STDC__) || defined (__cplusplus)
#  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
#  define YYSIZE_T size_t
# endif
#endif
#if ! defined (YYSIZE_T)
# define YYSIZE_T unsigned int
#endif

#define yyerrok		(yyerrstatus = 0)
#define yyclearin	(yychar = YYEMPTY)
#define YYEMPTY		(-2)
#define YYEOF		0

#define YYACCEPT	goto yyacceptlab
#define YYABORT		goto yyabortlab
#define YYERROR		goto yyerrlab1


/* Like YYERROR except do call yyerror.  This remains here temporarily
   to ease the transition to the new meaning of YYERROR, for GCC.
   Once GCC version 2 has supplanted version 1, this can go.  */

#define YYFAIL		goto yyerrlab

#define YYRECOVERING()  (!!yyerrstatus)

#define YYBACKUP(Token, Value)					\
do								\
  if (yychar == YYEMPTY && yylen == 1)				\
    {								\
      yychar = (Token);						\
      yylval = (Value);						\
      yytoken = YYTRANSLATE (yychar);				\
      YYPOPSTACK;						\
      goto yybackup;						\
    }								\
  else								\
    { 								\
      yyerror ("syntax error: cannot back up");\
      YYERROR;							\
    }								\
while (0)

#define YYTERROR	1
#define YYERRCODE	256

/* YYLLOC_DEFAULT -- Compute the default location (before the actions
   are run).  */

#ifndef YYLLOC_DEFAULT
# define YYLLOC_DEFAULT(Current, Rhs, N)         \
  Current.first_line   = Rhs[1].first_line;      \
  Current.first_column = Rhs[1].first_column;    \
  Current.last_line    = Rhs[N].last_line;       \
  Current.last_column  = Rhs[N].last_column;
#endif

/* YYLEX -- calling `yylex' with the right arguments.  */

#ifdef YYLEX_PARAM
# define YYLEX yylex (YYLEX_PARAM)
#else
# define YYLEX yylex ()
#endif

/* Enable debugging if requested.  */
#if YYDEBUG

# ifndef YYFPRINTF
#  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
#  define YYFPRINTF fprintf
# endif

# define YYDPRINTF(Args)			\
do {						\
  if (yydebug)					\
    YYFPRINTF Args;				\
} while (0)

# define YYDSYMPRINT(Args)			\
do {						\
  if (yydebug)					\
    yysymprint Args;				\
} while (0)

# define YYDSYMPRINTF(Title, Token, Value, Location)		\
do {								\
  if (yydebug)							\
    {								\
      YYFPRINTF (stderr, "%s ", Title);				\
      yysymprint (stderr, 					\
                  Token, Value);	\
      YYFPRINTF (stderr, "\n");					\
    }								\
} while (0)

/*------------------------------------------------------------------.
| yy_stack_print -- Print the state stack from its BOTTOM up to its |
| TOP (cinluded).                                                   |
`------------------------------------------------------------------*/

#if defined (__STDC__) || defined (__cplusplus)
static void
yy_stack_print (short *bottom, short *top)
#else
static void
yy_stack_print (bottom, top)
    short *bottom;
    short *top;
#endif
{
  YYFPRINTF (stderr, "Stack now");
  for (/* Nothing. */; bottom <= top; ++bottom)
    YYFPRINTF (stderr, " %d", *bottom);
  YYFPRINTF (stderr, "\n");
}

# define YY_STACK_PRINT(Bottom, Top)				\
do {								\
  if (yydebug)							\
    yy_stack_print ((Bottom), (Top));				\
} while (0)


/*------------------------------------------------.
| Report that the YYRULE is going to be reduced.  |
`------------------------------------------------*/

#if defined (__STDC__) || defined (__cplusplus)
static void
yy_reduce_print (int yyrule)
#else
static void
yy_reduce_print (yyrule)
    int yyrule;
#endif
{
  int yyi;
  unsigned int yylineno = yyrline[yyrule];
  YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ",
             yyrule - 1, yylineno);
  /* Print the symbols being reduced, and their result.  */
  for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
    YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]);
  YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]);
}

# define YY_REDUCE_PRINT(Rule)		\
do {					\
  if (yydebug)				\
    yy_reduce_print (Rule);		\
} while (0)

/* Nonzero means print parse trace.  It is left uninitialized so that
   multiple parsers can coexist.  */
int yydebug;
#else /* !YYDEBUG */
# define YYDPRINTF(Args)
# define YYDSYMPRINT(Args)
# define YYDSYMPRINTF(Title, Token, Value, Location)
# define YY_STACK_PRINT(Bottom, Top)
# define YY_REDUCE_PRINT(Rule)
#endif /* !YYDEBUG */


/* YYINITDEPTH -- initial size of the parser's stacks.  */
#ifndef	YYINITDEPTH
# define YYINITDEPTH 200
#endif

/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
   if the built-in stack extension method is used).

   Do not make this value too large; the results are undefined if
   SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
   evaluated with infinite-precision integer arithmetic.  */

#if YYMAXDEPTH == 0
# undef YYMAXDEPTH
#endif

#ifndef YYMAXDEPTH
# define YYMAXDEPTH 10000
#endif



#if YYERROR_VERBOSE

# ifndef yystrlen
#  if defined (__GLIBC__) && defined (_STRING_H)
#   define yystrlen strlen
#  else
/* Return the length of YYSTR.  */
static YYSIZE_T
#   if defined (__STDC__) || defined (__cplusplus)
yystrlen (const char *yystr)
#   else
yystrlen (yystr)
     const char *yystr;
#   endif
{
  register const char *yys = yystr;

  while (*yys++ != '\0')
    continue;

  return yys - yystr - 1;
}
#  endif
# endif

# ifndef yystpcpy
#  if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
#   define yystpcpy stpcpy
#  else
/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
   YYDEST.  */
static char *
#   if defined (__STDC__) || defined (__cplusplus)
yystpcpy (char *yydest, const char *yysrc)
#   else
yystpcpy (yydest, yysrc)
     char *yydest;
     const char *yysrc;
#   endif
{
  register char *yyd = yydest;
  register const char *yys = yysrc;

  while ((*yyd++ = *yys++) != '\0')
    continue;

  return yyd - 1;
}
#  endif
# endif

#endif /* !YYERROR_VERBOSE */



#if YYDEBUG
/*--------------------------------.
| Print this symbol on YYOUTPUT.  |
`--------------------------------*/

#if defined (__STDC__) || defined (__cplusplus)
static void
yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
#else
static void
yysymprint (yyoutput, yytype, yyvaluep)
    FILE *yyoutput;
    int yytype;
    YYSTYPE *yyvaluep;
#endif
{
  /* Pacify ``unused variable'' warnings.  */
  (void) yyvaluep;

  if (yytype < YYNTOKENS)
    {
      YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
# ifdef YYPRINT
      YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
# endif
    }
  else
    YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);

  switch (yytype)
    {
      default:
        break;
    }
  YYFPRINTF (yyoutput, ")");
}

#endif /* ! YYDEBUG */
/*-----------------------------------------------.
| Release the memory associated to this symbol.  |
`-----------------------------------------------*/

#if defined (__STDC__) || defined (__cplusplus)
static void
yydestruct (int yytype, YYSTYPE *yyvaluep)
#else
static void
yydestruct (yytype, yyvaluep)
    int yytype;
    YYSTYPE *yyvaluep;
#endif
{
  /* Pacify ``unused variable'' warnings.  */
  (void) yyvaluep;

  switch (yytype)
    {

      default:
        break;
    }
}


/* Prevent warnings from -Wmissing-prototypes.  */

#ifdef YYPARSE_PARAM
# if defined (__STDC__) || defined (__cplusplus)
int yyparse (void *YYPARSE_PARAM);
# else
int yyparse ();
# endif
#else /* ! YYPARSE_PARAM */
#if defined (__STDC__) || defined (__cplusplus)
int yyparse (void);
#else
int yyparse ();
#endif
#endif /* ! YYPARSE_PARAM */



/* The lookahead symbol.  */
int yychar;

/* The semantic value of the lookahead symbol.  */
YYSTYPE yylval;

/* Number of syntax errors so far.  */
int yynerrs;



/*----------.
| yyparse.  |
`----------*/

#ifdef YYPARSE_PARAM
# if defined (__STDC__) || defined (__cplusplus)
int yyparse (void *YYPARSE_PARAM)
# else
int yyparse (YYPARSE_PARAM)
  void *YYPARSE_PARAM;
# endif
#else /* ! YYPARSE_PARAM */
#if defined (__STDC__) || defined (__cplusplus)
int
yyparse (void)
#else
int
yyparse ()

#endif
#endif
{
  
  register int yystate;
  register int yyn;
  int yyresult;
  /* Number of tokens to shift before error messages enabled.  */
  int yyerrstatus;
  /* Lookahead token as an internal (translated) token number.  */
  int yytoken = 0;

  /* Three stacks and their tools:
     `yyss': related to states,
     `yyvs': related to semantic values,
     `yyls': related to locations.

     Refer to the stacks thru separate pointers, to allow yyoverflow
     to reallocate them elsewhere.  */

  /* The state stack.  */
  short	yyssa[YYINITDEPTH];
  short *yyss = yyssa;
  register short *yyssp;

  /* The semantic value stack.  */
  YYSTYPE yyvsa[YYINITDEPTH];
  YYSTYPE *yyvs = yyvsa;
  register YYSTYPE *yyvsp;



#define YYPOPSTACK   (yyvsp--, yyssp--)

  YYSIZE_T yystacksize = YYINITDEPTH;

  /* The variables used to return semantic value and location from the
     action routines.  */
  YYSTYPE yyval;


  /* When reducing, the number of symbols on the RHS of the reduced
     rule.  */
  int yylen;

  YYDPRINTF ((stderr, "Starting parse\n"));

  yystate = 0;
  yyerrstatus = 0;
  yynerrs = 0;
  yychar = YYEMPTY;		/* Cause a token to be read.  */

  /* Initialize stack pointers.
     Waste one element of value and location stack
     so that they stay on the same level as the state stack.
     The wasted elements are never initialized.  */

  yyssp = yyss;
  yyvsp = yyvs;

  goto yysetstate;

/*------------------------------------------------------------.
| yynewstate -- Push a new state, which is found in yystate.  |
`------------------------------------------------------------*/
 yynewstate:
  /* In all cases, when you get here, the value and location stacks
     have just been pushed. so pushing a state here evens the stacks.
     */
  yyssp++;

 yysetstate:
  *yyssp = yystate;

  if (yyss + yystacksize - 1 <= yyssp)
    {
      /* Get the current used size of the three stacks, in elements.  */
      YYSIZE_T yysize = yyssp - yyss + 1;

#ifdef yyoverflow
      {
	/* Give user a chance to reallocate the stack. Use copies of
	   these so that the &'s don't force the real ones into
	   memory.  */
	YYSTYPE *yyvs1 = yyvs;
	short *yyss1 = yyss;


	/* Each stack pointer address is followed by the size of the
	   data in use in that stack, in bytes.  This used to be a
	   conditional around just the two extra args, but that might
	   be undefined if yyoverflow is a macro.  */
	yyoverflow ("parser stack overflow",
		    &yyss1, yysize * sizeof (*yyssp),
		    &yyvs1, yysize * sizeof (*yyvsp),

		    &yystacksize);

	yyss = yyss1;
	yyvs = yyvs1;
      }
#else /* no yyoverflow */
# ifndef YYSTACK_RELOCATE
      goto yyoverflowlab;
# else
      /* Extend the stack our own way.  */
      if (YYMAXDEPTH <= yystacksize)
	goto yyoverflowlab;
      yystacksize *= 2;
      if (YYMAXDEPTH < yystacksize)
	yystacksize = YYMAXDEPTH;

      {
	short *yyss1 = yyss;
	union yyalloc *yyptr =
	  (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
	if (! yyptr)
	  goto yyoverflowlab;
	YYSTACK_RELOCATE (yyss);
	YYSTACK_RELOCATE (yyvs);

#  undef YYSTACK_RELOCATE
	if (yyss1 != yyssa)
	  YYSTACK_FREE (yyss1);
      }
# endif
#endif /* no yyoverflow */

      yyssp = yyss + yysize - 1;
      yyvsp = yyvs + yysize - 1;


      YYDPRINTF ((stderr, "Stack size increased to %lu\n",
		  (unsigned long int) yystacksize));

      if (yyss + yystacksize - 1 <= yyssp)
	YYABORT;
    }

  YYDPRINTF ((stderr, "Entering state %d\n", yystate));

  goto yybackup;

/*-----------.
| yybackup.  |
`-----------*/
yybackup:

/* Do appropriate processing given the current state.  */
/* Read a lookahead token if we need one and don't already have one.  */
/* yyresume: */

  /* First try to decide what to do without reference to lookahead token.  */

  yyn = yypact[yystate];
  if (yyn == YYPACT_NINF)
    goto yydefault;

  /* Not known => get a lookahead token if don't already have one.  */

  /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol.  */
  if (yychar == YYEMPTY)
    {
      YYDPRINTF ((stderr, "Reading a token: "));
      yychar = YYLEX;
    }

  if (yychar <= YYEOF)
    {
      yychar = yytoken = YYEOF;
      YYDPRINTF ((stderr, "Now at end of input.\n"));
    }
  else
    {
      yytoken = YYTRANSLATE (yychar);
      YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc);
    }

  /* If the proper action on seeing token YYTOKEN is to reduce or to
     detect an error, take that action.  */
  yyn += yytoken;
  if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
    goto yydefault;
  yyn = yytable[yyn];
  if (yyn <= 0)
    {
      if (yyn == 0 || yyn == YYTABLE_NINF)
	goto yyerrlab;
      yyn = -yyn;
      goto yyreduce;
    }

  if (yyn == YYFINAL)
    YYACCEPT;

  /* Shift the lookahead token.  */
  YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken]));

  /* Discard the token being shifted unless it is eof.  */
  if (yychar != YYEOF)
    yychar = YYEMPTY;

  *++yyvsp = yylval;


  /* Count tokens shifted since error; after three, turn off error
     status.  */
  if (yyerrstatus)
    yyerrstatus--;

  yystate = yyn;
  goto yynewstate;


/*-----------------------------------------------------------.
| yydefault -- do the default action for the current state.  |
`-----------------------------------------------------------*/
yydefault:
  yyn = yydefact[yystate];
  if (yyn == 0)
    goto yyerrlab;
  goto yyreduce;


/*-----------------------------.
| yyreduce -- Do a reduction.  |
`-----------------------------*/
yyreduce:
  /* yyn is the number of a rule to reduce with.  */
  yylen = yyr2[yyn];

  /* If YYLEN is nonzero, implement the default value of the action:
     `$$ = $1'.

     Otherwise, the following line sets YYVAL to garbage.
     This behavior is undocumented and Bison
     users should not rely upon it.  Assigning to YYVAL
     unconditionally makes the parser a bit smaller, and it avoids a
     GCC warning that YYVAL may be used uninitialized.  */
  yyval = yyvsp[1-yylen];


  YY_REDUCE_PRINT (yyn);
  switch (yyn)
    {
        case 3:
#line 586 "rib.y"
    {
					args[numArguments++].integer				=	(int) yyvsp[0].real;
					argCheck();
					yyval.integer	=	yyvsp[-1].integer	+	1;
				;}
    break;

  case 4:
#line 593 "rib.y"
    {
					args[numArguments++].integer				=	(int) yyvsp[0].real;
					argCheck();
					yyval.integer	=	1;
				;}
    break;

  case 5:
#line 603 "rib.y"
    {
					args[numArguments++].real					=	yyvsp[0].real;
					argCheck();
					yyval.integer	=	yyvsp[-1].integer	+	1;
				;}
    break;

  case 6:
#line 610 "rib.y"
    {
					args[numArguments++].real					=	yyvsp[0].real;
					argCheck();
					yyval.integer	=	1;
				;}
    break;

  case 7:
#line 619 "rib.y"
    {
					char	*theString	=	strdup(yyvsp[0].string);
					args[numArguments++].string					=	theString;
					allocatedStrings->push(theString);
					argCheck();
					yyval.integer	=	yyvsp[-1].integer	+	1;
				;}
    break;

  case 8:
#line 628 "rib.y"
    {
					char	*theString	=	strdup(yyvsp[0].string);
					args[numArguments++].string					=	theString;
					allocatedStrings->push(theString);
					argCheck();
					yyval.integer	=	1;
				;}
    break;

  case 9:
#line 640 "rib.y"
    {
					yyval.integer = yyvsp[-1].integer;
				;}
    break;

  case 10:
#line 646 "rib.y"
    {
					yyval.integer = 0;
				;}
    break;

  case 11:
#line 653 "rib.y"
    {
					yyval.integer	=	yyvsp[0].integer;
				;}
    break;

  case 12:
#line 658 "rib.y"
    {
					yyval.integer	=	yyvsp[0].integer;
				;}
    break;

  case 13:
#line 666 "rib.y"
    {
					yyval.integer = yyvsp[-1].integer;
				;}
    break;

  case 14:
#line 672 "rib.y"
    {
					yyval.integer = 0;
				;}
    break;

  case 15:
#line 681 "rib.y"
    {
					yyval.integer	=	yyvsp[-1].integer;
				;}
    break;

  case 16:
#line 686 "rib.y"
    {
					char	*theString	=	strdup(yyvsp[0].string);
					args[numArguments++].string					=	theString;
					allocatedStrings->push(theString);
					argCheck();
					yyval.integer	= 1;
				;}
    break;

  case 18:
#line 700 "rib.y"
    {
					yyval.integer	=	0;
				;}
    break;

  case 19:
#line 705 "rib.y"
    {
					yyval.integer	=	yyvsp[0].integer;
				;}
    break;

  case 20:
#line 712 "rib.y"
    {
				;}
    break;

  case 21:
#line 715 "rib.y"
    {
					int	i;

					assert(numParameters < maxParameter);

					// Fix the pointers
					for (i=0;i<numParameters;i++) {
						tokens[i]				=	parameters[i].name;

						if (parameters[i].type == RT_TEXT)
							vals[i]				=	(RtPointer) &args[parameters[i].valuesStart].string;
						else
							vals[i]				=	(RtPointer) &args[parameters[i].valuesStart];

						parameters[i].values	=	args + parameters[i].valuesStart;
					}
				;}
    break;

  case 22:
#line 736 "rib.y"
    {
					// A parameter is either a float array
					parameters[numParameters].name			=	yyvsp[-1].string;
					parameters[numParameters].type			=	RT_FLOAT;
					parameters[numParameters].numItems		=	yyvsp[0].integer;
					parameters[numParameters].valuesStart	=	numArguments-yyvsp[0].integer;
					numParameters++;
					paramCheck();
				;}
    break;

  case 23:
#line 748 "rib.y"
    {
					
					// Or a string array
					parameters[numParameters].name			=	yyvsp[-1].string;
					parameters[numParameters].type			=	RT_TEXT;
					parameters[numParameters].numItems		=	yyvsp[0].integer;
					parameters[numParameters].valuesStart	=	numArguments-yyvsp[0].integer;
					numParameters++;
					paramCheck();
				;}
    break;

  case 24:
#line 762 "rib.y"
    {
					char	*currentString;
					numArguments	=	0;
					numParameters	=	0;
					while((currentString=allocatedStrings->pop()) != NULL)
						free(currentString);

				;}
    break;

  case 26:
#line 775 "rib.y"
    {
					if (callback != NULL) {
						callback(yyvsp[0].string);
					}
				;}
    break;

  case 27:
#line 784 "rib.y"
    {
					RiDeclare(yyvsp[-1].string,yyvsp[0].string);
				;}
    break;

  case 28:
#line 789 "rib.y"
    {
					RiFrameBegin(0);
				;}
    break;

  case 29:
#line 795 "rib.y"
    {
					RiFrameBegin((int) yyvsp[0].real);
				;}
    break;

  case 30:
#line 800 "rib.y"
    {
					RiFrameEnd();
				;}
    break;

  case 31:
#line 805 "rib.y"
    {
					RiWorldBegin();
				;}
    break;

  case 32:
#line 810 "rib.y"
    {
					RiWorldEnd();
				;}
    break;

  case 33:
#line 818 "rib.y"
    {
					RiFormat((int) yyvsp[-2].real,(int) yyvsp[-1].real,yyvsp[0].real);
				;}
    break;

  case 34:
#line 824 "rib.y"
    {
					RiFrameAspectRatio(yyvsp[0].real);
				;}
    break;

  case 35:
#line 833 "rib.y"
    {
					RiScreenWindow(yyvsp[-3].real,yyvsp[-2].real,yyvsp[-1].real,yyvsp[0].real);
				;}
    break;

  case 36:
#line 844 "rib.y"
    {
					RiScreenWindow(yyvsp[-4].real,yyvsp[-3].real,yyvsp[-2].real,yyvsp[-1].real);
				;}
    break;

  case 37:
#line 853 "rib.y"
    {
					RiCropWindow(yyvsp[-3].real,yyvsp[-2].real,yyvsp[-1].real,yyvsp[0].real);
				;}
    break;

  case 38:
#line 864 "rib.y"
    {
					RiCropWindow(yyvsp[-4].real,yyvsp[-3].real,yyvsp[-2].real,yyvsp[-1].real);
				;}
    break;

  case 39:
#line 871 "rib.y"
    {
					RiProjectionV(yyvsp[-1].string,numParameters,tokens,vals);
				;}
    break;

  case 40:
#line 878 "rib.y"
    {
					RiClipping(yyvsp[-1].real,yyvsp[0].real);
				;}
    break;

  case 41:
#line 889 "rib.y"
    {
					RiClippingPlane(yyvsp[-5].real,yyvsp[-4].real,yyvsp[-3].real,yyvsp[-2].real,yyvsp[-1].real,yyvsp[0].real);
				;}
    break;

  case 42:
#line 897 "rib.y"
    {
					RiDepthOfField(yyvsp[-2].real,yyvsp[-1].real,yyvsp[0].real);
				;}
    break;

  case 43:
#line 902 "rib.y"
    {
					RiDepthOfField(C_INFINITY,1,1);
				;}
    break;

  case 44:
#line 909 "rib.y"
    {
					RiShutter(yyvsp[-1].real,yyvsp[0].real);
				;}
    break;

  case 45:
#line 915 "rib.y"
    {
					RiPixelVariance(yyvsp[0].real);
				;}
    break;

  case 46:
#line 922 "rib.y"
    {
					RiPixelSamples(yyvsp[-1].real,yyvsp[0].real);
				;}
    break;

  case 47:
#line 930 "rib.y"
    {
					RtFilterFunc	f;

					if ((f = getFilter(yyvsp[-2].string)) != NULL) {
						RiPixelFilter(f,yyvsp[-1].real,yyvsp[0].real);
					}
				;}
    break;

  case 48:
#line 941 "rib.y"
    {
					RiExposure(yyvsp[-1].real,yyvsp[0].real);
				;}
    break;

  case 49:
#line 948 "rib.y"
    {
					// No parameter list checking is performed for the shaders
					if (parameterListCheck()) {
						RiImagerV(yyvsp[-1].string,numParameters,tokens,vals);
					}
				;}
    break;

  case 50:
#line 961 "rib.y"
    {
					RiQuantize(yyvsp[-4].string,(int) yyvsp[-3].real,(int) yyvsp[-2].real,(int) yyvsp[-1].real,yyvsp[0].real);
				;}
    break;

  case 51:
#line 970 "rib.y"
    {
					RiDisplayV(yyvsp[-3].string,yyvsp[-2].string,yyvsp[-1].string,numParameters,tokens,vals);
				;}
    break;

  case 52:
#line 977 "rib.y"
    {
					if (parameterListCheck()) {
						RiHiderV(yyvsp[-1].string,numParameters,tokens,vals);
					}
				;}
    break;

  case 53:
#line 985 "rib.y"
    {
					if ((numArguments & 1) || ((numArguments % 6) != 0)) {
						error(CODE_MISSINGDATA,"ColorSamples: Invalid number of arguments (\"%d\") \n",numArguments);
					} else {
						int		n		=	numArguments/6;
						float	*argf1	=	(float *) get(0);
						float	*argf2	=	(float *) get(n*3);

						RiColorSamples(n,argf1,argf2);
					}
				;}
    break;

  case 54:
#line 1000 "rib.y"
    {
					if ((yyvsp[-1].integer != yyvsp[0].integer) || ((numArguments % 6) != 0)) {
						error(CODE_MISSINGDATA,"ColorSamples: Invalid number of arguments (\"%d\") \n",numArguments);
					} else {
						int		n		=	numArguments/6;
						float	*argf1	=	(float *) get(0);
						float	*argf2	=	(float *) get(n*3);

						RiColorSamples(n,argf1,argf2);
					}
				;}
    break;

  case 55:
#line 1014 "rib.y"
    {
					RiRelativeDetail(yyvsp[0].real);	
				;}
    break;

  case 56:
#line 1021 "rib.y"
    {
					if (parameterListCheck()) {
						RiOptionV(yyvsp[-1].string,numParameters,tokens,vals);
					}
				;}
    break;

  case 57:
#line 1028 "rib.y"
    {
					RiAttributeBegin();
				;}
    break;

  case 58:
#line 1033 "rib.y"
    {
					RiAttributeEnd();
				;}
    break;

  case 59:
#line 1041 "rib.y"
    {
					RtColor	color;

					color[0]	=	yyvsp[-2].real;
					color[1]	=	yyvsp[-1].real;
					color[2]	=	yyvsp[0].real;

					RiColor(color);
				;}
    break;

  case 60:
#line 1055 "rib.y"
    {
					RtColor	color;

					color[0]	=	yyvsp[-2].real;
					color[1]	=	yyvsp[-1].real;
					color[2]	=	yyvsp[0].real;

					RiOpacity(color);
				;}
    break;

  case 61:
#line 1071 "rib.y"
    {
					RtColor	color;

					color[0]	=	yyvsp[-3].real;
					color[1]	=	yyvsp[-2].real;
					color[2]	=	yyvsp[-1].real;

					RiColor(color);
				;}
    break;

  case 62:
#line 1087 "rib.y"
    {
					RtColor	color;

					color[0]	=	yyvsp[-3].real;
					color[1]	=	yyvsp[-2].real;
					color[2]	=	yyvsp[-1].real;

					RiOpacity(color);
				;}
    break;

  case 63:
#line 1106 "rib.y"
    {
					RiTextureCoordinates(yyvsp[-7].real,yyvsp[-6].real,yyvsp[-5].real,yyvsp[-4].real,yyvsp[-3].real,yyvsp[-2].real,yyvsp[-1].real,yyvsp[0].real);
				;}
    break;

  case 64:
#line 1121 "rib.y"
    {
					RiTextureCoordinates(yyvsp[-8].real,yyvsp[-7].real,yyvsp[-6].real,yyvsp[-5].real,yyvsp[-4].real,yyvsp[-3].real,yyvsp[-2].real,yyvsp[-1].real);
				;}
    break;

  case 65:
#line 1129 "rib.y"
    {
					if (lights == NULL)	lights	=	new CArray<RtLightHandle>;

					(*lights)[(int) yyvsp[-1].real]	=	RiLightSourceV(yyvsp[-2].string,numParameters,tokens,vals);
				;}
    break;

  case 66:
#line 1139 "rib.y"
    {
					if (lightNames == NULL)	lightNames	=	new CTrie<RtLightHandle>;

					lightNames->insert(yyvsp[-2].string,RiLightSourceV(yyvsp[-2].string,numParameters,tokens,vals));
				;}
    break;

  case 67:
#line 1148 "rib.y"
    {
					RiLightSourceV(yyvsp[-1].string,numParameters,tokens,vals);
				;}
    break;

  case 68:
#line 1156 "rib.y"
    {
					if (lights == NULL)	lights	=	new CArray<RtLightHandle>;

					(*lights)[(int) yyvsp[-1].real]	=	RiAreaLightSourceV(yyvsp[-2].string,numParameters,tokens,vals);
				;}
    break;

  case 69:
#line 1165 "rib.y"
    {
					if (lights == NULL)	lights	=	new CArray<RtLightHandle>;

					RiIlluminate((*lights)[(int) yyvsp[-1].real],(int) yyvsp[0].real);
				;}
    break;

  case 70:
#line 1174 "rib.y"
    {
					RiSurfaceV(yyvsp[-1].string,numParameters,tokens,vals);
				;}
    break;

  case 71:
#line 1181 "rib.y"
    {
					RiAtmosphereV(yyvsp[-1].string,numParameters,tokens,vals);
				;}
    break;

  case 72:
#line 1188 "rib.y"
    {
					RiInteriorV(yyvsp[-1].string,numParameters,tokens,vals);
				;}
    break;

  case 73:
#line 1195 "rib.y"
    {
					RiExteriorV(yyvsp[-1].string,numParameters,tokens,vals);
				;}
    break;

  case 74:
#line 1201 "rib.y"
    {
					RiShadingRate(yyvsp[0].real);
				;}
    break;

  case 75:
#line 1207 "rib.y"
    {
					RiShadingInterpolation(yyvsp[0].string);
				;}
    break;

  case 76:
#line 1213 "rib.y"
    {
					RiMatte((RtBoolean) yyvsp[0].real);
				;}
    break;

  case 77:
#line 1226 "rib.y"
    {
					RtBound	bound;

					bound[0]	=	yyvsp[-6].real;
					bound[1]	=	yyvsp[-5].real;
					bound[2]	=	yyvsp[-4].real;
					bound[3]	=	yyvsp[-3].real;
					bound[4]	=	yyvsp[-2].real;
					bound[5]	=	yyvsp[-1].real;

					RiBound(bound);
				;}
    break;

  case 78:
#line 1246 "rib.y"
    {
					RtBound	bound;

					bound[0]	=	yyvsp[-5].real;
					bound[1]	=	yyvsp[-4].real;
					bound[2]	=	yyvsp[-3].real;
					bound[3]	=	yyvsp[-2].real;
					bound[4]	=	yyvsp[-1].real;
					bound[5]	=	yyvsp[0].real;

					RiBound(bound);
				;}
    break;

  case 79:
#line 1268 "rib.y"
    {
					RtBound	bound;

					bound[0]	=	yyvsp[-6].real;
					bound[1]	=	yyvsp[-5].real;
					bound[2]	=	yyvsp[-4].real;
					bound[3]	=	yyvsp[-3].real;
					bound[4]	=	yyvsp[-2].real;
					bound[5]	=	yyvsp[-1].real;

					RiDetail(bound);
				;}
    break;

  case 80:
#line 1288 "rib.y"
    {
					RtBound	bound;

					bound[0]	=	yyvsp[-5].real;
					bound[1]	=	yyvsp[-4].real;
					bound[2]	=	yyvsp[-3].real;
					bound[3]	=	yyvsp[-2].real;
					bound[4]	=	yyvsp[-1].real;
					bound[5]	=	yyvsp[0].real;

					RiDetail(bound);
				;}
    break;

  case 81:
#line 1306 "rib.y"
    {
					RiDetailRange(yyvsp[-3].real,yyvsp[-2].real,yyvsp[-1].real,yyvsp[0].real);
				;}
    break;

  case 82:
#line 1317 "rib.y"
    {
					RiDetailRange(yyvsp[-4].real,yyvsp[-3].real,yyvsp[-2].real,yyvsp[-1].real);
				;}
    break;

  case 83:
#line 1324 "rib.y"
    {
					RiGeometricApproximation(yyvsp[-1].string,yyvsp[0].real);
				;}
    break;

  case 84:
#line 1330 "rib.y"
    {
					RiGeometricRepresentation(yyvsp[0].string);
				;}
    break;

  case 85:
#line 1336 "rib.y"
    {
					RiOrientation(yyvsp[0].string);
				;}
    break;

  case 86:
#line 1341 "rib.y"
    {
					RiReverseOrientation();
				;}
    break;

  case 87:
#line 1347 "rib.y"
    {
					RiSides((int) yyvsp[0].real);
				;}
    break;

  case 88:
#line 1352 "rib.y"
    {
					RiIdentity();
				;}
    break;

  case 89:
#line 1375 "rib.y"
    {
					RtMatrix	tmp;

					tmp[0][0]	=	yyvsp[-16].real;
					tmp[0][1]	=	yyvsp[-15].real;
					tmp[0][2]	=	yyvsp[-14].real;
					tmp[0][3]	=	yyvsp[-13].real;
					tmp[1][0]	=	yyvsp[-12].real;
					tmp[1][1]	=	yyvsp[-11].real;
					tmp[1][2]	=	yyvsp[-10].real;
					tmp[1][3]	=	yyvsp[-9].real;
					tmp[2][0]	=	yyvsp[-8].real;
					tmp[2][1]	=	yyvsp[-7].real;
					tmp[2][2]	=	yyvsp[-6].real;
					tmp[2][3]	=	yyvsp[-5].real;
					tmp[3][0]	=	yyvsp[-4].real;
					tmp[3][1]	=	yyvsp[-3].real;
					tmp[3][2]	=	yyvsp[-2].real;
					tmp[3][3]	=	yyvsp[-1].real;

					RiTransform(tmp);
				;}
    break;

  case 90:
#line 1417 "rib.y"
    {
					RtMatrix	tmp;

					tmp[0][0]	=	yyvsp[-16].real;
					tmp[0][1]	=	yyvsp[-15].real	;
					tmp[0][2]	=	yyvsp[-14].real;
					tmp[0][3]	=	yyvsp[-13].real;
					tmp[1][0]	=	yyvsp[-12].real;
					tmp[1][1]	=	yyvsp[-11].real;
					tmp[1][2]	=	yyvsp[-10].real;
					tmp[1][3]	=	yyvsp[-9].real;
					tmp[2][0]	=	yyvsp[-8].real;
					tmp[2][1]	=	yyvsp[-7].real;
					tmp[2][2]	=	yyvsp[-6].real;
					tmp[2][3]	=	yyvsp[-5].real;
					tmp[3][0]	=	yyvsp[-4].real;
					tmp[3][1]	=	yyvsp[-3].real;
					tmp[3][2]	=	yyvsp[-2].real;
					tmp[3][3]	=	yyvsp[-1].real;

					RiConcatTransform(tmp);
				;}
    break;

  case 91:
#line 1442 "rib.y"
    {
					RiPerspective(yyvsp[0].real);
				;}
    break;

  case 92:
#line 1450 "rib.y"
    {
					RiTranslate(yyvsp[-2].real,yyvsp[-1].real,yyvsp[0].real);
				;}
    break;

  case 93:
#line 1458 "rib.y"
    {
					RiScale(yyvsp[-2].real,yyvsp[-1].real,yyvsp[0].real);
				;}
    break;

  case 94:
#line 1467 "rib.y"
    {
					RiRotate(yyvsp[-3].real,yyvsp[-2].real,yyvsp[-1].real,yyvsp[0].real);
				;}
    break;

  case 95:
#line 1479 "rib.y"
    {
					RiSkew(yyvsp[-6].real,yyvsp[-5].real,yyvsp[-4].real,yyvsp[-3].real,yyvsp[-2].real,yyvsp[-1].real,yyvsp[0].real);
				;}
    break;

  case 96:
#line 1493 "rib.y"
    {
					RiSkew(yyvsp[-7].real,yyvsp[-6].real,yyvsp[-5].real,yyvsp[-4].real,yyvsp[-3].real,yyvsp[-2].real,yyvsp[-1].real);
				;}
    break;

  case 97:
#line 1500 "rib.y"
    {
					RiDeformationV(yyvsp[-1].string,numParameters,tokens,vals);
				;}
    break;

  case 98:
#line 1507 "rib.y"
    {
					RiDisplacementV(yyvsp[-1].string,numParameters,tokens,vals);
				;}
    break;

  case 99:
#line 1513 "rib.y"
    {
					RiCoordinateSystem(yyvsp[0].string);
				;}
    break;

  case 100:
#line 1519 "rib.y"
    {
					RiCoordSysTransform(yyvsp[0].string);
				;}
    break;

  case 101:
#line 1524 "rib.y"
    {
					RiTransformBegin();
				;}
    break;

  case 102:
#line 1529 "rib.y"
    {
					RiTransformEnd();
				;}
    break;

  case 103:
#line 1536 "rib.y"
    {
					if (parameterListCheck()) {
						RiAttributeV(yyvsp[-1].string,numParameters,tokens,vals);
					}
				;}
    break;

  case 104:
#line 1544 "rib.y"
    {
					if (parameterListCheck()) {	
						if (sizeCheck(numVertex,0,0,1)) {
							RiPolygonV(numVertex,numParameters,tokens,vals);
						}
					}
				;}
    break;

  case 105:
#line 1555 "rib.y"
    {
					int		*argi	=	(int *) get(0);

					if (parameterListCheck()) {
						if (sizeCheck(numVertex,0,0,1)) {
							RiGeneralPolygonV(yyvsp[-1].integer,argi,numParameters,tokens,vals);
						}
					}
				;}
    break;

  case 106:
#line 1569 "rib.y"
    {
					int	*argi1		=	(int *) get(0);
					int	*argi2		=	(int *) get(yyvsp[-2].integer);
					int	nvertices	=	0;
					int	i;
					int	maxVertex	=	0;


					// Find out how many items are in verts array
					for (i=0;i<yyvsp[-2].integer;i++) {
						nvertices	+=	argi1[i];
					}

					if (nvertices != yyvsp[-1].integer) {
						error(CODE_MISSINGDATA,"Vertex count mismatch (%d != %d)\n",nvertices,yyvsp[-1].integer);
					} else {
						// Find out the number of vertices required
						for (i=0,maxVertex=0;i<nvertices;i++) {
							if (argi2[i] > maxVertex)
								maxVertex	=	argi2[i];
						}

						maxVertex++;

						if (parameterListCheck()) {
							if (sizeCheck(maxVertex,0,nvertices,yyvsp[-2].integer)) {
								RiPointsPolygonsV(yyvsp[-2].integer,argi1,argi2,numParameters,tokens,vals);
							}
						}
					}
				;}
    break;

  case 107:
#line 1606 "rib.y"
    {
					int	*argi1		=	(int *) get(0);
					int	*argi2		=	(int *) get(yyvsp[-3].integer);
					int	*argi3		=	(int *) get(yyvsp[-2].integer+yyvsp[-3].integer);
					int	numvertices	=	0;
					int	numloops	=	0;
					int	maxVertex	=	0;
					int	i;

					for (i=0;i<yyvsp[-3].integer;i++) {
						numloops	+=	argi1[i];
					}

					if (numloops != yyvsp[-2].integer) {
						error(CODE_MISSINGDATA,"Loop count mismatch (%d != %d)\n",numloops,yyvsp[-2].integer);
					} else {
						for (i=0;i<yyvsp[-2].integer;i++) {
							numvertices	+=	argi2[i];
						}

						if (numvertices != yyvsp[-1].integer) {
							error(CODE_MISSINGDATA,"Vertex count mismatch (%d != %d)\n",numvertices,yyvsp[-1].integer);
						} else {
							for (i=0;i<numvertices;i++) {
								if (argi3[i] > maxVertex)
									maxVertex	=	argi3[i];
							}

							maxVertex++;

							if (parameterListCheck()) {
								if (sizeCheck(maxVertex,0,numvertices,yyvsp[-3].integer)) {
									RiPointsGeneralPolygonsV(yyvsp[-3].integer,argi1,argi2,argi3,numParameters,tokens,vals);
								}
							}
						}
					}
				;}
    break;

  case 108:
#line 1650 "rib.y"
    {
					RtBasis	*argf1,*argf2;

					if ((getBasis(&argf1,yyvsp[-3].string)) && (getBasis(&argf2,yyvsp[-1].string))) {
						RiBasis(argf1[0],(int) yyvsp[-2].real, argf2[0],(int) yyvsp[0].real);
					}
				;}
    break;

  case 109:
#line 1680 "rib.y"
    {
					RtBasis	*argf2;

					if (getBasis(&argf2,yyvsp[-1].string)) {
						RtBasis	tmp;
					
						tmp[0][0]	=	yyvsp[-19].real;
						tmp[0][1]	=	yyvsp[-18].real;
						tmp[0][2]	=	yyvsp[-17].real;
						tmp[0][3]	=	yyvsp[-16].real;
						tmp[1][0]	=	yyvsp[-15].real;
						tmp[1][1]	=	yyvsp[-14].real;
						tmp[1][2]	=	yyvsp[-13].real;
						tmp[1][3]	=	yyvsp[-12].real;
						tmp[2][0]	=	yyvsp[-11].real;
						tmp[2][1]	=	yyvsp[-10].real;
						tmp[2][2]	=	yyvsp[-9].real;
						tmp[2][3]	=	yyvsp[-8].real;
						tmp[3][0]	=	yyvsp[-7].real;
						tmp[3][1]	=	yyvsp[-6].real;
						tmp[3][2]	=	yyvsp[-5].real;
						tmp[3][3]	=	yyvsp[-4].real;
										
						RiBasis(tmp,(int) yyvsp[-2].real,argf2[0],(int) yyvsp[0].real);
					}
				;}
    break;

  case 110:
#line 1729 "rib.y"
    {
					RtBasis	*argf1;

					if (getBasis(&argf1,yyvsp[-20].string)) {
						RtBasis	tmp;
					
						tmp[0][0]	=	yyvsp[-17].real;
						tmp[0][1]	=	yyvsp[-16].real;
						tmp[0][2]	=	yyvsp[-15].real;
						tmp[0][3]	=	yyvsp[-14].real;
						tmp[1][0]	=	yyvsp[-13].real;
						tmp[1][1]	=	yyvsp[-12].real;
						tmp[1][2]	=	yyvsp[-11].real;
						tmp[1][3]	=	yyvsp[-10].real;
						tmp[2][0]	=	yyvsp[-9].real;
						tmp[2][1]	=	yyvsp[-8].real;
						tmp[2][2]	=	yyvsp[-7].real;
						tmp[2][3]	=	yyvsp[-6].real;
						tmp[3][0]	=	yyvsp[-5].real;
						tmp[3][1]	=	yyvsp[-4].real;
						tmp[3][2]	=	yyvsp[-3].real;
						tmp[3][3]	=	yyvsp[-2].real;

						RiBasis(argf1[0],(int) yyvsp[-19].real,tmp,(int) yyvsp[0].real);
					}
				;}
    break;

  case 111:
#line 1795 "rib.y"
    {
					RtBasis	b1,b2;

					b1[0][0]	=	yyvsp[-36].real;
					b1[0][1]	=	yyvsp[-35].real;
					b1[0][2]	=	yyvsp[-34].real;
					b1[0][3]	=	yyvsp[-33].real;
					b1[1][0]	=	yyvsp[-32].real;
					b1[1][1]	=	yyvsp[-31].real;
					b1[1][2]	=	yyvsp[-30].real;
					b1[1][3]	=	yyvsp[-29].real;
					b1[2][0]	=	yyvsp[-28].real;
					b1[2][1]	=	yyvsp[-27].real;
					b1[2][2]	=	yyvsp[-26].real;
					b1[2][3]	=	yyvsp[-25].real;
					b1[3][0]	=	yyvsp[-24].real;
					b1[3][1]	=	yyvsp[-23].real;
					b1[3][2]	=	yyvsp[-22].real;
					b1[3][3]	=	yyvsp[-21].real;

					b2[0][0]	=	yyvsp[-17].real;
					b2[0][1]	=	yyvsp[-16].real;
					b2[0][2]	=	yyvsp[-15].real;
					b2[0][3]	=	yyvsp[-14].real;
					b2[1][0]	=	yyvsp[-13].real;
					b2[1][1]	=	yyvsp[-12].real;
					b2[1][2]	=	yyvsp[-11].real;
					b2[1][3]	=	yyvsp[-10].real;
					b2[2][0]	=	yyvsp[-9].real;
					b2[2][1]	=	yyvsp[-8].real;
					b2[2][2]	=	yyvsp[-7].real;
					b2[2][3]	=	yyvsp[-6].real;
					b2[3][0]	=	yyvsp[-5].real;
					b2[3][1]	=	yyvsp[-4].real;
					b2[3][2]	=	yyvsp[-3].real;
					b2[3][3]	=	yyvsp[-2].real;

					RiBasis(b1,(int) yyvsp[-19].real,b2,(int) yyvsp[0].real);
				;}
    break;

  case 112:
#line 1838 "rib.y"
    {
					int	numExpectedVertices;
					int	numExpectedPatches	=	1;


					if (strcmp(yyvsp[-1].string,RI_BILINEAR) == 0) {
						numExpectedVertices	=	4;
					} else if (strcmp(yyvsp[-1].string,RI_BICUBIC) == 0) {
						numExpectedVertices	=	16;
					} else {
						error(CODE_BADTOKEN,"Unknown patch type: \"%s\"\n",yyvsp[-1].string);
						numExpectedVertices	=	0;
					}

					if (numExpectedVertices > 0) {
						if (parameterListCheck()) {
							if (sizeCheck(numExpectedVertices,4,4,1)) {
								RiPatchV(yyvsp[-1].string,numParameters,tokens,vals);
							}
						}
					}
				;}
    break;

  case 113:
#line 1868 "rib.y"
    {
					int	numExpectedVertices;
					int	numuPatches,numvPatches;
					int	nu	=	(int) yyvsp[-4].real;
					int	nv	=	(int) yyvsp[-2].real;
					CAttributes	*attributes	=	currentRenderer->getAttributes(FALSE);
					int	uw,vw;
					int	numVaryings;

					if (strcmp(yyvsp[-3].string,RI_PERIODIC) == 0) {
						uw	=	TRUE;
					} else {
						uw	=	FALSE;
					}

					if (strcmp(yyvsp[-1].string,RI_PERIODIC) == 0) {
						vw	=	TRUE;
					} else {
						vw	=	FALSE;
					}

					if (strcmp(yyvsp[-5].string,RI_BILINEAR) == 0) {
						numExpectedVertices	=	nu*nv;

						if (uw) {
							numuPatches	=	nu;
						} else {
							numuPatches	=	nu-1;
						}


						if (vw) {
							numvPatches	=	nv;
						} else {
							numvPatches	=	nv-1;
						}

						numVaryings		=	nu*nv;
					} else if (strcmp(yyvsp[-5].string,RI_BICUBIC) == 0) {
						numExpectedVertices	=	nu*nv;

						if (uw) {
							numuPatches	=	nu / attributes->uStep;
						} else {
							numuPatches	=	(nu - 4) / attributes->uStep + 1;
						}


						if (vw) {
							numvPatches	=	nv / attributes->vStep;
						} else {
							numvPatches	=	(nv - 4) / attributes->vStep + 1;
						}

						numVaryings		=	(numuPatches+1-uw)*(numvPatches+1-vw);
					} else {
						error(CODE_BADTOKEN,"Unknown patch type: \"%s\"\n",yyvsp[-5].string);
						numExpectedVertices	=	0;
					}

					if (numExpectedVertices > 0) {
						if (parameterListCheck()) {
							if (sizeCheck(numExpectedVertices,numVaryings,numuPatches*numvPatches*4,numuPatches*numvPatches)) {
								RiPatchMeshV(yyvsp[-5].string,(int) yyvsp[-4].real,yyvsp[-3].string,(int) yyvsp[-2].real,yyvsp[-1].string,numParameters,tokens,vals);
							}
						}
					}
				;}
    break;

  case 114:
#line 1949 "rib.y"
    {
					float	*argf1	=	(float *) get(0);
					float	*argf2	=	(float *) get(yyvsp[-8].integer);

					int		uPoints	=	(int) yyvsp[-10].real;
					int		uOrder	=	(int) yyvsp[-9].real;
					int		vPoints	=	(int) yyvsp[-5].real;
					int		vOrder	=	(int) yyvsp[-4].real;

					int		uPatches	=	uPoints - uOrder+1;
					int		vPatches	=	vPoints - vOrder+1;

					int		numExpectedVertices	=	uPoints*vPoints;
					int		numExpectedPatches	=	uPatches*vPatches;

					if (parameterListCheck()) {
						if (sizeCheck(numExpectedVertices,(uPoints-uOrder+2)*(vPoints-vOrder+2),uPatches*vPatches*4,uPatches*vPatches)) {
							RiNuPatchV((int) yyvsp[-10].real,(int) yyvsp[-9].real,argf1,yyvsp[-7].real,yyvsp[-6].real,(int) yyvsp[-5].real,(int) yyvsp[-4].real,argf2,yyvsp[-2].real,yyvsp[-1].real,numParameters,tokens,vals);
						}
					}
				;}
    break;

  case 115:
#line 1981 "rib.y"
    {
					int		*argi1	=	(int *)		get(0);
					int		*argi2	=	(int *)		get(yyvsp[-8].integer);
					float	*argf3	=	(float *)	get(yyvsp[-7].integer+yyvsp[-8].integer);
					float	*argf4	=	(float *)	get(yyvsp[-6].integer+yyvsp[-7].integer+yyvsp[-7].integer);
					float	*argf5	=	(float *)	get(yyvsp[-5].integer+yyvsp[-6].integer+yyvsp[-7].integer+yyvsp[-8].integer);
					int		*argi6	=	(int *)		get(yyvsp[-4].integer+yyvsp[-5].integer+yyvsp[-6].integer+yyvsp[-7].integer+yyvsp[-8].integer);
					float	*argf7	=	(float *)	get(yyvsp[-3].integer+yyvsp[-4].integer+yyvsp[-5].integer+yyvsp[-6].integer+yyvsp[-7].integer+yyvsp[-8].integer);
					float	*argf8	=	(float *)	get(yyvsp[-2].integer+yyvsp[-3].integer+yyvsp[-4].integer+yyvsp[-5].integer+yyvsp[-6].integer+yyvsp[-7].integer+yyvsp[-8].integer);
					float	*argf9	=	(float *)	get(yyvsp[-1].integer+yyvsp[-2].integer+yyvsp[-3].integer+yyvsp[-4].integer+yyvsp[-5].integer+yyvsp[-6].integer+yyvsp[-7].integer+yyvsp[-8].integer);

					RiTrimCurve(yyvsp[-8].integer,argi1,argi2,argf3,argf4,argf5,argi6,argf7,argf8,argf9);
				;}
    break;

  case 116:
#line 2001 "rib.y"
    {
					if (parameterListCheck()) {
						if (sizeCheck(0,4,4,1)) {
							RiSphereV(yyvsp[-4].real,yyvsp[-3].real,yyvsp[-2].real,yyvsp[-1].real,numParameters,tokens,vals);
						}
					}
				;}
    break;

  case 117:
#line 2017 "rib.y"
    {
					if (parameterListCheck()) {
						if (sizeCheck(0,4,4,1)) {
							RiSphereV(yyvsp[-5].real,yyvsp[-4].real,yyvsp[-3].real,yyvsp[-2].real,numParameters,tokens,vals);
						}
					}
				;}
    break;

  case 118:
#line 2030 "rib.y"
    {
					if (parameterListCheck()) {
						if (sizeCheck(0,4,4,1)) {
							RiConeV(yyvsp[-3].real,yyvsp[-2].real,yyvsp[-1].real,numParameters,tokens,vals);
						}
					}
				;}
    break;

  case 119:
#line 2045 "rib.y"
    {
					if (parameterListCheck()) {
						if (sizeCheck(0,4,4,1)) {
							RiConeV(yyvsp[-4].real,yyvsp[-3].real,yyvsp[-2].real,numParameters,tokens,vals);
						}
					}
				;}
    break;

  case 120:
#line 2059 "rib.y"
    {
					if (parameterListCheck()) {
						if (sizeCheck(0,4,4,1)) {
							RiCylinderV(yyvsp[-4].real,yyvsp[-3].real,yyvsp[-2].real,yyvsp[-1].real,numParameters,tokens,vals);
						}
					}
				;}
    break;

  case 121:
#line 2075 "rib.y"
    {
					if (parameterListCheck()) {
						if (sizeCheck(0,4,4,1)) {
							RiCylinderV(yyvsp[-5].real,yyvsp[-4].real,yyvsp[-3].real,yyvsp[-2].real,numParameters,tokens,vals);
						}
					}
				;}
    break;

  case 122:
#line 2092 "rib.y"
    {
					if (parameterListCheck()) {
						if (sizeCheck(0,4,4,1)) {
							RtPoint	p1,p2;

							p1[0]	=	yyvsp[-7].real;
							p1[1]	=	yyvsp[-6].real;
							p1[2]	=	yyvsp[-5].real;
							p2[0]	=	yyvsp[-4].real;
							p2[1]	=	yyvsp[-3].real;
							p2[2]	=	yyvsp[-2].real;

							RiHyperboloidV(p1,p2,yyvsp[-1].real,numParameters,tokens,vals);
						}
					}
				;}
    break;

  case 123:
#line 2120 "rib.y"
    {
					if (parameterListCheck()) {
						if (sizeCheck(0,4,4,1)) {
							RtPoint	p1,p2;

							p1[0]	=	yyvsp[-8].real;
							p1[1]	=	yyvsp[-7].real;
							p1[2]	=	yyvsp[-6].real;
							p2[0]	=	yyvsp[-5].real;
							p2[1]	=	yyvsp[-4].real;
							p2[2]	=	yyvsp[-3].real;

							RiHyperboloidV(p1,p2,yyvsp[-2].real,numParameters,tokens,vals);
						}
					}
				;}
    break;

  case 124:
#line 2143 "rib.y"
    {
					if (parameterListCheck()) {
						if (sizeCheck(0,4,4,1)) {
							RiParaboloidV(yyvsp[-4].real,yyvsp[-3].real,yyvsp[-2].real,yyvsp[-1].real,numParameters,tokens,vals);
						}
					}
				;}
    break;

  case 125:
#line 2159 "rib.y"
    {
					if (parameterListCheck()) {
						if (sizeCheck(0,4,4,1)) {
							RiParaboloidV(yyvsp[-5].real,yyvsp[-4].real,yyvsp[-3].real,yyvsp[-2].real,numParameters,tokens,vals);
						}
					}
				;}
    break;

  case 126:
#line 2172 "rib.y"
    {
					if (parameterListCheck()) {
						if (sizeCheck(0,4,4,1)) {
							RiDiskV(yyvsp[-3].real,yyvsp[-2].real,yyvsp[-1].real,numParameters,tokens,vals);
						}
					}
				;}
    break;

  case 127:
#line 2187 "rib.y"
    {
					if (parameterListCheck()) {
						if (sizeCheck(0,4,4,1)) {
							RiDiskV(yyvsp[-4].real,yyvsp[-3].real,yyvsp[-2].real,numParameters,tokens,vals);
						}
					}
				;}
    break;

  case 128:
#line 2202 "rib.y"
    {
					if (parameterListCheck()) {
						if (sizeCheck(0,4,4,1)) {
							RiTorusV(yyvsp[-5].real,yyvsp[-4].real,yyvsp[-3].real,yyvsp[-2].real,yyvsp[-1].real,numParameters,tokens,vals);
						}
					}
				;}
    break;

  case 129:
#line 2219 "rib.y"
    {
					if (parameterListCheck()) {
						if (sizeCheck(0,4,4,1)) {
							RiTorusV(yyvsp[-6].real,yyvsp[-5].real,yyvsp[-4].real,yyvsp[-3].real,yyvsp[-2].real,numParameters,tokens,vals);
						}
					}
				;}
    break;

  case 130:
#line 2232 "rib.y"
    {
					int			*argi1		=	(int *) get(0);
					int			numVertices,numUniforms;
					CAttributes	*attributes	=	currentRenderer->getAttributes(FALSE);
					int			wrap;
					int			numVaryings,i;

					if (strcmp(yyvsp[-1].string,RI_PERIODIC) == 0) {
						wrap	=	TRUE;
					} else {
						wrap	=	FALSE;
					}

					if (strcmp(yyvsp[-3].string,RI_LINEAR) == 0) {
						for (i=0,numVertices=0;i<yyvsp[-2].integer;i++) {
							numVertices	+=	argi1[i];
						}

						numVaryings		=	numVertices;
						numUniforms		=	yyvsp[-2].integer;
					} else if (strcmp(yyvsp[-3].string,RI_CUBIC) == 0) {
						for (i=0,numVertices=0,numVaryings=0,numUniforms=0;i<yyvsp[-2].integer;i++) {
							int	j		=	(argi1[i] - 4) / attributes->vStep + 1;
							numVertices	+=	argi1[0];
							numVaryings	+=	j + (1 - wrap);
						}
						numUniforms		=	yyvsp[-2].integer;
					} else {
						error(CODE_BADTOKEN,"Unknown patch type: \"%s\"\n",yyvsp[-3].string);
						numVertices	=	0;
					}

					if (numVertices > 0) {
						if (parameterListCheck()) {
							if (sizeCheck(numVertices,numVaryings,0,numUniforms)) {
								RiCurvesV(yyvsp[-3].string,yyvsp[-2].integer,argi1,yyvsp[-1].string,numParameters,tokens,vals);
							}
						}
					}
				;}
    break;

  case 131:
#line 2275 "rib.y"
    {
					if (parameterListCheck()) {
						if (sizeCheck(numVertex,0,0,1)) {
							RiPointsV(numVertex,numParameters,tokens,vals);
						}
					}
				;}
    break;

  case 132:
#line 2292 "rib.y"
    {
					int		*argi1,*argi2,*argi3,*argi4;
					char	**args1;
					float	*argf1;
					int		numVertices,i,j;

					if (parameterListCheck()) {
						argi1	=	(int *)		get(0);
						argi2	=	(int *)		get(yyvsp[-6].integer);
						args1	=	(char **)	get(yyvsp[-6].integer+yyvsp[-5].integer);
						argi3	=	(int *)		get(yyvsp[-6].integer+yyvsp[-5].integer+yyvsp[-4].integer);
						argi4	=	(int *)		get(yyvsp[-6].integer+yyvsp[-5].integer+yyvsp[-4].integer+yyvsp[-3].integer);
						argf1	=	(float *)	get(yyvsp[-6].integer+yyvsp[-5].integer+yyvsp[-4].integer+yyvsp[-3].integer+yyvsp[-2].integer);

						// Count the number of faces / vertices
						for (i=0,j=0;i<yyvsp[-6].integer;j+=argi1[i],i++);

						for (numVertices=-1,i=0;i<j;i++) {
							if (argi2[i] > numVertices)	numVertices	=	argi2[i];
						}
						numVertices++;


						if (sizeCheck(numVertices,numVertices,j,yyvsp[-6].integer)) {
							RiSubdivisionMeshV(yyvsp[-7].string,yyvsp[-6].integer,argi1,argi2,yyvsp[-4].integer,args1,argi3,argi4,argf1,numParameters,tokens,vals);
						}
					}
				;}
    break;

  case 133:
#line 2326 "rib.y"
    {
					int		*argi1,*argi2;
					int		numVertices,i,j;

					if (parameterListCheck()) {
						argi1	=	(int *) get(0);
						argi2	=	(int *) get(yyvsp[-2].integer);

						// Count the number of faces / vertices
						for (i=0,j=0;i<yyvsp[-2].integer;j+=argi1[i],i++);

						for (numVertices=-1,i=0;i<j;i++) {
							if (argi2[i] > numVertices)	numVertices	=	argi2[i];
						}
						numVertices++;


						if (sizeCheck(numVertices,numVertices,j,yyvsp[-2].integer)) {
							RiSubdivisionMeshV(yyvsp[-3].string,yyvsp[-2].integer,argi1,argi2,0,NULL,NULL,NULL,NULL,numParameters,tokens,vals);
						}
					}
				;}
    break;

  case 134:
#line 2354 "rib.y"
    {
					// FIXME: Not implemented
				;}
    break;

  case 135:
#line 2361 "rib.y"
    {
					if (parameterListCheck()) {
						RiGeometryV(yyvsp[-1].string,numParameters,tokens,vals);
					}
				;}
    break;

  case 136:
#line 2378 "rib.y"
    {
					RtBound			bound;
					CDelayedData	*cData	=	new CDelayedData;
					char			**arg;

					bound[0]	=	yyvsp[-6].real;
					bound[1]	=	yyvsp[-5].real;
					bound[2]	=	yyvsp[-4].real;
					bound[3]	=	yyvsp[-3].real;
					bound[4]	=	yyvsp[-2].real;
					bound[5]	=	yyvsp[-1].real;

					cData->bmin[COMP_X]	=	yyvsp[-6].real;
					cData->bmin[COMP_Y]	=	yyvsp[-5].real;
					cData->bmin[COMP_Z]	=	yyvsp[-4].real;

					cData->bmax[COMP_X]	=	yyvsp[-3].real;
					cData->bmax[COMP_Y]	=	yyvsp[-2].real;
					cData->bmax[COMP_Z]	=	yyvsp[-1].real;

					if (strcmp(yyvsp[-9].string,RI_PROCDELAYEDREADARCHIVE) == 0) {
						if (yyvsp[-8].integer != 1) {
							error(CODE_MISSINGDATA,"Proc delayed archive expects one argument (given %d)\n",yyvsp[-8].integer);
						} else {
							arg		=	(char **) get(0);

							cData->generator	=	strdup(arg[0]);

							RiProcedural((RtPointer) cData,bound,RiProcDelayedReadArchive,RiProcFree);
						}
					} else if (strcmp(yyvsp[-9].string,RI_PROCRUNPROGRAM) == 0) {
						if (yyvsp[-8].integer != 2) {
							error(CODE_MISSINGDATA,"Proc delayed archive expects two arguments (given %d)\n",yyvsp[-8].integer);
						} else {
							arg		=	(char **) get(0);

							cData->generator	=	strdup(arg[0]);
							cData->helper		=	strdup(arg[1]);

							RiProcedural((RtPointer) cData,bound,RiProcRunProgram,RiProcFree);
						}
					} else if (strcmp(yyvsp[-9].string,RI_PROCDYNAMICLOAD) == 0) {
						if (yyvsp[-8].integer != 2) {
							error(CODE_MISSINGDATA,"Proc delayed archive expects two arguments (given %d)\n",yyvsp[-8].integer);
						} else {
							arg		=	(char **) get(0);

							cData->generator	=	strdup(arg[0]);
							cData->helper		=	strdup(arg[1]);

							RiProcedural((RtPointer) cData,bound,RiProcDynamicLoad,RiProcFree);
						}
					} else {
						error(CODE_BADTOKEN,"Unknown procedural: %s\n",yyvsp[-9].string);
						delete cData;
					}
				;}
    break;

  case 137:
#line 2438 "rib.y"
    {
					RiSolidBegin(yyvsp[0].string);
				;}
    break;

  case 138:
#line 2443 "rib.y"
    {
					RiSolidEnd();
				;}
    break;

  case 139:
#line 2449 "rib.y"
    {
					if (ribObjects == NULL)	ribObjects	=	new CArray<RtPointer>;

					(*ribObjects)[(int) yyvsp[0].real]	=	RiObjectBegin();
				;}
    break;

  case 140:
#line 2456 "rib.y"
    {
					RiObjectEnd();
				;}
    break;

  case 141:
#line 2462 "rib.y"
    {
					if (ribObjects != NULL) {
						RiObjectInstance((*ribObjects)[(int) yyvsp[0].real]);
					} else {
						error(CODE_MISSINGDATA,"Object %d is not found\n",(int) yyvsp[0].real);
					}
				;}
    break;

  case 142:
#line 2472 "rib.y"
    {
					float	*argf	=	(float *) get(0);

					RiMotionBeginV(yyvsp[0].integer,argf);
				;}
    break;

  case 143:
#line 2479 "rib.y"
    {
					RiMotionEnd();
				;}
    break;

  case 144:
#line 2492 "rib.y"
    {
					RtFilterFunc	f;

					if ((f		=	getFilter(yyvsp[-3].string)) != NULL)  {
						RiMakeTextureV(yyvsp[-7].string,yyvsp[-6].string,yyvsp[-5].string,yyvsp[-4].string,f,yyvsp[-2].real,yyvsp[-1].real,numParameters,tokens,vals);
					}
				;}
    break;

  case 145:
#line 2509 "rib.y"
    {
					RtFilterFunc	f;

					if ((f		=	getFilter(yyvsp[-3].string)) != NULL) {
						RiMakeBumpV(yyvsp[-7].string,yyvsp[-6].string,yyvsp[-5].string,yyvsp[-4].string,f,yyvsp[-2].real,yyvsp[-1].real,numParameters,tokens,vals);
					}
				;}
    break;

  case 146:
#line 2524 "rib.y"
    {
					RtFilterFunc	f;

					if ((f		=	getFilter(yyvsp[-3].string)) != NULL) {
						RiMakeLatLongEnvironmentV(yyvsp[-5].string,yyvsp[-4].string,f,yyvsp[-2].real,yyvsp[-1].real,numParameters,tokens,vals);
					}
				;}
    break;

  case 147:
#line 2545 "rib.y"
    {
					RtFilterFunc	f;

					if ((f =	getFilter(yyvsp[-3].string)) != NULL) {
						RiMakeCubeFaceEnvironmentV(yyvsp[-11].string,yyvsp[-10].string,yyvsp[-9].string,yyvsp[-8].string,yyvsp[-7].string,yyvsp[-6].string,yyvsp[-5].string,yyvsp[-4].real,f,yyvsp[-2].real,yyvsp[-1].real,numParameters,tokens,vals);
					}
				;}
    break;

  case 148:
#line 2557 "rib.y"
    {
					RiMakeShadowV(yyvsp[-2].string,yyvsp[-1].string,numParameters,tokens,vals);
				;}
    break;

  case 149:
#line 2563 "rib.y"
    {
					RtErrorHandler 	e	=	getErrorHandler(yyvsp[0].string);

					if (e != NULL) {
						RiErrorHandler(e);
					}
				;}
    break;

  case 150:
#line 2573 "rib.y"
    {
				;}
    break;

  case 151:
#line 2578 "rib.y"
    {
				;}
    break;

  case 152:
#line 2582 "rib.y"
    {
					if (YYRECOVERING() == 0) {
						error(CODE_BADFILE,"Syntax error.\n");
					}
				;}
    break;


    }

/* Line 999 of yacc.c.  */
#line 3901 "rib.cpp"

  yyvsp -= yylen;
  yyssp -= yylen;


  YY_STACK_PRINT (yyss, yyssp);

  *++yyvsp = yyval;


  /* Now `shift' the result of the reduction.  Determine what state
     that goes to, based on the state we popped back to and the rule
     number reduced by.  */

  yyn = yyr1[yyn];

  yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
  if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
    yystate = yytable[yystate];
  else
    yystate = yydefgoto[yyn - YYNTOKENS];

  goto yynewstate;


/*------------------------------------.
| yyerrlab -- here on detecting error |
`------------------------------------*/
yyerrlab:
  /* If not already recovering from an error, report this error.  */
  if (!yyerrstatus)
    {
      ++yynerrs;
#if YYERROR_VERBOSE
      yyn = yypact[yystate];

      if (YYPACT_NINF < yyn && yyn < YYLAST)
	{
	  YYSIZE_T yysize = 0;
	  int yytype = YYTRANSLATE (yychar);
	  char *yymsg;
	  int yyx, yycount;

	  yycount = 0;
	  /* Start YYX at -YYN if negative to avoid negative indexes in
	     YYCHECK.  */
	  for (yyx = yyn < 0 ? -yyn : 0;
	       yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
	    if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
	      yysize += yystrlen (yytname[yyx]) + 15, yycount++;
	  yysize += yystrlen ("syntax error, unexpected ") + 1;
	  yysize += yystrlen (yytname[yytype]);
	  yymsg = (char *) YYSTACK_ALLOC (yysize);
	  if (yymsg != 0)
	    {
	      char *yyp = yystpcpy (yymsg, "syntax error, unexpected ");
	      yyp = yystpcpy (yyp, yytname[yytype]);

	      if (yycount < 5)
		{
		  yycount = 0;
		  for (yyx = yyn < 0 ? -yyn : 0;
		       yyx < (int) (sizeof (yytname) / sizeof (char *));
		       yyx++)
		    if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
		      {
			const char *yyq = ! yycount ? ", expecting " : " or ";
			yyp = yystpcpy (yyp, yyq);
			yyp = yystpcpy (yyp, yytname[yyx]);
			yycount++;
		      }
		}
	      yyerror (yymsg);
	      YYSTACK_FREE (yymsg);
	    }
	  else
	    yyerror ("syntax error; also virtual memory exhausted");
	}
      else
#endif /* YYERROR_VERBOSE */
	yyerror ("syntax error");
    }



  if (yyerrstatus == 3)
    {
      /* If just tried and failed to reuse lookahead token after an
	 error, discard it.  */

      /* Return failure if at end of input.  */
      if (yychar == YYEOF)
        {
	  /* Pop the error token.  */
          YYPOPSTACK;
	  /* Pop the rest of the stack.  */
	  while (yyss < yyssp)
	    {
	      YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
	      yydestruct (yystos[*yyssp], yyvsp);
	      YYPOPSTACK;
	    }
	  YYABORT;
        }

      YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc);
      yydestruct (yytoken, &yylval);
      yychar = YYEMPTY;

    }

  /* Else will try to reuse lookahead token after shifting the error
     token.  */
  goto yyerrlab1;


/*----------------------------------------------------.
| yyerrlab1 -- error raised explicitly by an action.  |
`----------------------------------------------------*/
yyerrlab1:
  yyerrstatus = 3;	/* Each real token shifted decrements this.  */

  for (;;)
    {
      yyn = yypact[yystate];
      if (yyn != YYPACT_NINF)
	{
	  yyn += YYTERROR;
	  if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
	    {
	      yyn = yytable[yyn];
	      if (0 < yyn)
		break;
	    }
	}

      /* Pop the current state because it cannot handle the error token.  */
      if (yyssp == yyss)
	YYABORT;

      YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
      yydestruct (yystos[yystate], yyvsp);
      yyvsp--;
      yystate = *--yyssp;

      YY_STACK_PRINT (yyss, yyssp);
    }

  if (yyn == YYFINAL)
    YYACCEPT;

  YYDPRINTF ((stderr, "Shifting error token, "));

  *++yyvsp = yylval;


  yystate = yyn;
  goto yynewstate;


/*-------------------------------------.
| yyacceptlab -- YYACCEPT comes here.  |
`-------------------------------------*/
yyacceptlab:
  yyresult = 0;
  goto yyreturn;

/*-----------------------------------.
| yyabortlab -- YYABORT comes here.  |
`-----------------------------------*/
yyabortlab:
  yyresult = 1;
  goto yyreturn;

#ifndef yyoverflow
/*----------------------------------------------.
| yyoverflowlab -- parser overflow comes here.  |
`----------------------------------------------*/
yyoverflowlab:
  yyerror ("parser stack overflow");
  yyresult = 2;
  /* Fall through.  */
#endif

yyreturn:
#ifndef yyoverflow
  if (yyss != yyssa)
    YYSTACK_FREE (yyss);
#endif
  return yyresult;
}


#line 2589 "rib.y"


#include "lex.rib.cpp"

// Our position in the rib file
static	int		ribStart	=	0;
static	int		ribStep		=	5*(1<<10);	// Parse 5 KB at a time

///////////////////////////////////////////////////////////////////////
// Function				:	riberror
// Description			:	Parser error file
// Return Value			:	-
// Comments				:
// Date last edited		:	10/8/2001
void	riberror(char *s,...) {
	warning(CODE_BADFILE,"RIB Parse error\n");
}

///////////////////////////////////////////////////////////////////////
// Function				:	parseRib
// Description			:	Parse a rib file
// Return Value			:	-
// Comments				:
// Date last edited		:	10/8/2001
void	ribParse(FILE *in,void (*c)(const char *)) {
	if (in != NULL) {
		ribin		=	in;

		// Save the environment first
		CArray<RtPointer>	*savedLights					=	lights;
		CTrie<RtPointer>	*savedLightNames				=	lightNames;
		CArray<RtPointer>	*savedObjects					=	ribObjects;
		CArray<char *>		*savedAllocatedStrings			=	allocatedStrings;
		int					savedRibLineno					=	ribLineno;
		const char			*savedActivity					=	stats.activity;
		void				(*savedCallback)(const char *)	=	callback;
		ERIBValue			*savedArgs						=	args;
		int					savedNumArguments				=	numArguments;
		int					savedMaxArgument				=	maxArgument;
		int					savedNumParameters				=	numParameters;
		int					savedMaxParameter				=	maxParameter;
		TParameter			*savedParameters				=	parameters;
		RtToken				*savedTokens					=	tokens;
		RtPointer			*savedVals						=	vals;

		// Init the environment
		lights				=	NULL;
		lightNames			=	NULL;
		ribObjects			=	NULL;
		allocatedStrings	=	new CArray<char *>;
		stats.activity		=	"Rib parsing";
		callback			=	c;
		maxArgument			=	1000;
		numArguments		=	0;
		args				=	new ERIBValue[maxArgument];
		maxParameter		=	20;
		numParameters		=	0;
		parameters			=	new TParameter[maxParameter];
		tokens				=	new RtToken[maxParameter];
		vals				=	new RtPointer[maxParameter];


		ribLineno			=	1;

		ribparse();

		if (lights != NULL)		delete lights;
		if (lightNames != NULL)	delete lightNames;
		if (ribObjects != NULL)	delete ribObjects;
		delete allocatedStrings;
		delete [] args;
		delete [] parameters;
		delete [] tokens;
		delete [] vals;
		

		tokens				=	savedTokens;
		vals				=	savedVals;
		parameters			=	savedParameters;
		numParameters		=	savedNumParameters;
		maxParameter		=	savedMaxParameter;
		maxArgument			=	savedMaxArgument;
		numArguments		=	savedNumArguments;
		args				=	savedArgs;
		lightNames			=	savedLightNames;
		lights				=	savedLights;
		ribObjects			=	savedObjects;
		ribLineno			=	savedRibLineno;
		allocatedStrings	=	savedAllocatedStrings;
		stats.activity		=	savedActivity;
		callback			=	savedCallback;
	}
}

///////////////////////////////////////////////////////////////////////
// Function				:	parseRib
// Description			:	Parse a rib file
// Return Value			:	-
// Comments				:
// Date last edited		:	10/8/2001
int		ribwrap(void) {
	return 1;
}



///////////////////////////////////////////////////////////////////////
// Function				:	parserCleanup
// Description			:	Clean the memory allocated by the parser
// Return Value			:	-
// Comments				:
// Date last edited		:	10/8/2001
void		parserCleanup() {
	yy_delete_buffer(yy_current_buffer);
	yy_init				= 1;
}


