/******************************************************************
 * File: vs20_parser.hpp
 *
 * This file was automatically generated by CppCC Version 0.0.5
 * DO NOT EDIT MANUALLY
 ******************************************************************/


#ifndef __VS20_PARSER_HH__
#define __VS20_PARSER_HH__

#include <string>
#include <exception>
using namespace std;

#include "vs20_token.hpp"
#include "vs20_scanner.hpp"
#include "VS_2_0Assembler.hpp"

#include "Instruction.hpp"
#include "Operand.hpp"
#include "Error.hpp"

#include <string.h>
#include <list>

#pragma warning(disable : 4290)
#pragma warning(disable : 4786)


namespace vs20
{

class ParseException : public exception
{
  public:
    
    ParseException (const string &message_ = "Parse exception") :
      message(message_)
    {}
    
    ParseException (const Position &pos_,
                   const string &message_ = "Parse exception") :
      message(message_), pos(pos_)
    {}
    
    ~ParseException () throw ()
    {}
    
    virtual operator string () const
    {
      return string(pos) + ": " + message;
    }
    
    virtual const char* what () throw ()
    {
      return message.c_str();
    }
    
    virtual Position& where () throw ()
    {
      return pos;
    }
    
  private:
  
    Position pos;
    string message;
}; // end class PasreException


class vs20_parser_base
{
  protected:
    bool onParseError (ParseException &pex) { return false; }
};


class vs20_parser : public vs20_parser_base,  public swShader::VS_2_0Assembler


{
  public: // methods
    
    vs20_parser (istream *in_ = NULL) throw (ScanException, ParseException) :
       scanner(in_), _la(0)
    {}
    
    // productions entry points:
    
    void
     main ()
       throw (ScanException, ParseException);
    void
     instruction ()
       throw (ScanException, ParseException);
    void
     vsInstruction ()
       throw (ScanException, ParseException);
    void
     dcl_positionInstruction ()
       throw (ScanException, ParseException);
    void
     dcl_blendweightInstruction ()
       throw (ScanException, ParseException);
    void
     dcl_blendindicesInstruction ()
       throw (ScanException, ParseException);
    void
     dcl_normalInstruction ()
       throw (ScanException, ParseException);
    void
     dcl_psizeInstruction ()
       throw (ScanException, ParseException);
    void
     dcl_texcoordInstruction ()
       throw (ScanException, ParseException);
    void
     dcl_tangentInstruction ()
       throw (ScanException, ParseException);
    void
     dcl_binormalInstruction ()
       throw (ScanException, ParseException);
    void
     dcl_tessfactorInstruction ()
       throw (ScanException, ParseException);
    void
     dcl_positiontInstruction ()
       throw (ScanException, ParseException);
    void
     dcl_colorInstruction ()
       throw (ScanException, ParseException);
    void
     dcl_fogInstruction ()
       throw (ScanException, ParseException);
    void
     dcl_depthInstruction ()
       throw (ScanException, ParseException);
    void
     dcl_sampleInstruction ()
       throw (ScanException, ParseException);
    void
     defInstruction ()
       throw (ScanException, ParseException);
    void
     defbInstruction ()
       throw (ScanException, ParseException);
    void
     defiInstruction ()
       throw (ScanException, ParseException);
    void
     absInstruction ()
       throw (ScanException, ParseException);
    void
     addInstruction ()
       throw (ScanException, ParseException);
    void
     crsInstruction ()
       throw (ScanException, ParseException);
    void
     dp3Instruction ()
       throw (ScanException, ParseException);
    void
     dp4Instruction ()
       throw (ScanException, ParseException);
    void
     dstInstruction ()
       throw (ScanException, ParseException);
    void
     expInstruction ()
       throw (ScanException, ParseException);
    void
     exppInstruction ()
       throw (ScanException, ParseException);
    void
     frcInstruction ()
       throw (ScanException, ParseException);
    void
     litInstruction ()
       throw (ScanException, ParseException);
    void
     logInstruction ()
       throw (ScanException, ParseException);
    void
     logpInstruction ()
       throw (ScanException, ParseException);
    void
     lrpInstruction ()
       throw (ScanException, ParseException);
    void
     m3x2Instruction ()
       throw (ScanException, ParseException);
    void
     m3x3Instruction ()
       throw (ScanException, ParseException);
    void
     m3x4Instruction ()
       throw (ScanException, ParseException);
    void
     m4x3Instruction ()
       throw (ScanException, ParseException);
    void
     m4x4Instruction ()
       throw (ScanException, ParseException);
    void
     madInstruction ()
       throw (ScanException, ParseException);
    void
     maxInstruction ()
       throw (ScanException, ParseException);
    void
     minInstruction ()
       throw (ScanException, ParseException);
    void
     movInstruction ()
       throw (ScanException, ParseException);
    void
     movaInstruction ()
       throw (ScanException, ParseException);
    void
     mulInstruction ()
       throw (ScanException, ParseException);
    void
     nopInstruction ()
       throw (ScanException, ParseException);
    void
     nrmInstruction ()
       throw (ScanException, ParseException);
    void
     powInstruction ()
       throw (ScanException, ParseException);
    void
     rcpInstruction ()
       throw (ScanException, ParseException);
    void
     rsqInstruction ()
       throw (ScanException, ParseException);
    void
     sgeInstruction ()
       throw (ScanException, ParseException);
    void
     sgnInstruction ()
       throw (ScanException, ParseException);
    void
     sincosInstruction ()
       throw (ScanException, ParseException);
    void
     sltInstruction ()
       throw (ScanException, ParseException);
    void
     callInstruction ()
       throw (ScanException, ParseException);
    void
     callnzInstruction ()
       throw (ScanException, ParseException);
    void
     elseInstruction ()
       throw (ScanException, ParseException);
    void
     endifInstruction ()
       throw (ScanException, ParseException);
    void
     endloopInstruction ()
       throw (ScanException, ParseException);
    void
     endrepInstruction ()
       throw (ScanException, ParseException);
    void
     ifInstruction ()
       throw (ScanException, ParseException);
    void
     labelInstruction ()
       throw (ScanException, ParseException);
    void
     loopInstruction ()
       throw (ScanException, ParseException);
    void
     repInstruction ()
       throw (ScanException, ParseException);
    void
     retInstruction ()
       throw (ScanException, ParseException);
    void
     instructionModifier ()
       throw (ScanException, ParseException);
    void
     dst ()
       throw (ScanException, ParseException);
    void
     dest ()
       throw (ScanException, ParseException);
    void
     a0 ()
       throw (ScanException, ParseException);
    void
     aL ()
       throw (ScanException, ParseException);
    void
     cn ()
       throw (ScanException, ParseException);
    void
     bn ()
       throw (ScanException, ParseException);
    void
     in ()
       throw (ScanException, ParseException);
    void
     fValue1 ()
       throw (ScanException, ParseException);
    void
     fValue2 ()
       throw (ScanException, ParseException);
    void
     fValue3 ()
       throw (ScanException, ParseException);
    void
     fValue4 ()
       throw (ScanException, ParseException);
    void
     integerValue1 ()
       throw (ScanException, ParseException);
    void
     integerValue2 ()
       throw (ScanException, ParseException);
    void
     integerValue3 ()
       throw (ScanException, ParseException);
    void
     integerValue4 ()
       throw (ScanException, ParseException);
    void
     booleanValue ()
       throw (ScanException, ParseException);
    void
     src ()
       throw (ScanException, ParseException);
    void
     src0 ()
       throw (ScanException, ParseException);
    void
     src1 ()
       throw (ScanException, ParseException);
    void
     src2 ()
       throw (ScanException, ParseException);
    void
     outputRegister ()
       throw (ScanException, ParseException);
    void
     inputRegister ()
       throw (ScanException, ParseException);
    void
     sourceModifier ()
       throw (ScanException, ParseException);
    void
     writeMask ()
       throw (ScanException, ParseException);
    void
     sourceSwizzle ()
       throw (ScanException, ParseException);
    void
     vertexRegister ()
       throw (ScanException, ParseException);
    void
     temporaryRegister ()
       throw (ScanException, ParseException);
    void
     constantFloatRegister ()
       throw (ScanException, ParseException);
    void
     constantIntegerRegister ()
       throw (ScanException, ParseException);
    void
     constantBooleanRegister ()
       throw (ScanException, ParseException);
    void
     a0Register ()
       throw (ScanException, ParseException);
    void
     aLRegister ()
       throw (ScanException, ParseException);
    void
     diffuseSpecularRegister ()
       throw (ScanException, ParseException);
    void
     fogRegister ()
       throw (ScanException, ParseException);
    void
     positionRegister ()
       throw (ScanException, ParseException);
    void
     pointSizeRegister ()
       throw (ScanException, ParseException);
    void
     textureCoordinateRegister ()
       throw (ScanException, ParseException);
    
    // productions LA methods:
    
    bool __la_main_ () throw (ScanException);
    bool __la_instruction_ () throw (ScanException);
    bool __la_vsInstruction_ () throw (ScanException);
    bool __la_dcl_positionInstruction_ () throw (ScanException);
    bool __la_dcl_blendweightInstruction_ () throw (ScanException);
    bool __la_dcl_blendindicesInstruction_ () throw (ScanException);
    bool __la_dcl_normalInstruction_ () throw (ScanException);
    bool __la_dcl_psizeInstruction_ () throw (ScanException);
    bool __la_dcl_texcoordInstruction_ () throw (ScanException);
    bool __la_dcl_tangentInstruction_ () throw (ScanException);
    bool __la_dcl_binormalInstruction_ () throw (ScanException);
    bool __la_dcl_tessfactorInstruction_ () throw (ScanException);
    bool __la_dcl_positiontInstruction_ () throw (ScanException);
    bool __la_dcl_colorInstruction_ () throw (ScanException);
    bool __la_dcl_fogInstruction_ () throw (ScanException);
    bool __la_dcl_depthInstruction_ () throw (ScanException);
    bool __la_dcl_sampleInstruction_ () throw (ScanException);
    bool __la_defInstruction_ () throw (ScanException);
    bool __la_defbInstruction_ () throw (ScanException);
    bool __la_defiInstruction_ () throw (ScanException);
    bool __la_absInstruction_ () throw (ScanException);
    bool __la_addInstruction_ () throw (ScanException);
    bool __la_crsInstruction_ () throw (ScanException);
    bool __la_dp3Instruction_ () throw (ScanException);
    bool __la_dp4Instruction_ () throw (ScanException);
    bool __la_dstInstruction_ () throw (ScanException);
    bool __la_expInstruction_ () throw (ScanException);
    bool __la_exppInstruction_ () throw (ScanException);
    bool __la_frcInstruction_ () throw (ScanException);
    bool __la_litInstruction_ () throw (ScanException);
    bool __la_logInstruction_ () throw (ScanException);
    bool __la_logpInstruction_ () throw (ScanException);
    bool __la_lrpInstruction_ () throw (ScanException);
    bool __la_m3x2Instruction_ () throw (ScanException);
    bool __la_m3x3Instruction_ () throw (ScanException);
    bool __la_m3x4Instruction_ () throw (ScanException);
    bool __la_m4x3Instruction_ () throw (ScanException);
    bool __la_m4x4Instruction_ () throw (ScanException);
    bool __la_madInstruction_ () throw (ScanException);
    bool __la_maxInstruction_ () throw (ScanException);
    bool __la_minInstruction_ () throw (ScanException);
    bool __la_movInstruction_ () throw (ScanException);
    bool __la_movaInstruction_ () throw (ScanException);
    bool __la_mulInstruction_ () throw (ScanException);
    bool __la_nopInstruction_ () throw (ScanException);
    bool __la_nrmInstruction_ () throw (ScanException);
    bool __la_powInstruction_ () throw (ScanException);
    bool __la_rcpInstruction_ () throw (ScanException);
    bool __la_rsqInstruction_ () throw (ScanException);
    bool __la_sgeInstruction_ () throw (ScanException);
    bool __la_sgnInstruction_ () throw (ScanException);
    bool __la_sincosInstruction_ () throw (ScanException);
    bool __la_sltInstruction_ () throw (ScanException);
    bool __la_callInstruction_ () throw (ScanException);
    bool __la_callnzInstruction_ () throw (ScanException);
    bool __la_elseInstruction_ () throw (ScanException);
    bool __la_endifInstruction_ () throw (ScanException);
    bool __la_endloopInstruction_ () throw (ScanException);
    bool __la_endrepInstruction_ () throw (ScanException);
    bool __la_ifInstruction_ () throw (ScanException);
    bool __la_labelInstruction_ () throw (ScanException);
    bool __la_loopInstruction_ () throw (ScanException);
    bool __la_repInstruction_ () throw (ScanException);
    bool __la_retInstruction_ () throw (ScanException);
    bool __la_instructionModifier_ () throw (ScanException);
    bool __la_dst_ () throw (ScanException);
    bool __la_dest_ () throw (ScanException);
    bool __la_a0_ () throw (ScanException);
    bool __la_aL_ () throw (ScanException);
    bool __la_cn_ () throw (ScanException);
    bool __la_bn_ () throw (ScanException);
    bool __la_in_ () throw (ScanException);
    bool __la_fValue1_ () throw (ScanException);
    bool __la_fValue2_ () throw (ScanException);
    bool __la_fValue3_ () throw (ScanException);
    bool __la_fValue4_ () throw (ScanException);
    bool __la_integerValue1_ () throw (ScanException);
    bool __la_integerValue2_ () throw (ScanException);
    bool __la_integerValue3_ () throw (ScanException);
    bool __la_integerValue4_ () throw (ScanException);
    bool __la_booleanValue_ () throw (ScanException);
    bool __la_src_ () throw (ScanException);
    bool __la_src0_ () throw (ScanException);
    bool __la_src1_ () throw (ScanException);
    bool __la_src2_ () throw (ScanException);
    bool __la_outputRegister_ () throw (ScanException);
    bool __la_inputRegister_ () throw (ScanException);
    bool __la_sourceModifier_ () throw (ScanException);
    bool __la_writeMask_ () throw (ScanException);
    bool __la_sourceSwizzle_ () throw (ScanException);
    bool __la_vertexRegister_ () throw (ScanException);
    bool __la_temporaryRegister_ () throw (ScanException);
    bool __la_constantFloatRegister_ () throw (ScanException);
    bool __la_constantIntegerRegister_ () throw (ScanException);
    bool __la_constantBooleanRegister_ () throw (ScanException);
    bool __la_a0Register_ () throw (ScanException);
    bool __la_aLRegister_ () throw (ScanException);
    bool __la_diffuseSpecularRegister_ () throw (ScanException);
    bool __la_fogRegister_ () throw (ScanException);
    bool __la_positionRegister_ () throw (ScanException);
    bool __la_pointSizeRegister_ () throw (ScanException);
    bool __la_textureCoordinateRegister_ () throw (ScanException);
    
    // lookahead entry points:
    
    // LA entry points for main
    
    bool __la_0_ (int depth) throw (ScanException);
    // LA entry points for instruction
    
    bool __la_1_ (int depth) throw (ScanException);
    bool __la_2_ (int depth) throw (ScanException);
    // LA entry points for vsInstruction
    
    // LA entry points for dcl_positionInstruction
    
    // LA entry points for dcl_blendweightInstruction
    
    // LA entry points for dcl_blendindicesInstruction
    
    // LA entry points for dcl_normalInstruction
    
    // LA entry points for dcl_psizeInstruction
    
    // LA entry points for dcl_texcoordInstruction
    
    // LA entry points for dcl_tangentInstruction
    
    // LA entry points for dcl_binormalInstruction
    
    // LA entry points for dcl_tessfactorInstruction
    
    // LA entry points for dcl_positiontInstruction
    
    // LA entry points for dcl_colorInstruction
    
    // LA entry points for dcl_fogInstruction
    
    // LA entry points for dcl_depthInstruction
    
    // LA entry points for dcl_sampleInstruction
    
    // LA entry points for defInstruction
    
    // LA entry points for defbInstruction
    
    // LA entry points for defiInstruction
    
    // LA entry points for absInstruction
    
    // LA entry points for addInstruction
    
    // LA entry points for crsInstruction
    
    // LA entry points for dp3Instruction
    
    // LA entry points for dp4Instruction
    
    // LA entry points for dstInstruction
    
    // LA entry points for expInstruction
    
    // LA entry points for exppInstruction
    
    // LA entry points for frcInstruction
    
    // LA entry points for litInstruction
    
    // LA entry points for logInstruction
    
    // LA entry points for logpInstruction
    
    // LA entry points for lrpInstruction
    
    // LA entry points for m3x2Instruction
    
    // LA entry points for m3x3Instruction
    
    // LA entry points for m3x4Instruction
    
    // LA entry points for m4x3Instruction
    
    // LA entry points for m4x4Instruction
    
    // LA entry points for madInstruction
    
    // LA entry points for maxInstruction
    
    // LA entry points for minInstruction
    
    // LA entry points for movInstruction
    
    // LA entry points for movaInstruction
    
    // LA entry points for mulInstruction
    
    // LA entry points for nopInstruction
    
    // LA entry points for nrmInstruction
    
    // LA entry points for powInstruction
    
    // LA entry points for rcpInstruction
    
    // LA entry points for rsqInstruction
    
    // LA entry points for sgeInstruction
    
    // LA entry points for sgnInstruction
    
    // LA entry points for sincosInstruction
    
    // LA entry points for sltInstruction
    
    // LA entry points for callInstruction
    
    // LA entry points for callnzInstruction
    
    // LA entry points for elseInstruction
    
    // LA entry points for endifInstruction
    
    // LA entry points for endloopInstruction
    
    // LA entry points for endrepInstruction
    
    // LA entry points for ifInstruction
    
    // LA entry points for labelInstruction
    
    // LA entry points for loopInstruction
    
    // LA entry points for repInstruction
    
    // LA entry points for retInstruction
    
    // LA entry points for instructionModifier
    
    // LA entry points for dst
    
    // LA entry points for dest
    
    // LA entry points for a0
    
    // LA entry points for aL
    
    // LA entry points for cn
    
    // LA entry points for bn
    
    // LA entry points for in
    
    // LA entry points for fValue1
    
    // LA entry points for fValue2
    
    // LA entry points for fValue3
    
    // LA entry points for fValue4
    
    // LA entry points for integerValue1
    
    // LA entry points for integerValue2
    
    // LA entry points for integerValue3
    
    // LA entry points for integerValue4
    
    // LA entry points for booleanValue
    
    // LA entry points for src
    
    // LA entry points for src0
    
    // LA entry points for src1
    
    // LA entry points for src2
    
    // LA entry points for outputRegister
    
    // LA entry points for inputRegister
    
    // LA entry points for sourceModifier
    
    // LA entry points for writeMask
    
    // LA entry points for sourceSwizzle
    
    bool __la_3_ (int depth) throw (ScanException);
    bool __la_4_ (int depth) throw (ScanException);
    // LA entry points for vertexRegister
    
    // LA entry points for temporaryRegister
    
    // LA entry points for constantFloatRegister
    
    // LA entry points for constantIntegerRegister
    
    // LA entry points for constantBooleanRegister
    
    // LA entry points for a0Register
    
    // LA entry points for aLRegister
    
    // LA entry points for diffuseSpecularRegister
    
    // LA entry points for fogRegister
    
    // LA entry points for positionRegister
    
    // LA entry points for pointSizeRegister
    
    // LA entry points for textureCoordinateRegister
    
    
    
  private: // methods
    
    void consumeToken (int tId)  throw (ScanException, ParseException)
    {
      if ((token = scanner.la())->id != tId)
      {
        ParseException pex(scanner.la()->bPos, "Parse error.");
        if (!onParseError(pex)) throw pex;
      }
      scanner.unchecked_consume();
    }
    
    bool laConsumeToken (int tId)  throw (ScanException, ParseException)
    {
      if (scanner.la()->id != tId) return false;
      scanner.unchecked_consume();
      return true;
    }
    
  public: // data
    
    vs20_scanner scanner;
    int _la;
    vs20_token *token;
    
  private: // user code
  
	private:
		swShader::Operand t;   // Temporary operand
	
		swShader::Instruction::Mnemonic m;  // Operation
		int usage_index;   // Vertex shader dcl
		swShader::Instruction::Modifier x;  // Instrution modifier
		swShader::Operand d;   // Destination
		swShader::Operand s0;   // Source 0
		swShader::Operand s1;   // Source 1
		swShader::Operand s2;   // Source 2
		swShader::Operand s3;   // Source 3
	

  
}; //end class vs20_parser


} //end namespace vs20


#endif // ifndef __VS20_PARSER_HH__


/* End of file. */
