Exemplo n.º 1
0
Arquivo: State.cs Projeto: vf1/bnf2dfa
        public static State MarkRange(State begin1, string name, int lookup, int beginOffset)
        {
            //State begin2;

            if (lookup == 0)
            {
                //begin2 = new State(Epsilon, begin1);
                ////begin2.IsBeginRange = true;
                ////begin2.RangeName = name;
                //begin2.Mark = Marks.BeginRange;
                //begin2.Name = name;
                //begin2.Offset = beginOffset;

                begin1.AddMark(new MarkImpl(Marks.BeginRange, name)
                {
                    Offset = beginOffset,
                });
            }
            else if (lookup == 1)
            {
                //begin2 = begin1;
                //begin2.MarkNext(name, Marks.BeginRange, beginOffset);
                begin1.MarkNext(name, Marks.BeginRange, beginOffset);
            }
            else
            {
                throw new ArgumentOutOfRangeException("lookup", "Must be 0 or 1, other value is not supported.");
            }



            begin1.FindEnd().AddMark(new MarkImpl(Marks.EndRange, name));

            return(begin1);

            //var end2 = new State();
            ////end2.IsEndRange = true;
            ////end2.RangeName = name;
            //end2.Mark = Marks.EndRange;
            //end2.Name = name;

            //var end1 = begin1.FindEnd();
            //end1.Transition.Add(Epsilon, end2);

            //return begin2;
        }
Exemplo n.º 2
0
Arquivo: State.cs Projeto: vf1/bnf2dfa
        public static State MarkBeginCount(State begin1, string name, int max)
        {
            begin1.AddMark(new MarkImpl()
            {
                Mark = Marks.Count,
                Name = name,
                Max  = max,
            });

            return(begin1);

            //return new State(Epsilon, begin1)
            //{
            //    Mark = Marks.Count,
            //    Name = name,
            //    Max = max,
            //};
        }
Exemplo n.º 3
0
Arquivo: State.cs Projeto: vf1/bnf2dfa
        public static State MarkCustom(State begin1, string name, string select, string custom, string type)
        {
            switch (select)
            {
            case "Begin":

                begin1.AddMark(new MarkImpl(Marks.Custom, name)
                {
                    Value = custom, Type = type,
                });

                return(begin1);

            //return new State(Epsilon, begin1)
            //{
            //    Mark = Marks.Custom,
            //    Name = name,
            //    Value = custom,
            //    Type = type,
            //};

            case "End":

                begin1.FindEnd().AddMark(new MarkImpl(Marks.Custom, name)
                {
                    Value = custom, Type = type,
                });

                //var end2 = new State()
                //{
                //    Mark = Marks.Custom,
                //    Name = name,
                //    Value = custom,
                //    Type = type,
                //};

                //begin1.FindEnd().Transition.Add(Epsilon, end2);

                return(begin1);
            }

            throw new Exception("Not implemented");
        }
Exemplo n.º 4
0
Arquivo: State.cs Projeto: vf1/bnf2dfa
        public static State MarkEndRange(State begin1, Marks mark, string name, bool atBegin, int offset)
        {
            if (atBegin)
            {
                begin1.AddMark(new MarkImpl()
                {
                    Mark   = mark,
                    Name   = name,
                    Offset = offset,
                });

                return(begin1);

                //return new State(Epsilon, begin1)
                //{
                //    Mark = mark,
                //    Name = name,
                //    Offset = offset,
                //};
            }
            else
            {
                begin1.FindEnd().AddMark(new MarkImpl(mark, name)
                {
                    Offset = offset,
                });

                //var end2 = new State()
                //{
                //    Mark = mark,
                //    Name = name,
                //    Offset = offset,
                //};

                //begin1.FindEnd().Transition.Add(Epsilon, end2);

                return(begin1);
            }
        }
Exemplo n.º 5
0
		public static State MarkBeginCount(State begin1, string name, int max)
		{
			begin1.AddMark(new MarkImpl()
				{
					Mark = Marks.Count,
					Name = name,
					Max = max,
				});

			return begin1;

			//return new State(Epsilon, begin1)
			//{
			//    Mark = Marks.Count,
			//    Name = name,
			//    Max = max,
			//};
		}
Exemplo n.º 6
0
		public static State MarkEndRange(State begin1, Marks mark, string name, bool atBegin, int offset)
		{
			if (atBegin)
			{
				begin1.AddMark(new MarkImpl()
					{
						Mark = mark,
						Name = name,
						Offset = offset,
					});

				return begin1;

				//return new State(Epsilon, begin1)
				//{
				//    Mark = mark,
				//    Name = name,
				//    Offset = offset,
				//};
			}
			else
			{
				begin1.FindEnd().AddMark(new MarkImpl(mark, name) { Offset = offset, });

				//var end2 = new State()
				//{
				//    Mark = mark,
				//    Name = name,
				//    Offset = offset,
				//};

				//begin1.FindEnd().Transition.Add(Epsilon, end2);

				return begin1;
			}
		}
Exemplo n.º 7
0
		public static State MarkRange(State begin1, string name, int lookup, int beginOffset)
		{
			//State begin2;

			if (lookup == 0)
			{
				//begin2 = new State(Epsilon, begin1);
				////begin2.IsBeginRange = true;
				////begin2.RangeName = name;
				//begin2.Mark = Marks.BeginRange;
				//begin2.Name = name;
				//begin2.Offset = beginOffset;

				begin1.AddMark(new MarkImpl(Marks.BeginRange, name) { Offset = beginOffset, });
			}
			else if (lookup == 1)
			{
				//begin2 = begin1;
				//begin2.MarkNext(name, Marks.BeginRange, beginOffset);
				begin1.MarkNext(name, Marks.BeginRange, beginOffset);
			}
			else
				throw new ArgumentOutOfRangeException("lookup", "Must be 0 or 1, other value is not supported.");



			begin1.FindEnd().AddMark(new MarkImpl(Marks.EndRange, name));

			return begin1;

			//var end2 = new State();
			////end2.IsEndRange = true;
			////end2.RangeName = name;
			//end2.Mark = Marks.EndRange;
			//end2.Name = name;

			//var end1 = begin1.FindEnd();
			//end1.Transition.Add(Epsilon, end2);

			//return begin2;
		}
Exemplo n.º 8
0
		public static State MarkCustom(State begin1, string name, string select, string custom, string type)
		{
			switch (select)
			{
				case "Begin":

					begin1.AddMark(new MarkImpl(Marks.Custom, name) { Value = custom, Type = type, });

					return begin1;

				//return new State(Epsilon, begin1)
				//{
				//    Mark = Marks.Custom,
				//    Name = name,
				//    Value = custom,
				//    Type = type,
				//};

				case "End":

					begin1.FindEnd().AddMark(new MarkImpl(Marks.Custom, name) { Value = custom, Type = type, });

					//var end2 = new State()
					//{
					//    Mark = Marks.Custom,
					//    Name = name,
					//    Value = custom,
					//    Type = type,
					//};

					//begin1.FindEnd().Transition.Add(Epsilon, end2);

					return begin1;
			}

			throw new Exception("Not implemented");
		}