Exemple #1
0
		public override void Initialize(ParserInitializeArgs args)
		{
			base.Initialize(args);
			if (Inner != null && args.Push(this))
				{
					Inner.Initialize(args);
				args.Pop();
			}
		}
Exemple #2
0
		public override void Initialize(ParserInitializeArgs args)
		{
			base.Initialize(args);
			if (Except != null && args.Push(this))
			{
				Except.Initialize(args);
				args.Pop();
			}
		}
Exemple #3
0
		public override void Initialize(ParserInitializeArgs args)
		{
			base.Initialize(args);
			if (args.Push(this))
			{
				if (ValueType != null)
					parseMethod = ValueType.GetMethod("Parse", BindingFlags.Static | BindingFlags.Public, null, new Type[] { typeof(string), typeof(NumberStyles) }, null);
				args.Pop();
			}
		}
Exemple #4
0
		public override void Initialize(ParserInitializeArgs args)
		{
			base.Initialize(args);
			if (args.Push(this))
			{
				skipMatches = this.Children().Any(r => r.Name != null);

				args.Pop();
			}
		}
Exemple #5
0
		public override void Initialize(ParserInitializeArgs args)
		{
			base.Initialize(args);
			if (args.Push(this))
			{
				if (Separator != null)
					Separator.Initialize(args);
				if (Until != null)
					Until.Initialize(args);
				separator = Separator ?? args.Grammar.Separator;
				skipUntilMatches = (Until != null && (Until.Name != null || Until.Children().Any(r => r.Name != null)));
				args.Pop();
			}
		}
Exemple #6
0
		public override void Initialize(ParserInitializeArgs args)
		{
			base.Initialize(args);
			if (args.Push(this))
			{
				if (line != null)
					line.Initialize(args);
				if (start != null)
					start.Initialize(args);
				if (end != null)
					end.Initialize(args);
				args.Pop();
			}
		}
Exemple #7
0
		public override void Initialize(ParserInitializeArgs args)
		{
			base.Initialize(args);
			separator = Separator ?? args.Grammar.Separator;
			if (Items.Count == 0)
				throw new InvalidOperationException("There are no items in this sequence");
			if (args.Push(this))
			{
				var leftItem = Items[0];
				if (leftItem != null)
				{
					foreach (var parent in args.RecursionFixes)
					{
						if (leftItem.IsLeftRecursive(parent))
						{
							Items[0] = new EmptyParser();
							break;
						}
					}
				}
				foreach (var item in Items.Where(r => r != null))
				{
					item.Initialize(args);
				}

				if (Separator != null)
					Separator.Initialize(args);

				args.Pop();
			}
		}
Exemple #8
0
		public override void Initialize(ParserInitializeArgs args)
		{
			base.Initialize(args);
			if (args.Push(this))
			{
				var first = new List<Parser>();
				var second = new List<Parser>();
				foreach (var item in Items)
				{
					if (item != null && item.IsLeftRecursive(new ParserContainsArgs(this)))
					{
						second.Add(item);
						args.RecursionFixes.Add(this);
						item.Initialize(args);
						args.RecursionFixes.Remove(this);
					}
					else
					{
						first.Add(item);
						if (item != null)
							item.Initialize(args);
					}
				}
				if (second.Count > 0)
				{
					Items.Clear();
					var secondParser = second.Count > 1 ? new AlternativeParser(second) : second[0];
					if (first.Count > 0)
					{
						var firstParser = first.Count > 1 ? new AlternativeParser(first) : first[0];
						if (first.Count == 1 && first[0] == null)
						{
							Items.Add(-secondParser);
						}
						else
							Items.Add(new SequenceParser(firstParser, -secondParser));
					}
					else
						Items.Add(+secondParser);
				}
				args.Pop();
			}
		}