예제 #1
0
            public string ParseExpression(Expression expression)
            {
                ExpressionParserRule rule = _parent._rules.FirstOrDefault(x => x.IsApplicable(expression));

                if (rule != null)
                {
                    ExpressionParseEventArgs eventArgs = new ExpressionParseEventArgs(ParseExpression, _expressionStack.FirstOrDefault(), _services);
                    _expressionStack.Push(expression);
                    string returnValue = rule.Parse(expression, eventArgs);
                    _expressionStack.Pop();
                    return(returnValue);
                }
                else
                {
                    throw new NotParsableException("There is no expression rule for this expression.", expression);
                }
            }
예제 #2
0
 public void AddRule(ExpressionParserRule rule)
 {
     _rules.Add(rule);
 }