More ground work for Uniform blocks

Moved some of the struct / indexing code
from glslang.y to the ParserHelper class
and prepared it for uniform blocks.

Change-Id: I2d5d380f662f36f04d74783fd542c4b258d3f3a5
Reviewed-on: https://swiftshader-review.googlesource.com/3441
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
diff --git a/src/OpenGL/compiler/ParseHelper.cpp b/src/OpenGL/compiler/ParseHelper.cpp
index 22e38a7..2904cfd 100644
--- a/src/OpenGL/compiler/ParseHelper.cpp
+++ b/src/OpenGL/compiler/ParseHelper.cpp
@@ -981,6 +981,26 @@
     return false;
 }
 
+bool TParseContext::functionCallLValueErrorCheck(const TFunction *fnCandidate, TIntermAggregate *aggregate)
+{
+	for(size_t i = 0; i < fnCandidate->getParamCount(); ++i)
+	{
+		TQualifier qual = fnCandidate->getParam(i).type->getQualifier();
+		if(qual == EvqOut || qual == EvqInOut)
+		{
+			TIntermTyped *node = (aggregate->getSequence())[i]->getAsTyped();
+			if(lValueErrorCheck(node->getLine(), "assign", node))
+			{
+				error(node->getLine(),
+					"Constant value cannot be passed for 'out' or 'inout' parameters.", "Error");
+				recover();
+				return true;
+			}
+		}
+	}
+	return false;
+}
+
 bool TParseContext::supportsExtension(const char* extension)
 {
     const TExtensionBehavior& extbehavior = extensionBehavior();
@@ -1403,7 +1423,7 @@
 // If there is an embedded/nested struct, it appropriately calls addConstStructNested or addConstStructFromAggr
 // function and returns the parse-tree with the values of the embedded/nested struct.
 //
-TIntermTyped* TParseContext::addConstStruct(TString& identifier, TIntermTyped* node, TSourceLoc line)
+TIntermTyped* TParseContext::addConstStruct(const TString& identifier, TIntermTyped* node, TSourceLoc line)
 {
     const TFieldList &fields = node->getType().getStruct()->fields();
     TIntermTyped *typedNode;
@@ -1433,13 +1453,394 @@
     return typedNode;
 }
 
+//
+// Parse an array index expression
+//
+TIntermTyped *TParseContext::addIndexExpression(TIntermTyped *baseExpression, const TSourceLoc &location, TIntermTyped *indexExpression)
+{
+	TIntermTyped *indexedExpression = NULL;
+
+	if(!baseExpression->isArray() && !baseExpression->isMatrix() && !baseExpression->isVector())
+	{
+		if(baseExpression->getAsSymbolNode())
+		{
+			error(location, " left of '[' is not of type array, matrix, or vector ",
+				baseExpression->getAsSymbolNode()->getSymbol().c_str());
+		}
+		else
+		{
+			error(location, " left of '[' is not of type array, matrix, or vector ", "expression");
+		}
+		recover();
+	}
+
+	TIntermConstantUnion *indexConstantUnion = indexExpression->getAsConstantUnion();
+
+	if(indexExpression->getQualifier() == EvqConstExpr && indexConstantUnion)
+	{
+		int index = indexConstantUnion->getIConst(0);
+		if(index < 0)
+		{
+			std::stringstream infoStream;
+			infoStream << index;
+			std::string info = infoStream.str();
+			error(location, "negative index", info.c_str());
+			recover();
+			index = 0;
+		}
+		if(baseExpression->getType().getQualifier() == EvqConstExpr)
+		{
+			if(baseExpression->isArray())
+			{
+				// constant folding for arrays
+				indexedExpression = addConstArrayNode(index, baseExpression, location);
+			}
+			else if(baseExpression->isVector())
+			{
+				// constant folding for vectors
+				TVectorFields fields;
+				fields.num = 1;
+				fields.offsets[0] = index; // need to do it this way because v.xy sends fields integer array
+				indexedExpression = addConstVectorNode(fields, baseExpression, location);
+			}
+			else if(baseExpression->isMatrix())
+			{
+				// constant folding for matrices
+				indexedExpression = addConstMatrixNode(index, baseExpression, location);
+			}
+		}
+		else
+		{
+			int safeIndex = -1;
+
+			if(baseExpression->isArray())
+			{
+				if(index >= baseExpression->getType().getArraySize())
+				{
+					std::stringstream extraInfoStream;
+					extraInfoStream << "array index out of range '" << index << "'";
+					std::string extraInfo = extraInfoStream.str();
+					error(location, "", "[", extraInfo.c_str());
+					recover();
+					safeIndex = baseExpression->getType().getArraySize() - 1;
+				}
+			}
+			else if((baseExpression->isVector() || baseExpression->isMatrix()) &&
+				baseExpression->getType().getNominalSize() <= index)
+			{
+				std::stringstream extraInfoStream;
+				extraInfoStream << "field selection out of range '" << index << "'";
+				std::string extraInfo = extraInfoStream.str();
+				error(location, "", "[", extraInfo.c_str());
+				recover();
+				safeIndex = baseExpression->getType().getNominalSize() - 1;
+			}
+
+			// Don't modify the data of the previous constant union, because it can point
+			// to builtins, like gl_MaxDrawBuffers. Instead use a new sanitized object.
+			if(safeIndex != -1)
+			{
+				ConstantUnion *safeConstantUnion = new ConstantUnion();
+				safeConstantUnion->setIConst(safeIndex);
+				indexConstantUnion->replaceConstantUnion(safeConstantUnion);
+			}
+
+			indexedExpression = intermediate.addIndex(EOpIndexDirect, baseExpression, indexExpression, location);
+		}
+	}
+	else
+	{
+		if(baseExpression->isInterfaceBlock())
+		{
+			error(location, "",
+				"[", "array indexes for interface blocks arrays must be constant integral expressions");
+			recover();
+		}
+		// FIXME
+		/*
+		else if(baseExpression->getQualifier() == EvqFragmentOut)
+		{
+			error(location, "", "[", "array indexes for fragment outputs must be constant integral expressions");
+			recover();
+		}
+		*/
+
+		indexedExpression = intermediate.addIndex(EOpIndexIndirect, baseExpression, indexExpression, location);
+	}
+
+	if(indexedExpression == 0)
+	{
+		ConstantUnion *unionArray = new ConstantUnion[1];
+		unionArray->setFConst(0.0f);
+		indexedExpression = intermediate.addConstantUnion(unionArray, TType(EbtFloat, EbpHigh, EvqConstExpr), location);
+	}
+	else if(baseExpression->isArray())
+	{
+		const TType &baseType = baseExpression->getType();
+		if(baseType.getStruct())
+		{
+			TType copyOfType(baseType.getStruct());
+			indexedExpression->setType(copyOfType);
+		}
+		else if(baseType.isInterfaceBlock())
+		{
+			TType copyOfType(baseType.getInterfaceBlock(), baseType.getQualifier(), baseType.getLayoutQualifier(), 0);
+			indexedExpression->setType(copyOfType);
+		}
+		else
+		{
+			indexedExpression->setType(TType(baseExpression->getBasicType(), baseExpression->getPrecision(),
+				EvqTemporary, static_cast<unsigned char>(baseExpression->getNominalSize()),
+				static_cast<unsigned char>(baseExpression->getSecondarySize())));
+		}
+
+		if(baseExpression->getType().getQualifier() == EvqConstExpr)
+		{
+			indexedExpression->getTypePointer()->setQualifier(EvqConstExpr);
+		}
+	}
+	else if(baseExpression->isMatrix())
+	{
+		TQualifier qualifier = baseExpression->getType().getQualifier() == EvqConstExpr ? EvqConstExpr : EvqTemporary;
+		indexedExpression->setType(TType(baseExpression->getBasicType(), baseExpression->getPrecision(),
+			qualifier, static_cast<unsigned char>(baseExpression->getSecondarySize())));
+	}
+	else if(baseExpression->isVector())
+	{
+		TQualifier qualifier = baseExpression->getType().getQualifier() == EvqConstExpr ? EvqConstExpr : EvqTemporary;
+		indexedExpression->setType(TType(baseExpression->getBasicType(), baseExpression->getPrecision(), qualifier));
+	}
+	else
+	{
+		indexedExpression->setType(baseExpression->getType());
+	}
+
+	return indexedExpression;
+}
+
+TIntermTyped *TParseContext::addFieldSelectionExpression(TIntermTyped *baseExpression, const TSourceLoc &dotLocation,
+	const TString &fieldString, const TSourceLoc &fieldLocation)
+{
+	TIntermTyped *indexedExpression = NULL;
+
+	if(baseExpression->isArray())
+	{
+		error(fieldLocation, "cannot apply dot operator to an array", ".");
+		recover();
+	}
+
+	if(baseExpression->isVector())
+	{
+		TVectorFields fields;
+		if(!parseVectorFields(fieldString, baseExpression->getNominalSize(), fields, fieldLocation))
+		{
+			fields.num = 1;
+			fields.offsets[0] = 0;
+			recover();
+		}
+
+		if(baseExpression->getType().getQualifier() == EvqConstExpr)
+		{
+			// constant folding for vector fields
+			indexedExpression = addConstVectorNode(fields, baseExpression, fieldLocation);
+			if(indexedExpression == 0)
+			{
+				recover();
+				indexedExpression = baseExpression;
+			}
+			else
+			{
+				indexedExpression->setType(TType(baseExpression->getBasicType(), baseExpression->getPrecision(),
+					EvqConstExpr, (unsigned char)(fieldString).size()));
+			}
+		}
+		else
+		{
+			TString vectorString = fieldString;
+			TIntermTyped *index = intermediate.addSwizzle(fields, fieldLocation);
+			indexedExpression = intermediate.addIndex(EOpVectorSwizzle, baseExpression, index, dotLocation);
+			indexedExpression->setType(TType(baseExpression->getBasicType(), baseExpression->getPrecision(),
+				EvqTemporary, (unsigned char)vectorString.size()));
+		}
+	}
+	else if(baseExpression->isMatrix())
+	{
+		TMatrixFields fields;
+		if(!parseMatrixFields(fieldString, baseExpression->getNominalSize(), baseExpression->getSecondarySize(), fields, fieldLocation))
+		{
+			fields.wholeRow = false;
+			fields.wholeCol = false;
+			fields.row = 0;
+			fields.col = 0;
+			recover();
+		}
+
+		if(fields.wholeRow || fields.wholeCol)
+		{
+			error(dotLocation, " non-scalar fields not implemented yet", ".");
+			recover();
+			ConstantUnion *unionArray = new ConstantUnion[1];
+			unionArray->setIConst(0);
+			TIntermTyped *index = intermediate.addConstantUnion(unionArray, TType(EbtInt, EbpUndefined, EvqConstExpr),
+				fieldLocation);
+			indexedExpression = intermediate.addIndex(EOpIndexDirect, baseExpression, index, dotLocation);
+			indexedExpression->setType(TType(baseExpression->getBasicType(), baseExpression->getPrecision(),
+				EvqTemporary, static_cast<unsigned char>(baseExpression->getNominalSize()),
+				static_cast<unsigned char>(baseExpression->getSecondarySize())));
+		}
+		else
+		{
+			ConstantUnion *unionArray = new ConstantUnion[1];
+			unionArray->setIConst(fields.col * baseExpression->getSecondarySize() + fields.row);
+			TIntermTyped *index = intermediate.addConstantUnion(unionArray, TType(EbtInt, EbpUndefined, EvqConstExpr),
+				fieldLocation);
+			indexedExpression = intermediate.addIndex(EOpIndexDirect, baseExpression, index, dotLocation);
+			indexedExpression->setType(TType(baseExpression->getBasicType(), baseExpression->getPrecision()));
+		}
+	}
+	else if(baseExpression->getBasicType() == EbtStruct)
+	{
+		bool fieldFound = false;
+		const TFieldList &fields = baseExpression->getType().getStruct()->fields();
+		if(fields.empty())
+		{
+			error(dotLocation, "structure has no fields", "Internal Error");
+			recover();
+			indexedExpression = baseExpression;
+		}
+		else
+		{
+			unsigned int i;
+			for(i = 0; i < fields.size(); ++i)
+			{
+				if(fields[i]->name() == fieldString)
+				{
+					fieldFound = true;
+					break;
+				}
+			}
+			if(fieldFound)
+			{
+				if(baseExpression->getType().getQualifier() == EvqConstExpr)
+				{
+					indexedExpression = addConstStruct(fieldString, baseExpression, dotLocation);
+					if(indexedExpression == 0)
+					{
+						recover();
+						indexedExpression = baseExpression;
+					}
+					else
+					{
+						indexedExpression->setType(*fields[i]->type());
+						// change the qualifier of the return type, not of the structure field
+						// as the structure definition is shared between various structures.
+						indexedExpression->getTypePointer()->setQualifier(EvqConstExpr);
+					}
+				}
+				else
+				{
+					ConstantUnion *unionArray = new ConstantUnion[1];
+					unionArray->setIConst(i);
+					TIntermTyped *index = intermediate.addConstantUnion(unionArray, *fields[i]->type(), fieldLocation);
+					indexedExpression = intermediate.addIndex(EOpIndexDirectStruct, baseExpression, index, dotLocation);
+					indexedExpression->setType(*fields[i]->type());
+				}
+			}
+			else
+			{
+				error(dotLocation, " no such field in structure", fieldString.c_str());
+				recover();
+				indexedExpression = baseExpression;
+			}
+		}
+	}
+	else if(baseExpression->isInterfaceBlock())
+	{
+		bool fieldFound = false;
+		const TFieldList &fields = baseExpression->getType().getInterfaceBlock()->fields();
+		if(fields.empty())
+		{
+			error(dotLocation, "interface block has no fields", "Internal Error");
+			recover();
+			indexedExpression = baseExpression;
+		}
+		else
+		{
+			unsigned int i;
+			for(i = 0; i < fields.size(); ++i)
+			{
+				if(fields[i]->name() == fieldString)
+				{
+					fieldFound = true;
+					break;
+				}
+			}
+			if(fieldFound)
+			{
+				ConstantUnion *unionArray = new ConstantUnion[1];
+				unionArray->setIConst(i);
+				TIntermTyped *index = intermediate.addConstantUnion(unionArray, *fields[i]->type(), fieldLocation);
+				indexedExpression = intermediate.addIndex(EOpIndexDirectInterfaceBlock, baseExpression, index,
+					dotLocation);
+				indexedExpression->setType(*fields[i]->type());
+			}
+			else
+			{
+				error(dotLocation, " no such field in interface block", fieldString.c_str());
+				recover();
+				indexedExpression = baseExpression;
+			}
+		}
+	}
+	else
+	{
+		if(shaderVersion < 300)
+		{
+			error(dotLocation, " field selection requires structure, vector, or matrix on left hand side",
+				fieldString.c_str());
+		}
+		else
+		{
+			error(dotLocation,
+				" field selection requires structure, vector, matrix, or interface block on left hand side",
+				fieldString.c_str());
+		}
+		recover();
+		indexedExpression = baseExpression;
+	}
+
+	return indexedExpression;
+}
+
 TLayoutQualifier TParseContext::parseLayoutQualifier(const TString &qualifierType, const TSourceLoc& qualifierTypeLine)
 {
     TLayoutQualifier qualifier;
 
     qualifier.location = -1;
+	qualifier.matrixPacking = EmpUnspecified;
+	qualifier.blockStorage = EbsUnspecified;
 
-    if (qualifierType == "location")
+	if(qualifierType == "shared")
+	{
+		qualifier.blockStorage = EbsShared;
+	}
+	else if(qualifierType == "packed")
+	{
+		qualifier.blockStorage = EbsPacked;
+	}
+	else if(qualifierType == "std140")
+	{
+		qualifier.blockStorage = EbsStd140;
+	}
+	else if(qualifierType == "row_major")
+	{
+		qualifier.matrixPacking = EmpRowMajor;
+	}
+	else if(qualifierType == "column_major")
+	{
+		qualifier.matrixPacking = EmpColumnMajor;
+	}
+	else if(qualifierType == "location")
     {
         error(qualifierTypeLine, "invalid layout qualifier", qualifierType.c_str(), "location requires an argument");
         recover();
@@ -1458,6 +1859,8 @@
     TLayoutQualifier qualifier;
 
     qualifier.location = -1;
+    qualifier.matrixPacking = EmpUnspecified;
+    qualifier.blockStorage = EbsUnspecified;
 
     if (qualifierType != "location")
     {
@@ -1489,6 +1892,14 @@
     {
         joinedQualifier.location = rightQualifier.location;
     }
+	if(rightQualifier.matrixPacking != EmpUnspecified)
+	{
+		joinedQualifier.matrixPacking = rightQualifier.matrixPacking;
+	}
+	if(rightQualifier.blockStorage != EbsUnspecified)
+	{
+		joinedQualifier.blockStorage = rightQualifier.blockStorage;
+	}
 
     return joinedQualifier;
 }
@@ -1539,6 +1950,98 @@
 	return type;
 }
 
+TFieldList *TParseContext::addStructDeclaratorList(const TPublicType &typeSpecifier, TFieldList *fieldList)
+{
+	if(voidErrorCheck(typeSpecifier.line, (*fieldList)[0]->name(), typeSpecifier))
+	{
+		recover();
+	}
+
+	for(unsigned int i = 0; i < fieldList->size(); ++i)
+	{
+		//
+		// Careful not to replace already known aspects of type, like array-ness
+		//
+		TType *type = (*fieldList)[i]->type();
+		type->setBasicType(typeSpecifier.type);
+		type->setNominalSize(typeSpecifier.primarySize);
+		type->setSecondarySize(typeSpecifier.secondarySize);
+		type->setPrecision(typeSpecifier.precision);
+		type->setQualifier(typeSpecifier.qualifier);
+		type->setLayoutQualifier(typeSpecifier.layoutQualifier);
+
+		// don't allow arrays of arrays
+		if(type->isArray())
+		{
+			if(arrayTypeErrorCheck(typeSpecifier.line, typeSpecifier))
+				recover();
+		}
+		if(typeSpecifier.array)
+			type->setArraySize(typeSpecifier.arraySize);
+		if(typeSpecifier.userDef)
+		{
+			type->setStruct(typeSpecifier.userDef->getStruct());
+		}
+
+		if(structNestingErrorCheck(typeSpecifier.line, *(*fieldList)[i]))
+		{
+			recover();
+		}
+	}
+
+	return fieldList;
+}
+
+TPublicType TParseContext::addStructure(const TSourceLoc &structLine, const TSourceLoc &nameLine,
+	const TString *structName, TFieldList *fieldList)
+{
+	TStructure *structure = new TStructure(structName, fieldList);
+	TType *structureType = new TType(structure);
+
+	// Store a bool in the struct if we're at global scope, to allow us to
+	// skip the local struct scoping workaround in HLSL.
+	structure->setUniqueId(TSymbolTableLevel::nextUniqueId());
+	structure->setAtGlobalScope(symbolTable.atGlobalLevel());
+
+	if(!structName->empty())
+	{
+		if(reservedErrorCheck(nameLine, *structName))
+		{
+			recover();
+		}
+		TVariable *userTypeDef = new TVariable(structName, *structureType, true);
+		if(!symbolTable.declare(*userTypeDef))
+		{
+			error(nameLine, "redefinition", structName->c_str(), "struct");
+			recover();
+		}
+	}
+
+	// ensure we do not specify any storage qualifiers on the struct members
+	for(unsigned int typeListIndex = 0; typeListIndex < fieldList->size(); typeListIndex++)
+	{
+		const TField &field = *(*fieldList)[typeListIndex];
+		const TQualifier qualifier = field.type()->getQualifier();
+		switch(qualifier)
+		{
+		case EvqGlobal:
+		case EvqTemporary:
+			break;
+		default:
+			error(field.line(), "invalid qualifier on struct member", getQualifierString(qualifier));
+			recover();
+			break;
+		}
+	}
+
+	TPublicType publicType;
+	publicType.setBasic(EbtStruct, EvqTemporary, structLine);
+	publicType.userDef = structureType;
+	exitStructDeclaration();
+
+	return publicType;
+}
+
 bool TParseContext::enterStructDeclaration(int line, const TString& identifier)
 {
     ++structNestingLevel;
@@ -1559,6 +2062,210 @@
     --structNestingLevel;
 }
 
+bool TParseContext::structNestingErrorCheck(const TSourceLoc &line, const TField &field)
+{
+	static const int kWebGLMaxStructNesting = 4;
+
+	if(field.type()->getBasicType() != EbtStruct)
+	{
+		return false;
+	}
+
+	// We're already inside a structure definition at this point, so add
+	// one to the field's struct nesting.
+	if(1 + field.type()->getDeepestStructNesting() > kWebGLMaxStructNesting)
+	{
+		std::stringstream reasonStream;
+		reasonStream << "Reference of struct type "
+			<< field.type()->getStruct()->name().c_str()
+			<< " exceeds maximum allowed nesting level of "
+			<< kWebGLMaxStructNesting;
+		std::string reason = reasonStream.str();
+		error(line, reason.c_str(), field.name().c_str(), "");
+		return true;
+	}
+
+	return false;
+}
+
+TIntermTyped *TParseContext::createUnaryMath(TOperator op, TIntermTyped *child, const TSourceLoc &loc, const TType *funcReturnType)
+{
+	if(child == nullptr)
+	{
+		return nullptr;
+	}
+
+	switch(op)
+	{
+	case EOpLogicalNot:
+		if(child->getBasicType() != EbtBool ||
+			child->isMatrix() ||
+			child->isArray() ||
+			child->isVector())
+		{
+			return nullptr;
+		}
+		break;
+	case EOpBitwiseNot:
+		if((child->getBasicType() != EbtInt && child->getBasicType() != EbtUInt) ||
+			child->isMatrix() ||
+			child->isArray())
+		{
+			return nullptr;
+		}
+		break;
+	case EOpPostIncrement:
+	case EOpPreIncrement:
+	case EOpPostDecrement:
+	case EOpPreDecrement:
+	case EOpNegative:
+		if(child->getBasicType() == EbtStruct ||
+			child->getBasicType() == EbtBool ||
+			child->isArray())
+		{
+			return nullptr;
+		}
+		// Operators for built-ins are already type checked against their prototype.
+	default:
+		break;
+	}
+
+	return intermediate.addUnaryMath(op, child, loc); // FIXME , funcReturnType);
+}
+
+TIntermTyped *TParseContext::addUnaryMath(TOperator op, TIntermTyped *child, const TSourceLoc &loc)
+{
+	TIntermTyped *node = createUnaryMath(op, child, loc, nullptr);
+	if(node == nullptr)
+	{
+		unaryOpError(loc, getOperatorString(op), child->getCompleteString());
+		recover();
+		return child;
+	}
+	return node;
+}
+
+TIntermTyped *TParseContext::addUnaryMathLValue(TOperator op, TIntermTyped *child, const TSourceLoc &loc)
+{
+	if(lValueErrorCheck(loc, getOperatorString(op), child))
+		recover();
+	return addUnaryMath(op, child, loc);
+}
+
+bool TParseContext::binaryOpCommonCheck(TOperator op, TIntermTyped *left, TIntermTyped *right, const TSourceLoc &loc)
+{
+	if(left->isArray() || right->isArray())
+	{
+		if(shaderVersion < 300)
+		{
+			error(loc, "Invalid operation for arrays", getOperatorString(op));
+			return false;
+		}
+
+		if(left->isArray() != right->isArray())
+		{
+			error(loc, "array / non-array mismatch", getOperatorString(op));
+			return false;
+		}
+
+		switch(op)
+		{
+		case EOpEqual:
+		case EOpNotEqual:
+		case EOpAssign:
+		case EOpInitialize:
+			break;
+		default:
+			error(loc, "Invalid operation for arrays", getOperatorString(op));
+			return false;
+		}
+		// At this point, size of implicitly sized arrays should be resolved.
+		if(left->getArraySize() != right->getArraySize())
+		{
+			error(loc, "array size mismatch", getOperatorString(op));
+			return false;
+		}
+	}
+
+	// Check ops which require integer / ivec parameters
+	bool isBitShift = false;
+	switch(op)
+	{
+	case EOpBitShiftLeft:
+	case EOpBitShiftRight:
+	case EOpBitShiftLeftAssign:
+	case EOpBitShiftRightAssign:
+		// Unsigned can be bit-shifted by signed and vice versa, but we need to
+		// check that the basic type is an integer type.
+		isBitShift = true;
+		if(!IsInteger(left->getBasicType()) || !IsInteger(right->getBasicType()))
+		{
+			return false;
+		}
+		break;
+	case EOpBitwiseAnd:
+	case EOpBitwiseXor:
+	case EOpBitwiseOr:
+	case EOpBitwiseAndAssign:
+	case EOpBitwiseXorAssign:
+	case EOpBitwiseOrAssign:
+		// It is enough to check the type of only one operand, since later it
+		// is checked that the operand types match.
+		if(!IsInteger(left->getBasicType()))
+		{
+			return false;
+		}
+		break;
+	default:
+		break;
+	}
+
+	// GLSL ES 1.00 and 3.00 do not support implicit type casting.
+	// So the basic type should usually match.
+	if(!isBitShift && left->getBasicType() != right->getBasicType())
+	{
+		return false;
+	}
+
+	// Check that type sizes match exactly on ops that require that.
+	// Also check restrictions for structs that contain arrays or samplers.
+	switch(op)
+	{
+	case EOpAssign:
+	case EOpInitialize:
+	case EOpEqual:
+	case EOpNotEqual:
+		// ESSL 1.00 sections 5.7, 5.8, 5.9
+		if(shaderVersion < 300 && left->getType().isStructureContainingArrays())
+		{
+			error(loc, "undefined operation for structs containing arrays", getOperatorString(op));
+			return false;
+		}
+		// Samplers as l-values are disallowed also in ESSL 3.00, see section 4.1.7,
+		// we interpret the spec so that this extends to structs containing samplers,
+		// similarly to ESSL 1.00 spec.
+		if((shaderVersion < 300 || op == EOpAssign || op == EOpInitialize) &&
+			left->getType().isStructureContainingSamplers())
+		{
+			error(loc, "undefined operation for structs containing samplers", getOperatorString(op));
+			return false;
+		}
+	case EOpLessThan:
+	case EOpGreaterThan:
+	case EOpLessThanEqual:
+	case EOpGreaterThanEqual:
+		if((left->getNominalSize() != right->getNominalSize()) ||
+			(left->getSecondarySize() != right->getSecondarySize()))
+		{
+			return false;
+		}
+	default:
+		break;
+	}
+
+	return true;
+}
+
 //
 // Parse an array of strings using yyparse.
 //
diff --git a/src/OpenGL/compiler/ParseHelper.h b/src/OpenGL/compiler/ParseHelper.h
index 149791e..72f5a48 100644
--- a/src/OpenGL/compiler/ParseHelper.h
+++ b/src/OpenGL/compiler/ParseHelper.h
@@ -39,6 +39,8 @@
             currentFunctionType(NULL),
             functionReturnsValue(false),
             checksPrecisionErrors(checksPrecErrors),
+            defaultMatrixPacking(EmpColumnMajor),
+            defaultBlockStorage(EbsShared),
             diagnostics(is),
             shaderVersion(100),
             directiveHandler(ext, diagnostics, shaderVersion),
@@ -58,6 +60,8 @@
     const TType* currentFunctionType;  // the return type of the function that's currently being parsed
     bool functionReturnsValue;   // true if a non-void function has a return
     bool checksPrecisionErrors;  // true if an error will be generated when a variable is declared without precision, explicit or implicit.
+    TLayoutMatrixPacking defaultMatrixPacking;
+    TLayoutBlockStorage defaultBlockStorage;
     TString HashErrMsg;
     bool AfterEOF;
     TDiagnostics diagnostics;
@@ -102,7 +106,8 @@
     bool nonInitErrorCheck(int line, TString& identifier, TPublicType& type, TVariable*& variable);
     bool paramErrorCheck(int line, TQualifier qualifier, TQualifier paramQualifier, TType* type);
     bool extensionErrorCheck(int line, const TString&);
-    bool layoutLocationErrorCheck(const TSourceLoc &location, const TLayoutQualifier &layoutQualifier);
+    bool layoutLocationErrorCheck(const TSourceLoc& location, const TLayoutQualifier &layoutQualifier);
+    bool functionCallLValueErrorCheck(const TFunction *fnCandidate, TIntermAggregate *);
 
     const TExtensionBehavior& extensionBehavior() const { return directiveHandler.extensionBehavior(); }
     bool supportsExtension(const char* extension);
@@ -125,7 +130,12 @@
     TIntermTyped* addConstVectorNode(TVectorFields&, TIntermTyped*, TSourceLoc);
     TIntermTyped* addConstMatrixNode(int , TIntermTyped*, TSourceLoc);
     TIntermTyped* addConstArrayNode(int index, TIntermTyped* node, TSourceLoc line);
-    TIntermTyped* addConstStruct(TString& , TIntermTyped*, TSourceLoc);
+    TIntermTyped* addConstStruct(const TString& , TIntermTyped*, TSourceLoc);
+    TIntermTyped *addIndexExpression(TIntermTyped *baseExpression, const TSourceLoc& location, TIntermTyped *indexExpression);
+    TIntermTyped* addFieldSelectionExpression(TIntermTyped *baseExpression, const TSourceLoc &dotLocation, const TString &fieldString, const TSourceLoc &fieldLocation);
+
+    TFieldList *addStructDeclaratorList(const TPublicType &typeSpecifier, TFieldList *fieldList);
+    TPublicType addStructure(const TSourceLoc &structLine, const TSourceLoc &nameLine, const TString *structName, TFieldList *fieldList);
 
     TLayoutQualifier parseLayoutQualifier(const TString &qualifierType, const TSourceLoc& qualifierTypeLine);
     TLayoutQualifier parseLayoutQualifier(const TString &qualifierType, const TSourceLoc& qualifierTypeLine, const TString &intValueString, int intValue, const TSourceLoc& intValueLine);
@@ -138,7 +148,18 @@
     bool enterStructDeclaration(TSourceLoc line, const TString& identifier);
     void exitStructDeclaration();
 
-    bool structNestingErrorCheck(TSourceLoc line, const TType& fieldType);
+	bool structNestingErrorCheck(const TSourceLoc &line, const TField &field);
+
+	TIntermTyped *addUnaryMath(TOperator op, TIntermTyped *child, const TSourceLoc &loc);
+	TIntermTyped *addUnaryMathLValue(TOperator op, TIntermTyped *child, const TSourceLoc &loc);
+
+private:
+	// The funcReturnType parameter is expected to be non-null when the operation is a built-in function.
+	// It is expected to be null for other unary operators.
+	TIntermTyped *createUnaryMath(TOperator op, TIntermTyped *child, const TSourceLoc &loc, const TType *funcReturnType);
+
+	// Return true if the checks pass
+	bool binaryOpCommonCheck(TOperator op, TIntermTyped *left, TIntermTyped *right, const TSourceLoc &loc);
 };
 
 int PaParseStrings(int count, const char* const string[], const int length[],
diff --git a/src/OpenGL/compiler/SymbolTable.h b/src/OpenGL/compiler/SymbolTable.h
index 7895f59..96a21bc 100644
--- a/src/OpenGL/compiler/SymbolTable.h
+++ b/src/OpenGL/compiler/SymbolTable.h
@@ -193,7 +193,7 @@
 
     bool insert(TSymbol &symbol)
     {
-		symbol.setUniqueId(++uniqueId);
+		symbol.setUniqueId(nextUniqueId());
 
         //
         // returning true means symbol was added to the table
@@ -213,6 +213,11 @@
             return (*it).second;
     }
 
+	static int nextUniqueId()
+	{
+		return ++uniqueId;
+	}
+
 protected:
     tLevel level;
 	static int uniqueId;     // for unique identification in code generation
diff --git a/src/OpenGL/compiler/glslang.y b/src/OpenGL/compiler/glslang.y
index a145694..3b9124d 100644
--- a/src/OpenGL/compiler/glslang.y
+++ b/src/OpenGL/compiler/glslang.y
@@ -255,208 +255,19 @@
         $$ = $1;
     }
     | postfix_expression LEFT_BRACKET integer_expression RIGHT_BRACKET {
-        if (!$1->isArray() && !$1->isMatrix() && !$1->isVector()) {
-            if ($1->getAsSymbolNode())
-                context->error($2.line, " left of '[' is not of type array, matrix, or vector ", $1->getAsSymbolNode()->getSymbol().c_str());
-            else
-                context->error($2.line, " left of '[' is not of type array, matrix, or vector ", "expression");
-            context->recover();
-        }
-        if ($1->getType().getQualifier() == EvqConstExpr && $3->getQualifier() == EvqConstExpr) {
-            if ($1->isArray()) { // constant folding for arrays
-                $$ = context->addConstArrayNode($3->getAsConstantUnion()->getIConst(0), $1, $2.line);
-            } else if ($1->isVector()) {  // constant folding for vectors
-                TVectorFields fields;
-                fields.num = 1;
-                fields.offsets[0] = $3->getAsConstantUnion()->getIConst(0); // need to do it this way because v.xy sends fields integer array
-                $$ = context->addConstVectorNode(fields, $1, $2.line);
-            } else if ($1->isMatrix()) { // constant folding for matrices
-                $$ = context->addConstMatrixNode($3->getAsConstantUnion()->getIConst(0), $1, $2.line);
-            }
-        } else {
-            if ($3->getQualifier() == EvqConstExpr) {
-                if (($1->isVector() || $1->isMatrix()) && $1->getType().getNominalSize() <= $3->getAsConstantUnion()->getIConst(0) && !$1->isArray() ) {
-                    std::stringstream extraInfoStream;
-                    extraInfoStream << "field selection out of range '" << $3->getAsConstantUnion()->getIConst(0) << "'";
-                    std::string extraInfo = extraInfoStream.str();
-                    context->error($2.line, "", "[", extraInfo.c_str());
-                    context->recover();
-                } else {
-                    if ($1->isArray()) {
-                        if ($1->getType().getArraySize() == 0) {
-                            if ($1->getType().getMaxArraySize() <= $3->getAsConstantUnion()->getIConst(0)) {
-                                if (context->arraySetMaxSize($1->getAsSymbolNode(), $1->getTypePointer(), $3->getAsConstantUnion()->getIConst(0), true, $2.line))
-                                    context->recover();
-                            } else {
-                                if (context->arraySetMaxSize($1->getAsSymbolNode(), $1->getTypePointer(), 0, false, $2.line))
-                                    context->recover();
-                            }
-                        } else if ( $3->getAsConstantUnion()->getIConst(0) >= $1->getType().getArraySize()) {
-                            std::stringstream extraInfoStream;
-                            extraInfoStream << "array index out of range '" << $3->getAsConstantUnion()->getIConst(0) << "'";
-                            std::string extraInfo = extraInfoStream.str();
-                            context->error($2.line, "", "[", extraInfo.c_str());
-                            context->recover();
-                        }
-                    }
-                    $$ = context->intermediate.addIndex(EOpIndexDirect, $1, $3, $2.line);
-                }
-            } else {
-                if ($1->isArray() && $1->getType().getArraySize() == 0) {
-                    context->error($2.line, "", "[", "array must be redeclared with a size before being indexed with a variable");
-                    context->recover();
-                }
-
-                $$ = context->intermediate.addIndex(EOpIndexIndirect, $1, $3, $2.line);
-            }
-        }
-        if ($$ == 0) {
-            ConstantUnion *unionArray = new ConstantUnion[1];
-            unionArray->setFConst(0.0f);
-            $$ = context->intermediate.addConstantUnion(unionArray, TType(EbtFloat, EbpHigh, EvqConstExpr), $2.line);
-        } else if ($1->isArray()) {
-            if ($1->getType().getStruct())
-                $$->setType(TType($1->getType().getStruct()));
-            else
-                $$->setType(TType($1->getBasicType(), $1->getPrecision(), EvqTemporary, $1->getNominalSize(), $1->getSecondarySize()));
-
-            if ($1->getType().getQualifier() == EvqConstExpr)
-                $$->getTypePointer()->setQualifier(EvqConstExpr);
-        } else if ($1->isMatrix() && $1->getType().getQualifier() == EvqConstExpr)
-            $$->setType(TType($1->getBasicType(), $1->getPrecision(), EvqConstExpr, $1->getSecondarySize()));
-        else if ($1->isMatrix())
-            $$->setType(TType($1->getBasicType(), $1->getPrecision(), EvqTemporary, $1->getSecondarySize()));
-        else if ($1->isVector() && $1->getType().getQualifier() == EvqConstExpr)
-            $$->setType(TType($1->getBasicType(), $1->getPrecision(), EvqConstExpr));
-        else if ($1->isVector())
-            $$->setType(TType($1->getBasicType(), $1->getPrecision(), EvqTemporary));
-        else
-            $$->setType($1->getType());
+        $$ = context->addIndexExpression($1, $2.line, $3);
     }
     | function_call {
         $$ = $1;
     }
     | postfix_expression DOT FIELD_SELECTION {
-        if ($1->isArray()) {
-            context->error($3.line, "cannot apply dot operator to an array", ".");
-            context->recover();
-        }
-
-        if ($1->isVector()) {
-            TVectorFields fields;
-            if (! context->parseVectorFields(*$3.string, $1->getNominalSize(), fields, $3.line)) {
-                fields.num = 1;
-                fields.offsets[0] = 0;
-                context->recover();
-            }
-
-            if ($1->getType().getQualifier() == EvqConstExpr) { // constant folding for vector fields
-                $$ = context->addConstVectorNode(fields, $1, $3.line);
-                if ($$ == 0) {
-                    context->recover();
-                    $$ = $1;
-                }
-                else
-                    $$->setType(TType($1->getBasicType(), $1->getPrecision(), EvqConstExpr, (int) (*$3.string).size()));
-            } else {
-                TString vectorString = *$3.string;
-                TIntermTyped* index = context->intermediate.addSwizzle(fields, $3.line);
-                $$ = context->intermediate.addIndex(EOpVectorSwizzle, $1, index, $2.line);
-                $$->setType(TType($1->getBasicType(), $1->getPrecision(), EvqTemporary, (int) vectorString.size()));
-            }
-        } else if ($1->isMatrix()) {
-            TMatrixFields fields;
-            if (! context->parseMatrixFields(*$3.string, $1->getNominalSize(), $1->getSecondarySize(), fields, $3.line)) {
-                fields.wholeRow = false;
-                fields.wholeCol = false;
-                fields.row = 0;
-                fields.col = 0;
-                context->recover();
-            }
-
-            if (fields.wholeRow || fields.wholeCol) {
-                context->error($2.line, " non-scalar fields not implemented yet", ".");
-                context->recover();
-                ConstantUnion *unionArray = new ConstantUnion[1];
-                unionArray->setIConst(0);
-                TIntermTyped* index = context->intermediate.addConstantUnion(unionArray, TType(EbtInt, EbpUndefined, EvqConstExpr), $3.line);
-                $$ = context->intermediate.addIndex(EOpIndexDirect, $1, index, $2.line);
-                $$->setType(TType($1->getBasicType(), $1->getPrecision(),EvqTemporary, $1->getNominalSize()));
-            } else {
-                ConstantUnion *unionArray = new ConstantUnion[1];
-                unionArray->setIConst(fields.col * $1->getNominalSize() + fields.row);
-                TIntermTyped* index = context->intermediate.addConstantUnion(unionArray, TType(EbtInt, EbpUndefined, EvqConstExpr), $3.line);
-                $$ = context->intermediate.addIndex(EOpIndexDirect, $1, index, $2.line);
-                $$->setType(TType($1->getBasicType(), $1->getPrecision()));
-            }
-        } else if ($1->getBasicType() == EbtStruct) {
-            bool fieldFound = false;
-            const TStructure* structure = $1->getType().getStruct();
-            if (structure == 0) {
-                context->error($2.line, "structure has no fields", "Internal Error");
-                context->recover();
-                $$ = $1;
-            } else {
-                unsigned int i;
-                const TFieldList& fields = structure->fields();
-                for (i = 0; i < fields.size(); ++i) {
-                    if (fields[i]->name() == *$3.string) {
-                        fieldFound = true;
-                        break;
-                    }
-                }
-                if (fieldFound) {
-                    if ($1->getType().getQualifier() == EvqConstExpr) {
-                        $$ = context->addConstStruct(*$3.string, $1, $2.line);
-                        if ($$ == 0) {
-                            context->recover();
-                            $$ = $1;
-                        }
-                        else {
-                            $$->setType(*fields[i]->type());
-                            // change the qualifier of the return type, not of the structure field
-                            // as the structure definition is shared between various structures.
-                            $$->getTypePointer()->setQualifier(EvqConstExpr);
-                        }
-                    } else {
-                        ConstantUnion *unionArray = new ConstantUnion[1];
-                        unionArray->setIConst(i);
-                        TIntermTyped* index = context->intermediate.addConstantUnion(unionArray, *(fields[i]->type()), $3.line);
-                        $$ = context->intermediate.addIndex(EOpIndexDirectStruct, $1, index, $2.line);
-                        $$->setType(*fields[i]->type());
-                    }
-                } else {
-                    context->error($2.line, " no such field in structure", $3.string->c_str());
-                    context->recover();
-                    $$ = $1;
-                }
-            }
-        } else {
-            context->error($2.line, " field selection requires structure, vector, or matrix on left hand side", $3.string->c_str());
-            context->recover();
-            $$ = $1;
-        }
-        // don't delete $3.string, it's from the pool
+        $$ = context->addFieldSelectionExpression($1, $2.line, *$3.string, $3.line);
     }
     | postfix_expression INC_OP {
-        if (context->lValueErrorCheck($2.line, "++", $1))
-            context->recover();
-        $$ = context->intermediate.addUnaryMath(EOpPostIncrement, $1, $2.line);
-        if ($$ == 0) {
-            context->unaryOpError($2.line, "++", $1->getCompleteString());
-            context->recover();
-            $$ = $1;
-        }
+        $$ = context->addUnaryMathLValue(EOpPostIncrement, $1, $2.line);
     }
     | postfix_expression DEC_OP {
-        if (context->lValueErrorCheck($2.line, "--", $1))
-            context->recover();
-        $$ = context->intermediate.addUnaryMath(EOpPostDecrement, $1, $2.line);
-        if ($$ == 0) {
-            context->unaryOpError($2.line, "--", $1->getCompleteString());
-            context->recover();
-            $$ = $1;
-        }
+        $$ = context->addUnaryMathLValue(EOpPostDecrement, $1, $2.line);
     }
     ;
 
@@ -2005,25 +1816,10 @@
 
 struct_specifier
     : STRUCT IDENTIFIER LEFT_BRACE { if (context->enterStructDeclaration($2.line, *$2.string)) context->recover(); } struct_declaration_list RIGHT_BRACE {
-        if (context->reservedErrorCheck($2.line, *$2.string))
-            context->recover();
-
-        TType* structure = new TType(new TStructure($2.string, $5));
-        TVariable* userTypeDef = new TVariable($2.string, *structure, true);
-        if (! context->symbolTable.declare(*userTypeDef)) {
-            context->error($2.line, "redefinition", $2.string->c_str(), "struct");
-            context->recover();
-        }
-        $$.setBasic(EbtStruct, EvqTemporary, $1.line);
-        $$.userDef = structure;
-        context->exitStructDeclaration();
+        $$ = context->addStructure($1.line, $2.line, $2.string, $5);
     }
     | STRUCT LEFT_BRACE { if (context->enterStructDeclaration($2.line, *$2.string)) context->recover(); } struct_declaration_list RIGHT_BRACE {
-        TString emptyName("");
-        TType* structure = new TType(new TStructure(&emptyName, $4));
-        $$.setBasic(EbtStruct, EvqTemporary, $1.line);
-        $$.userDef = structure;
-        context->exitStructDeclaration();
+        $$ = context->addStructure($1.line, $1.line, NewPoolTString(""), $4);
     }
     ;
 
@@ -2048,32 +1844,13 @@
 
 struct_declaration
     : type_specifier struct_declarator_list SEMICOLON {
-        $$ = $2;
-
-        if (context->voidErrorCheck($1.line, (*$2)[0]->name(), $1)) {
-            context->recover();
-        }
-        for (unsigned int i = 0; i < $$->size(); ++i) {
-            //
-            // Careful not to replace already known aspects of type, like array-ness
-            //
-            TType* type = (*$$)[i]->type();
-            type->setBasicType($1.type);
-            type->setNominalSize($1.primarySize);
-            type->setSecondarySize($1.secondarySize);
-            type->setPrecision($1.precision);
-
-            // don't allow arrays of arrays
-            if (type->isArray()) {
-                if (context->arrayTypeErrorCheck($1.line, $1))
-                    context->recover();
-            }
-            if ($1.array)
-                type->setArraySize($1.arraySize);
-            if ($1.userDef) {
-                type->setStruct($1.userDef->getStruct());
-            }
-        }
+        $$ = context->addStructDeclaratorList($1, $2);
+    }
+    | type_qualifier type_specifier struct_declarator_list SEMICOLON {
+        // ES3 Only, but errors should be handled elsewhere
+        $2.qualifier = $1.qualifier;
+        $2.layoutQualifier = $1.layoutQualifier;
+        $$ = context->addStructDeclaratorList($2, $3);
     }
     ;
 
diff --git a/src/OpenGL/compiler/glslang_tab.cpp b/src/OpenGL/compiler/glslang_tab.cpp
index e2b3472..7f601e7 100644
--- a/src/OpenGL/compiler/glslang_tab.cpp
+++ b/src/OpenGL/compiler/glslang_tab.cpp
@@ -556,16 +556,16 @@
 /* YYFINAL -- State number of the termination state.  */
 #define YYFINAL  107
 /* YYLAST -- Last index in YYTABLE.  */
-#define YYLAST   2056
+#define YYLAST   2137
 
 /* YYNTOKENS -- Number of terminals.  */
 #define YYNTOKENS  128
 /* YYNNTS -- Number of nonterminals.  */
 #define YYNNTS  89
 /* YYNRULES -- Number of rules.  */
-#define YYNRULES  255
+#define YYNRULES  256
 /* YYNRULES -- Number of states.  */
-#define YYNSTATES  370
+#define YYNSTATES  374
 
 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */
 #define YYUNDEFTOK  2
@@ -643,12 +643,12 @@
      473,   475,   477,   479,   481,   483,   485,   487,   489,   491,
      493,   495,   497,   499,   501,   503,   505,   507,   509,   511,
      513,   515,   517,   518,   525,   526,   532,   534,   537,   541,
-     543,   547,   549,   554,   556,   558,   560,   562,   564,   566,
-     568,   570,   572,   575,   576,   577,   583,   585,   587,   588,
-     591,   592,   595,   598,   602,   604,   607,   609,   612,   618,
-     622,   624,   626,   631,   632,   639,   640,   649,   650,   658,
-     660,   662,   664,   665,   668,   672,   675,   678,   681,   685,
-     688,   690,   693,   695,   697,   698
+     546,   548,   552,   554,   559,   561,   563,   565,   567,   569,
+     571,   573,   575,   577,   580,   581,   582,   588,   590,   592,
+     593,   596,   597,   600,   603,   607,   609,   612,   614,   617,
+     623,   627,   629,   631,   636,   637,   644,   645,   654,   655,
+     663,   665,   667,   669,   670,   673,   677,   680,   683,   686,
+     690,   693,   695,   698,   700,   702,   703
 };
 
 /* YYRHS -- A `-1'-separated list of the rules' RHS.  */
@@ -708,54 +708,54 @@
       -1,    74,    -1,   181,    -1,    77,    -1,    -1,    54,    76,
      108,   182,   184,   109,    -1,    -1,    54,   108,   183,   184,
      109,    -1,   185,    -1,   184,   185,    -1,   174,   186,   114,
-      -1,   187,    -1,   186,   111,   187,    -1,    76,    -1,    76,
-     106,   157,   107,    -1,   154,    -1,   158,    -1,   192,    -1,
-     191,    -1,   189,    -1,   201,    -1,   202,    -1,   205,    -1,
-     212,    -1,   108,   109,    -1,    -1,    -1,   108,   193,   200,
-     194,   109,    -1,   199,    -1,   191,    -1,    -1,   197,   199,
-      -1,    -1,   198,   191,    -1,   108,   109,    -1,   108,   200,
-     109,    -1,   190,    -1,   200,   190,    -1,   114,    -1,   156,
-     114,    -1,    19,   104,   156,   105,   203,    -1,   196,    17,
-     196,    -1,   196,    -1,   156,    -1,   169,    76,   113,   188,
-      -1,    -1,    56,   104,   206,   204,   105,   195,    -1,    -1,
-      16,   207,   196,    56,   104,   156,   105,   114,    -1,    -1,
-      18,   104,   208,   209,   211,   105,   195,    -1,   201,    -1,
-     189,    -1,   204,    -1,    -1,   210,   114,    -1,   210,   114,
-     156,    -1,    15,   114,    -1,    14,   114,    -1,    21,   114,
-      -1,    21,   156,   114,    -1,    20,   114,    -1,   214,    -1,
-     213,   214,    -1,   215,    -1,   158,    -1,    -1,   159,   216,
-     199,    -1
+      -1,   172,   174,   186,   114,    -1,   187,    -1,   186,   111,
+     187,    -1,    76,    -1,    76,   106,   157,   107,    -1,   154,
+      -1,   158,    -1,   192,    -1,   191,    -1,   189,    -1,   201,
+      -1,   202,    -1,   205,    -1,   212,    -1,   108,   109,    -1,
+      -1,    -1,   108,   193,   200,   194,   109,    -1,   199,    -1,
+     191,    -1,    -1,   197,   199,    -1,    -1,   198,   191,    -1,
+     108,   109,    -1,   108,   200,   109,    -1,   190,    -1,   200,
+     190,    -1,   114,    -1,   156,   114,    -1,    19,   104,   156,
+     105,   203,    -1,   196,    17,   196,    -1,   196,    -1,   156,
+      -1,   169,    76,   113,   188,    -1,    -1,    56,   104,   206,
+     204,   105,   195,    -1,    -1,    16,   207,   196,    56,   104,
+     156,   105,   114,    -1,    -1,    18,   104,   208,   209,   211,
+     105,   195,    -1,   201,    -1,   189,    -1,   204,    -1,    -1,
+     210,   114,    -1,   210,   114,   156,    -1,    15,   114,    -1,
+      14,   114,    -1,    21,   114,    -1,    21,   156,   114,    -1,
+      20,   114,    -1,   214,    -1,   213,   214,    -1,   215,    -1,
+     158,    -1,    -1,   159,   216,   199,    -1
 };
 
 /* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
 static const yytype_uint16 yyrline[] =
 {
        0,   190,   190,   225,   228,   233,   238,   243,   248,   254,
-     257,   336,   339,   441,   451,   464,   472,   572,   575,   583,
-     587,   594,   598,   605,   611,   620,   628,   705,   712,   722,
-     725,   735,   745,   767,   768,   769,   770,   778,   779,   788,
-     797,   810,   811,   819,   830,   831,   840,   852,   853,   863,
-     873,   883,   896,   897,   907,   920,   921,   935,   936,   950,
-     951,   965,   966,   979,   980,   993,   994,  1007,  1008,  1025,
-    1026,  1039,  1040,  1041,  1042,  1044,  1045,  1046,  1048,  1050,
-    1052,  1054,  1059,  1062,  1073,  1081,  1108,  1113,  1123,  1161,
-    1164,  1171,  1179,  1200,  1221,  1232,  1261,  1266,  1276,  1281,
-    1291,  1294,  1297,  1300,  1306,  1313,  1316,  1338,  1356,  1380,
-    1403,  1407,  1425,  1433,  1465,  1485,  1573,  1583,  1589,  1592,
-    1598,  1604,  1611,  1620,  1629,  1632,  1635,  1642,  1646,  1653,
-    1657,  1662,  1667,  1677,  1687,  1696,  1706,  1713,  1716,  1719,
-    1725,  1732,  1735,  1741,  1744,  1747,  1753,  1756,  1771,  1775,
-    1779,  1783,  1787,  1791,  1796,  1801,  1806,  1811,  1816,  1821,
-    1826,  1831,  1836,  1841,  1846,  1851,  1857,  1863,  1869,  1875,
-    1881,  1887,  1893,  1899,  1905,  1910,  1915,  1924,  1929,  1934,
-    1939,  1944,  1949,  1954,  1959,  1964,  1969,  1974,  1979,  1984,
-    1989,  1994,  2007,  2007,  2021,  2021,  2031,  2034,  2050,  2081,
-    2085,  2091,  2098,  2113,  2117,  2121,  2122,  2128,  2129,  2130,
-    2131,  2132,  2136,  2137,  2137,  2137,  2147,  2148,  2152,  2152,
-    2153,  2153,  2158,  2161,  2171,  2174,  2180,  2181,  2185,  2193,
-    2197,  2207,  2212,  2229,  2229,  2234,  2234,  2241,  2241,  2249,
-    2252,  2258,  2261,  2267,  2271,  2278,  2285,  2292,  2299,  2310,
-    2319,  2323,  2330,  2333,  2339,  2339
+     257,   260,   263,   266,   269,   275,   283,   383,   386,   394,
+     398,   405,   409,   416,   422,   431,   439,   516,   523,   533,
+     536,   546,   556,   578,   579,   580,   581,   589,   590,   599,
+     608,   621,   622,   630,   641,   642,   651,   663,   664,   674,
+     684,   694,   707,   708,   718,   731,   732,   746,   747,   761,
+     762,   776,   777,   790,   791,   804,   805,   818,   819,   836,
+     837,   850,   851,   852,   853,   855,   856,   857,   859,   861,
+     863,   865,   870,   873,   884,   892,   919,   924,   934,   972,
+     975,   982,   990,  1011,  1032,  1043,  1072,  1077,  1087,  1092,
+    1102,  1105,  1108,  1111,  1117,  1124,  1127,  1149,  1167,  1191,
+    1214,  1218,  1236,  1244,  1276,  1296,  1384,  1394,  1400,  1403,
+    1409,  1415,  1422,  1431,  1440,  1443,  1446,  1453,  1457,  1464,
+    1468,  1473,  1478,  1488,  1498,  1507,  1517,  1524,  1527,  1530,
+    1536,  1543,  1546,  1552,  1555,  1558,  1564,  1567,  1582,  1586,
+    1590,  1594,  1598,  1602,  1607,  1612,  1617,  1622,  1627,  1632,
+    1637,  1642,  1647,  1652,  1657,  1662,  1668,  1674,  1680,  1686,
+    1692,  1698,  1704,  1710,  1716,  1721,  1726,  1735,  1740,  1745,
+    1750,  1755,  1760,  1765,  1770,  1775,  1780,  1785,  1790,  1795,
+    1800,  1805,  1818,  1818,  1821,  1821,  1827,  1830,  1846,  1849,
+    1858,  1862,  1868,  1875,  1890,  1894,  1898,  1899,  1905,  1906,
+    1907,  1908,  1909,  1913,  1914,  1914,  1914,  1924,  1925,  1929,
+    1929,  1930,  1930,  1935,  1938,  1948,  1951,  1957,  1958,  1962,
+    1970,  1974,  1984,  1989,  2006,  2006,  2011,  2011,  2018,  2018,
+    2026,  2029,  2035,  2038,  2044,  2048,  2055,  2062,  2069,  2076,
+    2087,  2096,  2100,  2107,  2110,  2116,  2116
 };
 #endif
 
@@ -864,13 +864,13 @@
      180,   180,   180,   180,   180,   180,   180,   180,   180,   180,
      180,   180,   180,   180,   180,   180,   180,   180,   180,   180,
      180,   180,   180,   180,   180,   180,   180,   180,   180,   180,
-     180,   180,   182,   181,   183,   181,   184,   184,   185,   186,
-     186,   187,   187,   188,   189,   190,   190,   191,   191,   191,
-     191,   191,   192,   193,   194,   192,   195,   195,   197,   196,
-     198,   196,   199,   199,   200,   200,   201,   201,   202,   203,
-     203,   204,   204,   206,   205,   207,   205,   208,   205,   209,
-     209,   210,   210,   211,   211,   212,   212,   212,   212,   212,
-     213,   213,   214,   214,   216,   215
+     180,   180,   182,   181,   183,   181,   184,   184,   185,   185,
+     186,   186,   187,   187,   188,   189,   190,   190,   191,   191,
+     191,   191,   191,   192,   193,   194,   192,   195,   195,   197,
+     196,   198,   196,   199,   199,   200,   200,   201,   201,   202,
+     203,   203,   204,   204,   206,   205,   207,   205,   208,   205,
+     209,   209,   210,   210,   211,   211,   212,   212,   212,   212,
+     212,   213,   213,   214,   214,   216,   215
 };
 
 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
@@ -895,19 +895,19 @@
        1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
        1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
        1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
-       1,     1,     0,     6,     0,     5,     1,     2,     3,     1,
-       3,     1,     4,     1,     1,     1,     1,     1,     1,     1,
-       1,     1,     2,     0,     0,     5,     1,     1,     0,     2,
-       0,     2,     2,     3,     1,     2,     1,     2,     5,     3,
-       1,     1,     4,     0,     6,     0,     8,     0,     7,     1,
-       1,     1,     0,     2,     3,     2,     2,     2,     3,     2,
-       1,     2,     1,     1,     0,     3
+       1,     1,     0,     6,     0,     5,     1,     2,     3,     4,
+       1,     3,     1,     4,     1,     1,     1,     1,     1,     1,
+       1,     1,     1,     2,     0,     0,     5,     1,     1,     0,
+       2,     0,     2,     2,     3,     1,     2,     1,     2,     5,
+       3,     1,     1,     4,     0,     6,     0,     8,     0,     7,
+       1,     1,     1,     0,     2,     3,     2,     2,     2,     3,
+       2,     1,     2,     1,     1,     0,     3
 };
 
 /* 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 yytype_uint8 yydefact[] =
+static const yytype_uint16 yydefact[] =
 {
        0,     0,   137,   138,   139,     0,   121,   129,   152,   149,
      150,   151,   156,   157,   158,   159,   160,   161,   153,   154,
@@ -915,229 +915,270 @@
      122,   168,   169,   170,   171,   172,   173,     0,   119,   118,
        0,   148,   174,   175,   176,   178,   179,   180,   181,   182,
      183,   184,   185,   186,   177,   187,   188,   189,     0,   191,
-     253,   254,     0,    90,   100,     0,   105,   110,   126,     0,
-     124,   116,     0,   127,   135,   146,   190,     0,   250,   252,
+     254,   255,     0,    90,   100,     0,   105,   110,   126,     0,
+     124,   116,     0,   127,   135,   146,   190,     0,   251,   253,
      123,   115,     0,   132,   133,     0,   194,     0,    85,     0,
       88,   100,   120,   101,   102,   103,    91,     0,   100,     0,
-      86,   111,   125,   117,   136,   128,     0,     1,   251,     0,
-     192,     0,   143,     0,   141,     0,   255,    92,    97,    99,
+      86,   111,   125,   117,   136,   128,     0,     1,   252,     0,
+     192,     0,   143,     0,   141,     0,   256,    92,    97,    99,
      104,     0,   106,    93,     0,     0,     2,     6,     4,     5,
        7,    28,     0,     0,     0,    35,    34,    36,    33,     3,
        9,    29,    11,    16,    17,     0,     0,    22,     0,    37,
        0,    41,    44,    47,    52,    55,    57,    59,    61,    63,
-      65,    67,    84,     0,    26,    87,     0,     0,     0,   196,
-       0,   140,     0,     0,     0,   235,     0,     0,     0,     0,
-       0,   213,   222,   226,    37,    69,    82,     0,   204,     0,
-     146,   207,   224,   206,   205,     0,   208,   209,   210,   211,
-      94,    96,    98,     0,     0,   112,     0,   203,   114,    30,
-      31,     0,    13,    14,     0,     0,    20,    19,     0,    21,
-      23,    25,    32,     0,     0,     0,     0,     0,     0,     0,
+      65,    67,    84,     0,    26,    87,     0,     0,     0,     0,
+       0,   196,     0,   140,     0,     0,     0,   236,     0,     0,
+       0,     0,     0,   214,   223,   227,    37,    69,    82,     0,
+     205,     0,   146,   208,   225,   207,   206,     0,   209,   210,
+     211,   212,    94,    96,    98,     0,     0,   112,     0,   204,
+     114,    30,    31,     0,    13,    14,     0,     0,    20,    19,
+       0,    21,    23,    25,    32,     0,     0,     0,     0,     0,
        0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
-       0,     0,     0,   147,     0,   201,     0,   199,   195,   197,
-     144,   145,   142,   246,   245,   220,   237,     0,   249,   247,
-       0,   233,   212,     0,    72,    73,    75,    74,    77,    78,
-      79,    80,    81,    76,    71,     0,     0,   227,   223,   225,
-       0,   107,     0,   109,   113,     8,     0,    15,    27,    12,
-      18,    24,    38,    39,    40,    43,    42,    45,    46,    50,
-      51,    48,    49,    53,    54,    56,    58,    60,    62,    64,
-      66,     0,   193,     0,     0,   198,     0,     0,     0,     0,
-       0,   248,     0,   214,    70,    83,     0,   108,    10,     0,
-       0,   200,     0,   219,   221,   240,   239,   242,   220,     0,
-     231,     0,     0,     0,    95,    68,   202,     0,   241,     0,
-       0,   230,   228,     0,     0,   215,     0,   243,     0,   220,
-       0,   217,   234,   216,     0,   244,   238,   229,   232,   236
+       0,     0,     0,     0,     0,   147,     0,     0,   202,     0,
+     200,   195,   197,   144,   145,   142,   247,   246,   221,   238,
+       0,   250,   248,     0,   234,   213,     0,    72,    73,    75,
+      74,    77,    78,    79,    80,    81,    76,    71,     0,     0,
+     228,   224,   226,     0,   107,     0,   109,   113,     8,     0,
+      15,    27,    12,    18,    24,    38,    39,    40,    43,    42,
+      45,    46,    50,    51,    48,    49,    53,    54,    56,    58,
+      60,    62,    64,    66,     0,   193,     0,     0,     0,   198,
+       0,     0,     0,     0,     0,   249,     0,   215,    70,    83,
+       0,   108,    10,     0,   199,     0,   201,     0,   220,   222,
+     241,   240,   243,   221,   232,     0,     0,     0,    95,    68,
+     203,     0,   242,     0,     0,   231,   229,     0,     0,   216,
+       0,   244,     0,   221,     0,   218,   235,   217,     0,   245,
+     239,   230,   233,   237
 };
 
 /* YYDEFGOTO[NTERM-NUM].  */
 static const yytype_int16 yydefgoto[] =
 {
-      -1,   139,   140,   141,   286,   142,   143,   144,   145,   146,
-     147,   148,   184,   150,   151,   152,   153,   154,   155,   156,
-     157,   158,   159,   160,   161,   185,   186,   275,   187,   163,
-     188,   189,    62,    63,    64,   118,    96,    97,   119,    65,
+      -1,   139,   140,   141,   289,   142,   143,   144,   145,   146,
+     147,   148,   186,   150,   151,   152,   153,   154,   155,   156,
+     157,   158,   159,   160,   161,   187,   188,   278,   189,   163,
+     190,   191,    62,    63,    64,   118,    96,    97,   119,    65,
       66,    67,    68,    98,    69,    70,    71,    72,    73,   113,
-     114,    74,   164,    76,   166,   111,   168,   169,   246,   247,
-     208,   191,   192,   193,   194,   263,   343,   362,   316,   317,
-     318,   363,   195,   196,   197,   352,   342,   198,   322,   255,
-     319,   337,   349,   350,   199,    77,    78,    79,    89
+     114,    74,   164,    76,   166,   111,   170,   171,   249,   250,
+     210,   193,   194,   195,   196,   266,   347,   366,   320,   321,
+     322,   367,   197,   198,   199,   356,   346,   200,   326,   258,
+     323,   342,   353,   354,   201,    77,    78,    79,    89
 };
 
 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
    STATE-NUM.  */
-#define YYPACT_NINF -324
+#define YYPACT_NINF -316
 static const yytype_int16 yypact[] =
 {
-    1769,   -31,  -324,  -324,  -324,   144,  -324,  -324,  -324,  -324,
-    -324,  -324,  -324,  -324,  -324,  -324,  -324,  -324,  -324,  -324,
-    -324,  -324,  -324,  -324,  -324,  -324,  -324,  -324,  -324,  -324,
-    -324,  -324,  -324,  -324,  -324,  -324,  -324,    69,  -324,  -324,
-     -60,  -324,  -324,  -324,  -324,  -324,  -324,  -324,  -324,  -324,
-    -324,  -324,  -324,  -324,  -324,  -324,  -324,  -324,   -82,  -324,
-    -324,   -88,   -52,   -48,     1,   -23,  -324,     2,    11,  1843,
-    -324,  -324,  1979,    11,  -324,    -7,  -324,  1694,  -324,  -324,
-    -324,  -324,  1979,  -324,  -324,    18,  -324,    31,  -324,    59,
-    -324,    78,  -324,  -324,  -324,  -324,  -324,  1843,   113,    85,
-    -324,   -79,  -324,  -324,  -324,  -324,  1419,  -324,  -324,    55,
-    -324,  1843,    61,   -55,  -324,   356,  -324,  -324,  -324,  -324,
-     102,  1843,   -67,  -324,  1128,  1419,    75,  -324,  -324,  -324,
-    -324,  -324,  1419,  1419,  1419,  -324,  -324,  -324,  -324,  -324,
-    -324,   -27,  -324,  -324,  -324,    76,   -44,  1514,    79,  -324,
-    1419,    37,   -45,    30,   -57,    27,    56,    62,    60,    95,
-      96,   -83,  -324,    81,  -324,  -324,  1843,   114,   243,  -324,
-      80,  -324,    31,    77,    83,  -324,    89,    90,    84,  1226,
-      97,    91,  -324,  -324,   230,  -324,  -324,   -19,  -324,   -88,
-      -1,  -324,  -324,  -324,  -324,   472,  -324,  -324,  -324,  -324,
-      93,  -324,  -324,  1321,  1419,  -324,    99,  -324,  -324,  -324,
-    -324,   -37,  -324,  -324,  1419,  1911,  -324,  -324,  1419,    98,
-    -324,  -324,  -324,  1419,  1419,  1419,  1419,  1419,  1419,  1419,
-    1419,  1419,  1419,  1419,  1419,  1419,  1419,  1419,  1419,  1419,
-    1419,  1419,  1419,  -324,  1609,   103,   -18,  -324,  -324,  -324,
-    -324,  -324,  -324,  -324,  -324,   100,  -324,  1419,  -324,  -324,
-     -13,  -324,  -324,   588,  -324,  -324,  -324,  -324,  -324,  -324,
-    -324,  -324,  -324,  -324,  -324,  1419,  1419,  -324,  -324,  -324,
-    1419,  -324,   104,  -324,  -324,  -324,   105,    92,  -324,   109,
-    -324,  -324,  -324,  -324,  -324,    37,    37,   -45,   -45,    30,
-      30,    30,    30,   -57,   -57,    27,    56,    62,    60,    95,
-      96,    53,  -324,  1419,   114,  -324,   148,    59,   820,   936,
-     -35,  -324,  1033,   588,  -324,  -324,   107,  -324,  -324,  1419,
-     108,  -324,   112,  -324,  -324,  -324,  -324,  1033,   100,   175,
-      92,   145,   115,   116,  -324,  -324,  -324,  1419,  -324,   110,
-     117,   206,  -324,   118,   704,  -324,   -30,  1419,   704,   100,
-    1419,  -324,  -324,  -324,   119,    92,  -324,  -324,  -324,  -324
+    1775,   -35,  -316,  -316,  -316,   149,  -316,  -316,  -316,  -316,
+    -316,  -316,  -316,  -316,  -316,  -316,  -316,  -316,  -316,  -316,
+    -316,  -316,  -316,  -316,  -316,  -316,  -316,  -316,  -316,  -316,
+    -316,  -316,  -316,  -316,  -316,  -316,  -316,    55,  -316,  -316,
+     -61,  -316,  -316,  -316,  -316,  -316,  -316,  -316,  -316,  -316,
+    -316,  -316,  -316,  -316,  -316,  -316,  -316,  -316,   -78,  -316,
+    -316,   -51,   -40,   -30,     2,    -9,  -316,    27,    15,  1924,
+    -316,  -316,  2060,    15,  -316,   -15,  -316,  1700,  -316,  -316,
+    -316,  -316,  2060,  -316,  -316,     1,  -316,    53,  -316,    23,
+    -316,    20,  -316,  -316,  -316,  -316,  -316,  1924,   118,    88,
+    -316,   -68,  -316,  -316,  -316,  -316,  1423,  -316,  -316,   -38,
+    -316,  1850,    54,   -41,  -316,   360,  -316,  -316,  -316,  -316,
+      93,  1924,   -79,  -316,  1132,  1423,    74,  -316,  -316,  -316,
+    -316,  -316,  1423,  1423,  1423,  -316,  -316,  -316,  -316,  -316,
+    -316,   -18,  -316,  -316,  -316,    82,   -32,  1518,    87,  -316,
+    1423,    52,   -86,    78,   -70,    85,    66,    68,    70,   104,
+     105,   -73,  -316,   103,  -316,  -316,  1850,   170,  1924,   139,
+     244,  -316,    97,  -316,    53,   102,   108,  -316,   113,   114,
+     109,  1230,   116,   117,  -316,  -316,   106,  -316,  -316,    -1,
+    -316,   -51,    22,  -316,  -316,  -316,  -316,   476,  -316,  -316,
+    -316,  -316,   119,  -316,  -316,  1325,  1423,  -316,   120,  -316,
+    -316,  -316,  -316,   -31,  -316,  -316,  1423,  1992,  -316,  -316,
+    1423,   124,  -316,  -316,  -316,  1423,  1423,  1423,  1423,  1423,
+    1423,  1423,  1423,  1423,  1423,  1423,  1423,  1423,  1423,  1423,
+    1423,  1423,  1423,  1423,  1423,  -316,  1615,   139,   123,     9,
+    -316,  -316,  -316,  -316,  -316,  -316,  -316,  -316,   122,  -316,
+    1423,  -316,  -316,    11,  -316,  -316,   592,  -316,  -316,  -316,
+    -316,  -316,  -316,  -316,  -316,  -316,  -316,  -316,  1423,  1423,
+    -316,  -316,  -316,  1423,  -316,   125,  -316,  -316,  -316,   127,
+     126,  -316,   131,  -316,  -316,  -316,  -316,  -316,    52,    52,
+     -86,   -86,    78,    78,    78,    78,   -70,   -70,    85,    66,
+      68,    70,   104,   105,    69,  -316,    13,  1423,   139,  -316,
+     180,    23,   824,   940,   -12,  -316,  1037,   592,  -316,  -316,
+     132,  -316,  -316,  1423,  -316,   133,  -316,   134,  -316,  -316,
+    -316,  -316,  1037,   122,   126,   165,   138,   135,  -316,  -316,
+    -316,  1423,  -316,   137,   140,   241,  -316,   146,   708,  -316,
+     -11,  1423,   708,   122,  1423,  -316,  -316,  -316,   147,   126,
+    -316,  -316,  -316,  -316
 };
 
 /* YYPGOTO[NTERM-NUM].  */
 static const yytype_int16 yypgoto[] =
 {
-    -324,  -324,  -324,  -324,  -324,  -324,  -324,    13,  -324,  -324,
-    -324,  -324,   -95,  -324,   -56,   -53,  -108,   -62,   -10,    -8,
-      -6,    -5,    -3,    -2,  -324,  -103,  -124,  -324,  -130,  -117,
-       8,    12,  -324,  -324,  -324,   120,   147,   137,   121,  -324,
-    -324,  -305,  -324,  -324,  -324,   -33,   -64,   235,  -324,  -324,
-      71,   -54,     0,  -324,  -324,  -324,    86,  -154,  -324,   -69,
-    -198,   -73,  -176,  -294,  -324,  -324,  -324,  -107,  -323,  -324,
-    -324,   -87,    -4,   -61,  -324,  -324,   -80,  -324,  -324,  -324,
-    -324,  -324,  -324,  -324,  -324,  -324,   173,  -324,  -324
+    -316,  -316,  -316,  -316,  -316,  -316,  -316,    43,  -316,  -316,
+    -316,  -316,   -93,  -316,   -46,   -45,  -116,   -48,    24,    25,
+      28,    26,    21,    57,  -316,  -104,  -122,  -316,  -130,  -118,
+       8,    12,  -316,  -316,  -316,   144,   195,   206,   194,  -316,
+    -316,  -305,  -316,  -316,   -95,    10,   -62,   315,  -316,  -316,
+     150,   -49,     0,  -316,  -316,  -316,   159,  -156,    81,    14,
+    -201,     6,  -175,  -312,  -316,  -316,  -316,   -29,  -315,  -316,
+    -316,   -88,    64,    16,  -316,  -316,    -8,  -316,  -316,  -316,
+    -316,  -316,  -316,  -316,  -316,  -316,   254,  -316,  -316
 };
 
 /* 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 -219
+#define YYTABLE_NINF -220
 static const yytype_int16 yytable[] =
 {
-      75,   207,   116,   162,   211,   103,   283,   206,    60,   241,
-      92,   149,    61,    80,   249,   351,    85,   341,   104,   279,
-       7,   162,    87,   220,   334,   123,    88,   124,   109,   149,
-     230,   231,   341,   120,   125,   102,   367,   209,   210,   203,
-     105,    93,    94,    95,   242,    81,   204,   167,    86,   260,
-     171,    27,    28,    90,    29,   222,   172,   120,   212,   213,
-     361,   217,    37,    91,   361,   232,   233,   218,   285,    75,
-     338,   226,    75,   227,   276,   364,   276,    75,   101,   214,
-     207,   276,    75,   215,   287,    60,   282,    92,    99,    61,
-     249,   100,   276,   314,   291,   277,   315,    75,   276,   106,
-     162,   321,   167,   -26,   167,   106,   -89,   112,   149,    83,
-      84,    75,   311,   228,   229,   190,   234,   235,    93,    94,
-      95,    75,   299,   300,   301,   302,   110,   320,   292,   293,
-     294,   149,   149,   149,   149,   149,   149,   149,   149,   149,
-     149,   149,   149,   149,   149,   149,   149,   279,     2,     3,
-       4,   324,   325,    93,    94,    95,   223,   224,   225,   250,
-     251,   122,   368,   326,   276,   329,    75,   115,    75,   165,
-     295,   296,   303,   304,   170,   297,   298,   162,   200,   -27,
-     167,   216,   236,   221,   238,   149,   239,   237,   243,   240,
-     245,   253,   340,   256,   257,   190,   330,   254,   258,   280,
-     262,   261,  -148,   276,   332,   345,   284,   340,  -218,   313,
-     162,   327,   328,   -28,   344,   346,   347,   356,   149,    80,
-     354,   353,   358,   359,   357,   355,   305,   365,   290,   306,
-     333,   360,   307,   369,   308,   121,   207,   309,   117,   310,
-      82,   201,   202,   252,    75,   331,   335,     2,     3,     4,
-     108,   366,   244,     8,     9,    10,    11,   348,   336,   323,
-       0,     0,     0,   190,     0,     0,     0,     0,    12,    13,
-      14,    15,    16,    17,    18,    19,    20,    21,    22,    23,
-      24,    25,    26,     0,     0,     0,     0,     0,    31,    32,
-      33,    34,    35,    36,     0,     0,     0,    40,    41,     0,
-      42,    43,    44,     0,    45,    46,    47,    48,    49,    50,
-      51,    52,    53,    54,     0,    55,    56,    57,   190,   190,
-      59,     0,   190,   190,   264,   265,   266,   267,   268,   269,
-     270,   271,   272,   273,     0,     0,     0,   190,     0,     0,
-       0,     0,     0,   274,     0,     0,     0,     0,     0,     0,
-       0,     0,   248,     0,   190,     0,     0,     0,   190,     1,
+      75,   116,   162,   209,   213,   286,   208,   103,    60,    80,
+     339,    92,    61,   149,   252,    85,   168,   232,   233,   243,
+     162,   345,   282,   104,     7,   222,    87,   205,   355,    92,
+     228,   149,   229,   109,   206,   120,   123,   345,   124,   211,
+     212,    81,    93,    94,    95,   125,   365,    86,   371,   169,
+     365,   263,   234,   235,   244,    27,    28,   224,    29,   120,
+      93,    94,    95,    88,   173,    90,    37,   214,   215,    75,
+     174,   168,    75,   219,   288,   168,   165,    75,   102,   220,
+     279,    91,    75,   105,   209,    60,   290,   285,   216,    61,
+     252,   106,   217,   343,   368,    83,    84,    75,   294,   279,
+     279,   162,    99,   101,   169,   100,   247,   -89,   169,   110,
+     279,    75,   149,   280,   314,   192,   302,   303,   304,   305,
+     318,    75,   279,   319,   318,   325,   -26,   334,   106,   112,
+     324,   115,   295,   296,   297,   149,   149,   149,   149,   149,
+     149,   149,   149,   149,   149,   149,   149,   149,   149,   149,
+     149,   168,   282,     2,     3,     4,   328,   329,    93,    94,
+      95,   230,   231,   372,   122,   330,    75,   172,    75,   202,
+      75,   225,   226,   227,   236,   237,   253,   254,   -27,   162,
+     279,   333,   298,   299,   169,   300,   301,   218,   306,   307,
+     149,   223,   238,   239,   240,   241,   344,   192,   242,   335,
+     267,   268,   269,   270,   271,   272,   273,   274,   275,   276,
+     245,   349,   344,   162,    80,   248,   256,   259,   260,   277,
+     264,   360,   257,   261,   149,   283,   265,   287,  -148,   317,
+    -219,   369,   331,   338,   332,   -28,   337,   279,   351,   348,
+     350,   357,   209,   358,   359,   362,    75,   167,     2,     3,
+       4,   361,     6,     7,     8,     9,    10,    11,   363,   364,
+     293,   373,   308,   312,   309,   203,   192,   311,   310,    12,
+      13,    14,    15,    16,    17,    18,    19,    20,    21,    22,
+      23,    24,    25,    26,    27,    28,   117,    29,    30,    31,
+      32,    33,    34,    35,    36,    37,    38,    39,    40,    41,
+     313,    42,    43,    44,   121,    45,    46,    47,    48,    49,
+      50,    51,    52,    53,    54,   204,    55,    56,    57,    58,
+      82,    59,   192,   192,   255,   246,   192,   192,   316,   340,
+     327,   108,   336,   370,   352,     0,     0,     0,     0,   341,
+       0,     0,   192,     0,     0,     0,     0,     0,     0,     0,
+       0,     0,     0,   251,     0,     0,     0,     0,   192,     0,
+       0,     0,   192,     1,     2,     3,     4,     5,     6,     7,
+       8,     9,    10,    11,   175,   176,   177,     0,   178,   179,
+     180,   181,     0,     0,     0,    12,    13,    14,    15,    16,
+      17,    18,    19,    20,    21,    22,    23,    24,    25,    26,
+      27,    28,     0,    29,    30,    31,    32,    33,    34,    35,
+      36,    37,    38,    39,    40,    41,   182,    42,    43,    44,
+       0,    45,    46,    47,    48,    49,    50,    51,    52,    53,
+      54,     0,    55,    56,    57,    58,   126,    59,   127,   128,
+     129,   130,   131,     0,     0,   132,   133,     0,     0,     0,
+       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+       0,     0,     0,     0,   134,     0,     0,     0,   183,   184,
+       0,     0,     0,     0,   185,   135,   136,   137,   138,     1,
        2,     3,     4,     5,     6,     7,     8,     9,    10,    11,
-     173,   174,   175,     0,   176,   177,   178,   179,     0,     0,
+     175,   176,   177,     0,   178,   179,   180,   181,     0,     0,
        0,    12,    13,    14,    15,    16,    17,    18,    19,    20,
       21,    22,    23,    24,    25,    26,    27,    28,     0,    29,
       30,    31,    32,    33,    34,    35,    36,    37,    38,    39,
-      40,    41,   180,    42,    43,    44,     0,    45,    46,    47,
+      40,    41,   182,    42,    43,    44,     0,    45,    46,    47,
       48,    49,    50,    51,    52,    53,    54,     0,    55,    56,
       57,    58,   126,    59,   127,   128,   129,   130,   131,     0,
        0,   132,   133,     0,     0,     0,     0,     0,     0,     0,
        0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
-     134,     0,     0,     0,   181,   182,     0,     0,     0,     0,
-     183,   135,   136,   137,   138,     1,     2,     3,     4,     5,
-       6,     7,     8,     9,    10,    11,   173,   174,   175,     0,
-     176,   177,   178,   179,     0,     0,     0,    12,    13,    14,
+     134,     0,     0,     0,   183,   281,     0,     0,     0,     0,
+     185,   135,   136,   137,   138,     1,     2,     3,     4,     5,
+       6,     7,     8,     9,    10,    11,   175,   176,   177,     0,
+     178,   179,   180,   181,     0,     0,     0,    12,    13,    14,
       15,    16,    17,    18,    19,    20,    21,    22,    23,    24,
       25,    26,    27,    28,     0,    29,    30,    31,    32,    33,
-      34,    35,    36,    37,    38,    39,    40,    41,   180,    42,
+      34,    35,    36,    37,    38,    39,    40,    41,   182,    42,
       43,    44,     0,    45,    46,    47,    48,    49,    50,    51,
       52,    53,    54,     0,    55,    56,    57,    58,   126,    59,
      127,   128,   129,   130,   131,     0,     0,   132,   133,     0,
        0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
        0,     0,     0,     0,     0,     0,   134,     0,     0,     0,
-     181,   278,     0,     0,     0,     0,   183,   135,   136,   137,
+     183,     0,     0,     0,     0,     0,   185,   135,   136,   137,
      138,     1,     2,     3,     4,     5,     6,     7,     8,     9,
-      10,    11,   173,   174,   175,     0,   176,   177,   178,   179,
+      10,    11,   175,   176,   177,     0,   178,   179,   180,   181,
        0,     0,     0,    12,    13,    14,    15,    16,    17,    18,
       19,    20,    21,    22,    23,    24,    25,    26,    27,    28,
        0,    29,    30,    31,    32,    33,    34,    35,    36,    37,
-      38,    39,    40,    41,   180,    42,    43,    44,     0,    45,
+      38,    39,    40,    41,   182,    42,    43,    44,     0,    45,
       46,    47,    48,    49,    50,    51,    52,    53,    54,     0,
       55,    56,    57,    58,   126,    59,   127,   128,   129,   130,
      131,     0,     0,   132,   133,     0,     0,     0,     0,     0,
        0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
-       0,     0,   134,     0,     0,     0,   181,     0,     0,     0,
-       0,     0,   183,   135,   136,   137,   138,     1,     2,     3,
-       4,     5,     6,     7,     8,     9,    10,    11,   173,   174,
-     175,     0,   176,   177,   178,   179,     0,     0,     0,    12,
+       0,     0,   134,     0,     0,     0,   115,     0,     0,     0,
+       0,     0,   185,   135,   136,   137,   138,     1,     2,     3,
+       4,     5,     6,     7,     8,     9,    10,    11,   175,   176,
+     177,     0,   178,   179,   180,   181,     0,     0,     0,    12,
       13,    14,    15,    16,    17,    18,    19,    20,    21,    22,
       23,    24,    25,    26,    27,    28,     0,    29,    30,    31,
       32,    33,    34,    35,    36,    37,    38,    39,    40,    41,
-     180,    42,    43,    44,     0,    45,    46,    47,    48,    49,
+     182,    42,    43,    44,     0,    45,    46,    47,    48,    49,
       50,    51,    52,    53,    54,     0,    55,    56,    57,    58,
      126,    59,   127,   128,   129,   130,   131,     0,     0,   132,
      133,     0,     0,     0,     0,     0,     0,     0,     0,     0,
        0,     0,     0,     0,     0,     0,     0,     0,   134,     0,
-       0,     0,   115,     0,     0,     0,     0,     0,   183,   135,
+       0,     0,     0,     0,     0,     0,     0,     0,   185,   135,
      136,   137,   138,     1,     2,     3,     4,     5,     6,     7,
-       8,     9,    10,    11,   173,   174,   175,     0,   176,   177,
-     178,   179,     0,     0,     0,    12,    13,    14,    15,    16,
+       8,     9,    10,    11,     0,     0,     0,     0,     0,     0,
+       0,     0,     0,     0,     0,    12,    13,    14,    15,    16,
       17,    18,    19,    20,    21,    22,    23,    24,    25,    26,
       27,    28,     0,    29,    30,    31,    32,    33,    34,    35,
-      36,    37,    38,    39,    40,    41,   180,    42,    43,    44,
+      36,    37,    38,    39,    40,    41,     0,    42,    43,    44,
        0,    45,    46,    47,    48,    49,    50,    51,    52,    53,
       54,     0,    55,    56,    57,    58,   126,    59,   127,   128,
      129,   130,   131,     0,     0,   132,   133,     0,     0,     0,
        0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
-       0,     0,     0,     0,   134,     0,     0,     0,     0,     0,
-       0,     0,     0,     0,   183,   135,   136,   137,   138,     1,
-       2,     3,     4,     5,     6,     7,     8,     9,    10,    11,
+     167,     2,     3,     4,   134,     6,     7,     8,     9,    10,
+      11,     0,     0,     0,   185,   135,   136,   137,   138,     0,
+       0,     0,    12,    13,    14,    15,    16,    17,    18,    19,
+      20,    21,    22,    23,    24,    25,    26,    27,    28,     0,
+      29,    30,    31,    32,    33,    34,    35,    36,    37,    38,
+      39,    40,    41,     0,    42,    43,    44,     0,    45,    46,
+      47,    48,    49,    50,    51,    52,    53,    54,     0,    55,
+      56,    57,    58,   126,    59,   127,   128,   129,   130,   131,
+       0,     0,   132,   133,     0,     0,     0,     0,     0,     0,
        0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
-       0,    12,    13,    14,    15,    16,    17,    18,    19,    20,
-      21,    22,    23,    24,    25,    26,    27,    28,     0,    29,
-      30,    31,    32,    33,    34,    35,    36,    37,    38,    39,
-      40,    41,     0,    42,    43,    44,     0,    45,    46,    47,
-      48,    49,    50,    51,    52,    53,    54,     0,    55,    56,
-      57,    58,   126,    59,   127,   128,   129,   130,   131,     0,
-       0,   132,   133,     0,     0,     0,     0,     0,     0,     0,
-       0,     0,     0,     0,     0,     0,   339,     2,     3,     4,
-     134,     6,     7,     8,     9,    10,    11,     0,     0,     0,
-     183,   135,   136,   137,   138,     0,     0,     0,    12,    13,
+       0,   134,     8,     9,    10,    11,     0,     0,     0,     0,
+       0,     0,   135,   136,   137,   138,     0,    12,    13,    14,
+      15,    16,    17,    18,    19,    20,    21,    22,    23,    24,
+      25,    26,     0,     0,     0,     0,     0,    31,    32,    33,
+      34,    35,    36,     0,     0,     0,    40,    41,     0,    42,
+      43,    44,     0,    45,    46,    47,    48,    49,    50,    51,
+      52,    53,    54,     0,    55,    56,    57,     0,   126,    59,
+     127,   128,   129,   130,   131,     0,     0,   132,   133,     0,
+       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+       0,     0,     0,     0,     0,     0,   134,     0,     0,   207,
+       8,     9,    10,    11,     0,     0,     0,   135,   136,   137,
+     138,     0,     0,     0,     0,    12,    13,    14,    15,    16,
+      17,    18,    19,    20,    21,    22,    23,    24,    25,    26,
+       0,     0,     0,     0,     0,    31,    32,    33,    34,    35,
+      36,     0,     0,     0,    40,    41,     0,    42,    43,    44,
+       0,    45,    46,    47,    48,    49,    50,    51,    52,    53,
+      54,     0,    55,    56,    57,     0,   126,    59,   127,   128,
+     129,   130,   131,     0,     0,   132,   133,     0,     0,     0,
+       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+       0,     0,     0,     0,   134,     8,     9,    10,    11,     0,
+       0,     0,     0,     0,   262,   135,   136,   137,   138,     0,
+      12,    13,    14,    15,    16,    17,    18,    19,    20,    21,
+      22,    23,    24,    25,    26,     0,     0,     0,     0,     0,
+      31,    32,    33,    34,    35,    36,     0,     0,     0,    40,
+      41,     0,    42,    43,    44,     0,    45,    46,    47,    48,
+      49,    50,    51,    52,    53,    54,     0,    55,    56,    57,
+       0,   126,    59,   127,   128,   129,   130,   131,     0,     0,
+     132,   133,     0,     0,     0,     0,     0,     0,     0,     0,
+       0,     0,     0,     0,     0,     0,     0,     0,     0,   134,
+       0,     0,   284,     8,     9,    10,    11,     0,     0,     0,
+     135,   136,   137,   138,     0,     0,     0,     0,    12,    13,
       14,    15,    16,    17,    18,    19,    20,    21,    22,    23,
-      24,    25,    26,    27,    28,     0,    29,    30,    31,    32,
-      33,    34,    35,    36,    37,    38,    39,    40,    41,     0,
+      24,    25,    26,     0,     0,     0,     0,     0,    31,    32,
+      33,    34,    35,    36,     0,     0,     0,    40,    41,     0,
       42,    43,    44,     0,    45,    46,    47,    48,    49,    50,
-      51,    52,    53,    54,     0,    55,    56,    57,    58,   126,
+      51,    52,    53,    54,     0,    55,    56,    57,     0,   126,
       59,   127,   128,   129,   130,   131,     0,     0,   132,   133,
        0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
        0,     0,     0,     0,     0,     0,     0,   134,     8,     9,
@@ -1145,134 +1186,115 @@
      137,   138,     0,    12,    13,    14,    15,    16,    17,    18,
       19,    20,    21,    22,    23,    24,    25,    26,     0,     0,
        0,     0,     0,    31,    32,    33,    34,    35,    36,     0,
-       0,     0,    40,    41,     0,    42,    43,    44,     0,    45,
+       0,     0,    40,   221,     0,    42,    43,    44,     0,    45,
       46,    47,    48,    49,    50,    51,    52,    53,    54,     0,
       55,    56,    57,     0,   126,    59,   127,   128,   129,   130,
      131,     0,     0,   132,   133,     0,     0,     0,     0,     0,
-       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
-       0,     0,   134,     0,     0,   205,     8,     9,    10,    11,
+       0,     0,     0,     0,     0,     0,     0,     0,   167,     2,
+       3,     4,   134,     6,     7,     8,     9,    10,    11,     0,
        0,     0,     0,   135,   136,   137,   138,     0,     0,     0,
-       0,    12,    13,    14,    15,    16,    17,    18,    19,    20,
-      21,    22,    23,    24,    25,    26,     0,     0,     0,     0,
-       0,    31,    32,    33,    34,    35,    36,     0,     0,     0,
-      40,    41,     0,    42,    43,    44,     0,    45,    46,    47,
-      48,    49,    50,    51,    52,    53,    54,     0,    55,    56,
-      57,     0,   126,    59,   127,   128,   129,   130,   131,     0,
-       0,   132,   133,     0,     0,     0,     0,     0,     0,     0,
+      12,    13,    14,    15,    16,    17,    18,    19,    20,    21,
+      22,    23,    24,    25,    26,    27,    28,     0,    29,    30,
+      31,    32,    33,    34,    35,    36,    37,    38,    39,    40,
+      41,     0,    42,    43,    44,     0,    45,    46,    47,    48,
+      49,    50,    51,    52,    53,    54,     0,    55,    56,    57,
+      58,     0,    59,     0,     0,     0,     0,     0,     0,     0,
+     107,     0,     0,     1,     2,     3,     4,     5,     6,     7,
+       8,     9,    10,    11,     0,     0,     0,     0,     0,     0,
+       0,     0,     0,     0,   315,    12,    13,    14,    15,    16,
+      17,    18,    19,    20,    21,    22,    23,    24,    25,    26,
+      27,    28,     0,    29,    30,    31,    32,    33,    34,    35,
+      36,    37,    38,    39,    40,    41,     0,    42,    43,    44,
+       0,    45,    46,    47,    48,    49,    50,    51,    52,    53,
+      54,     0,    55,    56,    57,    58,     0,    59,     1,     2,
+       3,     4,     5,     6,     7,     8,     9,    10,    11,     0,
        0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
-     134,     8,     9,    10,    11,     0,     0,     0,     0,     0,
-     259,   135,   136,   137,   138,     0,    12,    13,    14,    15,
-      16,    17,    18,    19,    20,    21,    22,    23,    24,    25,
-      26,     0,     0,     0,     0,     0,    31,    32,    33,    34,
-      35,    36,     0,     0,     0,    40,    41,     0,    42,    43,
-      44,     0,    45,    46,    47,    48,    49,    50,    51,    52,
-      53,    54,     0,    55,    56,    57,     0,   126,    59,   127,
-     128,   129,   130,   131,     0,     0,   132,   133,     0,     0,
-       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
-       0,     0,     0,     0,     0,   134,     0,     0,   281,     8,
-       9,    10,    11,     0,     0,     0,   135,   136,   137,   138,
-       0,     0,     0,     0,    12,    13,    14,    15,    16,    17,
-      18,    19,    20,    21,    22,    23,    24,    25,    26,     0,
-       0,     0,     0,     0,    31,    32,    33,    34,    35,    36,
-       0,     0,     0,    40,    41,     0,    42,    43,    44,     0,
-      45,    46,    47,    48,    49,    50,    51,    52,    53,    54,
-       0,    55,    56,    57,     0,   126,    59,   127,   128,   129,
-     130,   131,     0,     0,   132,   133,     0,     0,     0,     0,
-       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
-       0,     0,     0,   134,     8,     9,    10,    11,     0,     0,
-       0,     0,     0,     0,   135,   136,   137,   138,     0,    12,
+      12,    13,    14,    15,    16,    17,    18,    19,    20,    21,
+      22,    23,    24,    25,    26,    27,    28,     0,    29,    30,
+      31,    32,    33,    34,    35,    36,    37,    38,    39,    40,
+      41,     0,    42,    43,    44,     0,    45,    46,    47,    48,
+      49,    50,    51,    52,    53,    54,     0,    55,    56,    57,
+      58,     0,    59,   167,     2,     3,     4,     0,     6,     7,
+       8,     9,    10,    11,     0,     0,     0,     0,     0,     0,
+       0,     0,     0,     0,     0,    12,    13,    14,    15,    16,
+      17,    18,    19,    20,    21,    22,    23,    24,    25,    26,
+      27,    28,     0,    29,    30,    31,    32,    33,    34,    35,
+      36,    37,    38,    39,    40,    41,     0,    42,    43,    44,
+       0,    45,    46,    47,    48,    49,    50,    51,    52,    53,
+      54,     0,    55,    56,    57,    58,     0,    59,     2,     3,
+       4,     0,     0,     0,     8,     9,    10,    11,     0,     0,
+       0,     0,     0,     0,     0,     0,     0,     0,     0,    12,
       13,    14,    15,    16,    17,    18,    19,    20,    21,    22,
       23,    24,    25,    26,     0,     0,     0,     0,     0,    31,
-      32,    33,    34,    35,    36,     0,     0,     0,    40,   219,
+      32,    33,    34,    35,    36,     0,     0,     0,    40,    41,
        0,    42,    43,    44,     0,    45,    46,    47,    48,    49,
       50,    51,    52,    53,    54,     0,    55,    56,    57,     0,
-     126,    59,   127,   128,   129,   130,   131,     0,     0,   132,
-     133,     0,     0,     0,     0,     0,     0,     0,     0,     0,
-       0,     0,     0,     2,     3,     4,     0,     0,   134,     8,
-       9,    10,    11,     0,     0,     0,     0,     0,     0,   135,
-     136,   137,   138,     0,    12,    13,    14,    15,    16,    17,
-      18,    19,    20,    21,    22,    23,    24,    25,    26,     0,
-       0,     0,     0,     0,    31,    32,    33,    34,    35,    36,
-       0,     0,     0,    40,    41,     0,    42,    43,    44,     0,
-      45,    46,    47,    48,    49,    50,    51,    52,    53,    54,
-       0,    55,    56,    57,     0,     0,    59,     0,     0,     0,
-       0,     0,     0,     0,   107,     0,     0,     1,     2,     3,
-       4,     5,     6,     7,     8,     9,    10,    11,     0,     0,
-       0,     0,     0,     0,     0,     0,     0,     0,   312,    12,
-      13,    14,    15,    16,    17,    18,    19,    20,    21,    22,
-      23,    24,    25,    26,    27,    28,     0,    29,    30,    31,
-      32,    33,    34,    35,    36,    37,    38,    39,    40,    41,
-       0,    42,    43,    44,     0,    45,    46,    47,    48,    49,
-      50,    51,    52,    53,    54,     0,    55,    56,    57,    58,
-       0,    59,     1,     2,     3,     4,     5,     6,     7,     8,
-       9,    10,    11,     0,     0,     0,     0,     0,     0,     0,
-       0,     0,     0,     0,    12,    13,    14,    15,    16,    17,
-      18,    19,    20,    21,    22,    23,    24,    25,    26,    27,
-      28,     0,    29,    30,    31,    32,    33,    34,    35,    36,
-      37,    38,    39,    40,    41,     0,    42,    43,    44,     0,
-      45,    46,    47,    48,    49,    50,    51,    52,    53,    54,
-       0,    55,    56,    57,    58,     0,    59,     2,     3,     4,
-       0,     0,     0,     8,     9,    10,    11,     0,     0,     0,
-       0,     0,     0,     0,     0,     0,     0,     0,    12,    13,
-      14,    15,    16,    17,    18,    19,    20,    21,    22,    23,
-      24,    25,    26,     0,     0,     0,     0,     0,    31,    32,
-      33,    34,    35,    36,     0,     0,     0,    40,    41,     0,
-      42,    43,    44,     0,    45,    46,    47,    48,    49,    50,
-      51,    52,    53,    54,     0,    55,    56,    57,     0,     0,
-      59,     8,     9,    10,    11,     0,     0,     0,     0,     0,
-       0,     0,     0,     0,     0,     0,    12,    13,    14,    15,
-      16,    17,    18,    19,    20,    21,    22,    23,    24,    25,
-      26,     0,     0,     0,     0,     0,    31,    32,    33,    34,
-      35,    36,     0,     0,     0,    40,    41,     0,    42,    43,
-      44,     0,    45,    46,    47,    48,    49,    50,    51,    52,
-      53,    54,     0,    55,    56,    57,     0,   288,    59,     8,
-       9,    10,    11,   289,     0,     0,     0,     0,     0,     0,
-       0,     0,     0,     0,    12,    13,    14,    15,    16,    17,
-      18,    19,    20,    21,    22,    23,    24,    25,    26,     0,
-       0,     0,     0,     0,    31,    32,    33,    34,    35,    36,
-       0,     0,     0,    40,    41,     0,    42,    43,    44,     0,
-      45,    46,    47,    48,    49,    50,    51,    52,    53,    54,
-       0,    55,    56,    57,     0,     0,    59
+       0,    59,     8,     9,    10,    11,     0,     0,     0,     0,
+       0,     0,     0,     0,     0,     0,     0,    12,    13,    14,
+      15,    16,    17,    18,    19,    20,    21,    22,    23,    24,
+      25,    26,     0,     0,     0,     0,     0,    31,    32,    33,
+      34,    35,    36,     0,     0,     0,    40,    41,     0,    42,
+      43,    44,     0,    45,    46,    47,    48,    49,    50,    51,
+      52,    53,    54,     0,    55,    56,    57,     0,   291,    59,
+       8,     9,    10,    11,   292,     0,     0,     0,     0,     0,
+       0,     0,     0,     0,     0,    12,    13,    14,    15,    16,
+      17,    18,    19,    20,    21,    22,    23,    24,    25,    26,
+       0,     0,     0,     0,     0,    31,    32,    33,    34,    35,
+      36,     0,     0,     0,    40,    41,     0,    42,    43,    44,
+       0,    45,    46,    47,    48,    49,    50,    51,    52,    53,
+      54,     0,    55,    56,    57,     0,     0,    59
 };
 
 static const yytype_int16 yycheck[] =
 {
-       0,   125,    89,   106,   134,    69,   204,   124,     0,    92,
-       9,   106,     0,    44,   168,   338,    76,   322,    72,   195,
-       9,   124,   104,   147,   318,   104,   114,   106,    82,   124,
-      87,    88,   337,    97,   113,    68,   359,   132,   133,   106,
-      73,    40,    41,    42,   127,    76,   113,   111,   108,   179,
-     105,    40,    41,   105,    43,   150,   111,   121,    85,    86,
-     354,   105,    51,   111,   358,   122,   123,   111,   105,    69,
-     105,   116,    72,   118,   111,   105,   111,    77,    76,   106,
-     204,   111,    82,   110,   214,    77,   203,     9,   111,    77,
-     244,   114,   111,   111,   218,   114,   114,    97,   111,   106,
-     203,   114,   166,   104,   168,   106,   105,    76,   203,    40,
-      41,   111,   242,    83,    84,   115,    89,    90,    40,    41,
-      42,   121,   230,   231,   232,   233,   108,   257,   223,   224,
-     225,   226,   227,   228,   229,   230,   231,   232,   233,   234,
-     235,   236,   237,   238,   239,   240,   241,   323,     4,     5,
-       6,   275,   276,    40,    41,    42,   119,   120,   121,    79,
-      80,    76,   360,   280,   111,   112,   166,   108,   168,   114,
-     226,   227,   234,   235,   113,   228,   229,   280,    76,   104,
-     244,   105,   126,   104,   124,   280,    91,   125,   107,    93,
-      76,   114,   322,   104,   104,   195,   313,   114,   114,   106,
-     109,   104,   104,   111,    56,   329,   107,   337,   108,   106,
-     313,   107,   107,   104,   107,   107,   104,   347,   313,    44,
-     105,    76,   105,    17,   114,   109,   236,   357,   215,   237,
-     317,   113,   238,   114,   239,    98,   360,   240,    91,   241,
-       5,   121,   121,   172,   244,   314,   319,     4,     5,     6,
-      77,   358,   166,    10,    11,    12,    13,   337,   319,   263,
-      -1,    -1,    -1,   263,    -1,    -1,    -1,    -1,    25,    26,
-      27,    28,    29,    30,    31,    32,    33,    34,    35,    36,
-      37,    38,    39,    -1,    -1,    -1,    -1,    -1,    45,    46,
-      47,    48,    49,    50,    -1,    -1,    -1,    54,    55,    -1,
-      57,    58,    59,    -1,    61,    62,    63,    64,    65,    66,
-      67,    68,    69,    70,    -1,    72,    73,    74,   318,   319,
-      77,    -1,   322,   323,    94,    95,    96,    97,    98,    99,
-     100,   101,   102,   103,    -1,    -1,    -1,   337,    -1,    -1,
-      -1,    -1,    -1,   113,    -1,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,   109,    -1,   354,    -1,    -1,    -1,   358,     3,
+       0,    89,   106,   125,   134,   206,   124,    69,     0,    44,
+     322,     9,     0,   106,   170,    76,   111,    87,    88,    92,
+     124,   326,   197,    72,     9,   147,   104,   106,   343,     9,
+     116,   124,   118,    82,   113,    97,   104,   342,   106,   132,
+     133,    76,    40,    41,    42,   113,   358,   108,   363,   111,
+     362,   181,   122,   123,   127,    40,    41,   150,    43,   121,
+      40,    41,    42,   114,   105,   105,    51,    85,    86,    69,
+     111,   166,    72,   105,   105,   170,   114,    77,    68,   111,
+     111,   111,    82,    73,   206,    77,   216,   205,   106,    77,
+     246,   106,   110,   105,   105,    40,    41,    97,   220,   111,
+     111,   205,   111,    76,   166,   114,   168,   105,   170,   108,
+     111,   111,   205,   114,   244,   115,   232,   233,   234,   235,
+     111,   121,   111,   114,   111,   114,   104,   114,   106,    76,
+     260,   108,   225,   226,   227,   228,   229,   230,   231,   232,
+     233,   234,   235,   236,   237,   238,   239,   240,   241,   242,
+     243,   246,   327,     4,     5,     6,   278,   279,    40,    41,
+      42,    83,    84,   364,    76,   283,   166,   113,   168,    76,
+     170,   119,   120,   121,    89,    90,    79,    80,   104,   283,
+     111,   112,   228,   229,   246,   230,   231,   105,   236,   237,
+     283,   104,   126,   125,   124,    91,   326,   197,    93,   317,
+      94,    95,    96,    97,    98,    99,   100,   101,   102,   103,
+     107,   333,   342,   317,    44,    76,   114,   104,   104,   113,
+     104,   351,   114,   114,   317,   106,   109,   107,   104,   106,
+     108,   361,   107,   321,   107,   104,    56,   111,   104,   107,
+     107,    76,   364,   105,   109,   105,   246,     3,     4,     5,
+       6,   114,     8,     9,    10,    11,    12,    13,    17,   113,
+     217,   114,   238,   242,   239,   121,   266,   241,   240,    25,
+      26,    27,    28,    29,    30,    31,    32,    33,    34,    35,
+      36,    37,    38,    39,    40,    41,    91,    43,    44,    45,
+      46,    47,    48,    49,    50,    51,    52,    53,    54,    55,
+     243,    57,    58,    59,    98,    61,    62,    63,    64,    65,
+      66,    67,    68,    69,    70,   121,    72,    73,    74,    75,
+       5,    77,   322,   323,   174,   166,   326,   327,   247,   323,
+     266,    77,   318,   362,   342,    -1,    -1,    -1,    -1,   323,
+      -1,    -1,   342,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+      -1,    -1,    -1,   109,    -1,    -1,    -1,    -1,   358,    -1,
+      -1,    -1,   362,     3,     4,     5,     6,     7,     8,     9,
+      10,    11,    12,    13,    14,    15,    16,    -1,    18,    19,
+      20,    21,    -1,    -1,    -1,    25,    26,    27,    28,    29,
+      30,    31,    32,    33,    34,    35,    36,    37,    38,    39,
+      40,    41,    -1,    43,    44,    45,    46,    47,    48,    49,
+      50,    51,    52,    53,    54,    55,    56,    57,    58,    59,
+      -1,    61,    62,    63,    64,    65,    66,    67,    68,    69,
+      70,    -1,    72,    73,    74,    75,    76,    77,    78,    79,
+      80,    81,    82,    -1,    -1,    85,    86,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,   104,    -1,    -1,    -1,   108,   109,
+      -1,    -1,    -1,    -1,   114,   115,   116,   117,   118,     3,
        4,     5,     6,     7,     8,     9,    10,    11,    12,    13,
       14,    15,    16,    -1,    18,    19,    20,    21,    -1,    -1,
       -1,    25,    26,    27,    28,    29,    30,    31,    32,    33,
@@ -1295,7 +1317,7 @@
       78,    79,    80,    81,    82,    -1,    -1,    85,    86,    -1,
       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
       -1,    -1,    -1,    -1,    -1,    -1,   104,    -1,    -1,    -1,
-     108,   109,    -1,    -1,    -1,    -1,   114,   115,   116,   117,
+     108,    -1,    -1,    -1,    -1,    -1,   114,   115,   116,   117,
      118,     3,     4,     5,     6,     7,     8,     9,    10,    11,
       12,    13,    14,    15,    16,    -1,    18,    19,    20,    21,
       -1,    -1,    -1,    25,    26,    27,    28,    29,    30,    31,
@@ -1318,36 +1340,63 @@
       76,    77,    78,    79,    80,    81,    82,    -1,    -1,    85,
       86,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   104,    -1,
-      -1,    -1,   108,    -1,    -1,    -1,    -1,    -1,   114,   115,
+      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   114,   115,
      116,   117,   118,     3,     4,     5,     6,     7,     8,     9,
-      10,    11,    12,    13,    14,    15,    16,    -1,    18,    19,
-      20,    21,    -1,    -1,    -1,    25,    26,    27,    28,    29,
+      10,    11,    12,    13,    -1,    -1,    -1,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    25,    26,    27,    28,    29,
       30,    31,    32,    33,    34,    35,    36,    37,    38,    39,
       40,    41,    -1,    43,    44,    45,    46,    47,    48,    49,
-      50,    51,    52,    53,    54,    55,    56,    57,    58,    59,
+      50,    51,    52,    53,    54,    55,    -1,    57,    58,    59,
       -1,    61,    62,    63,    64,    65,    66,    67,    68,    69,
       70,    -1,    72,    73,    74,    75,    76,    77,    78,    79,
       80,    81,    82,    -1,    -1,    85,    86,    -1,    -1,    -1,
       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,   104,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,   114,   115,   116,   117,   118,     3,
-       4,     5,     6,     7,     8,     9,    10,    11,    12,    13,
+       3,     4,     5,     6,   104,     8,     9,    10,    11,    12,
+      13,    -1,    -1,    -1,   114,   115,   116,   117,   118,    -1,
+      -1,    -1,    25,    26,    27,    28,    29,    30,    31,    32,
+      33,    34,    35,    36,    37,    38,    39,    40,    41,    -1,
+      43,    44,    45,    46,    47,    48,    49,    50,    51,    52,
+      53,    54,    55,    -1,    57,    58,    59,    -1,    61,    62,
+      63,    64,    65,    66,    67,    68,    69,    70,    -1,    72,
+      73,    74,    75,    76,    77,    78,    79,    80,    81,    82,
+      -1,    -1,    85,    86,    -1,    -1,    -1,    -1,    -1,    -1,
       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-      -1,    25,    26,    27,    28,    29,    30,    31,    32,    33,
-      34,    35,    36,    37,    38,    39,    40,    41,    -1,    43,
-      44,    45,    46,    47,    48,    49,    50,    51,    52,    53,
-      54,    55,    -1,    57,    58,    59,    -1,    61,    62,    63,
-      64,    65,    66,    67,    68,    69,    70,    -1,    72,    73,
-      74,    75,    76,    77,    78,    79,    80,    81,    82,    -1,
-      -1,    85,    86,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,    -1,     3,     4,     5,     6,
-     104,     8,     9,    10,    11,    12,    13,    -1,    -1,    -1,
-     114,   115,   116,   117,   118,    -1,    -1,    -1,    25,    26,
+      -1,   104,    10,    11,    12,    13,    -1,    -1,    -1,    -1,
+      -1,    -1,   115,   116,   117,   118,    -1,    25,    26,    27,
+      28,    29,    30,    31,    32,    33,    34,    35,    36,    37,
+      38,    39,    -1,    -1,    -1,    -1,    -1,    45,    46,    47,
+      48,    49,    50,    -1,    -1,    -1,    54,    55,    -1,    57,
+      58,    59,    -1,    61,    62,    63,    64,    65,    66,    67,
+      68,    69,    70,    -1,    72,    73,    74,    -1,    76,    77,
+      78,    79,    80,    81,    82,    -1,    -1,    85,    86,    -1,
+      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    -1,   104,    -1,    -1,   107,
+      10,    11,    12,    13,    -1,    -1,    -1,   115,   116,   117,
+     118,    -1,    -1,    -1,    -1,    25,    26,    27,    28,    29,
+      30,    31,    32,    33,    34,    35,    36,    37,    38,    39,
+      -1,    -1,    -1,    -1,    -1,    45,    46,    47,    48,    49,
+      50,    -1,    -1,    -1,    54,    55,    -1,    57,    58,    59,
+      -1,    61,    62,    63,    64,    65,    66,    67,    68,    69,
+      70,    -1,    72,    73,    74,    -1,    76,    77,    78,    79,
+      80,    81,    82,    -1,    -1,    85,    86,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,   104,    10,    11,    12,    13,    -1,
+      -1,    -1,    -1,    -1,   114,   115,   116,   117,   118,    -1,
+      25,    26,    27,    28,    29,    30,    31,    32,    33,    34,
+      35,    36,    37,    38,    39,    -1,    -1,    -1,    -1,    -1,
+      45,    46,    47,    48,    49,    50,    -1,    -1,    -1,    54,
+      55,    -1,    57,    58,    59,    -1,    61,    62,    63,    64,
+      65,    66,    67,    68,    69,    70,    -1,    72,    73,    74,
+      -1,    76,    77,    78,    79,    80,    81,    82,    -1,    -1,
+      85,    86,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   104,
+      -1,    -1,   107,    10,    11,    12,    13,    -1,    -1,    -1,
+     115,   116,   117,   118,    -1,    -1,    -1,    -1,    25,    26,
       27,    28,    29,    30,    31,    32,    33,    34,    35,    36,
-      37,    38,    39,    40,    41,    -1,    43,    44,    45,    46,
-      47,    48,    49,    50,    51,    52,    53,    54,    55,    -1,
+      37,    38,    39,    -1,    -1,    -1,    -1,    -1,    45,    46,
+      47,    48,    49,    50,    -1,    -1,    -1,    54,    55,    -1,
       57,    58,    59,    -1,    61,    62,    63,    64,    65,    66,
-      67,    68,    69,    70,    -1,    72,    73,    74,    75,    76,
+      67,    68,    69,    70,    -1,    72,    73,    74,    -1,    76,
       77,    78,    79,    80,    81,    82,    -1,    -1,    85,    86,
       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
       -1,    -1,    -1,    -1,    -1,    -1,    -1,   104,    10,    11,
@@ -1359,90 +1408,59 @@
       62,    63,    64,    65,    66,    67,    68,    69,    70,    -1,
       72,    73,    74,    -1,    76,    77,    78,    79,    80,    81,
       82,    -1,    -1,    85,    86,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,   104,    -1,    -1,   107,    10,    11,    12,    13,
+      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,     3,     4,
+       5,     6,   104,     8,     9,    10,    11,    12,    13,    -1,
       -1,    -1,    -1,   115,   116,   117,   118,    -1,    -1,    -1,
-      -1,    25,    26,    27,    28,    29,    30,    31,    32,    33,
-      34,    35,    36,    37,    38,    39,    -1,    -1,    -1,    -1,
-      -1,    45,    46,    47,    48,    49,    50,    -1,    -1,    -1,
-      54,    55,    -1,    57,    58,    59,    -1,    61,    62,    63,
-      64,    65,    66,    67,    68,    69,    70,    -1,    72,    73,
-      74,    -1,    76,    77,    78,    79,    80,    81,    82,    -1,
-      -1,    85,    86,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+      25,    26,    27,    28,    29,    30,    31,    32,    33,    34,
+      35,    36,    37,    38,    39,    40,    41,    -1,    43,    44,
+      45,    46,    47,    48,    49,    50,    51,    52,    53,    54,
+      55,    -1,    57,    58,    59,    -1,    61,    62,    63,    64,
+      65,    66,    67,    68,    69,    70,    -1,    72,    73,    74,
+      75,    -1,    77,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       0,    -1,    -1,     3,     4,     5,     6,     7,     8,     9,
+      10,    11,    12,    13,    -1,    -1,    -1,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,   109,    25,    26,    27,    28,    29,
+      30,    31,    32,    33,    34,    35,    36,    37,    38,    39,
+      40,    41,    -1,    43,    44,    45,    46,    47,    48,    49,
+      50,    51,    52,    53,    54,    55,    -1,    57,    58,    59,
+      -1,    61,    62,    63,    64,    65,    66,    67,    68,    69,
+      70,    -1,    72,    73,    74,    75,    -1,    77,     3,     4,
+       5,     6,     7,     8,     9,    10,    11,    12,    13,    -1,
       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-     104,    10,    11,    12,    13,    -1,    -1,    -1,    -1,    -1,
-     114,   115,   116,   117,   118,    -1,    25,    26,    27,    28,
-      29,    30,    31,    32,    33,    34,    35,    36,    37,    38,
-      39,    -1,    -1,    -1,    -1,    -1,    45,    46,    47,    48,
-      49,    50,    -1,    -1,    -1,    54,    55,    -1,    57,    58,
-      59,    -1,    61,    62,    63,    64,    65,    66,    67,    68,
-      69,    70,    -1,    72,    73,    74,    -1,    76,    77,    78,
-      79,    80,    81,    82,    -1,    -1,    85,    86,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,   104,    -1,    -1,   107,    10,
-      11,    12,    13,    -1,    -1,    -1,   115,   116,   117,   118,
-      -1,    -1,    -1,    -1,    25,    26,    27,    28,    29,    30,
-      31,    32,    33,    34,    35,    36,    37,    38,    39,    -1,
-      -1,    -1,    -1,    -1,    45,    46,    47,    48,    49,    50,
-      -1,    -1,    -1,    54,    55,    -1,    57,    58,    59,    -1,
-      61,    62,    63,    64,    65,    66,    67,    68,    69,    70,
-      -1,    72,    73,    74,    -1,    76,    77,    78,    79,    80,
-      81,    82,    -1,    -1,    85,    86,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,   104,    10,    11,    12,    13,    -1,    -1,
-      -1,    -1,    -1,    -1,   115,   116,   117,   118,    -1,    25,
+      25,    26,    27,    28,    29,    30,    31,    32,    33,    34,
+      35,    36,    37,    38,    39,    40,    41,    -1,    43,    44,
+      45,    46,    47,    48,    49,    50,    51,    52,    53,    54,
+      55,    -1,    57,    58,    59,    -1,    61,    62,    63,    64,
+      65,    66,    67,    68,    69,    70,    -1,    72,    73,    74,
+      75,    -1,    77,     3,     4,     5,     6,    -1,     8,     9,
+      10,    11,    12,    13,    -1,    -1,    -1,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    25,    26,    27,    28,    29,
+      30,    31,    32,    33,    34,    35,    36,    37,    38,    39,
+      40,    41,    -1,    43,    44,    45,    46,    47,    48,    49,
+      50,    51,    52,    53,    54,    55,    -1,    57,    58,    59,
+      -1,    61,    62,    63,    64,    65,    66,    67,    68,    69,
+      70,    -1,    72,    73,    74,    75,    -1,    77,     4,     5,
+       6,    -1,    -1,    -1,    10,    11,    12,    13,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    25,
       26,    27,    28,    29,    30,    31,    32,    33,    34,    35,
       36,    37,    38,    39,    -1,    -1,    -1,    -1,    -1,    45,
       46,    47,    48,    49,    50,    -1,    -1,    -1,    54,    55,
       -1,    57,    58,    59,    -1,    61,    62,    63,    64,    65,
       66,    67,    68,    69,    70,    -1,    72,    73,    74,    -1,
-      76,    77,    78,    79,    80,    81,    82,    -1,    -1,    85,
-      86,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,     4,     5,     6,    -1,    -1,   104,    10,
-      11,    12,    13,    -1,    -1,    -1,    -1,    -1,    -1,   115,
-     116,   117,   118,    -1,    25,    26,    27,    28,    29,    30,
-      31,    32,    33,    34,    35,    36,    37,    38,    39,    -1,
-      -1,    -1,    -1,    -1,    45,    46,    47,    48,    49,    50,
-      -1,    -1,    -1,    54,    55,    -1,    57,    58,    59,    -1,
-      61,    62,    63,    64,    65,    66,    67,    68,    69,    70,
-      -1,    72,    73,    74,    -1,    -1,    77,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,     0,    -1,    -1,     3,     4,     5,
-       6,     7,     8,     9,    10,    11,    12,    13,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   109,    25,
-      26,    27,    28,    29,    30,    31,    32,    33,    34,    35,
-      36,    37,    38,    39,    40,    41,    -1,    43,    44,    45,
-      46,    47,    48,    49,    50,    51,    52,    53,    54,    55,
-      -1,    57,    58,    59,    -1,    61,    62,    63,    64,    65,
-      66,    67,    68,    69,    70,    -1,    72,    73,    74,    75,
-      -1,    77,     3,     4,     5,     6,     7,     8,     9,    10,
-      11,    12,    13,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    25,    26,    27,    28,    29,    30,
-      31,    32,    33,    34,    35,    36,    37,    38,    39,    40,
-      41,    -1,    43,    44,    45,    46,    47,    48,    49,    50,
-      51,    52,    53,    54,    55,    -1,    57,    58,    59,    -1,
-      61,    62,    63,    64,    65,    66,    67,    68,    69,    70,
-      -1,    72,    73,    74,    75,    -1,    77,     4,     5,     6,
-      -1,    -1,    -1,    10,    11,    12,    13,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    25,    26,
-      27,    28,    29,    30,    31,    32,    33,    34,    35,    36,
-      37,    38,    39,    -1,    -1,    -1,    -1,    -1,    45,    46,
-      47,    48,    49,    50,    -1,    -1,    -1,    54,    55,    -1,
-      57,    58,    59,    -1,    61,    62,    63,    64,    65,    66,
-      67,    68,    69,    70,    -1,    72,    73,    74,    -1,    -1,
-      77,    10,    11,    12,    13,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,    -1,    25,    26,    27,    28,
-      29,    30,    31,    32,    33,    34,    35,    36,    37,    38,
-      39,    -1,    -1,    -1,    -1,    -1,    45,    46,    47,    48,
-      49,    50,    -1,    -1,    -1,    54,    55,    -1,    57,    58,
-      59,    -1,    61,    62,    63,    64,    65,    66,    67,    68,
-      69,    70,    -1,    72,    73,    74,    -1,    76,    77,    10,
-      11,    12,    13,    82,    -1,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    25,    26,    27,    28,    29,    30,
-      31,    32,    33,    34,    35,    36,    37,    38,    39,    -1,
-      -1,    -1,    -1,    -1,    45,    46,    47,    48,    49,    50,
-      -1,    -1,    -1,    54,    55,    -1,    57,    58,    59,    -1,
-      61,    62,    63,    64,    65,    66,    67,    68,    69,    70,
-      -1,    72,    73,    74,    -1,    -1,    77
+      -1,    77,    10,    11,    12,    13,    -1,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    -1,    -1,    25,    26,    27,
+      28,    29,    30,    31,    32,    33,    34,    35,    36,    37,
+      38,    39,    -1,    -1,    -1,    -1,    -1,    45,    46,    47,
+      48,    49,    50,    -1,    -1,    -1,    54,    55,    -1,    57,
+      58,    59,    -1,    61,    62,    63,    64,    65,    66,    67,
+      68,    69,    70,    -1,    72,    73,    74,    -1,    76,    77,
+      10,    11,    12,    13,    82,    -1,    -1,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    25,    26,    27,    28,    29,
+      30,    31,    32,    33,    34,    35,    36,    37,    38,    39,
+      -1,    -1,    -1,    -1,    -1,    45,    46,    47,    48,    49,
+      50,    -1,    -1,    -1,    54,    55,    -1,    57,    58,    59,
+      -1,    61,    62,    63,    64,    65,    66,    67,    68,    69,
+      70,    -1,    72,    73,    74,    -1,    -1,    77
 };
 
 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
@@ -1465,27 +1483,28 @@
       81,    82,    85,    86,   104,   115,   116,   117,   118,   129,
      130,   131,   133,   134,   135,   136,   137,   138,   139,   140,
      141,   142,   143,   144,   145,   146,   147,   148,   149,   150,
-     151,   152,   153,   157,   180,   114,   182,   174,   184,   185,
-     113,   105,   111,    14,    15,    16,    18,    19,    20,    21,
-      56,   108,   109,   114,   140,   153,   154,   156,   158,   159,
-     180,   189,   190,   191,   192,   200,   201,   202,   205,   212,
-      76,   163,   166,   106,   113,   107,   157,   154,   188,   140,
-     140,   156,    85,    86,   106,   110,   105,   105,   111,    55,
-     154,   104,   140,   119,   120,   121,   116,   118,    83,    84,
-      87,    88,   122,   123,    89,    90,   126,   125,   124,    91,
-      93,    92,   127,   107,   184,    76,   186,   187,   109,   185,
-      79,    80,   178,   114,   114,   207,   104,   104,   114,   114,
-     156,   104,   109,   193,    94,    95,    96,    97,    98,    99,
-     100,   101,   102,   103,   113,   155,   111,   114,   109,   190,
-     106,   107,   157,   188,   107,   105,   132,   156,    76,    82,
-     135,   154,   140,   140,   140,   142,   142,   143,   143,   144,
-     144,   144,   144,   145,   145,   146,   147,   148,   149,   150,
-     151,   156,   109,   106,   111,   114,   196,   197,   198,   208,
-     156,   114,   206,   200,   154,   154,   157,   107,   107,   112,
-     157,   187,    56,   199,   191,   189,   201,   209,   105,     3,
-     156,   169,   204,   194,   107,   154,   107,   104,   204,   210,
-     211,   196,   203,    76,   105,   109,   156,   114,   105,    17,
-     113,   191,   195,   199,   105,   156,   195,   196,   188,   114
+     151,   152,   153,   157,   180,   114,   182,     3,   172,   174,
+     184,   185,   113,   105,   111,    14,    15,    16,    18,    19,
+      20,    21,    56,   108,   109,   114,   140,   153,   154,   156,
+     158,   159,   180,   189,   190,   191,   192,   200,   201,   202,
+     205,   212,    76,   163,   166,   106,   113,   107,   157,   154,
+     188,   140,   140,   156,    85,    86,   106,   110,   105,   105,
+     111,    55,   154,   104,   140,   119,   120,   121,   116,   118,
+      83,    84,    87,    88,   122,   123,    89,    90,   126,   125,
+     124,    91,    93,    92,   127,   107,   184,   174,    76,   186,
+     187,   109,   185,    79,    80,   178,   114,   114,   207,   104,
+     104,   114,   114,   156,   104,   109,   193,    94,    95,    96,
+      97,    98,    99,   100,   101,   102,   103,   113,   155,   111,
+     114,   109,   190,   106,   107,   157,   188,   107,   105,   132,
+     156,    76,    82,   135,   154,   140,   140,   140,   142,   142,
+     143,   143,   144,   144,   144,   144,   145,   145,   146,   147,
+     148,   149,   150,   151,   156,   109,   186,   106,   111,   114,
+     196,   197,   198,   208,   156,   114,   206,   200,   154,   154,
+     157,   107,   107,   112,   114,   157,   187,    56,   199,   191,
+     189,   201,   209,   105,   156,   169,   204,   194,   107,   154,
+     107,   104,   204,   210,   211,   196,   203,    76,   105,   109,
+     156,   114,   105,    17,   113,   191,   195,   199,   105,   156,
+     195,   196,   188,   114
 };
 
 #define yyerrok		(yyerrstatus = 0)
@@ -2397,83 +2416,7 @@
   case 10:
 
     {
-        if (!(yyvsp[(1) - (4)].interm.intermTypedNode)->isArray() && !(yyvsp[(1) - (4)].interm.intermTypedNode)->isMatrix() && !(yyvsp[(1) - (4)].interm.intermTypedNode)->isVector()) {
-            if ((yyvsp[(1) - (4)].interm.intermTypedNode)->getAsSymbolNode())
-                context->error((yyvsp[(2) - (4)].lex).line, " left of '[' is not of type array, matrix, or vector ", (yyvsp[(1) - (4)].interm.intermTypedNode)->getAsSymbolNode()->getSymbol().c_str());
-            else
-                context->error((yyvsp[(2) - (4)].lex).line, " left of '[' is not of type array, matrix, or vector ", "expression");
-            context->recover();
-        }
-        if ((yyvsp[(1) - (4)].interm.intermTypedNode)->getType().getQualifier() == EvqConstExpr && (yyvsp[(3) - (4)].interm.intermTypedNode)->getQualifier() == EvqConstExpr) {
-            if ((yyvsp[(1) - (4)].interm.intermTypedNode)->isArray()) { // constant folding for arrays
-                (yyval.interm.intermTypedNode) = context->addConstArrayNode((yyvsp[(3) - (4)].interm.intermTypedNode)->getAsConstantUnion()->getIConst(0), (yyvsp[(1) - (4)].interm.intermTypedNode), (yyvsp[(2) - (4)].lex).line);
-            } else if ((yyvsp[(1) - (4)].interm.intermTypedNode)->isVector()) {  // constant folding for vectors
-                TVectorFields fields;
-                fields.num = 1;
-                fields.offsets[0] = (yyvsp[(3) - (4)].interm.intermTypedNode)->getAsConstantUnion()->getIConst(0); // need to do it this way because v.xy sends fields integer array
-                (yyval.interm.intermTypedNode) = context->addConstVectorNode(fields, (yyvsp[(1) - (4)].interm.intermTypedNode), (yyvsp[(2) - (4)].lex).line);
-            } else if ((yyvsp[(1) - (4)].interm.intermTypedNode)->isMatrix()) { // constant folding for matrices
-                (yyval.interm.intermTypedNode) = context->addConstMatrixNode((yyvsp[(3) - (4)].interm.intermTypedNode)->getAsConstantUnion()->getIConst(0), (yyvsp[(1) - (4)].interm.intermTypedNode), (yyvsp[(2) - (4)].lex).line);
-            }
-        } else {
-            if ((yyvsp[(3) - (4)].interm.intermTypedNode)->getQualifier() == EvqConstExpr) {
-                if (((yyvsp[(1) - (4)].interm.intermTypedNode)->isVector() || (yyvsp[(1) - (4)].interm.intermTypedNode)->isMatrix()) && (yyvsp[(1) - (4)].interm.intermTypedNode)->getType().getNominalSize() <= (yyvsp[(3) - (4)].interm.intermTypedNode)->getAsConstantUnion()->getIConst(0) && !(yyvsp[(1) - (4)].interm.intermTypedNode)->isArray() ) {
-                    std::stringstream extraInfoStream;
-                    extraInfoStream << "field selection out of range '" << (yyvsp[(3) - (4)].interm.intermTypedNode)->getAsConstantUnion()->getIConst(0) << "'";
-                    std::string extraInfo = extraInfoStream.str();
-                    context->error((yyvsp[(2) - (4)].lex).line, "", "[", extraInfo.c_str());
-                    context->recover();
-                } else {
-                    if ((yyvsp[(1) - (4)].interm.intermTypedNode)->isArray()) {
-                        if ((yyvsp[(1) - (4)].interm.intermTypedNode)->getType().getArraySize() == 0) {
-                            if ((yyvsp[(1) - (4)].interm.intermTypedNode)->getType().getMaxArraySize() <= (yyvsp[(3) - (4)].interm.intermTypedNode)->getAsConstantUnion()->getIConst(0)) {
-                                if (context->arraySetMaxSize((yyvsp[(1) - (4)].interm.intermTypedNode)->getAsSymbolNode(), (yyvsp[(1) - (4)].interm.intermTypedNode)->getTypePointer(), (yyvsp[(3) - (4)].interm.intermTypedNode)->getAsConstantUnion()->getIConst(0), true, (yyvsp[(2) - (4)].lex).line))
-                                    context->recover();
-                            } else {
-                                if (context->arraySetMaxSize((yyvsp[(1) - (4)].interm.intermTypedNode)->getAsSymbolNode(), (yyvsp[(1) - (4)].interm.intermTypedNode)->getTypePointer(), 0, false, (yyvsp[(2) - (4)].lex).line))
-                                    context->recover();
-                            }
-                        } else if ( (yyvsp[(3) - (4)].interm.intermTypedNode)->getAsConstantUnion()->getIConst(0) >= (yyvsp[(1) - (4)].interm.intermTypedNode)->getType().getArraySize()) {
-                            std::stringstream extraInfoStream;
-                            extraInfoStream << "array index out of range '" << (yyvsp[(3) - (4)].interm.intermTypedNode)->getAsConstantUnion()->getIConst(0) << "'";
-                            std::string extraInfo = extraInfoStream.str();
-                            context->error((yyvsp[(2) - (4)].lex).line, "", "[", extraInfo.c_str());
-                            context->recover();
-                        }
-                    }
-                    (yyval.interm.intermTypedNode) = context->intermediate.addIndex(EOpIndexDirect, (yyvsp[(1) - (4)].interm.intermTypedNode), (yyvsp[(3) - (4)].interm.intermTypedNode), (yyvsp[(2) - (4)].lex).line);
-                }
-            } else {
-                if ((yyvsp[(1) - (4)].interm.intermTypedNode)->isArray() && (yyvsp[(1) - (4)].interm.intermTypedNode)->getType().getArraySize() == 0) {
-                    context->error((yyvsp[(2) - (4)].lex).line, "", "[", "array must be redeclared with a size before being indexed with a variable");
-                    context->recover();
-                }
-
-                (yyval.interm.intermTypedNode) = context->intermediate.addIndex(EOpIndexIndirect, (yyvsp[(1) - (4)].interm.intermTypedNode), (yyvsp[(3) - (4)].interm.intermTypedNode), (yyvsp[(2) - (4)].lex).line);
-            }
-        }
-        if ((yyval.interm.intermTypedNode) == 0) {
-            ConstantUnion *unionArray = new ConstantUnion[1];
-            unionArray->setFConst(0.0f);
-            (yyval.interm.intermTypedNode) = context->intermediate.addConstantUnion(unionArray, TType(EbtFloat, EbpHigh, EvqConstExpr), (yyvsp[(2) - (4)].lex).line);
-        } else if ((yyvsp[(1) - (4)].interm.intermTypedNode)->isArray()) {
-            if ((yyvsp[(1) - (4)].interm.intermTypedNode)->getType().getStruct())
-                (yyval.interm.intermTypedNode)->setType(TType((yyvsp[(1) - (4)].interm.intermTypedNode)->getType().getStruct()));
-            else
-                (yyval.interm.intermTypedNode)->setType(TType((yyvsp[(1) - (4)].interm.intermTypedNode)->getBasicType(), (yyvsp[(1) - (4)].interm.intermTypedNode)->getPrecision(), EvqTemporary, (yyvsp[(1) - (4)].interm.intermTypedNode)->getNominalSize(), (yyvsp[(1) - (4)].interm.intermTypedNode)->getSecondarySize()));
-
-            if ((yyvsp[(1) - (4)].interm.intermTypedNode)->getType().getQualifier() == EvqConstExpr)
-                (yyval.interm.intermTypedNode)->getTypePointer()->setQualifier(EvqConstExpr);
-        } else if ((yyvsp[(1) - (4)].interm.intermTypedNode)->isMatrix() && (yyvsp[(1) - (4)].interm.intermTypedNode)->getType().getQualifier() == EvqConstExpr)
-            (yyval.interm.intermTypedNode)->setType(TType((yyvsp[(1) - (4)].interm.intermTypedNode)->getBasicType(), (yyvsp[(1) - (4)].interm.intermTypedNode)->getPrecision(), EvqConstExpr, (yyvsp[(1) - (4)].interm.intermTypedNode)->getSecondarySize()));
-        else if ((yyvsp[(1) - (4)].interm.intermTypedNode)->isMatrix())
-            (yyval.interm.intermTypedNode)->setType(TType((yyvsp[(1) - (4)].interm.intermTypedNode)->getBasicType(), (yyvsp[(1) - (4)].interm.intermTypedNode)->getPrecision(), EvqTemporary, (yyvsp[(1) - (4)].interm.intermTypedNode)->getSecondarySize()));
-        else if ((yyvsp[(1) - (4)].interm.intermTypedNode)->isVector() && (yyvsp[(1) - (4)].interm.intermTypedNode)->getType().getQualifier() == EvqConstExpr)
-            (yyval.interm.intermTypedNode)->setType(TType((yyvsp[(1) - (4)].interm.intermTypedNode)->getBasicType(), (yyvsp[(1) - (4)].interm.intermTypedNode)->getPrecision(), EvqConstExpr));
-        else if ((yyvsp[(1) - (4)].interm.intermTypedNode)->isVector())
-            (yyval.interm.intermTypedNode)->setType(TType((yyvsp[(1) - (4)].interm.intermTypedNode)->getBasicType(), (yyvsp[(1) - (4)].interm.intermTypedNode)->getPrecision(), EvqTemporary));
-        else
-            (yyval.interm.intermTypedNode)->setType((yyvsp[(1) - (4)].interm.intermTypedNode)->getType());
+        (yyval.interm.intermTypedNode) = context->addIndexExpression((yyvsp[(1) - (4)].interm.intermTypedNode), (yyvsp[(2) - (4)].lex).line, (yyvsp[(3) - (4)].interm.intermTypedNode));
     }
     break;
 
@@ -2487,134 +2430,21 @@
   case 12:
 
     {
-        if ((yyvsp[(1) - (3)].interm.intermTypedNode)->isArray()) {
-            context->error((yyvsp[(3) - (3)].lex).line, "cannot apply dot operator to an array", ".");
-            context->recover();
-        }
-
-        if ((yyvsp[(1) - (3)].interm.intermTypedNode)->isVector()) {
-            TVectorFields fields;
-            if (! context->parseVectorFields(*(yyvsp[(3) - (3)].lex).string, (yyvsp[(1) - (3)].interm.intermTypedNode)->getNominalSize(), fields, (yyvsp[(3) - (3)].lex).line)) {
-                fields.num = 1;
-                fields.offsets[0] = 0;
-                context->recover();
-            }
-
-            if ((yyvsp[(1) - (3)].interm.intermTypedNode)->getType().getQualifier() == EvqConstExpr) { // constant folding for vector fields
-                (yyval.interm.intermTypedNode) = context->addConstVectorNode(fields, (yyvsp[(1) - (3)].interm.intermTypedNode), (yyvsp[(3) - (3)].lex).line);
-                if ((yyval.interm.intermTypedNode) == 0) {
-                    context->recover();
-                    (yyval.interm.intermTypedNode) = (yyvsp[(1) - (3)].interm.intermTypedNode);
-                }
-                else
-                    (yyval.interm.intermTypedNode)->setType(TType((yyvsp[(1) - (3)].interm.intermTypedNode)->getBasicType(), (yyvsp[(1) - (3)].interm.intermTypedNode)->getPrecision(), EvqConstExpr, (int) (*(yyvsp[(3) - (3)].lex).string).size()));
-            } else {
-                TString vectorString = *(yyvsp[(3) - (3)].lex).string;
-                TIntermTyped* index = context->intermediate.addSwizzle(fields, (yyvsp[(3) - (3)].lex).line);
-                (yyval.interm.intermTypedNode) = context->intermediate.addIndex(EOpVectorSwizzle, (yyvsp[(1) - (3)].interm.intermTypedNode), index, (yyvsp[(2) - (3)].lex).line);
-                (yyval.interm.intermTypedNode)->setType(TType((yyvsp[(1) - (3)].interm.intermTypedNode)->getBasicType(), (yyvsp[(1) - (3)].interm.intermTypedNode)->getPrecision(), EvqTemporary, (int) vectorString.size()));
-            }
-        } else if ((yyvsp[(1) - (3)].interm.intermTypedNode)->isMatrix()) {
-            TMatrixFields fields;
-            if (! context->parseMatrixFields(*(yyvsp[(3) - (3)].lex).string, (yyvsp[(1) - (3)].interm.intermTypedNode)->getNominalSize(), (yyvsp[(1) - (3)].interm.intermTypedNode)->getSecondarySize(), fields, (yyvsp[(3) - (3)].lex).line)) {
-                fields.wholeRow = false;
-                fields.wholeCol = false;
-                fields.row = 0;
-                fields.col = 0;
-                context->recover();
-            }
-
-            if (fields.wholeRow || fields.wholeCol) {
-                context->error((yyvsp[(2) - (3)].lex).line, " non-scalar fields not implemented yet", ".");
-                context->recover();
-                ConstantUnion *unionArray = new ConstantUnion[1];
-                unionArray->setIConst(0);
-                TIntermTyped* index = context->intermediate.addConstantUnion(unionArray, TType(EbtInt, EbpUndefined, EvqConstExpr), (yyvsp[(3) - (3)].lex).line);
-                (yyval.interm.intermTypedNode) = context->intermediate.addIndex(EOpIndexDirect, (yyvsp[(1) - (3)].interm.intermTypedNode), index, (yyvsp[(2) - (3)].lex).line);
-                (yyval.interm.intermTypedNode)->setType(TType((yyvsp[(1) - (3)].interm.intermTypedNode)->getBasicType(), (yyvsp[(1) - (3)].interm.intermTypedNode)->getPrecision(),EvqTemporary, (yyvsp[(1) - (3)].interm.intermTypedNode)->getNominalSize()));
-            } else {
-                ConstantUnion *unionArray = new ConstantUnion[1];
-                unionArray->setIConst(fields.col * (yyvsp[(1) - (3)].interm.intermTypedNode)->getNominalSize() + fields.row);
-                TIntermTyped* index = context->intermediate.addConstantUnion(unionArray, TType(EbtInt, EbpUndefined, EvqConstExpr), (yyvsp[(3) - (3)].lex).line);
-                (yyval.interm.intermTypedNode) = context->intermediate.addIndex(EOpIndexDirect, (yyvsp[(1) - (3)].interm.intermTypedNode), index, (yyvsp[(2) - (3)].lex).line);
-                (yyval.interm.intermTypedNode)->setType(TType((yyvsp[(1) - (3)].interm.intermTypedNode)->getBasicType(), (yyvsp[(1) - (3)].interm.intermTypedNode)->getPrecision()));
-            }
-        } else if ((yyvsp[(1) - (3)].interm.intermTypedNode)->getBasicType() == EbtStruct) {
-            bool fieldFound = false;
-            const TStructure* structure = (yyvsp[(1) - (3)].interm.intermTypedNode)->getType().getStruct();
-            if (structure == 0) {
-                context->error((yyvsp[(2) - (3)].lex).line, "structure has no fields", "Internal Error");
-                context->recover();
-                (yyval.interm.intermTypedNode) = (yyvsp[(1) - (3)].interm.intermTypedNode);
-            } else {
-                unsigned int i;
-                const TFieldList& fields = structure->fields();
-                for (i = 0; i < fields.size(); ++i) {
-                    if (fields[i]->name() == *(yyvsp[(3) - (3)].lex).string) {
-                        fieldFound = true;
-                        break;
-                    }
-                }
-                if (fieldFound) {
-                    if ((yyvsp[(1) - (3)].interm.intermTypedNode)->getType().getQualifier() == EvqConstExpr) {
-                        (yyval.interm.intermTypedNode) = context->addConstStruct(*(yyvsp[(3) - (3)].lex).string, (yyvsp[(1) - (3)].interm.intermTypedNode), (yyvsp[(2) - (3)].lex).line);
-                        if ((yyval.interm.intermTypedNode) == 0) {
-                            context->recover();
-                            (yyval.interm.intermTypedNode) = (yyvsp[(1) - (3)].interm.intermTypedNode);
-                        }
-                        else {
-                            (yyval.interm.intermTypedNode)->setType(*fields[i]->type());
-                            // change the qualifier of the return type, not of the structure field
-                            // as the structure definition is shared between various structures.
-                            (yyval.interm.intermTypedNode)->getTypePointer()->setQualifier(EvqConstExpr);
-                        }
-                    } else {
-                        ConstantUnion *unionArray = new ConstantUnion[1];
-                        unionArray->setIConst(i);
-                        TIntermTyped* index = context->intermediate.addConstantUnion(unionArray, *(fields[i]->type()), (yyvsp[(3) - (3)].lex).line);
-                        (yyval.interm.intermTypedNode) = context->intermediate.addIndex(EOpIndexDirectStruct, (yyvsp[(1) - (3)].interm.intermTypedNode), index, (yyvsp[(2) - (3)].lex).line);
-                        (yyval.interm.intermTypedNode)->setType(*fields[i]->type());
-                    }
-                } else {
-                    context->error((yyvsp[(2) - (3)].lex).line, " no such field in structure", (yyvsp[(3) - (3)].lex).string->c_str());
-                    context->recover();
-                    (yyval.interm.intermTypedNode) = (yyvsp[(1) - (3)].interm.intermTypedNode);
-                }
-            }
-        } else {
-            context->error((yyvsp[(2) - (3)].lex).line, " field selection requires structure, vector, or matrix on left hand side", (yyvsp[(3) - (3)].lex).string->c_str());
-            context->recover();
-            (yyval.interm.intermTypedNode) = (yyvsp[(1) - (3)].interm.intermTypedNode);
-        }
-        // don't delete $3.string, it's from the pool
+        (yyval.interm.intermTypedNode) = context->addFieldSelectionExpression((yyvsp[(1) - (3)].interm.intermTypedNode), (yyvsp[(2) - (3)].lex).line, *(yyvsp[(3) - (3)].lex).string, (yyvsp[(3) - (3)].lex).line);
     }
     break;
 
   case 13:
 
     {
-        if (context->lValueErrorCheck((yyvsp[(2) - (2)].lex).line, "++", (yyvsp[(1) - (2)].interm.intermTypedNode)))
-            context->recover();
-        (yyval.interm.intermTypedNode) = context->intermediate.addUnaryMath(EOpPostIncrement, (yyvsp[(1) - (2)].interm.intermTypedNode), (yyvsp[(2) - (2)].lex).line);
-        if ((yyval.interm.intermTypedNode) == 0) {
-            context->unaryOpError((yyvsp[(2) - (2)].lex).line, "++", (yyvsp[(1) - (2)].interm.intermTypedNode)->getCompleteString());
-            context->recover();
-            (yyval.interm.intermTypedNode) = (yyvsp[(1) - (2)].interm.intermTypedNode);
-        }
+        (yyval.interm.intermTypedNode) = context->addUnaryMathLValue(EOpPostIncrement, (yyvsp[(1) - (2)].interm.intermTypedNode), (yyvsp[(2) - (2)].lex).line);
     }
     break;
 
   case 14:
 
     {
-        if (context->lValueErrorCheck((yyvsp[(2) - (2)].lex).line, "--", (yyvsp[(1) - (2)].interm.intermTypedNode)))
-            context->recover();
-        (yyval.interm.intermTypedNode) = context->intermediate.addUnaryMath(EOpPostDecrement, (yyvsp[(1) - (2)].interm.intermTypedNode), (yyvsp[(2) - (2)].lex).line);
-        if ((yyval.interm.intermTypedNode) == 0) {
-            context->unaryOpError((yyvsp[(2) - (2)].lex).line, "--", (yyvsp[(1) - (2)].interm.intermTypedNode)->getCompleteString());
-            context->recover();
-            (yyval.interm.intermTypedNode) = (yyvsp[(1) - (2)].interm.intermTypedNode);
-        }
+        (yyval.interm.intermTypedNode) = context->addUnaryMathLValue(EOpPostDecrement, (yyvsp[(1) - (2)].interm.intermTypedNode), (yyvsp[(2) - (2)].lex).line);
     }
     break;
 
@@ -4645,18 +4475,7 @@
   case 193:
 
     {
-        if (context->reservedErrorCheck((yyvsp[(2) - (6)].lex).line, *(yyvsp[(2) - (6)].lex).string))
-            context->recover();
-
-        TType* structure = new TType(new TStructure((yyvsp[(2) - (6)].lex).string, (yyvsp[(5) - (6)].interm.fieldList)));
-        TVariable* userTypeDef = new TVariable((yyvsp[(2) - (6)].lex).string, *structure, true);
-        if (! context->symbolTable.declare(*userTypeDef)) {
-            context->error((yyvsp[(2) - (6)].lex).line, "redefinition", (yyvsp[(2) - (6)].lex).string->c_str(), "struct");
-            context->recover();
-        }
-        (yyval.interm.type).setBasic(EbtStruct, EvqTemporary, (yyvsp[(1) - (6)].lex).line);
-        (yyval.interm.type).userDef = structure;
-        context->exitStructDeclaration();
+        (yyval.interm.type) = context->addStructure((yyvsp[(1) - (6)].lex).line, (yyvsp[(2) - (6)].lex).line, (yyvsp[(2) - (6)].lex).string, (yyvsp[(5) - (6)].interm.fieldList));
     }
     break;
 
@@ -4668,11 +4487,7 @@
   case 195:
 
     {
-        TString emptyName("");
-        TType* structure = new TType(new TStructure(&emptyName, (yyvsp[(4) - (5)].interm.fieldList)));
-        (yyval.interm.type).setBasic(EbtStruct, EvqTemporary, (yyvsp[(1) - (5)].lex).line);
-        (yyval.interm.type).userDef = structure;
-        context->exitStructDeclaration();
+        (yyval.interm.type) = context->addStructure((yyvsp[(1) - (5)].lex).line, (yyvsp[(1) - (5)].lex).line, NewPoolTString(""), (yyvsp[(4) - (5)].interm.fieldList));
     }
     break;
 
@@ -4703,51 +4518,36 @@
   case 198:
 
     {
-        (yyval.interm.fieldList) = (yyvsp[(2) - (3)].interm.fieldList);
-
-        if (context->voidErrorCheck((yyvsp[(1) - (3)].interm.type).line, (*(yyvsp[(2) - (3)].interm.fieldList))[0]->name(), (yyvsp[(1) - (3)].interm.type))) {
-            context->recover();
-        }
-        for (unsigned int i = 0; i < (yyval.interm.fieldList)->size(); ++i) {
-            //
-            // Careful not to replace already known aspects of type, like array-ness
-            //
-            TType* type = (*(yyval.interm.fieldList))[i]->type();
-            type->setBasicType((yyvsp[(1) - (3)].interm.type).type);
-            type->setNominalSize((yyvsp[(1) - (3)].interm.type).primarySize);
-            type->setSecondarySize((yyvsp[(1) - (3)].interm.type).secondarySize);
-            type->setPrecision((yyvsp[(1) - (3)].interm.type).precision);
-
-            // don't allow arrays of arrays
-            if (type->isArray()) {
-                if (context->arrayTypeErrorCheck((yyvsp[(1) - (3)].interm.type).line, (yyvsp[(1) - (3)].interm.type)))
-                    context->recover();
-            }
-            if ((yyvsp[(1) - (3)].interm.type).array)
-                type->setArraySize((yyvsp[(1) - (3)].interm.type).arraySize);
-            if ((yyvsp[(1) - (3)].interm.type).userDef) {
-                type->setStruct((yyvsp[(1) - (3)].interm.type).userDef->getStruct());
-            }
-        }
+        (yyval.interm.fieldList) = context->addStructDeclaratorList((yyvsp[(1) - (3)].interm.type), (yyvsp[(2) - (3)].interm.fieldList));
     }
     break;
 
   case 199:
 
     {
+        // ES3 Only, but errors should be handled elsewhere
+        (yyvsp[(2) - (4)].interm.type).qualifier = (yyvsp[(1) - (4)].interm.type).qualifier;
+        (yyvsp[(2) - (4)].interm.type).layoutQualifier = (yyvsp[(1) - (4)].interm.type).layoutQualifier;
+        (yyval.interm.fieldList) = context->addStructDeclaratorList((yyvsp[(2) - (4)].interm.type), (yyvsp[(3) - (4)].interm.fieldList));
+    }
+    break;
+
+  case 200:
+
+    {
         (yyval.interm.fieldList) = NewPoolTFieldList();
         (yyval.interm.fieldList)->push_back((yyvsp[(1) - (1)].interm.field));
     }
     break;
 
-  case 200:
+  case 201:
 
     {
         (yyval.interm.fieldList)->push_back((yyvsp[(3) - (3)].interm.field));
     }
     break;
 
-  case 201:
+  case 202:
 
     {
         if (context->reservedErrorCheck((yyvsp[(1) - (1)].lex).line, *(yyvsp[(1) - (1)].lex).string))
@@ -4758,7 +4558,7 @@
     }
     break;
 
-  case 202:
+  case 203:
 
     {
         if (context->reservedErrorCheck((yyvsp[(1) - (4)].lex).line, *(yyvsp[(1) - (4)].lex).string))
@@ -4774,24 +4574,19 @@
     }
     break;
 
-  case 203:
+  case 204:
 
     { (yyval.interm.intermTypedNode) = (yyvsp[(1) - (1)].interm.intermTypedNode); }
     break;
 
-  case 204:
-
-    { (yyval.interm.intermNode) = (yyvsp[(1) - (1)].interm.intermNode); }
-    break;
-
   case 205:
 
-    { (yyval.interm.intermNode) = (yyvsp[(1) - (1)].interm.intermAggregate); }
+    { (yyval.interm.intermNode) = (yyvsp[(1) - (1)].interm.intermNode); }
     break;
 
   case 206:
 
-    { (yyval.interm.intermNode) = (yyvsp[(1) - (1)].interm.intermNode); }
+    { (yyval.interm.intermNode) = (yyvsp[(1) - (1)].interm.intermAggregate); }
     break;
 
   case 207:
@@ -4821,21 +4616,26 @@
 
   case 212:
 
-    { (yyval.interm.intermAggregate) = 0; }
+    { (yyval.interm.intermNode) = (yyvsp[(1) - (1)].interm.intermNode); }
     break;
 
   case 213:
 
-    { context->symbolTable.push(); }
+    { (yyval.interm.intermAggregate) = 0; }
     break;
 
   case 214:
 
-    { context->symbolTable.pop(); }
+    { context->symbolTable.push(); }
     break;
 
   case 215:
 
+    { context->symbolTable.pop(); }
+    break;
+
+  case 216:
+
     {
         if ((yyvsp[(3) - (5)].interm.intermAggregate) != 0) {
             (yyvsp[(3) - (5)].interm.intermAggregate)->setOp(EOpSequence);
@@ -4845,11 +4645,6 @@
     }
     break;
 
-  case 216:
-
-    { (yyval.interm.intermNode) = (yyvsp[(1) - (1)].interm.intermNode); }
-    break;
-
   case 217:
 
     { (yyval.interm.intermNode) = (yyvsp[(1) - (1)].interm.intermNode); }
@@ -4857,32 +4652,37 @@
 
   case 218:
 
-    { context->symbolTable.push(); }
+    { (yyval.interm.intermNode) = (yyvsp[(1) - (1)].interm.intermNode); }
     break;
 
   case 219:
 
-    { context->symbolTable.pop(); (yyval.interm.intermNode) = (yyvsp[(2) - (2)].interm.intermNode); }
+    { context->symbolTable.push(); }
     break;
 
   case 220:
 
-    { context->symbolTable.push(); }
+    { context->symbolTable.pop(); (yyval.interm.intermNode) = (yyvsp[(2) - (2)].interm.intermNode); }
     break;
 
   case 221:
 
-    { context->symbolTable.pop(); (yyval.interm.intermNode) = (yyvsp[(2) - (2)].interm.intermNode); }
+    { context->symbolTable.push(); }
     break;
 
   case 222:
 
+    { context->symbolTable.pop(); (yyval.interm.intermNode) = (yyvsp[(2) - (2)].interm.intermNode); }
+    break;
+
+  case 223:
+
     {
         (yyval.interm.intermNode) = 0;
     }
     break;
 
-  case 223:
+  case 224:
 
     {
         if ((yyvsp[(2) - (3)].interm.intermAggregate)) {
@@ -4893,31 +4693,31 @@
     }
     break;
 
-  case 224:
+  case 225:
 
     {
         (yyval.interm.intermAggregate) = context->intermediate.makeAggregate((yyvsp[(1) - (1)].interm.intermNode), 0);
     }
     break;
 
-  case 225:
+  case 226:
 
     {
         (yyval.interm.intermAggregate) = context->intermediate.growAggregate((yyvsp[(1) - (2)].interm.intermAggregate), (yyvsp[(2) - (2)].interm.intermNode), 0);
     }
     break;
 
-  case 226:
+  case 227:
 
     { (yyval.interm.intermNode) = 0; }
     break;
 
-  case 227:
+  case 228:
 
     { (yyval.interm.intermNode) = static_cast<TIntermNode*>((yyvsp[(1) - (2)].interm.intermTypedNode)); }
     break;
 
-  case 228:
+  case 229:
 
     {
         if (context->boolErrorCheck((yyvsp[(1) - (5)].lex).line, (yyvsp[(3) - (5)].interm.intermTypedNode)))
@@ -4926,7 +4726,7 @@
     }
     break;
 
-  case 229:
+  case 230:
 
     {
         (yyval.interm.nodePair).node1 = (yyvsp[(1) - (3)].interm.intermNode);
@@ -4934,7 +4734,7 @@
     }
     break;
 
-  case 230:
+  case 231:
 
     {
         (yyval.interm.nodePair).node1 = (yyvsp[(1) - (1)].interm.intermNode);
@@ -4942,7 +4742,7 @@
     }
     break;
 
-  case 231:
+  case 232:
 
     {
         (yyval.interm.intermTypedNode) = (yyvsp[(1) - (1)].interm.intermTypedNode);
@@ -4951,7 +4751,7 @@
     }
     break;
 
-  case 232:
+  case 233:
 
     {
         TIntermNode* intermNode;
@@ -4969,12 +4769,12 @@
     }
     break;
 
-  case 233:
+  case 234:
 
     { context->symbolTable.push(); ++context->loopNestingLevel; }
     break;
 
-  case 234:
+  case 235:
 
     {
         context->symbolTable.pop();
@@ -4983,12 +4783,12 @@
     }
     break;
 
-  case 235:
+  case 236:
 
     { ++context->loopNestingLevel; }
     break;
 
-  case 236:
+  case 237:
 
     {
         if (context->boolErrorCheck((yyvsp[(8) - (8)].lex).line, (yyvsp[(6) - (8)].interm.intermTypedNode)))
@@ -4999,24 +4799,17 @@
     }
     break;
 
-  case 237:
-
-    { context->symbolTable.push(); ++context->loopNestingLevel; }
-    break;
-
   case 238:
 
-    {
-        context->symbolTable.pop();
-        (yyval.interm.intermNode) = context->intermediate.addLoop(ELoopFor, (yyvsp[(4) - (7)].interm.intermNode), reinterpret_cast<TIntermTyped*>((yyvsp[(5) - (7)].interm.nodePair).node1), reinterpret_cast<TIntermTyped*>((yyvsp[(5) - (7)].interm.nodePair).node2), (yyvsp[(7) - (7)].interm.intermNode), (yyvsp[(1) - (7)].lex).line);
-        --context->loopNestingLevel;
-    }
+    { context->symbolTable.push(); ++context->loopNestingLevel; }
     break;
 
   case 239:
 
     {
-        (yyval.interm.intermNode) = (yyvsp[(1) - (1)].interm.intermNode);
+        context->symbolTable.pop();
+        (yyval.interm.intermNode) = context->intermediate.addLoop(ELoopFor, (yyvsp[(4) - (7)].interm.intermNode), reinterpret_cast<TIntermTyped*>((yyvsp[(5) - (7)].interm.nodePair).node1), reinterpret_cast<TIntermTyped*>((yyvsp[(5) - (7)].interm.nodePair).node2), (yyvsp[(7) - (7)].interm.intermNode), (yyvsp[(1) - (7)].lex).line);
+        --context->loopNestingLevel;
     }
     break;
 
@@ -5030,26 +4823,33 @@
   case 241:
 
     {
-        (yyval.interm.intermTypedNode) = (yyvsp[(1) - (1)].interm.intermTypedNode);
+        (yyval.interm.intermNode) = (yyvsp[(1) - (1)].interm.intermNode);
     }
     break;
 
   case 242:
 
     {
-        (yyval.interm.intermTypedNode) = 0;
+        (yyval.interm.intermTypedNode) = (yyvsp[(1) - (1)].interm.intermTypedNode);
     }
     break;
 
   case 243:
 
     {
+        (yyval.interm.intermTypedNode) = 0;
+    }
+    break;
+
+  case 244:
+
+    {
         (yyval.interm.nodePair).node1 = (yyvsp[(1) - (2)].interm.intermTypedNode);
         (yyval.interm.nodePair).node2 = 0;
     }
     break;
 
-  case 244:
+  case 245:
 
     {
         (yyval.interm.nodePair).node1 = (yyvsp[(1) - (3)].interm.intermTypedNode);
@@ -5057,7 +4857,7 @@
     }
     break;
 
-  case 245:
+  case 246:
 
     {
         if (context->loopNestingLevel <= 0) {
@@ -5068,7 +4868,7 @@
     }
     break;
 
-  case 246:
+  case 247:
 
     {
         if (context->loopNestingLevel <= 0) {
@@ -5079,7 +4879,7 @@
     }
     break;
 
-  case 247:
+  case 248:
 
     {
         (yyval.interm.intermNode) = context->intermediate.addBranch(EOpReturn, (yyvsp[(1) - (2)].lex).line);
@@ -5090,7 +4890,7 @@
     }
     break;
 
-  case 248:
+  case 249:
 
     {
         (yyval.interm.intermNode) = context->intermediate.addBranch(EOpReturn, (yyvsp[(2) - (3)].interm.intermTypedNode), (yyvsp[(1) - (3)].lex).line);
@@ -5105,7 +4905,7 @@
     }
     break;
 
-  case 249:
+  case 250:
 
     {
         FRAG_ONLY("discard", (yyvsp[(1) - (2)].lex).line);
@@ -5113,18 +4913,10 @@
     }
     break;
 
-  case 250:
-
-    {
-        (yyval.interm.intermNode) = (yyvsp[(1) - (1)].interm.intermNode);
-        context->treeRoot = (yyval.interm.intermNode);
-    }
-    break;
-
   case 251:
 
     {
-        (yyval.interm.intermNode) = context->intermediate.growAggregate((yyvsp[(1) - (2)].interm.intermNode), (yyvsp[(2) - (2)].interm.intermNode), 0);
+        (yyval.interm.intermNode) = (yyvsp[(1) - (1)].interm.intermNode);
         context->treeRoot = (yyval.interm.intermNode);
     }
     break;
@@ -5132,7 +4924,8 @@
   case 252:
 
     {
-        (yyval.interm.intermNode) = (yyvsp[(1) - (1)].interm.intermNode);
+        (yyval.interm.intermNode) = context->intermediate.growAggregate((yyvsp[(1) - (2)].interm.intermNode), (yyvsp[(2) - (2)].interm.intermNode), 0);
+        context->treeRoot = (yyval.interm.intermNode);
     }
     break;
 
@@ -5146,6 +4939,13 @@
   case 254:
 
     {
+        (yyval.interm.intermNode) = (yyvsp[(1) - (1)].interm.intermNode);
+    }
+    break;
+
+  case 255:
+
+    {
         TFunction* function = (yyvsp[(1) - (1)].interm).function;
         
         const TSymbol *builtIn = context->symbolTable.findBuiltIn(function->getMangledName(), context->shaderVersion);
@@ -5232,7 +5032,7 @@
     }
     break;
 
-  case 255:
+  case 256:
 
     {
         //?? Check that all paths return a value if return type != void ?
diff --git a/src/OpenGL/compiler/intermediate.h b/src/OpenGL/compiler/intermediate.h
index e0ca128..7a38049 100644
--- a/src/OpenGL/compiler/intermediate.h
+++ b/src/OpenGL/compiler/intermediate.h
@@ -89,6 +89,7 @@
     EOpIndexDirect,
     EOpIndexIndirect,
     EOpIndexDirectStruct,
+    EOpIndexDirectInterfaceBlock,
 
     EOpVectorSwizzle,
 
@@ -295,6 +296,7 @@
     int getNominalSize() const { return type.getNominalSize(); }
 	int getSecondarySize() const { return type.getSecondarySize(); }
     
+	bool isInterfaceBlock() const { return type.isInterfaceBlock(); }
     bool isMatrix() const { return type.isMatrix(); }
     bool isArray()  const { return type.isArray(); }
     bool isVector() const { return type.isVector(); }
@@ -412,6 +414,9 @@
     float getFConst(int index) const { return unionArrayPointer ? unionArrayPointer[index].getFConst() : 0.0f; }
     bool getBConst(int index) const { return unionArrayPointer ? unionArrayPointer[index].getBConst() : false; }
 
+	// Previous union pointer freed on pool deallocation.
+	void replaceConstantUnion(ConstantUnion *safeConstantUnion) { unionArrayPointer = safeConstantUnion; }
+
     virtual TIntermConstantUnion* getAsConstantUnion()  { return this; }
     virtual void traverse(TIntermTraverser*);