Example #1
0
        protected override IEnumerable <UnparsableAst> GetChildren(Unparser.ChildBnfTerms childBnfTerms, object astValue, Unparser.Direction direction)
        {
            System.Collections.IEnumerable astCollection = (System.Collections.IEnumerable)astValue;

            if (astCollection == null && this.EmptyCollectionHandling == EmptyCollectionHandling.ReturnNull)
            {
                yield break;    // this null value should be handled as an empty collection
            }
            if (direction == Unparser.Direction.RightToLeft)
            {
                astCollection = astCollection.ReverseNonGenericOptimized();
            }

            bool firstElement = true;

            foreach (object astElement in astCollection)
            {
                if (!firstElement && this.delimiter != null)
                {
                    yield return(new UnparsableAst(this.delimiter, astCollection));
                }

                yield return(new UnparsableAst(this.element, astElement));

                firstElement = false;
            }
        }
Example #2
0
        protected override IEnumerable <UnparsableAst> GetChildren(Unparser.ChildBnfTerms childBnfTerms, object astValue, Unparser.Direction direction)
        {
            foreach (var childRuleReferredBnfTerm in childBnfTerms.Select((childBnfTerm, index) =>
                                                                          new ReferredBnfTermEI(childBnfTerms.ContentIndex, childBnfTerm, direction == Unparser.Direction.LeftToRight ? index : childBnfTerms.Count - 1 - index)
                                                                          ))
            {
                object childAstValue;
                Member member;

                if (IsMemberAtRule(childRuleReferredBnfTerm))
                {
                    member        = GetMemberByAtRule(childRuleReferredBnfTerm);
                    childAstValue = GetValue(member.MemberInfo, astValue);
                }
                else if (childRuleReferredBnfTerm.BnfTerm is BnfiTermCopy)
                {
                    member        = null;
                    childAstValue = astValue;
                }
                else
                {
                    member        = null;
                    childAstValue = astValue;
                }

                if (childAstValue == null && childRuleReferredBnfTerm.BnfTerm is BnfiTermConversion && ((BnfiTermConversion)childRuleReferredBnfTerm.BnfTerm).isOptionalValue)
                {
                    continue;
                }

                yield return(new UnparsableAst(childRuleReferredBnfTerm.BnfTerm, childAstValue, member));
            }
        }
Example #3
0
 protected abstract IEnumerable <UnparsableAst> GetChildren(Unparser.ChildBnfTerms childBnfTerms, object astValue, Unparser.Direction direction);
Example #4
0
 IEnumerable <UnparsableAst> IUnparsableNonTerminal.GetChildren(Unparser.ChildBnfTerms childBnfTerms, object astValue, Unparser.Direction direction)
 {
     return(GetChildren(childBnfTerms, astValue, direction));
 }
Example #5
0
 protected override IEnumerable <UnparsableAst> GetChildren(Unparser.ChildBnfTerms childBnfTerms, object astValue, Unparser.Direction direction)
 {
     return(childBnfTerms.Select(childBnfTerm => new UnparsableAst(childBnfTerm, astValue)));
 }
Example #6
0
 protected override IEnumerable <UnparsableAst> GetChildren(Unparser.ChildBnfTerms childBnfTerms, object astValue, Unparser.Direction direction)
 {
     return(childBnfTerms.Select(childBnfTerm => new UnparsableAst(childBnfTerm, astValue: valueCreatorFromNoAst != null ? valueCreatorFromNoAst() : null)));
 }