public void TestLogLevel()
        {
            var res = ContentMatchExpression.CreateContentMatchExpression(new ContentToken("l:we"));

            Assert.IsInstanceOfType(res, typeof(LogLevelMatchExpression));
            Assert.AreEqual("l:ew", res.EvalToString(false));
        }
        public void TestPid1()
        {
            var res = ContentMatchExpression.CreateContentMatchExpression(new ContentToken("p:99"));

            Assert.IsInstanceOfType(res, typeof(ProcessIdMatchExpression));
            Assert.AreEqual("p:99", res.EvalToString(false));
        }
        public void TestTid2()
        {
            var res = ContentMatchExpression.CreateContentMatchExpression(new ContentToken("t:99,98"));

            Assert.IsInstanceOfType(res, typeof(ThreadIdMatchExpression));
            Assert.AreEqual("t:99,98", res.EvalToString(false));
        }
        public void TestDatetimeEnd()
        {
            var res = ContentMatchExpression.CreateContentMatchExpression(new ContentToken("e:\"1990.09.27 3:00 PM\""));

            Assert.IsInstanceOfType(res, typeof(DatetimeEndMatchExpression));
            Assert.AreEqual("e:1990-09-27T15:00:00", res.EvalToString(false));
        }
        public void TestTextMatch3()
        {
            var res = ContentMatchExpression.CreateContentMatchExpression(new ContentToken("c:\"basic text\""));

            Assert.IsInstanceOfType(res, typeof(TextMatchExpression));
            Assert.AreEqual("\"basic text\"", res.EvalToString(false));
        }
        public void TestEndIdx()
        {
            var res = ContentMatchExpression.CreateContentMatchExpression(new ContentToken(@"ei:18"));

            Assert.IsInstanceOfType(res, typeof(EndIdxExpression));
            Assert.AreEqual(@"ei:18", res.EvalToString(false));
        }
        public void TestRegexMatch2()
        {
            var res = ContentMatchExpression.CreateContentMatchExpression(new ContentToken(@"r:""\w+ """""""""""));

            Assert.IsInstanceOfType(res, typeof(RegexMatchExpression));
            Assert.AreEqual(@"r:""\w+ """"""""""", res.EvalToString(false));
        }
Example #8
0
        private static Expression MkLeaf(Token token)
        {
            if (token is ContentToken)
            {
                return(ContentMatchExpression.CreateContentMatchExpression((ContentToken)token));
            }

            throw new ParsingException($"{token.ToString()} is not {nameof(ContentToken)}", token.Index);
        }
Example #9
0
 internal Expression ParseContent() // E -> C E'
 {
     if (this.input.Peek() is ContentToken)
     {
         ContentToken ct  = (ContentToken)this.input.Read();
         Expression   res = ContentMatchExpression.CreateContentMatchExpression(ct);
         return(this.ParseExPrime(res));
     }
     else
     {
         return(null);
     }
 }