コード例 #1
0
 /// <summary>
 /// CheckParms( Parser.Token, CValue) - This method makes certain the single argument is non-null.
 ///		Raises an exception if it is.
 /// </summary>
 /// <param name="oToken">Parser.Token object</param>
 /// <param name="arg1">CValue argument</param>
 private void CheckParms(Parser.Token oToken, CValue arg1)
 {
     if (arg1 == null)
     {
         throw new ApplicationException("Argument not supplied near " + oToken.ToString() + " operation.");
     }
 }
コード例 #2
0
 public override bool IsMatch(Parser.Token tkn)
 {
     return(tkn.ToString() == "<=");
 }
コード例 #3
0
        /// <summary>
        /// Paren() : This method evaluates Parenthesis in the equation and
        ///		insures they are handled properly according to the Order of Operations. Because this is last in the chain,
        ///		it also evaluates Variable and Function names.
        /// </summary>
        /// <returns>CValue object that holds an operation.</returns>
        private CValue Paren()
        {
            bool   bFunc  = false;
            CValue oValue = null;

            if (m_currentToken.ToString() == "(")
            {
                PositionNextToken();


                oValue = Relational();

                if (m_currentToken.ToString() == ",")
                {
                    return(oValue);
                }

                if (m_currentToken.ToString() != ")")
                {
                    throw new ApplicationException("Unmatched parenthesis in equation.");
                }
            }
            else
            {
                switch (m_currentToken.TokenType)
                {
                case Parser.CharType.CT_NUMBER:
                    oValue = new CNumber(m_currentToken.ToString());
                    break;

                case Parser.CharType.CT_LETTER:
                {
                    if (m_nextToken.ToString() == "(")
                    {
                        int iIdx = m_slFunctions.IndexOfKey(m_currentToken.ToString());

                        if (iIdx < 0)
                        {
                            throw new ApplicationException("Function not found - " + m_currentToken.ToString());
                        }

                        CFunction oFunc = (CFunction)m_slFunctions.GetByIndex(iIdx);

                        ArrayList alValues = new ArrayList();

                        PositionNextToken();


                        do
                        {
                            PositionNextToken();
                            oValue = AddSub();

                            alValues.Add(oValue);
                        } while (m_currentToken.ToString() != ")" && m_currentToken != "");


                        bFunc = true;

                        oValue = oFunc.CreateInstance(alValues);

                        PositionNextToken();
                    }
                    else
                    {
                        oValue = GetVariableByName(m_currentToken.ToString());
                    }

                    break;
                }
                }
            }


            if (!bFunc)
            {
                PositionNextToken();
            }

            return(oValue);
        }