Exemplo n.º 1
0
 public IEnumerable <IExpressionToken> Compile(IExpressionItem item)
 {
     if (item is null || item.Childs.IsNullOrEmpty())
     {
         throw new CompileException($"Expression item is null or item do not has any childs. Expression: {item.Expression}", typeof(FunctionCompiler));
     }
     return(Compile(item.Childs));
 }
Exemplo n.º 2
0
        public IEnumerable <IExpressionToken> Compile(IExpressionItem item)
        {
            if (item is null)
            {
                throw new CompileException("Expression item is null.", typeof(StringCompiler <T>));
            }

            return(Compile(item.Expression));
        }
Exemplo n.º 3
0
 /// <summary>
 /// Indicates that the given item is the next expected, giving it a
 /// name and specifying whether it is required.
 /// </summary>
 /// <param name="itemName">The name that the token will be identified with in the outer expression.</param>
 /// <param name="item">The expression item to add to the sequence.</param>
 /// <returns>The updated expression.</returns>
 public Options Add(string itemName, IExpressionItem item)
 {
     if (item == null)
     {
         throw new ArgumentNullException("item");
     }
     options.Add(new ExpressionItem(itemName, false, item));
     return this;
 }
Exemplo n.º 4
0
 /// <summary>
 /// Indicates that the given item is the next expected, giving it a
 /// name and specifying whether it is required.
 /// </summary>
 /// <param name="itemName">The name that the token will be identified with in the outer expression.</param>
 /// <param name="item">The expression item to add to the sequence.</param>
 /// <returns>The updated expression.</returns>
 public Options Add(string itemName, IExpressionItem item)
 {
     if (item == null)
     {
         throw new ArgumentNullException("item");
     }
     options.Add(new ExpressionItem(itemName, false, item));
     return(this);
 }
        public override object CreateNewInstance(SelectItem item)
        {
            IExpressionItem expressionItem = item.Value as IExpressionItem;

            Debug.Assert(expressionItem != null);

            ActivityFactory factory = Parent.EditingContext.Services.GetService <ActivityFactory>();

            Debug.Assert(factory != null);
            object     instance     = factory.CreateActivity(expressionItem.CreateActivity, Parent.GetModelProperty());
            Type       argumentType = typeof(InArgument <>).MakeGenericType(expressionItem.ValueType);
            InArgument arg          = Activator.CreateInstance(argumentType, instance) as InArgument;

            return(arg);
        }
Exemplo n.º 6
0
        public IEnumerable <IExpressionItem> ExpressionStructure(string value)
        {
            IExpressionItem[] result = null;

            if (IsExpression(value))
            {
                var resultItem = new GrammarExpressionItem()
                {
                    Item       = this,
                    Expression = value
                };

                result = new IExpressionItem[] { resultItem };
            }

            return(result);
        }
Exemplo n.º 7
0
        public IEnumerable <IExpressionItem> ExpressionStructure(string value)
        {
            IExpressionItem[] result = null;
            if (this._rightSide == null)
            {
                throw new GrammarParseException($"Right side rule of NonTerminal: {this.Name} is null.", new NullReferenceException());
            }

            if (IsExpression(value))
            {
                result = new IExpressionItem[]
                {
                    new GrammarExpressionItem()
                    {
                        Item       = this,
                        Expression = value,
                        Childs     = this._rightSide.ExpressionStructure(value)
                    }
                };
            }

            return(result);
        }
Exemplo n.º 8
0
 /// <summary>
 /// Initializes a new instance of an ExpressionItem.
 /// </summary>
 /// <param name="itemName">The name of the item.</param>
 /// <param name="isRequired">Specifies whether the item missing results in the outer expression not matching.</param>
 /// <param name="item">The actual item that is expected.</param>
 public ExpressionItem(string itemName, bool isRequired, IExpressionItem item)
 {
     ItemName   = itemName;
     IsRequired = isRequired;
     Item       = item;
 }
Exemplo n.º 9
0
 /// <summary>
 /// Initializes a new instance of an ExpressionItem.
 /// </summary>
 /// <param name="itemName">The name of the item.</param>
 /// <param name="isRequired">Specifies whether the item missing results in the outer expression not matching.</param>
 /// <param name="item">The actual item that is expected.</param>
 public ExpressionItem(string itemName, bool isRequired, IExpressionItem item)
 {
     ItemName = itemName;
     IsRequired = isRequired;
     Item = item;
 }
Exemplo n.º 10
0
 public override IEnumerable <IExpressionToken> Compile(IExpressionItem item)
 {
     return(Compile(item.Expression));
 }
Exemplo n.º 11
0
 public IEnumerable <IExpressionToken> Compile(IExpressionItem item)
 {
     return(((ICompiler)this.Rule).Compile(item));
 }