/*==================================================================
=  文件名  : Grambase
=  主要功能: 
=  修改日期: 
=  作者    : shen beide
====================================================================*/

#if !defined(_GRAMBASE_H)
#define _GRAMBASE_H

#include "PubHeader.h"

#include "Array.h"
#include "ObArray.h"
#include "ObList.h"

//////////////////////////////////////////
class GramRules;
class GramState;

#define GRAM_FUNC_HEADER '$'

class GramTransition
{
public:
    bool        m_isGramFunc;       // GramFunc(定义时以$打头) 或 GramString 
    OTSTR       m_strCondition;    // 为空时, 表示直接跳转
    GramState*  m_pNextGramState;
};

class GramState
{
public:
    long     m_nId;

    /////////////////////////////////////////////
    long     m_RuleId;

    TObArray<GramTransition> m_TransitionList;

public:    
    GramState(long nId=1);
   ~GramState();

    ///////////////////////////////////////////////
    bool AddTransition(bool isGramFunc, char* szCondition, GramState* pNextState);
    GramState* FindTransition(bool isGramFunc, char* szCondition,bool bCaseSensitive,bool bReverseFind,bool& isLastTransition);
    
    bool isAcceptable() { return (m_RuleId==-1)? false:true; }

    friend class LexRules;

    OTSTR m_strTransitionDescription;
};


#endif
