Exemple #1
0
        private string GenerateAlternativesExpression(Expression expression)
        {
            AlternativesExpression alternatives = expression as AlternativesExpression;

            return(this.GenerateExpression(alternatives.NonAlternativesExpression) + " | " +
                   this.GenerateExpression(alternatives.Expression));
        }
        private static TreeViewItem AsTreeViewItem(AlternativesExpression expression)
        {
            var result = new TreeViewItem();

            result.Header = expression.Description;
            foreach (var subtree in expression.Subexpressions.Select(exp => AsTreeViewItem((dynamic)exp)))
            {
                result.Items.Add(subtree);
            }
            return(result);
        }
Exemple #3
0
        private ParseAction ImportAlternativesExpression(Expression exp,
                                                         Entity entity,
                                                         ParseAction parent = null,
                                                         bool optional      = false)
        {
            AlternativesExpression alternative = ((AlternativesExpression)exp);

            ConsumeAny consume = new ConsumeAny()
            {
                Parent = parent
            };

            // AlternativesExpression is constructed recusively, unroll it...
            while (true)
            {
                // add first part
                consume.Actions.Add(this.ImportPropertiesAndParseActions(
                                        alternative.NonAlternativesExpression, entity, consume, optional
                                        ));
                // add remaining parts
                if (alternative.Expression is NonAlternativesExpression)
                {
                    // last part
                    consume.Actions.Add(this.ImportPropertiesAndParseActions(
                                            alternative.Expression, entity, consume, optional
                                            ));
                    break;
                }
                else
                {
                    // recurse
                    alternative =
                        (AlternativesExpression)alternative.Expression;
                }
            }

            return(consume);
        }