Example #1
0
        protected void ContractTo(BnfiTermCollection target)
        {
            if (!this.IsContractible)
            {
                GrammarHelper.ThrowGrammarErrorException(GrammarErrorLevel.Error, "This collection should not be a right-value: {0}", this.Name);
            }

            if (!this.listKind.HasValue)
            {
                GrammarHelper.ThrowGrammarErrorException(GrammarErrorLevel.Error, "Right-value collection has not been initialized: {0}", this.Name);
            }

            // note: target.RuleRaw is set and target.SetState is called by _MakePlusRule/_MakeStarRule
            if (this.listKind == ListKind.Plus)
            {
                _MakePlusRule(target, this.delimiter, this.element);
            }
            else if (this.listKind == ListKind.Star)
            {
                _MakeStarRule(target, this.delimiter, this.element);
            }
            else
            {
                throw new InvalidOperationException(string.Format("Unknown listKind: {0}", this.listKind));
            }

            this.RuleRaw = null;
            this.ClearState();
            this.hasBeenContracted = true;
        }
Example #2
0
 protected static BnfiTermCollection _MakeStarRule(BnfiTermCollection bnfiTermCollection, BnfTerm delimiter, BnfTerm element)
 {
     bnfiTermCollection.SetState(ListKind.Star, element, delimiter);
     Irony.Parsing.Grammar.CurrentGrammar.MakeStarRule(bnfiTermCollection, delimiter, element);
     bnfiTermCollection.CheckAfterRuleHasBeenSetThatChildrenAreNotContracted();
     return(bnfiTermCollection);
 }
Example #3
0
        public static BnfiTermCollection <TCollectionType, TElementType> PlusList <TCollectionType, TElementType>(BnfTerm bnfTermElement, BnfTerm delimiter = null)
            where TCollectionType : ICollection <TElementType>, new()
        {
            var bnfiTermCollection = BnfiTermCollection <TCollectionType, TElementType> .CreateContractible();

            MakePlusRule(bnfiTermCollection, delimiter, bnfTermElement);
            return(bnfiTermCollection);
        }
Example #4
0
 internal static BnfiTermCollection <TCollectionType, TElementType> MakeStarRule <TCollectionType, TElementType>(BnfiTermCollection <TCollectionType, TElementType> bnfiTermCollection, BnfTerm delimiter, IBnfiTerm <TElementType> element)
     where TCollectionType : ICollection <TElementType>, new()
 {
     return((BnfiTermCollection <TCollectionType, TElementType>)_MakeStarRule(bnfiTermCollection, delimiter, element.AsBnfTerm()));
 }
Example #5
0
 internal static BnfiTermCollection <TCollectionType, TElementType> MakePlusRule <TCollectionType, TElementType>(BnfiTermCollection <TCollectionType, TElementType> bnfiTermCollection, BnfTerm delimiter, BnfTerm element)
     where TCollectionType : ICollection <TElementType>, new()
 {
     return((BnfiTermCollection <TCollectionType, TElementType>)_MakePlusRule(bnfiTermCollection, delimiter, element));
 }
Example #6
0
 public static BnfiTermCollectionTL MakeStarRule(BnfiTermCollectionTL bnfiTermCollection, BnfTerm delimiter, BnfTerm element)
 {
     return(BnfiTermCollection.MakeStarRule(bnfiTermCollection, delimiter, element));
 }
Example #7
0
 public static BnfiTermCollection <TCollectionType, TElementType> MakeStarRule <TCollectionType, TElementType>(BnfiTermCollection <TCollectionType, TElementType> bnfiTermCollection, BnfTerm delimiter, IBnfiTerm <TElementType> element)
     where TCollectionType : ICollection <TElementType>, new()
 {
     return(BnfiTermCollection.MakeStarRule(bnfiTermCollection, delimiter, element));
 }
Example #8
0
 public static BnfiTermCollectionTL StarListTL(this BnfTerm bnfTermElement, BnfTerm delimiter = null)
 {
     return(BnfiTermCollection.StarListTL(bnfTermElement, delimiter));
 }
Example #9
0
 public static BnfiTermCollection <List <TElementType>, TElementType> PlusList <TElementType>(this BnfTerm bnfTermElement, BnfTerm delimiter = null)
 {
     return(BnfiTermCollection.PlusList <TElementType>(bnfTermElement, delimiter));
 }
Example #10
0
 public static BnfiTermCollection <TCollectionType, TElementType> PlusList <TCollectionType, TElementType>(this BnfTerm bnfTermElement, BnfTerm delimiter = null)
     where TCollectionType : ICollection <TElementType>, new()
 {
     return(BnfiTermCollection.PlusList <TCollectionType, TElementType>(bnfTermElement, delimiter));
 }
Example #11
0
 public static BnfiTermCollection <List <TElementType>, TElementType> StarList <TElementType>(this IBnfiTerm <TElementType> bnfTermElement, BnfTerm delimiter = null)
 {
     return(BnfiTermCollection.StarList(bnfTermElement, delimiter));
 }
Example #12
0
 public static BnfiTermCollectionTL PlusListTL(this BnfTerm bnfTermElement, Type elementType, BnfTerm delimiter = null)
 {
     return(BnfiTermCollection.PlusListTL(elementType, bnfTermElement, delimiter));
 }