//--------------------------------------------------------------------------- /* Copy state of a parser object to this. * \param a_Parser the source object. * * Clears Variables and Functions of this parser. * Copies the states of all internal variables. * Resets parse function to string parse mode. */ public void Assign(ParserXBase a_Parser) { if (a_Parser == this) { return; } // Don't copy bytecode instead cause the parser to create new bytecode // by resetting the parse function. ReInit(); m_pTokenReader = new TokenReader(a_Parser.m_pTokenReader.Clone(this)); m_OprtDef = a_Parser.m_OprtDef; m_FunDef = a_Parser.m_FunDef; m_PostOprtDef = a_Parser.m_PostOprtDef; m_InfixOprtDef = a_Parser.m_InfixOprtDef; m_valDef = a_Parser.m_valDef; m_valDynVarShadow = a_Parser.m_valDynVarShadow; m_varDef = a_Parser.m_varDef; // Copy user defined variables // Copy charsets m_sNameChars = a_Parser.m_sNameChars; m_sOprtChars = a_Parser.m_sOprtChars; m_sInfixOprtChars = a_Parser.m_sInfixOprtChars; m_bAutoCreateVar = a_Parser.m_bAutoCreateVar; // Things that should not be copied: // - m_vStackBuffer // - m_cache // - m_rpn }
//--------------------------------------------------------------------------- void SetParent(ParserXBase a_pParent) { m_pParser = a_pParent; m_pFunDef = a_pParent.m_FunDef; m_pOprtDef = a_pParent.m_OprtDef; m_pInfixOprtDef = a_pParent.m_InfixOprtDef; m_pPostOprtDef = a_pParent.m_PostOprtDef; m_pVarDef = a_pParent.m_varDef; m_pConstDef = a_pParent.m_valDef; m_pDynVarShadowValues = a_pParent.m_valDynVarShadow; }
//--------------------------------------------------------------------------- /* Constructor. * * Create a Token reader and bind it to a parser object. * * \pre [assert] a_pParser may not be nullptr * \post #m_pParser==a_pParser * \param a_pParent Parent parser object of the token reader. */ internal TokenReader(ParserXBase a_pParent) { m_sExpr = ""; m_nPos = 0; m_nNumBra = 0; m_nNumIndex = 0; m_nNumCurly = 0; m_nNumIfElse = 0; m_nSynFlags = 0; m_vTokens = new List <IToken>(); m_eLastTokCode = ECmdCode.cmUNKNOWN; m_vValueReader = new List <IValueReader>(); m_UsedVar = new TokenMap(); m_fZero = 0; SetParent(a_pParent); }
//--------------------------------------------------------------------------- /* Create instance of a ParserTokenReader identical with this * and return its pointer. * * This is a factory method the calling function must take care of the object destruction. * * \return A new ParserTokenReader object. */ internal TokenReader Clone(ParserXBase parserXBase1) { return(new TokenReader(this)); }
protected ParserXBase(ParserXBase a_Parser) : this() { m_pTokenReader = new TokenReader(this); Assign(a_Parser); }