Ejemplo n.º 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.");
     }
 }
Ejemplo n.º 2
0
 public override bool IsMatch(Parser.Token tkn)
 {
     return(tkn.ToString() == "<=");
 }
Ejemplo n.º 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();

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

                        alValues.Add(oValue);
                    } while (m_currentToken.ToString() == ",");
                    if (m_currentToken.ToString() == ")")
                    {
                        PositionNextToken();
                    }


                    bFunc = true;


                    oValue = oFunc.CreateInstance(alValues);
                }
                else
                {
                    oValue = GetVariableByName(m_currentToken.ToString());
                }

                break;
            }
            }
        }

        if (!bFunc)
        {
            PositionNextToken();
        }

        return(oValue);
    }