private void SetDefaultProperty(GXProperties properties, String prop, String value)
 {
     if (!properties.ContainsKey(prop))
     {
         properties.Set(prop, value);
     }
 }
        private EvalValue eval(Tokenizer tokenizer)
        {
            String token = getNextToken(tokenizer);

            if (token.ToUpper().Equals("!".ToUpper()))
            {
                // Expresion '!expr'
                return(eval(tokenizer) == 0 ? 1 : 0);
            }
            if (token.ToUpper().Equals("-".ToUpper()))
            {
                // Expresion '-expr'
                return(-eval(tokenizer));
            }
            if (token.ToUpper().Equals("+".ToUpper()))
            {
                // Expresion '+expr'
                return(eval(tokenizer));
            }

            // Finished processing
            // So check if it is an expression with parentheses, a number, or a function
            if (token.StartsWith("(") && token.EndsWith(")"))
            {
                // Si es una expresion entre parentesis
                return(eval(token.Substring(1, (token.Length - 1) - (1)).Trim()));
            }
            if (System.Char.IsDigit(token[0]) || token[0] == '.')
            {
                // If it is a constant (number)
                try
                {
                    return(decimal.Parse(token, System.Globalization.CultureInfo.InvariantCulture));
                }
                catch (FormatException e)
                {
                    throwException(EVALUATION_ERROR, e.Message);
                    return(0);
                }
            }
            if (token.StartsWith("'"))
            {
                // If it is a constant (char)
                string s  = "";
                string tk = tokenizer.NextToken();
                while (tk != "'")
                {
                    s += tk;
                    tk = tokenizer.NextToken();
                }
                return(new EvalValue(s));
            }
            if (token.ToUpper().Equals("PI".ToUpper()))
            {
                return((decimal)System.Math.PI);
            }

            if (parms.ContainsKey(token))
            {
                // If it is a variable, return its value
                try
                {
                    return(eval(parms[token]));
                }
                catch (FormatException e)
                {
                    throwException(EVALUATION_ERROR, "Variable " + token + " cannot be evaluated: " + e.Message);
                }
            }

            //If it is none of this, it must be a function

            int indexLeftParen  = token.IndexOf((System.Char) '(');
            int indexRightParen = token.LastIndexOf((System.Char) ')');

            if (indexLeftParen == -1 || indexRightParen == -1 || indexRightParen <= indexLeftParen)
            {
                // If it is not a function, it is a variable without reference
                return(throwException(EVALUATION_ERROR, "Invalid variable reference: " + token));
            }

            String funcName = token.Substring(0, (indexLeftParen) - (0));

            return(evalFuncCall(funcName, token.Substring(indexLeftParen + 1, (indexRightParen) - (indexLeftParen + 1))));
        }