Exemplo n.º 1
0
        private static PassiveExpression _PreAlph(PassiveExpression expression)
        {
            Pattern pattern5 = new Pattern(new SymbolVariable("s.1"), new SymbolVariable("s.1"));

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

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

            if (pattern6.Match(expression))
            {
                expression = PassiveExpression.Build(_Alphabet(PassiveExpression.Build()));
                Pattern pattern7 = new Pattern(new ExpressionVariable("e.A"), new SymbolVariable("s.1"), new ExpressionVariable("e.B"), new SymbolVariable("s.2"), new ExpressionVariable("e.C"));
                pattern7.CopyBoundVariables(pattern6);
                if (pattern7.Match(expression))
                {
                    return(PassiveExpression.Build(true));
                }
            }
            ;

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

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

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

            if (pattern2.Match(expression))
            {
                expression = PassiveExpression.Build(_PreAlph(PassiveExpression.Build(pattern2.GetVariable("s.1"), pattern2.GetVariable("s.2"))));
                {
                    Pattern pattern3 = new Pattern(true);
                    pattern3.CopyBoundVariables(pattern2);
                    if (pattern3.Match(expression))
                    {
                        return(PassiveExpression.Build(pattern3.GetVariable("s.1"), pattern3.GetVariable("s.2")));
                    }
                    ;

                    Pattern pattern4 = new Pattern(false);
                    pattern4.CopyBoundVariables(pattern2);
                    if (pattern4.Match(expression))
                    {
                        return(PassiveExpression.Build(pattern4.GetVariable("s.2"), pattern4.GetVariable("s.1")));
                    }
                    ;

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

            throw new RecognitionImpossibleException("Recognition impossible. Last expression: " + expression.ToString());
        }
Exemplo n.º 3
0
        private static PassiveExpression _Read__in(PassiveExpression expression)
        {
            Pattern pattern8 = new Pattern();

            if (RefalBase.Match(expression, pattern8))
            {
                return(PassiveExpression.Build());
            }
            ;

            Pattern pattern9 = new Pattern(0);

            if (RefalBase.Match(expression, pattern9))
            {
                return(PassiveExpression.Build());
            }
            ;

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

            if (RefalBase.Match(expression, pattern10))
            {
                return(PassiveExpression.Build(" ".ToCharArray(), pattern10.GetVariable("e.1"), _Read__in(PassiveExpression.Build(_Card(PassiveExpression.Build())))));
            }
            ;

            throw new RecognitionImpossibleException("Recognition impossible. Last expression: " + ExpressionToString(expression, 0));
        }
Exemplo n.º 4
0
        private static PassiveExpression _Output(PassiveExpression expression)
        {
            Pattern pattern2 = new Pattern();

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

            Pattern pattern3 = new Pattern(0);

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

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

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

            throw new RecognitionImpossibleException("Recognition impossible. Last expression: " + expression.ToString());
        }
Exemplo n.º 5
0
        private static PassiveExpression _Check__end(PassiveExpression expression)
        {
            Pattern pattern3 = new Pattern();

            if (RefalBase.Match(expression, pattern3))
            {
                return(PassiveExpression.Build(_Prout(PassiveExpression.Build("End of session".ToCharArray()))));
            }
            ;

            Pattern pattern4 = new Pattern("*".ToCharArray(), "Error");

            if (RefalBase.Match(expression, pattern4))
            {
                return(PassiveExpression.Build(_Job(PassiveExpression.Build())));
            }
            ;

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

            if (RefalBase.Match(expression, pattern5))
            {
                return(PassiveExpression.Build(_Out(PassiveExpression.Build(_UpD(PassiveExpression.Build(pattern5.GetVariable("e.X")))))));
            }
            ;

            throw new RecognitionImpossibleException("Recognition impossible. Last expression: " + ExpressionToString(expression, 0));
        }
Exemplo n.º 6
0
        private static PassiveExpression _Next(PassiveExpression expression)
        {
            Pattern pattern2 = new Pattern();

            if (pattern2.Match(expression))
            {
                expression = PassiveExpression.Build(_Get(PassiveExpression.Build(1)));
                {
                    Pattern pattern3 = new Pattern("*".ToCharArray(), new ExpressionVariable("e.1"));
                    pattern3.CopyBoundVariables(pattern2);
                    if (pattern3.Match(expression))
                    {
                        return(PassiveExpression.Build(_Putz(PassiveExpression.Build(2, "*".ToCharArray(), pattern3.GetVariable("e.1"))), _Next(PassiveExpression.Build())));
                    }
                    ;

                    Pattern pattern4 = new Pattern(new ExpressionVariable("e.1"));
                    pattern4.CopyBoundVariables(pattern2);
                    if (pattern4.Match(expression))
                    {
                        return(PassiveExpression.Build(pattern4.GetVariable("e.1")));
                    }
                    ;

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

            throw new RecognitionImpossibleException("Recognition impossible. Last expression: " + expression.ToString());
        }
Exemplo n.º 7
0
        private static PassiveExpression Chpm(PassiveExpression expression)
        {
            Pattern pattern2 = new Pattern("+".ToCharArray(), new ExpressionVariable("e.1"));

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

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

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

            Pattern pattern4 = new Pattern();

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

            throw new RecognitionImpossibleException("Recognition impossible");
        }
Exemplo n.º 8
0
        private static PassiveExpression _Transla(PassiveExpression expression)
        {
            Pattern pattern48 = new Pattern(new OpeningBrace(), new ExpressionVariable("e.ML"), new OpeningBrace(), new ExpressionVariable("e.1"), new ClosingBrace(), new ClosingBrace(), new OpeningBrace(), "(".ToCharArray(), new ExpressionVariable("e.2"), new ClosingBrace());

            if (pattern48.Match(expression))
            {
                return(PassiveExpression.Build(_Transla(PassiveExpression.Build(new OpeningBrace(), pattern48.GetVariable("e.ML"), new OpeningBrace(), pattern48.GetVariable("e.1"), new ClosingBrace(), new OpeningBrace(), new ClosingBrace(), new ClosingBrace(), new OpeningBrace(), pattern48.GetVariable("e.2"), new ClosingBrace()))));
            }
            ;

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

            if (pattern49.Match(expression))
            {
                return(PassiveExpression.Build(_Transla(PassiveExpression.Build(new OpeningBrace(), pattern49.GetVariable("e.ML"), new OpeningBrace(), pattern49.GetVariable("e.1"), "(".ToCharArray(), pattern49.GetVariable("e.2"), ")".ToCharArray(), new ClosingBrace(), new ClosingBrace(), new OpeningBrace(), pattern49.GetVariable("e.3"), new ClosingBrace()))));
            }
            ;

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

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

            Pattern pattern51 = new Pattern(new OpeningBrace(), new OpeningBrace(), new ExpressionVariable("e.1"), new ClosingBrace(), new ClosingBrace(), new OpeningBrace(), ".]".ToCharArray(), new ClosingBrace());

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

            Pattern pattern52 = new Pattern(new OpeningBrace(), new OpeningBrace(), new ExpressionVariable("e.1"), new ClosingBrace(), new ClosingBrace(), new OpeningBrace(), "]".ToCharArray(), new ClosingBrace());

            if (pattern52.Match(expression))
            {
                return(PassiveExpression.Build(pattern52.GetVariable("e.1"), ")e.MR".ToCharArray()));
            }
            ;

            Pattern pattern53 = new Pattern(new OpeningBrace(), new ExpressionVariable("e.ML"), new OpeningBrace(), new ExpressionVariable("e.1"), new ClosingBrace(), new ClosingBrace(), new OpeningBrace(), "]".ToCharArray(), new ClosingBrace());

            if (pattern53.Match(expression))
            {
                return(PassiveExpression.Build(_Ermes(PassiveExpression.Build("ERROR: Unbalanced left parenth. after pointer".ToCharArray()))));
            }
            ;

            Pattern pattern54 = new Pattern(new OpeningBrace(), new ExpressionVariable("e.ML"), new OpeningBrace(), new ExpressionVariable("e.1"), new ClosingBrace(), new ClosingBrace(), new OpeningBrace(), new TermVariable("t.A"), new ExpressionVariable("e.2"), new ClosingBrace());

            if (pattern54.Match(expression))
            {
                return(PassiveExpression.Build(_Transla(PassiveExpression.Build(new OpeningBrace(), pattern54.GetVariable("e.ML"), new OpeningBrace(), pattern54.GetVariable("e.1"), pattern54.GetVariable("t.A"), new ClosingBrace(), new ClosingBrace(), new OpeningBrace(), pattern54.GetVariable("e.2"), new ClosingBrace()))));
            }
            ;

            throw new RecognitionImpossibleException("Recognition impossible. Last expression: " + expression.ToString());
        }
Exemplo n.º 9
0
        private static PassiveExpression _Output(PassiveExpression expression)
        {
            Pattern pattern2 = new Pattern(new OpeningBrace(), new ClosingBrace(), new OpeningBrace(), new SymbolVariable("s.D"), new ClosingBrace());

            if (pattern2.Match(expression))
            {
                return(PassiveExpression.Build(_Output(PassiveExpression.Build(new OpeningBrace(), _Get(PassiveExpression.Build(pattern2.GetVariable("s.D"))), new ClosingBrace(), new OpeningBrace(), pattern2.GetVariable("s.D"), new ClosingBrace()))));
            }
            ;

            Pattern pattern3 = new Pattern(new OpeningBrace(), 0, new ClosingBrace(), new OpeningBrace(), new SymbolVariable("s.D"), new ClosingBrace());

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

            Pattern pattern4 = new Pattern(new OpeningBrace(), new ExpressionVariable("e.1"), new ClosingBrace(), new OpeningBrace(), new SymbolVariable("s.D"), new ClosingBrace());

            if (pattern4.Match(expression))
            {
                return(PassiveExpression.Build(_Prout(PassiveExpression.Build(pattern4.GetVariable("e.1"))), _Output(PassiveExpression.Build(new OpeningBrace(), _Get(PassiveExpression.Build(pattern4.GetVariable("s.D"))), new ClosingBrace(), new OpeningBrace(), pattern4.GetVariable("s.D"), new ClosingBrace()))));
            }
            ;

            throw new RecognitionImpossibleException("Recognition impossible. Last expression: " + expression.ToString());
        }
Exemplo n.º 10
0
        public static PassiveExpression Get(PassiveExpression expression)
        {
            if (expression == null || expression.IsEmpty)
            {
                return(Card(expression));
            }

            string       handle = expression[0].ToString();
            StreamReader sr     = openFiles[handle] as StreamReader;

            if (sr == null)
            {
                return(Card(expression));
            }

            string s = sr.ReadLine();

            if (s != null)
            {
                return(PassiveExpression.Build(s.ToCharArray()));
            }
            else
            {
                return(PassiveExpression.Build(0));
            }
        }
Exemplo n.º 11
0
        private static PassiveExpression PreAlph(PassiveExpression expression)
        {
            Pattern pattern2 = new Pattern(new SymbolVariable("s.1"), new SymbolVariable("s.1"));

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

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

            if (RefalBase.Match(expression, pattern3))
            {
                PassiveExpression expression4 = PassiveExpression.Build(Alphabet(PassiveExpression.Build()));
                Pattern           pattern4    = new Pattern(new ExpressionVariable("e.A"), new SymbolVariable("s.1"), new ExpressionVariable("e.B"), new SymbolVariable("s.2"), new ExpressionVariable("e.C"));
                pattern4.BindVariables(pattern3);
                if (RefalBase.Match(expression4, pattern4))
                {
                    return(PassiveExpression.Build(true));
                }
                ;
            }
            ;

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

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

            throw new RecognitionImpossibleException("Recognition impossible");
        }
Exemplo n.º 12
0
        private static PassiveExpression _Prout__lm(PassiveExpression expression)
        {
            Pattern pattern45 = new Pattern(new OpeningBrace(), new ExpressionVariable("e.1"), "*".ToCharArray(), new ClosingBrace(), new ExpressionVariable("e.2"));

            if (RefalBase.Match(expression, pattern45))
            {
                return(PassiveExpression.Build(_Prout__lm(PassiveExpression.Build(pattern45.GetVariable("e.1"))), _Prout(PassiveExpression.Build("*** *(".ToCharArray(), pattern45.GetVariable("e.2")))));
            }
            ;

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

            if (RefalBase.Match(expression, pattern46))
            {
                return(PassiveExpression.Build(_Prout__lm(PassiveExpression.Build(pattern46.GetVariable("e.1"))), _Prout(PassiveExpression.Build("*** (".ToCharArray(), pattern46.GetVariable("e.2")))));
            }
            ;

            Pattern pattern47 = new Pattern("$".ToCharArray(), new ExpressionVariable("e.1"));

            if (RefalBase.Match(expression, pattern47))
            {
                return(PassiveExpression.Build(_Prout(PassiveExpression.Build("*** ".ToCharArray(), pattern47.GetVariable("e.1")))));
            }
            ;

            throw new RecognitionImpossibleException("Recognition impossible. Last expression: " + ExpressionToString(expression, 0));
        }
Exemplo n.º 13
0
		private static PassiveExpression _Code__op(PassiveExpression expression)
		{
			Pattern pattern72 = new Pattern("+".ToCharArray());
			if (pattern72.Match(expression))
			{
				return PassiveExpression.Build("ADD ".ToCharArray());
			};

			Pattern pattern73 = new Pattern("-".ToCharArray());
			if (pattern73.Match(expression))
			{
				return PassiveExpression.Build("SUB ".ToCharArray());
			};

			Pattern pattern74 = new Pattern("*".ToCharArray());
			if (pattern74.Match(expression))
			{
				return PassiveExpression.Build("MUL ".ToCharArray());
			};

			Pattern pattern75 = new Pattern("/".ToCharArray());
			if (pattern75.Match(expression))
			{
				return PassiveExpression.Build("DIV ".ToCharArray());
			};

			Pattern pattern76 = new Pattern("^".ToCharArray());
			if (pattern76.Match(expression))
			{
				return PassiveExpression.Build("POW ".ToCharArray());
			};

			throw new RecognitionImpossibleException("Recognition impossible. Last expression: " + expression.ToString());
		}
Exemplo n.º 14
0
        private static PassiveExpression _Parse1(PassiveExpression expression)
        {
            Pattern pattern91 = new Pattern(new OpeningBrace(), new ExpressionVariable("e.1"), new ClosingBrace(), new OpeningBrace(), "L".ToCharArray(), new ExpressionVariable("e.A1"), new ClosingBrace(), new SymbolVariable("s.A"), new ExpressionVariable("e.2"));

            if (RefalBase.Match(expression, pattern91))
            {
                return(PassiveExpression.Build(_Word(PassiveExpression.Build(new OpeningBrace(), pattern91.GetVariable("e.1"), new ClosingBrace(), new OpeningBrace(), pattern91.GetVariable("s.A"), new ClosingBrace(), pattern91.GetVariable("e.2")))));
            }
            ;

            Pattern pattern92 = new Pattern(new OpeningBrace(), new ExpressionVariable("e.1"), new ClosingBrace(), new OpeningBrace(), "D".ToCharArray(), new ExpressionVariable("e.A1"), new ClosingBrace(), new SymbolVariable("s.A"), new ExpressionVariable("e.2"));

            if (RefalBase.Match(expression, pattern92))
            {
                return(PassiveExpression.Build(_Number(PassiveExpression.Build(new OpeningBrace(), pattern92.GetVariable("e.1"), new ClosingBrace(), new OpeningBrace(), pattern92.GetVariable("s.A"), new ClosingBrace(), pattern92.GetVariable("e.2")))));
            }
            ;

            Pattern pattern93 = new Pattern(new OpeningBrace(), new ExpressionVariable("e.1"), new ClosingBrace(), new OpeningBrace(), new SymbolVariable("s.T"), new ExpressionVariable("e.A1"), new ClosingBrace(), new SymbolVariable("s.A"), new ExpressionVariable("e.2"));

            if (RefalBase.Match(expression, pattern93))
            {
                return(PassiveExpression.Build(_Parse(PassiveExpression.Build(new OpeningBrace(), pattern93.GetVariable("e.1"), pattern93.GetVariable("s.A"), new ClosingBrace(), pattern93.GetVariable("e.2")))));
            }
            ;

            throw new RecognitionImpossibleException("Recognition impossible. Last expression: " + ExpressionToString(expression, 0));
        }
Exemplo n.º 15
0
		private static PassiveExpression _Outform(PassiveExpression expression)
		{
			Pattern pattern68 = new Pattern(new SymbolVariable("s.S"));
			if (pattern68.Match(expression))
			{
				expression = PassiveExpression.Build(_Type(PassiveExpression.Build(pattern68.GetVariable("s.S"))));
				{
					Pattern pattern69 = new Pattern("Wi".ToCharArray(), new ExpressionVariable("e.S1"));
					pattern69.CopyBoundVariables(pattern68);
					if (pattern69.Match(expression))
					{
						return PassiveExpression.Build(_Explode(PassiveExpression.Build(pattern69.GetVariable("s.S"))));
					};

					Pattern pattern70 = new Pattern("N".ToCharArray(), new ExpressionVariable("e.S1"));
					pattern70.CopyBoundVariables(pattern68);
					if (pattern70.Match(expression))
					{
						return PassiveExpression.Build(_Symb(PassiveExpression.Build(pattern70.GetVariable("s.S"))));
					};

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

			throw new RecognitionImpossibleException("Recognition impossible. Last expression: " + expression.ToString());
		}
Exemplo n.º 16
0
        private static PassiveExpression _Number(PassiveExpression expression)
        {
            Pattern pattern102 = new Pattern(new OpeningBrace(), new ExpressionVariable("e.1"), new ClosingBrace(), new OpeningBrace(), new ExpressionVariable("e.N"), new ClosingBrace(), new SymbolVariable("s.X"), new ExpressionVariable("e.2"));

            if (RefalBase.Match(expression, pattern102))
            {
                expression = PassiveExpression.Build(_Type(PassiveExpression.Build(pattern102.GetVariable("s.X"))));
                Pattern pattern103 = new Pattern("D".ToCharArray(), new ExpressionVariable("e.X1"));
                pattern103.CopyBoundVariables(pattern102);
                if (RefalBase.Match(expression, pattern103))
                {
                    return(PassiveExpression.Build(_Number(PassiveExpression.Build(new OpeningBrace(), pattern103.GetVariable("e.1"), new ClosingBrace(), new OpeningBrace(), pattern103.GetVariable("e.N"), pattern103.GetVariable("s.X"), new ClosingBrace(), pattern103.GetVariable("e.2")))));
                }
            }
            ;

            Pattern pattern104 = new Pattern(new OpeningBrace(), new ExpressionVariable("e.1"), new ClosingBrace(), new OpeningBrace(), new ExpressionVariable("e.N"), new ClosingBrace(), new ExpressionVariable("e.X"));

            if (RefalBase.Match(expression, pattern104))
            {
                return(PassiveExpression.Build(_Parse(PassiveExpression.Build(new OpeningBrace(), pattern104.GetVariable("e.1"), _Numb(PassiveExpression.Build(pattern104.GetVariable("e.N"))), new ClosingBrace(), pattern104.GetVariable("e.X")))));
            }
            ;

            throw new RecognitionImpossibleException("Recognition impossible. Last expression: " + ExpressionToString(expression, 0));
        }
Exemplo n.º 17
0
		private static PassiveExpression _Quotes(PassiveExpression expression)
		{
			Pattern pattern28 = new Pattern(new SymbolVariable("s.Q"), new OpeningBrace(), new ExpressionVariable("e.1"), new ClosingBrace(), new ExpressionVariable("e.0"), "\\\\".ToCharArray(), "\\\\".ToCharArray(), new ExpressionVariable("e.2"));
			if (pattern28.Match(expression))
			{
				return PassiveExpression.Build(_Quotes(PassiveExpression.Build(pattern28.GetVariable("s.Q"), new OpeningBrace(), pattern28.GetVariable("e.1"), pattern28.GetVariable("e.0"), "\\\\".ToCharArray(), "\\\\".ToCharArray(), new ClosingBrace(), pattern28.GetVariable("e.2"))));
			};

			Pattern pattern29 = new Pattern(new SymbolVariable("s.Q"), new OpeningBrace(), new ExpressionVariable("e.1"), new ClosingBrace(), new ExpressionVariable("e.0"), "\\\\".ToCharArray(), new SymbolVariable("s.Q"), new ExpressionVariable("e.2"));
			if (pattern29.Match(expression))
			{
				return PassiveExpression.Build(_Quotes(PassiveExpression.Build(pattern29.GetVariable("s.Q"), new OpeningBrace(), pattern29.GetVariable("e.1"), pattern29.GetVariable("e.0"), "\\\\".ToCharArray(), pattern29.GetVariable("s.Q"), new ClosingBrace(), pattern29.GetVariable("e.2"))));
			};

			Pattern pattern30 = new Pattern(new SymbolVariable("s.Q"), new OpeningBrace(), new ExpressionVariable("e.1"), new ClosingBrace(), new ExpressionVariable("e.0"), new SymbolVariable("s.Q"), new ExpressionVariable("e.2"));
			if (pattern30.Match(expression))
			{
				return PassiveExpression.Build(new OpeningBrace(), pattern30.GetVariable("e.1"), pattern30.GetVariable("e.0"), new ClosingBrace(), pattern30.GetVariable("e.2"));
			};

			Pattern pattern31 = new Pattern(new SymbolVariable("s.Q"), new OpeningBrace(), new ExpressionVariable("e.1"), new ClosingBrace(), new ExpressionVariable("e.2"));
			if (pattern31.Match(expression))
			{
				return PassiveExpression.Build(new OpeningBrace(), new ClosingBrace(), pattern31.GetVariable("e.1"), pattern31.GetVariable("e.2"));
			};

			throw new RecognitionImpossibleException("Recognition impossible. Last expression: " + expression.ToString());
		}
Exemplo n.º 18
0
        private static PassiveExpression RAdd(PassiveExpression expression)
        {
            Pattern pattern2 = new Pattern(new Pattern(new ExpressionVariable("e.1")), new Pattern("0".ToCharArray()));

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

            Pattern pattern3 = new Pattern(new Pattern(new ExpressionVariable("e.1")), new Pattern(new ExpressionVariable("e.2"), "\'".ToCharArray()));

            if (RefalBase.Match(expression, pattern3))
            {
                return(PassiveExpression.Build(RAdd(PassiveExpression.Build(PassiveExpression.CreateSubexpression(pattern3.GetVariable("e.1")), PassiveExpression.CreateSubexpression(pattern3.GetVariable("e.2")))), "\'".ToCharArray()));
            }
            ;

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

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

            throw new RecognitionImpossibleException("Recognition impossible");
        }
Exemplo n.º 19
0
        private static PassiveExpression _RAdd(PassiveExpression expression)
        {
            Pattern pattern2 = new Pattern(new OpeningBrace(), new ExpressionVariable("e.1"), new ClosingBrace(), new OpeningBrace(), "0".ToCharArray(), 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 ExpressionVariable("e.2"), "\'".ToCharArray(), new ClosingBrace());

            if (pattern3.Match(expression))
            {
                return(PassiveExpression.Build(_RAdd(PassiveExpression.Build(new OpeningBrace(), pattern3.GetVariable("e.1"), new ClosingBrace(), new OpeningBrace(), pattern3.GetVariable("e.2"), new ClosingBrace())), "\'".ToCharArray()));
            }
            ;

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

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

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

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

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

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

            Pattern pattern4 = new Pattern();

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

            throw new RecognitionImpossibleException("Recognition impossible. Last expression: " + expression.ToString());
        }
Exemplo n.º 21
0
        public PassiveExpression Div(PassiveExpression expression)
        {
            BigInteger op1, op2;

            GetBigIntegerArguments(expression, out op1, out op2);

            return(PassiveExpression.Build(ConvertBigIntegerToRefalNumber(op1 / op2)));
        }
Exemplo n.º 22
0
        private static PassiveExpression _Checkf(PassiveExpression expression)
        {
            Pattern pattern38 = new Pattern("+".ToCharArray());

            if (RefalBase.Match(expression, pattern38))
            {
                return(PassiveExpression.Build("Add"));
            }
            ;

            Pattern pattern39 = new Pattern("-".ToCharArray());

            if (RefalBase.Match(expression, pattern39))
            {
                return(PassiveExpression.Build("Sub"));
            }
            ;

            Pattern pattern40 = new Pattern("*".ToCharArray());

            if (RefalBase.Match(expression, pattern40))
            {
                return(PassiveExpression.Build("Mul"));
            }
            ;

            Pattern pattern41 = new Pattern("/".ToCharArray());

            if (RefalBase.Match(expression, pattern41))
            {
                return(PassiveExpression.Build("Div"));
            }
            ;

            Pattern pattern42 = new Pattern(new SymbolVariable("s.F"));

            if (RefalBase.Match(expression, pattern42))
            {
                expression = PassiveExpression.Build(_Type(PassiveExpression.Build(pattern42.GetVariable("s.F"))));
                Pattern pattern43 = new Pattern("Wi".ToCharArray(), new ExpressionVariable("e.F1"));
                pattern43.CopyBoundVariables(pattern42);
                if (RefalBase.Match(expression, pattern43))
                {
                    return(PassiveExpression.Build(pattern43.GetVariable("s.F")));
                }
            }
            ;

            Pattern pattern44 = new Pattern(new SymbolVariable("s.F"));

            if (RefalBase.Match(expression, pattern44))
            {
                return(PassiveExpression.Build());
            }
            ;

            throw new RecognitionImpossibleException("Recognition impossible. Last expression: " + ExpressionToString(expression, 0));
        }
Exemplo n.º 23
0
        public PassiveExpression Type(PassiveExpression expression)
        {
            if (expression == null || expression.IsEmpty)
            {
                return(PassiveExpression.Build('*', 0, expression));
            }

            object o = expression[0];

            if (o is OpeningBrace)
            {
                return(PassiveExpression.Build('B', 0, expression));
            }

            if (o is char)
            {
                char c       = (char)o;
                char subtype = Char.IsUpper(c) ? 'u' : 'l';

                if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'))
                {
                    return(PassiveExpression.Build('L', subtype, expression));
                }

                if (c >= '0' && c <= '9')
                {
                    return(PassiveExpression.Build('D', 0, expression));
                }

                if (Char.IsControl(c))
                {
                    return(PassiveExpression.Build('O', subtype, expression));
                }

                // printable
                return(PassiveExpression.Build('P', subtype, expression));
            }

            if (o is int || o is long)
            {
                return(PassiveExpression.Build('N', 0, expression));
            }

            if (o is string)
            {
                string s       = o as string;
                char   subtype = 'i';

                if (s.Length == 0 || !(Char.IsLetter(s[0])) || s.IndexOf(" ") >= 0)
                {
                    subtype = 'q';
                }

                return(PassiveExpression.Build('W', subtype, expression));
            }

            return(PassiveExpression.Build('P', 'l', expression));
        }
Exemplo n.º 24
0
        public PassiveExpression Numb(PassiveExpression expression)
        {
            if (expression == null || expression.IsEmpty)
            {
                return(PassiveExpression.Build());
            }

            return(PassiveExpression.Build(ConvertBigIntegerToRefalNumber(ToBigInteger(expression.ToString()))));
        }
Exemplo n.º 25
0
        public static PassiveExpression _Numb(PassiveExpression expression)
        {
            if (expression == null || expression.IsEmpty)
            {
                return(new PassiveExpression());
            }

            return(PassiveExpression.Build(Convert.ToInt32(expression.ToString())));
        }
Exemplo n.º 26
0
        protected override MatchResult MatchAny(PassiveExpression expression, ref int exIndex)
        {
            if (this.Expression == null)
            {
                // start with empty expression, don't advance exIndex
                this.Expression = PassiveExpression.Build();
                return(MatchResult.PartialSuccess);
            }
            else
            {
                if (expression == null || exIndex >= expression.Count)
                {
                    return(MatchResult.Failure);
                }

                // continue adding terms to expression
                object ex = expression[exIndex++];

                // add single symbol
                if (!(ex is StructureBrace))
                {
                    this.Expression.Add(ex);
                    return(MatchResult.PartialSuccess);
                }
                else if (ex is OpeningBrace)
                {
                    // add subexpression
                    this.Expression.Add(ex);

                    // extract subexpression within the structure braces
                    int rank = 1;
                    while (exIndex < expression.Count && rank > 0)
                    {
                        ex = expression[exIndex++];
                        this.Expression.Add(ex);

                        if (ex is OpeningBrace)
                        {
                            rank++;
                        }
                        else if (ex is ClosingBrace)
                        {
                            rank--;
                        }
                    }

                    // subexpression with surrounding braces is extracted
                    if (rank == 0)
                    {
                        return(MatchResult.PartialSuccess);
                    }
                }

                return(MatchResult.Failure);
            }
        }
Exemplo n.º 27
0
		private static PassiveExpression _Nil(PassiveExpression expression)
		{
			Pattern pattern5 = new Pattern(new ExpressionVariable("e.X"));
			if (pattern5.Match(expression))
			{
				return PassiveExpression.Build();
			};

			throw new RecognitionImpossibleException("Recognition impossible. Last expression: " + expression.ToString());
		}
Exemplo n.º 28
0
		private static PassiveExpression _Invitation(PassiveExpression expression)
		{
			Pattern pattern3 = new Pattern();
			if (pattern3.Match(expression))
			{
				return PassiveExpression.Build(_Prout(PassiveExpression.Build()), _Prout(PassiveExpression.Build()), _Prout(PassiveExpression.Build("Type in an expression (one line), or Ctrl-Z to terminate".ToCharArray())));
			};

			throw new RecognitionImpossibleException("Recognition impossible. Last expression: " + expression.ToString());
		}
Exemplo n.º 29
0
		private static PassiveExpression _Introduction(PassiveExpression expression)
		{
			Pattern pattern2 = new Pattern();
			if (pattern2.Match(expression))
			{
				return PassiveExpression.Build(_Prout(PassiveExpression.Build("This is a program to translate an arithmetic expression".ToCharArray())), _Prout(PassiveExpression.Build("into a code for a one-address computer. Primary operands".ToCharArray())), _Prout(PassiveExpression.Build("are identifiers and whole numbers. Operations are:".ToCharArray())), _Prout(PassiveExpression.Build("+, -, *, /, ^with usual priorities. Parentheses as usual.".ToCharArray())), _Prout(PassiveExpression.Build("Example: Joe^2*5/(SUM + 318)".ToCharArray())), _Prout(PassiveExpression.Build()));
			};

			throw new RecognitionImpossibleException("Recognition impossible. Last expression: " + expression.ToString());
		}
Exemplo n.º 30
0
		private static PassiveExpression _Loop(PassiveExpression expression)
		{
			Pattern pattern4 = new Pattern();
			if (pattern4.Match(expression))
			{
				return PassiveExpression.Build(_Nil(PassiveExpression.Build(_Dgall(PassiveExpression.Build()))), _Invitation(PassiveExpression.Build()), _Inout(PassiveExpression.Build(_Card(PassiveExpression.Build()))));
			};

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