Example #1
0
        public Expression Parse(string syntax)
        {
            if (string.IsNullOrEmpty(syntax))
            {
                return(null);
            }

            Expression tree = null;

            // All parsed syntax string are stored into cache
            // A bunch of properties have the same syntax so it's worth caching the result
            if (!m_ParsedExpressionCache.TryGetValue(syntax, out tree))
            {
                StyleSyntaxTokenizer tokenizer = new StyleSyntaxTokenizer();
                tokenizer.Tokenize(syntax);

                try
                {
                    tree = ParseExpression(tokenizer);
                }
                catch (Exception e)
                {
                    Debug.LogException(e);
                }

                m_ParsedExpressionCache[syntax] = tree;
            }

            return(tree);
        }
        public Expression Parse(string syntax)
        {
            bool       flag = string.IsNullOrEmpty(syntax);
            Expression result;

            if (flag)
            {
                result = null;
            }
            else
            {
                Expression expression = null;
                bool       flag2      = !this.m_ParsedExpressionCache.TryGetValue(syntax, out expression);
                if (flag2)
                {
                    StyleSyntaxTokenizer styleSyntaxTokenizer = new StyleSyntaxTokenizer();
                    styleSyntaxTokenizer.Tokenize(syntax);
                    try
                    {
                        expression = this.ParseExpression(styleSyntaxTokenizer);
                    }
                    catch (Exception exception)
                    {
                        Debug.LogException(exception);
                    }
                    this.m_ParsedExpressionCache[syntax] = expression;
                }
                result = expression;
            }
            return(result);
        }