public void SymbolVariable_MatchesAnySymbol()
		{
			var pattern = new Pattern(new SymbolVariable("s.1")); // s.1
			var expr = PassiveExpression.Build(123); // 123

			var result = pattern.Match(expr);
			Assert.IsTrue(result);
			Assert.IsTrue(pattern.Variables.ContainsKey("s.1"));
			Assert.AreEqual(123, pattern.Variables["s.1"].Value);

			expr = PassiveExpression.Build('A'); // 'A'

			result = pattern.Match(expr);
			Assert.IsTrue(result);
			Assert.IsTrue(pattern.Variables.ContainsKey("s.1"));
			Assert.AreEqual('A', pattern.Variables["s.1"].Value);
		}
		public void SymbolChain_DontMatchDifferentSymbolChain()
		{
			var pattern = new Pattern(123, 'T', 'e', 's', 't'); // 123 'Test'
			var expr = PassiveExpression.Build(123, 'T', 'E', 'S', 'T'); // 123 'TEST'

			var result = pattern.Match(expr);
			Assert.IsFalse(result);
		}
		public void SymbolChain_MatchesSameSymbolChain()
		{
			var pattern = new Pattern(123, 'T', 'e', 's', 't'); // 123 'Test'
			var expr = PassiveExpression.Build(123, 'T', 'e', 's', 't'); // 123 'Test'

			var result = pattern.Match(expr);
			Assert.IsTrue(result);
		}
		public void Symbol_MatchesSameSymbol()
		{
			var pattern = new Pattern(123); // 123
			var expr = PassiveExpression.Build(123); // 123

			var result = pattern.Match(expr);
			Assert.IsTrue(result);
		}
		public void Symbol_DontMatchAnotherSymbol()
		{
			var pattern = new Pattern(123); // 123
			var expr = PassiveExpression.Build('X'); // 'X'

			var result = pattern.Match(expr);
			Assert.IsFalse(result);
		}
Esempio n. 6
0
        public static PassiveExpression _Go(PassiveExpression expression)
        {
            Pattern pattern1 = new Pattern();

            if (pattern1.Match(expression))
            {
                return(PassiveExpression.Build(_Job(PassiveExpression.Build(_Card(PassiveExpression.Build())))));
            }
            ;

            throw new RecognitionImpossibleException("Recognition impossible. Last expression: " + expression.ToString());
        }
Esempio n. 7
0
        private static PassiveExpression _Table(PassiveExpression expression)
        {
            Pattern pattern8 = new Pattern();

            if (pattern8.Match(expression))
            {
                return(PassiveExpression.Build(new OpeningBrace(), new OpeningBrace(), "cane".ToCharArray(), new ClosingBrace(), "dog".ToCharArray(), new ClosingBrace(), new OpeningBrace(), new OpeningBrace(), "gatto".ToCharArray(), new ClosingBrace(), "cat".ToCharArray(), new ClosingBrace(), new OpeningBrace(), new OpeningBrace(), "cavallo".ToCharArray(), new ClosingBrace(), "horse".ToCharArray(), new ClosingBrace(), new OpeningBrace(), new OpeningBrace(), "rana".ToCharArray(), new ClosingBrace(), "frog".ToCharArray(), new ClosingBrace(), new OpeningBrace(), new OpeningBrace(), "porco".ToCharArray(), new ClosingBrace(), "pig".ToCharArray(), new ClosingBrace()));
            }
            ;

            throw new RecognitionImpossibleException("Recognition impossible. Last expression: " + expression.ToString());
        }
Esempio n. 8
0
        private static PassiveExpression _InputFile(PassiveExpression expression)
        {
            Pattern pattern2 = new Pattern();

            if (pattern2.Match(expression))
            {
                return(PassiveExpression.Build(1));
            }
            ;

            throw new RecognitionImpossibleException("Recognition impossible. Last expression: " + expression.ToString());
        }
Esempio n. 9
0
        public static PassiveExpression _Go(PassiveExpression expression)
        {
            Pattern pattern1 = new Pattern();

            if (pattern1.Match(expression))
            {
                return(PassiveExpression.Build(_Prout(PassiveExpression.Build("Hello".ToCharArray()))));
            }
            ;

            throw new RecognitionImpossibleException("Recognition impossible. Last expression: " + expression.ToString());
        }
Esempio n. 10
0
        private static PassiveExpression _Destroy(PassiveExpression expression)
        {
            Pattern pattern58 = new Pattern(new ExpressionVariable("e.E"));

            if (pattern58.Match(expression))
            {
                return(PassiveExpression.Build());
            }
            ;

            throw new RecognitionImpossibleException("Recognition impossible. Last expression: " + expression.ToString());
        }
Esempio n. 11
0
        private static PassiveExpression _Ermes(PassiveExpression expression)
        {
            Pattern pattern59 = new Pattern(new ExpressionVariable("e.X"));

            if (pattern59.Match(expression))
            {
                return(PassiveExpression.Build(_Prout(PassiveExpression.Build(_Put(PassiveExpression.Build(2, pattern59.GetVariable("e.X")))))));
            }
            ;

            throw new RecognitionImpossibleException("Recognition impossible. Last expression: " + expression.ToString());
        }
Esempio n. 12
0
        public static PassiveExpression _Go(PassiveExpression expression)
        {
            Pattern pattern1 = new Pattern();

            if (pattern1.Match(expression))
            {
                return(PassiveExpression.Build(_Prout(PassiveExpression.Build("0 + 0 = ", _RAdd(PassiveExpression.Build(new OpeningBrace(), "0".ToCharArray(), new ClosingBrace(), new OpeningBrace(), "0".ToCharArray(), new ClosingBrace())))), _Prout(PassiveExpression.Build("0\' + 0 = ", _RAdd(PassiveExpression.Build(new OpeningBrace(), "0\'".ToCharArray(), new ClosingBrace(), new OpeningBrace(), "0".ToCharArray(), new ClosingBrace())))), _Prout(PassiveExpression.Build("0 + 0\' = ", _RAdd(PassiveExpression.Build(new OpeningBrace(), "0".ToCharArray(), new ClosingBrace(), new OpeningBrace(), "0\'".ToCharArray(), new ClosingBrace())))), _Prout(PassiveExpression.Build("0\' + 0\' = ", _RAdd(PassiveExpression.Build(new OpeningBrace(), "0\'".ToCharArray(), new ClosingBrace(), new OpeningBrace(), "0\'".ToCharArray(), new ClosingBrace())))), _Prout(PassiveExpression.Build("0\'\' + 0\'\'\' = ", _RAdd(PassiveExpression.Build(new OpeningBrace(), "0\'\'".ToCharArray(), new ClosingBrace(), new OpeningBrace(), "0\'\'\'".ToCharArray(), new ClosingBrace()))))));
            }
            ;

            throw new RecognitionImpossibleException("Recognition impossible. Last expression: " + expression.ToString());
        }
Esempio n. 13
0
        private static PassiveExpression _Alphabet(PassiveExpression expression)
        {
            Pattern pattern6 = new Pattern();

            if (pattern6.Match(expression))
            {
                return(PassiveExpression.Build("abcdefghijklmnopqrstuvwxyz".ToCharArray()));
            }
            ;

            throw new RecognitionImpossibleException("Recognition impossible. Last expression: " + expression.ToString());
        }
Esempio n. 14
0
        public static PassiveExpression _Go(PassiveExpression expression)
        {
            Pattern pattern1 = new Pattern();

            if (pattern1.Match(expression))
            {
                return(PassiveExpression.Build(_Open(PassiveExpression.Build("r".ToCharArray(), 1, _Arg(PassiveExpression.Build(1)))), _Open(PassiveExpression.Build("w".ToCharArray(), 2, _Arg(PassiveExpression.Build(2)))), _Mbprep(PassiveExpression.Build(_Next(PassiveExpression.Build())))));
            }
            ;

            throw new RecognitionImpossibleException("Recognition impossible. Last expression: " + expression.ToString());
        }
Esempio n. 15
0
        public static PassiveExpression _Go(PassiveExpression expression)
        {
            Pattern pattern1 = new Pattern();

            if (pattern1.Match(expression))
            {
                return(PassiveExpression.Build(_Open(PassiveExpression.Build("r".ToCharArray(), "File", "test09.ref")), _Output(PassiveExpression.Build(new OpeningBrace(), new ClosingBrace(), new OpeningBrace(), "File", new ClosingBrace()))));
            }
            ;

            throw new RecognitionImpossibleException("Recognition impossible. Last expression: " + expression.ToString());
        }
Esempio n. 16
0
        private static PassiveExpression _Putz(PassiveExpression expression)
        {
            Pattern pattern57 = new Pattern(new SymbolVariable("s.C"), new ExpressionVariable("e.E"));

            if (pattern57.Match(expression))
            {
                return(PassiveExpression.Build(_Destroy(PassiveExpression.Build(_Put(PassiveExpression.Build(pattern57.GetVariable("s.C"), pattern57.GetVariable("e.E")))))));
            }
            ;

            throw new RecognitionImpossibleException("Recognition impossible. Last expression: " + expression.ToString());
        }
Esempio n. 17
0
		private static PassiveExpression _Code__gen(PassiveExpression expression)
		{
			Pattern pattern60 = new Pattern(new ExpressionVariable("e.1"), "fail".ToCharArray());
			if (pattern60.Match(expression))
			{
				return PassiveExpression.Build();
			};

			Pattern pattern61 = new Pattern(new OpeningBrace(), new SymbolVariable("s.N"), new ClosingBrace(), "-".ToCharArray(), new OpeningBrace(), new ClosingBrace(), new ExpressionVariable("e.2"));
			if (pattern61.Match(expression))
			{
				return PassiveExpression.Build(_Code__gen(PassiveExpression.Build(new OpeningBrace(), pattern61.GetVariable("s.N"), new ClosingBrace(), pattern61.GetVariable("e.2"))), "Minus ;".ToCharArray());
			};

			Pattern pattern62 = new Pattern(new OpeningBrace(), new SymbolVariable("s.N"), new ClosingBrace(), new SymbolVariable("s.Op"), new OpeningBrace(), new ExpressionVariable("e.1"), new ClosingBrace(), new SymbolVariable("s.2"));
			if (pattern62.Match(expression))
			{
				return PassiveExpression.Build(_Code__gen(PassiveExpression.Build(new OpeningBrace(), pattern62.GetVariable("s.N"), new ClosingBrace(), pattern62.GetVariable("e.1"))), _Code__op(PassiveExpression.Build(pattern62.GetVariable("s.Op"))), _Outform(PassiveExpression.Build(pattern62.GetVariable("s.2"))), ";".ToCharArray());
			};

			Pattern pattern63 = new Pattern(new OpeningBrace(), new SymbolVariable("s.N"), new ClosingBrace(), "+".ToCharArray(), new OpeningBrace(), new SymbolVariable("s.1"), new ClosingBrace(), new ExpressionVariable("e.2"));
			if (pattern63.Match(expression))
			{
				return PassiveExpression.Build(_Code__gen(PassiveExpression.Build(new OpeningBrace(), pattern63.GetVariable("s.N"), new ClosingBrace(), pattern63.GetVariable("e.2"))), _Code__op(PassiveExpression.Build("+".ToCharArray())), _Outform(PassiveExpression.Build(pattern63.GetVariable("s.1"))), ";".ToCharArray());
			};

			Pattern pattern64 = new Pattern(new OpeningBrace(), new SymbolVariable("s.N"), new ClosingBrace(), "*".ToCharArray(), new OpeningBrace(), new SymbolVariable("s.1"), new ClosingBrace(), new ExpressionVariable("e.2"));
			if (pattern64.Match(expression))
			{
				return PassiveExpression.Build(_Code__gen(PassiveExpression.Build(new OpeningBrace(), pattern64.GetVariable("s.N"), new ClosingBrace(), pattern64.GetVariable("e.2"))), _Code__op(PassiveExpression.Build("*".ToCharArray())), _Outform(PassiveExpression.Build(pattern64.GetVariable("s.1"))), ";".ToCharArray());
			};

			Pattern pattern65 = new Pattern(new OpeningBrace(), new SymbolVariable("s.N"), new ClosingBrace(), new SymbolVariable("s.Op"), new OpeningBrace(), new ExpressionVariable("e.1"), new ClosingBrace(), new ExpressionVariable("e.2"));
			if (pattern65.Match(expression))
			{
				return PassiveExpression.Build(_Code__gen(PassiveExpression.Build(new OpeningBrace(), pattern65.GetVariable("s.N"), new ClosingBrace(), pattern65.GetVariable("e.2"))), "STORE R+".ToCharArray(), _Symb(PassiveExpression.Build(pattern65.GetVariable("s.N"))), ";".ToCharArray(), _Code__gen(PassiveExpression.Build(new OpeningBrace(), _Add(PassiveExpression.Build(new OpeningBrace(), pattern65.GetVariable("s.N"), new ClosingBrace(), 1)), new ClosingBrace(), pattern65.GetVariable("e.1"))), _Code__op(PassiveExpression.Build(pattern65.GetVariable("s.Op"))), "R+".ToCharArray(), _Symb(PassiveExpression.Build(pattern65.GetVariable("s.N"))), ";".ToCharArray());
			};

			Pattern pattern66 = new Pattern(new OpeningBrace(), new SymbolVariable("s.N"), new ClosingBrace(), new SymbolVariable("s.Symb"));
			if (pattern66.Match(expression))
			{
				return PassiveExpression.Build("LOAD ".ToCharArray(), _Outform(PassiveExpression.Build(pattern66.GetVariable("s.Symb"))), ";".ToCharArray());
			};

			Pattern pattern67 = new Pattern(new OpeningBrace(), new SymbolVariable("s.N"), new ClosingBrace(), new ExpressionVariable("e.X"));
			if (pattern67.Match(expression))
			{
				return PassiveExpression.Build(new OpeningBrace(), "Syntax error".ToCharArray(), new ClosingBrace(), ";".ToCharArray());
			};

			throw new RecognitionImpossibleException("Recognition impossible. Last expression: " + expression.ToString());
		}
Esempio n. 18
0
        private static PassiveExpression _AddB(PassiveExpression expression)
        {
            Pattern pattern2 = new Pattern(new OpeningBrace(), new ClosingBrace(), new OpeningBrace(), new ExpressionVariable("e.1"), new ClosingBrace());

            if (pattern2.Match(expression))
            {
                return(PassiveExpression.Build(pattern2.GetVariable("e.1")));
            }
            ;

            Pattern pattern3 = new Pattern(new OpeningBrace(), new ExpressionVariable("e.1"), new ClosingBrace(), new OpeningBrace(), new ClosingBrace());

            if (pattern3.Match(expression))
            {
                return(PassiveExpression.Build(pattern3.GetVariable("e.1")));
            }
            ;

            Pattern pattern4 = new Pattern(new OpeningBrace(), new ExpressionVariable("e.1"), "0".ToCharArray(), new ClosingBrace(), new OpeningBrace(), new ExpressionVariable("e.2"), new SymbolVariable("s.3"), new ClosingBrace());

            if (pattern4.Match(expression))
            {
                return(PassiveExpression.Build(_AddB(PassiveExpression.Build(new OpeningBrace(), pattern4.GetVariable("e.1"), new ClosingBrace(), new OpeningBrace(), pattern4.GetVariable("e.2"), new ClosingBrace())), pattern4.GetVariable("s.3")));
            }
            ;

            Pattern pattern5 = new Pattern(new OpeningBrace(), new ExpressionVariable("e.1"), new SymbolVariable("s.3"), new ClosingBrace(), new OpeningBrace(), new ExpressionVariable("e.2"), "0".ToCharArray(), new ClosingBrace());

            if (pattern5.Match(expression))
            {
                return(PassiveExpression.Build(_AddB(PassiveExpression.Build(new OpeningBrace(), pattern5.GetVariable("e.1"), new ClosingBrace(), new OpeningBrace(), pattern5.GetVariable("e.2"), new ClosingBrace())), pattern5.GetVariable("s.3")));
            }
            ;

            Pattern pattern6 = new Pattern(new OpeningBrace(), new ExpressionVariable("e.1"), "1".ToCharArray(), new ClosingBrace(), new OpeningBrace(), new ExpressionVariable("e.2"), "1".ToCharArray(), new ClosingBrace());

            if (pattern6.Match(expression))
            {
                return(PassiveExpression.Build(_AddB(PassiveExpression.Build(new OpeningBrace(), "1".ToCharArray(), new ClosingBrace(), new OpeningBrace(), _AddB(PassiveExpression.Build(new OpeningBrace(), pattern6.GetVariable("e.1"), new ClosingBrace(), new OpeningBrace(), pattern6.GetVariable("e.2"), new ClosingBrace())), new ClosingBrace())), "0".ToCharArray()));
            }
            ;

            Pattern pattern7 = new Pattern(new ExpressionVariable("e.1"));

            if (pattern7.Match(expression))
            {
                return(PassiveExpression.Build("** error! **".ToCharArray()));
            }
            ;

            throw new RecognitionImpossibleException("Recognition impossible. Last expression: " + expression.ToString());
        }
Esempio n. 19
0
        // extract arguments specified as <Function t.1 e.2>
        void GetArguments(PassiveExpression expression, out object arg1, out object arg2)
        {
            var p = new Pattern(new TermVariable("t.1"), new ExpressionVariable("e.2"));

            if (p.Match(expression))
            {
                arg1 = p.GetVariable("t.1");
                arg2 = p.GetVariable("e.2");
                return;
            }

            // can't find match
            throw new RecognitionImpossibleException();
        }
Esempio n. 20
0
		private static PassiveExpression _Pr__lmb(PassiveExpression expression)
		{
			Pattern pattern41 = new Pattern(new OpeningBrace(), new ExpressionVariable("e.1"), new ClosingBrace(), new ExpressionVariable("e.2"));
			if (pattern41.Match(expression))
			{
				return PassiveExpression.Build(_Pr__lmb(PassiveExpression.Build(pattern41.GetVariable("e.1"))), _Prout(PassiveExpression.Build("(".ToCharArray(), pattern41.GetVariable("e.2"))));
			};

			Pattern pattern42 = new Pattern("$".ToCharArray(), new ExpressionVariable("e.1"));
			if (pattern42.Match(expression))
			{
				return PassiveExpression.Build();
			};

			throw new RecognitionImpossibleException("Recognition impossible. Last expression: " + expression.ToString());
		}
Esempio n. 21
0
		private static PassiveExpression _Out(PassiveExpression expression)
		{
			Pattern pattern8 = new Pattern();
			if (pattern8.Match(expression))
			{
				return PassiveExpression.Build(_Loop(PassiveExpression.Build()));
			};

			Pattern pattern9 = new Pattern(new ExpressionVariable("e.1"));
			if (pattern9.Match(expression))
			{
				return PassiveExpression.Build(_Prout(PassiveExpression.Build("The translation is:".ToCharArray())), _Write(PassiveExpression.Build(pattern9.GetVariable("e.1"))), _Loop(PassiveExpression.Build()));
			};

			throw new RecognitionImpossibleException("Recognition impossible. Last expression: " + expression.ToString());
		}
Esempio n. 22
0
		private static PassiveExpression _Inout(PassiveExpression expression)
		{
			Pattern pattern6 = new Pattern(0);
			if (pattern6.Match(expression))
			{
				return PassiveExpression.Build(_Prout(PassiveExpression.Build("End of session".ToCharArray())));
			};

			Pattern pattern7 = new Pattern(new ExpressionVariable("e.X"));
			if (pattern7.Match(expression))
			{
				return PassiveExpression.Build(_Out(PassiveExpression.Build(_Translate(PassiveExpression.Build(_Lex(PassiveExpression.Build(new OpeningBrace(), "$".ToCharArray(), new ClosingBrace(), pattern7.GetVariable("e.X"))))))));
			};

			throw new RecognitionImpossibleException("Recognition impossible. Last expression: " + expression.ToString());
		}
Esempio n. 23
0
		private static PassiveExpression _Translate(PassiveExpression expression)
		{
			Pattern pattern43 = new Pattern();
			if (pattern43.Match(expression))
			{
				return PassiveExpression.Build();
			};

			Pattern pattern44 = new Pattern(new ExpressionVariable("e.1"));
			if (pattern44.Match(expression))
			{
				return PassiveExpression.Build(_Code__gen(PassiveExpression.Build(new OpeningBrace(), 1, new ClosingBrace(), _Parse(PassiveExpression.Build(pattern44.GetVariable("e.1"))), _Dg(PassiveExpression.Build("compl".ToCharArray())))));
			};

			throw new RecognitionImpossibleException("Recognition impossible. Last expression: " + expression.ToString());
		}
Esempio n. 24
0
        public static PassiveExpression _Br(PassiveExpression expression)
        {
            // <Br e.N '=' e.Expr>, where e.N is expression which does not
            // include '=' on the upper level of the bracket's structure
            Pattern pattern = new Pattern(new ExpressionVariable("Key"), '=', new ExpressionVariable("Value"));

            if (pattern.Match(expression))
            {
                PassiveExpression key    = (PassiveExpression)pattern.GetVariable("Key");
                PassiveExpression value  = (PassiveExpression)pattern.GetVariable("Value");
                string            strKey = key.ToString();

                buriedKeys[strKey]   = key;
                buriedValues[strKey] = value;
            }

            throw new RecognitionImpossibleException("<Br e.N '=' e.Expr>: unexpected arguments");
        }
Esempio n. 25
0
        private static PassiveExpression _Lookm0(PassiveExpression expression)
        {
            Pattern pattern11 = new Pattern(new ExpressionVariable("e.1"), "[".ToCharArray(), new ExpressionVariable("e.2"));

            if (pattern11.Match(expression))
            {
                return(PassiveExpression.Build(_Lookm(PassiveExpression.Build(new OpeningBrace(), new ClosingBrace(), pattern11.GetVariable("e.1"), "[".ToCharArray(), pattern11.GetVariable("e.2")))));
            }
            ;

            Pattern pattern12 = new Pattern(new ExpressionVariable("e.1"));

            if (pattern12.Match(expression))
            {
                return(PassiveExpression.Build(pattern12.GetVariable("e.1")));
            }
            ;

            throw new RecognitionImpossibleException("Recognition impossible. Last expression: " + expression.ToString());
        }
Esempio n. 26
0
        private static PassiveExpression _Out(PassiveExpression expression)
        {
            Pattern pattern36 = new Pattern(new ExpressionVariable("e.1"), ".EOL.", new ExpressionVariable("e.2"));

            if (pattern36.Match(expression))
            {
                return(PassiveExpression.Build(_Putz(PassiveExpression.Build(2, _Elpar(PassiveExpression.Build(pattern36.GetVariable("e.1"))))), _Out(PassiveExpression.Build(pattern36.GetVariable("e.2")))));
            }
            ;

            Pattern pattern37 = new Pattern(new ExpressionVariable("e.1"));

            if (pattern37.Match(expression))
            {
                return(PassiveExpression.Build(_Mbprep(PassiveExpression.Build(_Elpar(PassiveExpression.Build(pattern37.GetVariable("e.1")))))));
            }
            ;

            throw new RecognitionImpossibleException("Recognition impossible. Last expression: " + expression.ToString());
        }
Esempio n. 27
0
        private static PassiveExpression _Elpar(PassiveExpression expression)
        {
            Pattern pattern38 = new Pattern(new ExpressionVariable("e.1"), new OpeningBrace(), new ExpressionVariable("e.2"), new ClosingBrace(), new ExpressionVariable("e.3"));

            if (pattern38.Match(expression))
            {
                return(PassiveExpression.Build(pattern38.GetVariable("e.1"), pattern38.GetVariable("e.2"), _Elpar(PassiveExpression.Build(pattern38.GetVariable("e.3")))));
            }
            ;

            Pattern pattern39 = new Pattern(new ExpressionVariable("e.1"));

            if (pattern39.Match(expression))
            {
                return(PassiveExpression.Build(pattern39.GetVariable("e.1")));
            }
            ;

            throw new RecognitionImpossibleException("Recognition impossible. Last expression: " + expression.ToString());
        }
Esempio n. 28
0
        private static PassiveExpression _Trlmb(PassiveExpression expression)
        {
            Pattern pattern55 = new Pattern(new OpeningBrace(), new ExpressionVariable("e.1"), new ClosingBrace(), new OpeningBrace(), new ExpressionVariable("e.2"), new ClosingBrace(), new ExpressionVariable("e.L"));

            if (pattern55.Match(expression))
            {
                return(PassiveExpression.Build(pattern55.GetVariable("e.1"), ")(".ToCharArray(), _Trlmb(PassiveExpression.Build(new OpeningBrace(), pattern55.GetVariable("e.2"), new ClosingBrace(), pattern55.GetVariable("e.L")))));
            }
            ;

            Pattern pattern56 = new Pattern(new OpeningBrace(), new ExpressionVariable("e.1"), new ClosingBrace());

            if (pattern56.Match(expression))
            {
                return(PassiveExpression.Build(pattern56.GetVariable("e.1")));
            }
            ;

            throw new RecognitionImpossibleException("Recognition impossible. Last expression: " + expression.ToString());
        }
Esempio n. 29
0
        private static PassiveExpression _Before(PassiveExpression expression)
        {
            Pattern pattern4 = new Pattern(new SymbolVariable("s.1"), new SymbolVariable("s.2"), "In", new ExpressionVariable("e.A"), new SymbolVariable("s.1"), new ExpressionVariable("e.B"), new SymbolVariable("s.2"), new ExpressionVariable("e.C"));

            if (pattern4.Match(expression))
            {
                return(PassiveExpression.Build(true));
            }
            ;

            Pattern pattern5 = new Pattern(new ExpressionVariable("e.Z"));

            if (pattern5.Match(expression))
            {
                return(PassiveExpression.Build(false));
            }
            ;

            throw new RecognitionImpossibleException("Recognition impossible. Last expression: " + expression.ToString());
        }
Esempio n. 30
0
        private static PassiveExpression _Order1(PassiveExpression expression)
        {
            Pattern pattern3 = new Pattern(true, new OpeningBrace(), new ExpressionVariable("e.1"), new ClosingBrace(), new ExpressionVariable("e.2"));

            if (pattern3.Match(expression))
            {
                return(PassiveExpression.Build(pattern3.GetVariable("e.1"), pattern3.GetVariable("e.2")));
            }
            ;

            Pattern pattern4 = new Pattern(false, new OpeningBrace(), new ExpressionVariable("e.1"), new ClosingBrace(), new ExpressionVariable("e.2"));

            if (pattern4.Match(expression))
            {
                return(PassiveExpression.Build(pattern4.GetVariable("e.2"), pattern4.GetVariable("e.1")));
            }
            ;

            throw new RecognitionImpossibleException("Recognition impossible. Last expression: " + expression.ToString());
        }
Esempio n. 31
0
        private static PassiveExpression _PreAlph(PassiveExpression expression)
        {
            Pattern pattern2 = new Pattern(new SymbolVariable("s.1"), new SymbolVariable("s.1"));

            if (pattern2.Match(expression))
            {
                return(PassiveExpression.Build(true));
            }
            ;

            Pattern pattern3 = new Pattern(new SymbolVariable("s.1"), new SymbolVariable("s.2"));

            if (pattern3.Match(expression))
            {
                return(PassiveExpression.Build(_Before(PassiveExpression.Build(pattern3.GetVariable("s.1"), pattern3.GetVariable("s.2"), "In", _Alphabet(PassiveExpression.Build())))));
            }
            ;

            throw new RecognitionImpossibleException("Recognition impossible. Last expression: " + expression.ToString());
        }
Esempio n. 32
0
        private static PassiveExpression _Chpm(PassiveExpression expression)
        {
            Pattern pattern2 = new Pattern(new ExpressionVariable("e.1"), "+".ToCharArray(), new ExpressionVariable("e.2"));

            if (pattern2.Match(expression))
            {
                return(PassiveExpression.Build(pattern2.GetVariable("e.1"), "-".ToCharArray(), _Chpm(PassiveExpression.Build(pattern2.GetVariable("e.2")))));
            }
            ;

            Pattern pattern3 = new Pattern(new ExpressionVariable("e.1"));

            if (pattern3.Match(expression))
            {
                return(PassiveExpression.Build(pattern3.GetVariable("e.1")));
            }
            ;

            throw new RecognitionImpossibleException("Recognition impossible. Last expression: " + expression.ToString());
        }
Esempio n. 33
0
        private static PassiveExpression _Job(PassiveExpression expression)
        {
            Pattern pattern2 = new Pattern(0);

            if (pattern2.Match(expression))
            {
                return(PassiveExpression.Build());
            }
            ;

            Pattern pattern3 = new Pattern(new ExpressionVariable("e.X"));

            if (pattern3.Match(expression))
            {
                return(PassiveExpression.Build(_Prout(PassiveExpression.Build(_Trans__line(PassiveExpression.Build(pattern3.GetVariable("e.X"))))), _Job(PassiveExpression.Build(_Card(PassiveExpression.Build())))));
            }
            ;

            throw new RecognitionImpossibleException("Recognition impossible. Last expression: " + expression.ToString());
        }
Esempio n. 34
0
        private static PassiveExpression _Trans(PassiveExpression expression)
        {
            Pattern pattern9 = new Pattern(new OpeningBrace(), new ExpressionVariable("e.It"), new ClosingBrace(), new ExpressionVariable("e.1"), new OpeningBrace(), new OpeningBrace(), new ExpressionVariable("e.It"), new ClosingBrace(), new ExpressionVariable("e.Eng"), new ClosingBrace(), new ExpressionVariable("e.2"));

            if (pattern9.Match(expression))
            {
                return(PassiveExpression.Build(pattern9.GetVariable("e.Eng")));
            }
            ;

            Pattern pattern10 = new Pattern(new OpeningBrace(), new ExpressionVariable("e.It"), new ClosingBrace(), new ExpressionVariable("e.1"));

            if (pattern10.Match(expression))
            {
                return(PassiveExpression.Build("***".ToCharArray()));
            }
            ;

            throw new RecognitionImpossibleException("Recognition impossible. Last expression: " + expression.ToString());
        }
Esempio n. 35
0
		private static PassiveExpression _Id__tail(PassiveExpression expression)
		{
			Pattern pattern32 = new Pattern(new OpeningBrace(), new ExpressionVariable("e.1"), new ClosingBrace(), new SymbolVariable("s.A"), new ExpressionVariable("e.2"));
			if (pattern32.Match(expression))
			{
				expression = PassiveExpression.Build(_Type(PassiveExpression.Build(pattern32.GetVariable("s.A"))));
				{
					Pattern pattern33 = new Pattern("L".ToCharArray(), new ExpressionVariable("e.3"));
					pattern33.CopyBoundVariables(pattern32);
					if (pattern33.Match(expression))
					{
						return PassiveExpression.Build(_Id__tail(PassiveExpression.Build(new OpeningBrace(), pattern33.GetVariable("e.1"), pattern33.GetVariable("s.A"), new ClosingBrace(), pattern33.GetVariable("e.2"))));
					};

					Pattern pattern34 = new Pattern("D".ToCharArray(), new ExpressionVariable("e.3"));
					pattern34.CopyBoundVariables(pattern32);
					if (pattern34.Match(expression))
					{
						return PassiveExpression.Build(_Id__tail(PassiveExpression.Build(new OpeningBrace(), pattern34.GetVariable("e.1"), pattern34.GetVariable("s.A"), new ClosingBrace(), pattern34.GetVariable("e.2"))));
					};

					Pattern pattern35 = new Pattern(new SymbolVariable("s.T"), new ExpressionVariable("e.3"));
					pattern35.CopyBoundVariables(pattern32);
					if (pattern35.Match(expression))
					{
						return PassiveExpression.Build(new OpeningBrace(), pattern35.GetVariable("e.1"), new ClosingBrace(), pattern35.GetVariable("s.A"), pattern35.GetVariable("e.2"));
					};

					throw new RecognitionImpossibleException("Recognition impossible. Last expression: " + expression.ToString());
				}
			};

			Pattern pattern37 = new Pattern(new OpeningBrace(), new ExpressionVariable("e.1"), new ClosingBrace());
			if (pattern37.Match(expression))
			{
				return PassiveExpression.Build(new OpeningBrace(), pattern37.GetVariable("e.1"), new ClosingBrace());
			};

			throw new RecognitionImpossibleException("Recognition impossible. Last expression: " + expression.ToString());
		}
Esempio n. 36
0
		public PassiveExpression Br(PassiveExpression expression)
		{
			// <Br e.N '=' e.Expr>, where e.N is expression which does not
			// include '=' on the upper level of the bracket's structure
			Pattern pattern = new Pattern(new ExpressionVariable("Key"), '=', new ExpressionVariable("Value"));
			if (pattern.Match(expression))
			{
				var key = (PassiveExpression)pattern.GetVariable("Key");
				var value = (PassiveExpression)pattern.GetVariable("Value");
				var strKey = key.ToString();

				BuriedKeys[strKey] = key;
				BuriedValues[strKey] = value;

				return PassiveExpression.Build();
			}

			throw new RecognitionImpossibleException("<Br e.N '=' e.Expr>: unexpected arguments");
		}
Esempio n. 37
0
		// extract arguments specified as <Function t.1 e.2>
		void GetArguments(PassiveExpression expression, out object arg1, out object arg2)
		{
			var p = new Pattern(new TermVariable("t.1"), new ExpressionVariable("e.2"));
			if (p.Match(expression))
			{
				arg1 = p.GetVariable("t.1");
				arg2 = p.GetVariable("e.2");
				return;
			}

			// can't find match
			throw new RecognitionImpossibleException();
		}
		public void SymbolVariable_DontMatchSymbolChain()
		{
			var pattern = new Pattern(new SymbolVariable("s.1")); // s.1
			var expr = PassiveExpression.Build(123, 321); // 123 321

			var result = pattern.Match(expr);
			Assert.IsFalse(result);
		}
		public void SymbolVariable_DontMatchBraces()
		{
			var pattern = new Pattern(new SymbolVariable("s.1")); // s.1
			var expr = PassiveExpression.Build(new OpeningBrace()); // (

			var result = pattern.Match(expr);
			Assert.IsFalse(result);
		}
		public void TermVariable_MatchesNonEmptyExpressionInBraces()
		{
			var pattern = new Pattern(new TermVariable("t.1")); // t.1
			var expr = PassiveExpression.Build(new OpeningBrace(), "Hello", new ClosingBrace()); // ()

			var result = pattern.Match(expr);
			Assert.IsTrue(result);
			Assert.IsTrue(pattern.Variables.ContainsKey("t.1"));
			Assert.AreEqual(PassiveExpression.Build(new OpeningBrace(), "Hello", new ClosingBrace()), pattern.Variables["t.1"].Value);
		}
		public void ExpressionVariable_MatchesEmptyExpression()
		{
			var pattern = new Pattern(new ExpressionVariable("e.1")); // e.1
			var expr = PassiveExpression.Build(); // 

			var result = pattern.Match(expr);
			Assert.IsTrue(result);
			Assert.IsTrue(pattern.Variables.ContainsKey("e.1"));
		}
		public void ExpressionVariableInBraces_DontMatchEmptyExpression()
		{
			var pattern = new Pattern(new OpeningBrace(), new ExpressionVariable("e.1"), new ClosingBrace()); // (e.1)
			var expr = PassiveExpression.Build(); //

			var result = pattern.Match(expr);
			Assert.IsFalse(result);
		}
		public void ExpressionVariableInBraces_MatchesNonEmptyBraces()
		{
			var pattern = new Pattern(new OpeningBrace(), new ExpressionVariable("e.1"), new ClosingBrace()); // (e.1)
			var expr = PassiveExpression.Build(new OpeningBrace(), 123, new ClosingBrace()); // (123)

			var result = pattern.Match(expr);
			Assert.IsTrue(result);
			Assert.IsTrue(pattern.Variables.ContainsKey("e.1"));
			Assert.AreEqual(PassiveExpression.Build(123), pattern.Variables["e.1"].Value);
		}
		public void ComplexPattern_MatchesExpression2()
		{
			var pattern = new Pattern(new OpeningBrace(), new ExpressionVariable("e.1"), new SymbolVariable("s.3"),
				new ClosingBrace(), new OpeningBrace(), new ExpressionVariable("e.2"), '0', new ClosingBrace()); // (e.1 s.3) (e.2 '0')
			var expr = PassiveExpression.Build(new OpeningBrace(), '0', '1', new ClosingBrace(),
				new OpeningBrace(), '0', new ClosingBrace()); // ('01') ('0')

			var result = pattern.Match(expr);
			Assert.IsTrue(result);
			Assert.IsTrue(pattern.Variables.ContainsKey("e.1"));
			Assert.IsTrue(pattern.Variables.ContainsKey("e.2"));
			Assert.IsTrue(pattern.Variables.ContainsKey("s.3"));
			Assert.AreEqual(PassiveExpression.Build('0'), pattern.Variables["e.1"].Value);
			Assert.AreEqual(PassiveExpression.Build(), pattern.Variables["e.2"].Value);
			Assert.AreEqual('1', pattern.Variables["s.3"].Value);
		}