示例#1
0
		ProtectionSettingsInfo ToInfo(Rule rule, PatternExpression expr) {
			var info = new ProtectionSettingsInfo();

			info.Condition = expr;

			info.Exclude = false;
			info.ApplyToMember = true;

			var settings = new StringBuilder();
			if (rule.Preset != ProtectionPreset.None)
				settings.AppendFormat("preset({0});", rule.Preset.ToString().ToLowerInvariant());
			foreach (var item in rule) {
				settings.Append(item.Action == SettingItemAction.Add ? '+' : '-');
				settings.Append(item.Id);
				if (item.Count > 0) {
					settings.Append('(');
					int i = 0;
					foreach (var arg in item) {
						if (i != 0)
							settings.Append(',');
						settings.AppendFormat("{0}='{1}'", arg.Key, arg.Value.Replace("'", "\\'"));
						i++;
					}
					settings.Append(')');
				}
				settings.Append(';');
			}
			info.Settings = settings.ToString();

			return info;
		}
示例#2
0
        public void MutateRecursively638()
        {
            IndexTrackingMutator   indexTrackingMutator;
            BooleanExpression      booleanExpression;
            PatternExpression      patternExpression;
            List <AphidExpression> list;
            List <AphidExpression> list1;

            string[] ss = new string[1];
            indexTrackingMutator = new IndexTrackingMutator(ss);
            AphidExpressionContext s0 = new AphidExpressionContext();

            s0.Filename       = (string)null;
            s0.Code           = (string)null;
            booleanExpression = new BooleanExpression(s0, false);
            ((AphidExpression)booleanExpression).Index  = 0;
            ((AphidExpression)booleanExpression).Length = 0;
            AphidExpressionContext s1 = new AphidExpressionContext();

            s1.Filename       = (string)null;
            s1.Code           = (string)null;
            patternExpression = new PatternExpression
                                    (s1, (AphidExpression)booleanExpression, (List <AphidExpression>)null);
            ((AphidExpression)patternExpression).Index  = 0;
            ((AphidExpression)patternExpression).Length = 0;
            AphidExpression[] aphidExpressions = new AphidExpression[1];
            aphidExpressions[0] = (AphidExpression)patternExpression;
            list  = new List <AphidExpression>((IEnumerable <AphidExpression>)aphidExpressions);
            list1 = this.MutateRecursively((AphidMutator)indexTrackingMutator, list);
            Assert.IsNotNull((object)list1);
            Assert.AreEqual <int>(4, list1.Capacity);
            Assert.AreEqual <int>(1, list1.Count);
        }
示例#3
0
        /// <summary>
        ///     Parses the specified pattern into expression.
        /// </summary>
        /// <param name="pattern">The pattern to parse.</param>
        /// <returns>The parsed expression.</returns>
        /// <exception cref="InvalidPatternException">
        ///     The pattern is invalid.
        /// </exception>
        public PatternExpression Parse(string pattern)
        {
            if (pattern == null)
            {
                throw new ArgumentNullException("pattern");
            }

            try
            {
                tokenizer.Initialize(pattern);
                lookAhead = tokenizer.NextToken();
                PatternExpression ret = ParseExpression(true);
                if (PeekToken() != null)
                {
                    throw new InvalidPatternException("Extra tokens beyond the end of pattern.");
                }
                return(ret);
            }
            catch (Exception ex)
            {
                if (ex is InvalidPatternException)
                {
                    throw;
                }
                throw new InvalidPatternException("Invalid pattern.", ex);
            }
        }
示例#4
0
        public void MutateRecursively217()
        {
            IndexTrackingMutator   indexTrackingMutator;
            BooleanExpression      booleanExpression;
            PatternExpression      patternExpression;
            List <AphidExpression> list;
            List <AphidExpression> list1;

            indexTrackingMutator = new IndexTrackingMutator((string[])null);
            booleanExpression    = new BooleanExpression((AphidExpressionContext)null, false);
            ((AphidExpression)booleanExpression).Index  = 0;
            ((AphidExpression)booleanExpression).Length = 0;
            patternExpression = new PatternExpression((AphidExpressionContext)null,
                                                      (AphidExpression)booleanExpression, (List <AphidExpression>)null);
            ((AphidExpression)patternExpression).Index  = 0;
            ((AphidExpression)patternExpression).Length = 0;
            AphidExpression[] aphidExpressions = new AphidExpression[2];
            aphidExpressions[0] = (AphidExpression)patternExpression;
            aphidExpressions[1] = (AphidExpression)booleanExpression;
            list  = new List <AphidExpression>((IEnumerable <AphidExpression>)aphidExpressions);
            list1 = this.MutateRecursively((AphidMutator)indexTrackingMutator, list);
            Assert.IsNotNull((object)list1);
            Assert.AreEqual <int>(4, list1.Capacity);
            Assert.AreEqual <int>(2, list1.Count);
        }
示例#5
0
        public void MutateRecursivelyThrowsNullReferenceException696()
        {
            IndexTrackingMutator   indexTrackingMutator;
            ForEachExpression      forEachExpression;
            PatternExpression      patternExpression;
            List <AphidExpression> list;
            List <AphidExpression> list1;

            indexTrackingMutator = new IndexTrackingMutator((string[])null);
            AphidExpressionContext s0 = new AphidExpressionContext();

            s0.Filename = (string)null;
            s0.Code     = (string)null;
            List <AphidExpression> list2 = new List <AphidExpression>();

            forEachExpression =
                new ForEachExpression(s0, (AphidExpression)null, list2, (AphidExpression)null);
            ((AphidExpression)forEachExpression).Index  = 0;
            ((AphidExpression)forEachExpression).Length = 0;
            AphidExpressionContext s1 = new AphidExpressionContext();

            s1.Filename       = (string)null;
            s1.Code           = (string)null;
            patternExpression = new PatternExpression
                                    (s1, (AphidExpression)forEachExpression, (List <AphidExpression>)null);
            ((AphidExpression)patternExpression).Index  = 0;
            ((AphidExpression)patternExpression).Length = 0;
            AphidExpression[] aphidExpressions = new AphidExpression[1];
            aphidExpressions[0] = (AphidExpression)patternExpression;
            list  = new List <AphidExpression>((IEnumerable <AphidExpression>)aphidExpressions);
            list1 = this.MutateRecursively((AphidMutator)indexTrackingMutator, list);
        }
示例#6
0
        public void MutateRecursivelyThrowsNullReferenceException267()
        {
            IndexTrackingMutator   indexTrackingMutator;
            LoadScriptExpression   loadScriptExpression;
            PatternExpression      patternExpression;
            List <AphidExpression> list;
            List <AphidExpression> list1;

            string[] ss = new string[1];
            indexTrackingMutator = new IndexTrackingMutator(ss);
            AphidExpressionContext s0 = new AphidExpressionContext();

            s0.Filename          = (string)null;
            s0.Code              = (string)null;
            loadScriptExpression = new LoadScriptExpression(s0, (AphidExpression)null);
            ((AphidExpression)loadScriptExpression).Index  = 0;
            ((AphidExpression)loadScriptExpression).Length = 0;
            AphidExpressionContext s1 = new AphidExpressionContext();

            s1.Filename       = (string)null;
            s1.Code           = (string)null;
            patternExpression = new PatternExpression
                                    (s1, (AphidExpression)loadScriptExpression, (List <AphidExpression>)null);
            ((AphidExpression)patternExpression).Index  = 0;
            ((AphidExpression)patternExpression).Length = 0;
            AphidExpression[] aphidExpressions = new AphidExpression[1];
            aphidExpressions[0] = (AphidExpression)patternExpression;
            list  = new List <AphidExpression>((IEnumerable <AphidExpression>)aphidExpressions);
            list1 = this.MutateRecursively((AphidMutator)indexTrackingMutator, list);
        }
示例#7
0
 /// <summary>
 /// Matches a phone number.
 /// </summary>
 /// <param name="pattern">The pattern.</param>
 /// <param name="kind">The kind.</param>
 /// <returns>Returns a <see cref="PatternExpression"/>.</returns>
 public static PatternExpression Phone(this PatternExpression pattern, PhoneNumberKind kind = PhoneNumberKind.Default)
 {
     switch (kind)
     {
     default:
         return(new PatternExpression(pattern.Build() + @"^((\(\d{3}\) ?)|(\d{3}-))?\d{3}-\d{4}$"));
     }
 }
        /// <summary>
        /// Visit pattern
        /// </summary>
        /// <param name="expression"></param>
        /// <returns></returns>
        public Expression VisitPattern([NotNull] PatternExpression expression)
        {
            Check.NotNull(expression, nameof(expression));

            Visit(expression.NodePattern);
            if (!(expression.PatternElementChain is null))
            {
                foreach (Tuple <RelationshipPatternExpression, NodePatternExpression> chain in expression.PatternElementChain)
                {
                    Visit(chain.Item1);
                    Visit(chain.Item2);
                }
            }

            return(expression);
        }
示例#9
0
        public void MutateRecursivelyThrowsNullReferenceException120()
        {
            IndexTrackingMutator   indexTrackingMutator;
            PatternExpression      patternExpression;
            List <AphidExpression> list;
            List <AphidExpression> list1;

            indexTrackingMutator = new IndexTrackingMutator((string[])null);
            patternExpression    = new PatternExpression((AphidExpressionContext)null,
                                                         (AphidExpression)null, (List <AphidExpression>)null);
            ((AphidExpression)patternExpression).Index  = 0;
            ((AphidExpression)patternExpression).Length = 0;
            AphidExpression[] aphidExpressions = new AphidExpression[1];
            aphidExpressions[0] = (AphidExpression)patternExpression;
            list  = new List <AphidExpression>((IEnumerable <AphidExpression>)aphidExpressions);
            list1 = this.MutateRecursively((AphidMutator)indexTrackingMutator, list);
        }
示例#10
0
        public override bool Execute()
        {
            GDataCredentials credentials = GetDataCredentials();
            RequestSettings  settings    = new RequestSettings("code.google.com/p/exult/", credentials);

            settings.AutoPaging = true;
            settings.PageSize   = 100;

            DocumentsRequest request = new DocumentsRequest(settings);
            Feed <Document>  feed    = request.GetFolders();

            List <ITaskItem> outputs = new List <ITaskItem>();

            // this takes care of paging the results in
            List <Document> entries = feed.Entries.ToList();
            IDictionary <string, Document> documentDictionary = entries.ToDictionary(item => item.Self);

            RequireDirectory(TargetDirectory);

            foreach (Document entry in entries)
            {
                if (_Cancelled)
                {
                    return(false);
                }

                List <PathMapping> paths = GetPaths(entry, documentDictionary).ToList();

                //handle each path, as we may allow multiple locations for a collection
                foreach (PathMapping path in paths)
                {
                    if (Pattern == null || PatternExpression.IsMatch(path.TitlePath))
                    {
                        Log.LogMessage(MessageImportance.High, "Matched \"{0}\"", path.TitlePath);
                        outputs.Add(BuildFolder(entry, path));
                    }
                    else
                    {
                        Log.LogMessage(MessageImportance.Low, "Skipped \"{0}\"", path.TitlePath);
                    }
                }
            }
            Folders = outputs.ToArray();
            return(true);
        }
示例#11
0
        public UstNode VisitPatternNotLiteral([NotNull] DslParser.PatternNotLiteralContext context)
        {
            Token      patternLiteral = (Token)VisitPatternLiteral(context.patternLiteral());
            Expression result;

            if (context.PatternNot() != null)
            {
                result = new PatternExpression(patternLiteral, true)
                {
                    TextSpan = context.GetTextSpan()
                };
            }
            else
            {
                result = patternLiteral;
            }
            return(result);
        }
示例#12
0
        public static PatternExpression Create(
            AphidExpressionContext context_aphidExpressionContext,
            AphidExpression value_aphidExpression,
            List <AphidExpression> patterns_list,
            int value_i,
            int value_i1
            )
        {
            PatternExpression patternExpression = new PatternExpression
                                                      (context_aphidExpressionContext, value_aphidExpression, patterns_list);

            ((AphidExpression)patternExpression).Index  = value_i;
            ((AphidExpression)patternExpression).Length = value_i1;
            return(patternExpression);

            // TODO: Edit factory method of PatternExpression
            // This method should be able to configure the object in all possible ways.
            // Add as many parameters as needed,
            // and assign their values to each field by using the API.
        }
示例#13
0
 public virtual void Accept(PatternExpression expression)
 {
 }
示例#14
0
 public virtual void Enter(PatternExpression patternExpression)
 {
 }
示例#15
0
 public virtual void Exit(PatternExpression patternExpression)
 {
 }
示例#16
0
 [DebuggerStepThrough] protected virtual void EmitPatternExpression(PatternExpression expression, bool isStatement = false)
 {
     throw new NotImplementedException();
 }
示例#17
0
        public void TestPredicate()
        {
            MacroScopeParser parser     = Factory.CreateParser("a >= b");
            Expression       expression = parser.predicate() as Expression;

            Assert.IsNotNull(expression);
            Assert.AreEqual("a", TestUtil.Stringify(expression.Left));
            Assert.AreSame(ExpressionOperator.GreaterOrEqual,
                           expression.Operator);
            Assert.AreEqual("b", TestUtil.Stringify(expression.Right));

            parser     = Factory.CreateParser("c is null");
            expression = parser.predicate() as Expression;
            Assert.IsNotNull(expression);
            Assert.AreEqual("c", TestUtil.Stringify(expression.Left));
            Assert.AreSame(ExpressionOperator.IsNull,
                           expression.Operator);
            Assert.IsNull(expression.Right);

            CheckPredicate("c IS NOT NULL");

            parser     = Factory.CreateParser("d like 'Smith%'");
            expression = parser.predicate() as Expression;
            Assert.IsNotNull(expression);
            Assert.AreEqual("d", TestUtil.Stringify(expression.Left));
            Assert.AreSame(ExpressionOperator.Like,
                           expression.Operator);

            PatternExpression patternExpression = expression.Right as PatternExpression;

            Assert.IsNotNull(patternExpression);
            Assert.AreEqual("'Smith%'", TestUtil.Stringify(patternExpression.Expression));
            Assert.IsNull(patternExpression.Escape);

            parser     = Factory.CreateParser("comment LIKE '%30!%%' ESCAPE '!'");
            expression = parser.predicate() as Expression;
            Assert.IsNotNull(expression);

            patternExpression = expression.Right as PatternExpression;
            Assert.IsNotNull(patternExpression);
            Assert.AreEqual("'%30!%%'", TestUtil.Stringify(patternExpression.Expression));
            Assert.AreEqual("'!'", TestUtil.Stringify(patternExpression.Escape));

            parser     = Factory.CreateParser("e between 1 and 10");
            expression = parser.predicate() as Expression;
            Assert.IsNotNull(expression);
            Assert.AreSame(ExpressionOperator.Between, expression.Operator);
            Assert.AreEqual("e BETWEEN 1 AND 10", TestUtil.Stringify(expression));

            parser     = Factory.CreateParser("f in(+2, +3, +5, +7)");
            expression = parser.predicate() as Expression;
            Assert.IsNotNull(expression);
            Assert.AreEqual("f IN (2, 3, 5, 7)", TestUtil.Stringify(expression));

            string idempotent = "g1 NOT IN (SELECT name\r\nFROM week)";

            parser     = Factory.CreateParser(idempotent);
            expression = parser.predicate() as Expression;
            Assert.IsNotNull(expression);
            Assert.AreEqual(idempotent, TestUtil.Stringify(expression));

            CheckPredicate("EXISTS (SELECT *\r\nFROM warehouse)");
        }
示例#18
0
 public virtual UstNode Visit(PatternExpression patternExpression)
 {
     return(VisitChildren(patternExpression));
 }
示例#19
0
        public override bool Execute()
        {
            GDataCredentials credentials = GetDataCredentials();
            RequestSettings  settings    = new RequestSettings("code.google.com/p/exult/", credentials);

            settings.AutoPaging = true;
            settings.PageSize   = 100;

            List <ITaskItem> folderContent = new List <ITaskItem>();

            WarnIfUneven(Tuple.Create("Folders", Folders), Tuple.Create("FolderListings", FolderListings));
            foreach (var tuple in Zip(Folders, FolderListings))
            {
                if (_Cancelled)
                {
                    return(false);
                }

                ITaskItem folder        = tuple.Item1;
                ITaskItem folderListing = tuple.Item2;

                folder.LoadCustomMetadata();
                folder.RequireDocumentType(Document.DocumentType.Folder);

                //yada/hrm.folder -> yada/hrm/
                string folderPath = Path.Combine(Path.GetDirectoryName(folder.ItemSpec), Path.GetFileNameWithoutExtension(folder.ItemSpec));
                RequireDirectory(folderPath);
                PathMapping folderMapping = new PathMapping(folderPath);

                Request request = new Request(settings);

                string resourceId = folder.RequireResourceId();

                Log.LogMessage(MessageImportance.High, "Getting Folder Content \"{0}\"", folder.RequireTitlePath());
                Feed <Document> feed = request.GetFolderContent(resourceId);

                // this takes care of paging the results in
                List <Document> documents = feed.Entries.Where(item => item.Type != Document.DocumentType.Folder).ToList();
                Log.LogMessage(MessageImportance.Normal, "Found {0} Item(s)", documents.Count);

                DateTime folderTimestamp = folder.GetTimestamp();
                DateTime latestTimestamp = folderTimestamp;

                foreach (Document document in documents)
                {
                    if (_Cancelled)
                    {
                        return(false);
                    }

                    if (document.Updated > latestTimestamp)
                    {
                        latestTimestamp = document.Updated;
                    }
                    if (Pattern == null || PatternExpression.IsMatch(document.Title))
                    {
                        Log.LogMessage(MessageImportance.Normal, "Matched \"{0}\"", document.Title);
                        folderContent.Add(BuildContent(folder, document, folderMapping));
                    }
                    else
                    {
                        Log.LogMessage(MessageImportance.Low, "Skipped \"{0}\"", document.Title);
                    }
                }
                folder.CopyMetadataTo(folderListing);
                folderListing.Save(Log, latestTimestamp);
            }
            FolderContent = folderContent.ToArray();
            return(true);
        }
示例#20
0
 public override void Accept(PatternExpression expression)
 {
     expression.VisitChildren(this);
 }
示例#21
0
        public void SetUp(List <string> args)
        {
            if (verbose)
            {
                Console.WriteLine("import path:");

                foreach (string directory in pathResolver.Directories)
                {
                    Console.WriteLine("  " + directory);
                }
            }

            AppDomain domain = Thread.GetDomain();

            rootModule = new Module(null, null);

            foreach (Assembly assembly in domain.GetAssemblies())
            {
                AssemblyLoaded(assembly);
            }

            domain.AssemblyLoad += OnDomainAssemblyLoad;

            rootModule.SetName("null", null);
            rootModule.SetName("true", true);
            rootModule.SetName("false", false);
            rootModule.SetName("args", args);

            DefaultWhitespace.SetUp(rootModule, grammar);
            LineComment.SetUp(rootModule, grammar);
            BlockComment.SetUp(rootModule, grammar);
            Whitespace.SetUp(rootModule, grammar);
            Name.SetUp(rootModule, grammar);
            Name.SetUp(rootModule, grammar);
            Number.SetUp(rootModule, grammar);
            Base.String.SetUp(rootModule, grammar);

            Expression.SetUp(rootModule, grammar);
            ValueExpression.SetUp(rootModule, grammar);
            NameExpression.SetUp(rootModule, grammar);
            ParenExpression.SetUp(rootModule, grammar);
            MemberExpression.SetUp(rootModule, grammar);
            CallExpression.SetUp(rootModule, grammar);
            CallInParentScopeExpression.SetUp(rootModule, grammar);
            NewExpression.SetUp(rootModule, grammar);
            TypeExpression.SetUp(rootModule, grammar);
            IsExpression.SetUp(rootModule, grammar);
            AsExpression.SetUp(rootModule, grammar);
            UnaryExpression.SetUp(rootModule, grammar);
            NotExpression.SetUp(rootModule, grammar);
            MultiplicativeExpression.SetUp(rootModule, grammar);
            MultiplyExpression.SetUp(rootModule, grammar);
            DivideExpression.SetUp(rootModule, grammar);
            AdditiveExpression.SetUp(rootModule, grammar);
            AddExpression.SetUp(rootModule, grammar);
            SubtractExpression.SetUp(rootModule, grammar);
            ComparisonExpression.SetUp(rootModule, grammar);
            LessExpression.SetUp(rootModule, grammar);
            LessOrEqualExpression.SetUp(rootModule, grammar);
            EqualityExpression.SetUp(rootModule, grammar);
            InequalityExpression.SetUp(rootModule, grammar);
            GreaterExpression.SetUp(rootModule, grammar);
            GreaterOrEqualExpression.SetUp(rootModule, grammar);
            JunctionExpression.SetUp(rootModule, grammar);
            AndExpression.SetUp(rootModule, grammar);
            AssignmentExpression.SetUp(rootModule, grammar);
            AssignExpression.SetUp(rootModule, grammar);

            /*
             *  NameExpression = ValueExpression
             * ParenExpression = ValueExpression
             *
             * CallExpression < ValueExpression
             * CallInParentScopeExpression = CallExpression
             * MemberExpression = CallExpression
             *
             * NewExpression < CallExpression
             * TypeExpression < NewExpression
             * UnaryExpression < TypeExpression
             * MultiplicativeExpression < UnaryExpression
             * AdditiveExpression < MultiplicativeExpression
             * ComparisonExpression < AdditiveExpression
             * JunctionExpression < ComparisonExpression
             * AssignmentExpression < JunctionExpression
             */

            Precedence.SetPrecedence(NameExpression.pattern.Precedence,
                                     ValueExpression.pattern.Precedence, Relation.Equal);

            Precedence.SetPrecedence(ParenExpression.pattern.Precedence,
                                     ValueExpression.pattern.Precedence, Relation.Equal);

            Precedence.SetPrecedence(CallExpression.pattern.Precedence,
                                     ValueExpression.pattern.Precedence, Relation.Lower);

            Precedence.SetPrecedence(CallInParentScopeExpression.pattern.Precedence,
                                     CallExpression.pattern.Precedence, Relation.Equal);

            Precedence.SetPrecedence(MemberExpression.pattern.Precedence,
                                     CallExpression.pattern.Precedence, Relation.Equal);

            Precedence.SetPrecedence(NewExpression.pattern.Precedence,
                                     CallExpression.pattern.Precedence, Relation.Lower);

            Precedence.SetPrecedence(TypeExpression.pattern.Precedence,
                                     NewExpression.pattern.Precedence, Relation.Lower);

            Precedence.SetPrecedence(UnaryExpression.pattern.Precedence,
                                     TypeExpression.pattern.Precedence, Relation.Lower);

            Precedence.SetPrecedence(MultiplicativeExpression.pattern.Precedence,
                                     UnaryExpression.pattern.Precedence, Relation.Lower);

            Precedence.SetPrecedence(AdditiveExpression.pattern.Precedence,
                                     MultiplicativeExpression.pattern.Precedence, Relation.Lower);

            Precedence.SetPrecedence(ComparisonExpression.pattern.Precedence,
                                     AdditiveExpression.pattern.Precedence, Relation.Lower);

            Precedence.SetPrecedence(JunctionExpression.pattern.Precedence,
                                     ComparisonExpression.pattern.Precedence, Relation.Lower);

            Precedence.SetPrecedence(AssignmentExpression.pattern.Precedence,
                                     JunctionExpression.pattern.Precedence, Relation.Lower);

            Grammar.PatternChanged(ValueExpression.pattern,
                                   NameExpression.pattern,
                                   ParenExpression.pattern,
                                   MemberExpression.pattern,
                                   CallExpression.pattern,
                                   NewExpression.pattern,
                                   TypeExpression.pattern,
                                   UnaryExpression.pattern,
                                   MultiplicativeExpression.pattern,
                                   AdditiveExpression.pattern,
                                   ComparisonExpression.pattern,
                                   JunctionExpression.pattern,
                                   AssignmentExpression.pattern);

            PatternExpression.SetUp(rootModule, grammar);
            ReferencePatternExpression.SetUp(rootModule, grammar);
            AnyPatternExpression.SetUp(rootModule, grammar);
            TextPatternExpression.SetUp(rootModule, grammar);
            Option.SetUp(rootModule, grammar);
            BlockPatternExpression.SetUp(rootModule, grammar);
            ParenPatternExpression.SetUp(rootModule, grammar);
            TokenPatternExpression.SetUp(rootModule, grammar);
            RangePatternExpression.SetUp(rootModule, grammar);
            RepeatPatternExpression.SetUp(rootModule, grammar);
            AndPatternExpression.SetUp(rootModule, grammar);
            NotPatternExpression.SetUp(rootModule, grammar);
            LabelPatternExpression.SetUp(rootModule, grammar);
            SequencePatternExpression.SetUp(rootModule, grammar);
            AltPatternExpression.SetUp(rootModule, grammar);

            /*
             *  EndPatternExpression = ReferencePatternExpression
             * AnyPatternExpression = ReferencePatternExpression
             *  TextPatternExpression = ReferencePatternExpression
             *  BlockPatternExpression = ReferencePatternExpression
             *  ParenPatternExpression = ReferencePatternExpression
             *  TokenPatternExpression = ReferencePatternExpression
             *
             *  RangePatternExpression < ReferencePatternExpression
             *
             *  AndPatternExpression < RangePatternExpression
             *  NotPatternExpression = AndPatternExpression
             *  RepeatPatternExpression = AndPatternExpression
             *
             *  LabelPatternExpression < AndPatternExpression
             *  SequencePatternExpression < LabelPatternExpression
             *  AltPatternExpression < SequencePatternExpression
             */

            Precedence.SetPrecedence(AnyPatternExpression.pattern.Precedence,
                                     ReferencePatternExpression.pattern.Precedence, Relation.Equal);

            Precedence.SetPrecedence(TextPatternExpression.pattern.Precedence,
                                     ReferencePatternExpression.pattern.Precedence, Relation.Equal);

            Precedence.SetPrecedence(BlockPatternExpression.pattern.Precedence,
                                     ReferencePatternExpression.pattern.Precedence, Relation.Equal);

            Precedence.SetPrecedence(ParenPatternExpression.pattern.Precedence,
                                     ReferencePatternExpression.pattern.Precedence, Relation.Equal);

            Precedence.SetPrecedence(TokenPatternExpression.pattern.Precedence,
                                     ReferencePatternExpression.pattern.Precedence, Relation.Equal);

            Precedence.SetPrecedence(RangePatternExpression.pattern.Precedence,
                                     ReferencePatternExpression.pattern.Precedence, Relation.Lower);

            Precedence.SetPrecedence(AndPatternExpression.pattern.Precedence,
                                     RangePatternExpression.pattern.Precedence, Relation.Lower);

            Precedence.SetPrecedence(NotPatternExpression.pattern.Precedence,
                                     AndPatternExpression.pattern.Precedence, Relation.Equal);

            Precedence.SetPrecedence(RepeatPatternExpression.pattern.Precedence,
                                     AndPatternExpression.pattern.Precedence, Relation.Equal);

            Precedence.SetPrecedence(LabelPatternExpression.pattern.Precedence,
                                     AndPatternExpression.pattern.Precedence, Relation.Lower);

            Precedence.SetPrecedence(SequencePatternExpression.pattern.Precedence,
                                     LabelPatternExpression.pattern.Precedence, Relation.Lower);

            Precedence.SetPrecedence(AltPatternExpression.pattern.Precedence,
                                     SequencePatternExpression.pattern.Precedence, Relation.Lower);

            Grammar.PatternChanged(ReferencePatternExpression.pattern,
                                   AnyPatternExpression.pattern,
                                   TextPatternExpression.pattern,
                                   BlockPatternExpression.pattern,
                                   ParenPatternExpression.pattern,
                                   TokenPatternExpression.pattern,
                                   RangePatternExpression.pattern,
                                   RepeatPatternExpression.pattern,
                                   AndPatternExpression.pattern,
                                   NotPatternExpression.pattern,
                                   LabelPatternExpression.pattern,
                                   SequencePatternExpression.pattern,
                                   AltPatternExpression.pattern);

            Statement.SetUp(rootModule, grammar);
            ExpressionStatement.SetUp(rootModule, grammar);
            CompoundStatement.SetUp(rootModule, grammar);
            PrintStatement.SetUp(rootModule, grammar);
            IfStatement.SetUp(rootModule, grammar);
            WhileStatement.SetUp(rootModule, grammar);
            ReturnStatement.SetUp(rootModule, grammar);
            ThrowStatement.SetUp(rootModule, grammar);
            TryStatement.SetUp(rootModule, grammar);
            ModuleStatement.SetUp(rootModule, grammar);
            FunctionStatement.SetUp(rootModule, grammar);
            Member.SetUp(rootModule, grammar);
            PatternMember.SetUp(rootModule, grammar);
            FieldMember.SetUp(rootModule, grammar);
            ConstructorMember.SetUp(rootModule, grammar);
            MethodMember.SetUp(rootModule, grammar);
            ClassStatement.SetUp(rootModule, grammar);
            SetPrecedenceStatement.SetUp(rootModule, grammar);
            UsingStatement.SetUp(rootModule, grammar);
            ImportStatement.SetUp(rootModule, grammar);
            TopLevelStatement.SetUp(rootModule, grammar);
            Program.SetUp(rootModule, grammar);

            Grammar.PatternChanged(Member.pattern, Statement.pattern);

            grammar.RootPattern = Program.pattern;

            hasBeenSetUp = true;
        }