//-----------------------------------------------------------------------
    void CompositorScriptCompiler::parseClearBuffers(void)
    {
		assert(mScriptContext.pass);
		// while there are tokens for the action, get next token and set buffer flag
		uint32 bufferFlags = 0;

		while (getRemainingTokensForAction() > 0)
		{
		    switch (getNextTokenID())
		    {
            case ID_CLR_COLOUR:
                bufferFlags |= FBT_COLOUR;
                break;

            case ID_CLR_DEPTH:
                bufferFlags |= FBT_DEPTH;
                break;

            case ID_STENCIL:
                bufferFlags |= FBT_STENCIL;
                break;

            default:
                break;
		    }
		}
		mScriptContext.pass->setClearBuffers(bufferFlags);
    }
	//-----------------------------------------------------------------------
	void CompositorScriptCompiler::parseInput(void)
	{
		// input parameters depends on context either target or pass
		if (mScriptContext.section == CSS_TARGET)
		{
		    // for input in target, there is only one parameter
		    assert(mScriptContext.target);
		    if (testNextTokenID(ID_PREVIOUS))
                mScriptContext.target->setInputMode(CompositionTargetPass::IM_PREVIOUS);
            else
                mScriptContext.target->setInputMode(CompositionTargetPass::IM_NONE);
		}
		else // assume for pass section context
		{
		    // for input in pass, there are two parameters
		    assert(mScriptContext.pass);
		    uint32 id = static_cast<uint32>(getNextTokenValue());
		    const String& textureName = getNextTokenLabel();
			// MRT index?
			size_t mrtIndex = 0;
			if (getRemainingTokensForAction() > 0)
			{
				mrtIndex = static_cast<size_t>(getNextTokenValue()); 
			}
		    mScriptContext.pass->setInput(id, textureName, mrtIndex);
		}

	}
	//-----------------------------------------------------------------------
	void CompositorScriptCompiler::parseTexture(void)
	{
	    assert(mScriptContext.technique);
		const String textureName = getNextTokenLabel();
        CompositionTechnique::TextureDefinition* textureDef = mScriptContext.technique->createTextureDefinition(textureName);
        // if peek next token is target_width then get token and use 0 for width
        // determine width parameter
		if (testNextTokenID(ID_TARGET_WIDTH_SCALED))
		{
			getNextToken();
			// a value of zero causes texture to be size of render target
			textureDef->width = 0;
			// get factor from next token
			textureDef->widthFactor = static_cast<float>(getNextTokenValue());

		}
        else if (testNextTokenID(ID_TARGET_WIDTH))
        {
            getNextToken();
            // a value of zero causes texture to be size of render target
            textureDef->width = 0;
			textureDef->widthFactor = 1.0f;
        }
        else
        {
            textureDef->width = static_cast<size_t>(getNextTokenValue());
        }
        // determine height parameter
		if (testNextTokenID(ID_TARGET_HEIGHT_SCALED))
		{
			getNextToken();
			// a value of zero causes texture to be dependent on render target
			textureDef->height = 0;
			// get factor from next token
			textureDef->heightFactor = static_cast<float>(getNextTokenValue());

		}
        else if (testNextTokenID(ID_TARGET_HEIGHT))
        {
            getNextToken();
            // a value of zero causes texture to be size of render target
            textureDef->height = 0;
			textureDef->heightFactor = 1.0f;
        }
        else
        {
            textureDef->height = static_cast<size_t>(getNextTokenValue());
        }
        // get pixel factor
		while (getRemainingTokensForAction() > 0)
		{
			switch (getNextTokenID())
			{
			case ID_PF_A8R8G8B8:
				textureDef->formatList.push_back(PF_A8R8G8B8);
				break;

			case ID_PF_R8G8B8A8:
				textureDef->formatList.push_back(PF_R8G8B8A8);
				break;
			case ID_PF_R8G8B8:
				textureDef->formatList.push_back(PF_R8G8B8);
				break;
			case ID_PF_FLOAT16_R:
				textureDef->formatList.push_back(PF_FLOAT16_R);
				break;
			case ID_PF_FLOAT16_GR:
				textureDef->formatList.push_back(PF_FLOAT16_GR);
				break;
			case ID_PF_FLOAT16_RGB:
				textureDef->formatList.push_back(PF_FLOAT16_RGB);
				break;
			case ID_PF_FLOAT16_RGBA:
				textureDef->formatList.push_back(PF_FLOAT16_RGBA);
				break;
			case ID_PF_FLOAT32_R:
				textureDef->formatList.push_back(PF_FLOAT32_R);
				break;
			case ID_PF_FLOAT32_GR:
				textureDef->formatList.push_back(PF_FLOAT32_GR);
				break;
			case ID_PF_FLOAT32_RGB:
				textureDef->formatList.push_back(PF_FLOAT32_RGB);
				break;
			case ID_PF_FLOAT32_RGBA:
				textureDef->formatList.push_back(PF_FLOAT32_RGBA);
				break;
			default:
				// should never get here?
				break;
			}
		}
	}