Esempio n. 1
0
 public static IEnumerable <State> GetNfas(RulePath path, IEnumerable <IExpression> expressions)
 {
     foreach (var expression in expressions)
     {
         yield return(expression.GetNfa(path));
     }
 }
Esempio n. 2
0
        public State OnMarkRule(State start, RulePath path)
        {
            if (markAction != null)
                return markAction(start, path);

            return start;
        }
Esempio n. 3
0
 protected State OnMarkRule(State start, RulePath path)
 {
     if (markAction != null)
     {
         return(markAction(start, path));
     }
     return(start);
 }
Esempio n. 4
0
		public State GetNfa(RulePath path)
		{
			if (rules.ContainsKey(name) == false)
				throw new Exception(string.Format(@"@RuleLinkExpression: |{0}| rule not", name));

			var newPath = path + name;

			return OnMarkRule(rules[name].GetNfa(newPath), newPath);
		}
Esempio n. 5
0
		public State GetNfa(RulePath path)
		{
			switch (name)
			{
				case "RepeatBy":
					return State.NoCloneRepeatBy(arguments[0].GetNfa(path), arguments[1].GetNfa(path));
				default:
					throw new NotImplementedException(string.Format(@"@FuncCallExpression: |{0}| function is not defined", name));
			}
		}
Esempio n. 6
0
        public State GetNfa(RulePath path)
        {
            if (rules.ContainsKey(name) == false)
            {
                throw new Exception(string.Format(@"@RuleLinkExpression: |{0}| rule not", name));
            }

            var newPath = path + name;

            return(OnMarkRule(rules[name].GetNfa(newPath), newPath));
        }
Esempio n. 7
0
        public State GetNfa(RulePath path)
        {
            switch (name)
            {
            case "RepeatBy":
                return(State.NoCloneRepeatBy(arguments[0].GetNfa(path), arguments[1].GetNfa(path)));

            default:
                throw new NotImplementedException(string.Format(@"@FuncCallExpression: |{0}| function is not defined", name));
            }
        }
Esempio n. 8
0
        public State GetNfa(RulePath path, GetNfaParams param)
        {
            var result = State.NoCloneRepeatBy(value.GetNfa(path, param), by.GetNfa(path, param));

            if (count1 <= 0)
                result = State.NoCloneOption(result);

            if (count1 > 1)
                result = State.Repeat(count1, count2, result);

            return result;
        }
Esempio n. 9
0
		public State GetNfa(RulePath path)
		{
			if (hex1 != null)
			{
				if (hex2 == null)
					return Thompson.Create(hex1.Value);
				else
					return Thompson.Create(hex1.Value, hex2.Value);
			}
			else
			{
				return Thompson.Create(hexs.ToArray());
			}
		}
Esempio n. 10
0
        public State GetNfa(RulePath path)
        {
            var result = State.NoCloneRepeatBy(value.GetNfa(path), by.GetNfa(path));

            if (count1 <= 0)
            {
                result = State.NoCloneOption(result);
            }

            if (count1 > 1)
            {
                result = State.Repeat(count1, count2, result);
            }

            return(result);
        }
Esempio n. 11
0
 public State GetNfa(RulePath path)
 {
     if (hex1 != null)
     {
         if (hex2 == null)
         {
             return(Thompson.Create(hex1.Value));
         }
         else
         {
             return(Thompson.Create(hex1.Value, hex2.Value));
         }
     }
     else
     {
         return(Thompson.Create(hexs.ToArray()));
     }
 }
Esempio n. 12
0
 public State GetNfa(RulePath path)
 {
     return(State.NoCloneOption(expression.GetNfa(path)));
 }
Esempio n. 13
0
 public State GetNfa(RulePath path)
 {
     return(OnMarkRule(Thompson.Create(chars), path + chars));
 }
Esempio n. 14
0
 public State GetNfa(RulePath path, GetNfaParams param)
 {
     return State.NoCloneOption(expression.GetNfa(path, param));
 }
Esempio n. 15
0
 public static State[] GetNfasArray(RulePath path, IEnumerable <IExpression> expressions)
 {
     return(new List <State>(GetNfas(path, expressions)).ToArray());
 }
Esempio n. 16
0
 public State GetNfa(RulePath path, GetNfaParams param)
 {
     return(State.NoCloneConcatanation(Builder.BaseExpression.GetNfasArray(path, expressions, param)));
 }
Esempio n. 17
0
 public State GetNfa(RulePath path, GetNfaParams param)
 {
     return(State.NoCloneOption(expression.GetNfa(path, param)));
 }
Esempio n. 18
0
		public State GetNfa(RulePath path)
		{
			return State.Substract(value1.GetNfa(path), value2.GetNfa(path));
		}
Esempio n. 19
0
 public State GetNfa(RulePath path)
 {
     return(State.Substract(value1.GetNfa(path), value2.GetNfa(path)));
 }
Esempio n. 20
0
        public State MarkRuleHandler(State start, RulePath path)
        {
            ActionsDescription mark;

            if (marks.TryGetValue(path.Value, out mark) && mark.IsEmpty == false)
            {
                mark.UseCount++;

                foreach (var action in mark.Actions)
                {
                    switch (action.Mark)
                    {
                    case Marks.Custom:
                        start = State.MarkCustom(start, action.Args[0], action.Args[1], action.Args[2], action.Args[3]);
                        break;

                    case Marks.Const:
                        start.MarkConst(action.Args[0], action.Args[1], int.Parse(action.Args[2]));
                        break;

                    case Marks.Range:
                        start = State.MarkRange(start, action.Args[0], int.Parse(action.Args[1]), int.Parse(action.Args[2]));
                        break;

                    case Marks.BeginRange:
                        start = State.MarkBeginRange(start, action.Args[0], action.Args[1] == "AtBegin", int.Parse(action.Args[2]));
                        break;

                    case Marks.EndRange:
                    case Marks.EndRangeIfInvalid:
                        start = State.MarkEndRange(start, action.Mark, action.Args[0], action.Args[1] == "AtBegin", int.Parse(action.Args[2]));
                        break;

                    case Marks.ContinueRange:
                        start.MarkContinueRange(action.Args[0]);
                        break;

                    case Marks.Decimal:
                        start.MarkDecimal(action.Args[0], action.Args[1], action.Args[2]);
                        break;

                    case Marks.Hex:
                        start.MarkHex(action.Args[0], action.Args[1], action.Args[2]);
                        break;

                    case Marks.Count:
                        start.MarkCount(action.Args[0], int.Parse(action.Args[1]), int.Parse(action.Args[2]));
                        break;

                    case Marks.Bool:
                    case Marks.BoolEx:
                    case Marks.BoolExNot:
                        start.MarkBool(action.Mark, action.Args[0]);
                        break;

                    case Marks.ResetRange:
                        start.MarkReset(action.Args[0]);
                        break;

                    case Marks.ResetRangeIfInvalid:
                        start.MarkResetIfInvalid(action.Args[0]);
                        break;

                    default:
                        throw new Exception();
                    }
                }
            }

            return(start);
        }
Esempio n. 21
0
 public State GetNfa(RulePath path, GetNfaParams param)
 {
     return param.OnMarkRule(Thompson.Create(chars), path + chars);
 }
Esempio n. 22
0
 public State GetNfa(RulePath path, GetNfaParams param)
 {
     return State.NoCloneAlternation(Builder.BaseExpression.GetNfasArray(path, expressions, param));
 }
Esempio n. 23
0
 public State GetNfa(RulePath path)
 {
     return(State.Repeat(count1, count2, value.GetNfa(path)));
 }
Esempio n. 24
0
 public State GetNfa(RulePath path, GetNfaParams param)
 {
     return(param.OnMarkRule(Thompson.Create(chars), path + chars));
 }
Esempio n. 25
0
 public State GetNfa(RulePath path, GetNfaParams param)
 {
     return State.Repeat(count1, count2, value.GetNfa(path, param));
 }
Esempio n. 26
0
 public State GetNfa(RulePath path)
 {
     return(State.NoCloneAlternation(Builder.BaseExpression.GetNfasArray(path, expressions)));
 }
Esempio n. 27
0
        public State MarkRuleHandler(State start, RulePath path)
        {
            ActionsDescription mark;
            if (marks.TryGetValue(path.Value, out mark) && mark.IsEmpty == false)
            {
                mark.UseCount++;

                foreach (var action in mark.Actions)
                {
                    switch (action.Mark)
                    {
                        case Marks.Custom:
                            start = State.MarkCustom(start, action.Args[0], action.Args[1], action.Args[2], action.Args[3]);
                            break;
                        case Marks.Const:
                            start.MarkConst(action.Args[0], action.Args[1], int.Parse(action.Args[2]));
                            break;
                        case Marks.Range:
                            start = State.MarkRange(start, action.Args[0], int.Parse(action.Args[1]), int.Parse(action.Args[2]));
                            break;
                        case Marks.BeginRange:
                            start = State.MarkBeginRange(start, action.Args[0], action.Args[1] == "AtBegin", int.Parse(action.Args[2]));
                            break;
                        case Marks.EndRange:
                        case Marks.EndRangeIfInvalid:
                            start = State.MarkEndRange(start, action.Mark, action.Args[0], action.Args[1] == "AtBegin", int.Parse(action.Args[2]));
                            break;
                        case Marks.ContinueRange:
                            start.MarkContinueRange(action.Args[0]);
                            break;
                        case Marks.Decimal:
                            start.MarkDecimal(action.Args[0], action.Args[1], action.Args[2]);
                            break;
                        case Marks.Hex:
                            start.MarkHex(action.Args[0], action.Args[1], action.Args[2]);
                            break;
                        case Marks.Count:
                            start.MarkCount(action.Args[0], int.Parse(action.Args[1]), int.Parse(action.Args[2]));
                            break;
                        case Marks.Bool:
                        case Marks.BoolEx:
                        case Marks.BoolExNot:
                            start.MarkBool(action.Mark, action.Args[0]);
                            break;
                        case Marks.ResetRange:
                            start.MarkReset(action.Args[0]);
                            break;
                        case Marks.ResetRangeIfInvalid:
                            start.MarkResetIfInvalid(action.Args[0]);
                            break;
                        default:
                            throw new Exception();
                    }
                }
            }

            return start;
        }
Esempio n. 28
0
			public static IEnumerable<State> GetNfas(RulePath path, IEnumerable<IExpression> expressions)
			{
				foreach (var expression in expressions)
					yield return expression.GetNfa(path);
			}
Esempio n. 29
0
		public State GetNfa(RulePath path)
		{
			return State.NoCloneConcatanation(Builder.BaseExpression.GetNfasArray(path, expressions));
		}
Esempio n. 30
0
			public static State[] GetNfasArray(RulePath path, IEnumerable<IExpression> expressions)
			{
				return new List<State>(GetNfas(path, expressions)).ToArray();
			}
Esempio n. 31
0
 public State GetNfa(RulePath path, GetNfaParams param)
 {
     return(State.Substract(value1.GetNfa(path, param), value2.GetNfa(path, param)));
 }
Esempio n. 32
0
			protected State OnMarkRule(State start, RulePath path)
			{
				return builder.OnMarkRule(start, path);
			}
Esempio n. 33
0
		public State GetNfa(RulePath path)
		{
			return State.NoCloneOption(expression.GetNfa(path));
		}
Esempio n. 34
0
 public State GetNfa(RulePath path, GetNfaParams param)
 {
     return State.Substract(value1.GetNfa(path, param), value2.GetNfa(path, param));
 }
Esempio n. 35
0
 public State GetNfa(RulePath path, GetNfaParams param)
 {
     return(State.Repeat(count1, count2, value.GetNfa(path, param)));
 }
Esempio n. 36
0
		public State GetNfa(RulePath path)
		{
			return OnMarkRule(Thompson.Create(chars), path + chars);
		}
Esempio n. 37
0
 protected State OnMarkRule(State start, RulePath path)
 {
     return(builder.OnMarkRule(start, path));
 }
Esempio n. 38
0
		public State GetNfa(RulePath path)
		{
			return State.Repeat(count1, count2, value.GetNfa(path));
		}