Example #1
0
		public void InitializeItems(ParserInitializeArgs args)
		{
			foreach (var item in Items)
			{
				if (item != null)
					item.Initialize(args);
			}
		}
Example #2
0
		public override void Initialize(ParserInitializeArgs args)
		{
			base.Initialize(args);
			if (Inner != null && args.Push(this))
				{
					Inner.Initialize(args);
				args.Pop();
			}
		}
Example #3
0
		public override void Initialize(ParserInitializeArgs args)
		{
			base.Initialize(args);
			if (Except != null && args.Push(this))
			{
				Except.Initialize(args);
				args.Pop();
			}
		}
Example #4
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();
			}
		}
Example #5
0
		public override void Initialize(ParserInitializeArgs args)
		{
			base.Initialize(args);
			if (args.Push(this))
			{
				skipMatches = this.Children().Any(r => r.Name != null);

				args.Pop();
			}
		}
Example #6
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();
			}
		}
Example #7
0
		public override void Initialize(ParserInitializeArgs args)
		{
			base.Initialize(args);
			caseSensitive = CaseSensitive ?? args.Grammar.CaseSensitive;
		}
Example #8
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();
			}
		}
Example #9
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();
			}
		}
Example #10
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();
			}
		}