Example #1
0
		/// <summary>
		/// Initializes a new instance of the <see cref="TagDirective"/> class.
		/// </summary>
		/// <param name="handle">The handle.</param>
		/// <param name="prefix">The prefix.</param>
		/// <param name="start">The start position of the token.</param>
		/// <param name="end">The end position of the token.</param>
		public TagDirective(string handle, string prefix, Mark start, Mark end)
			: base(start, end)
		{
			if(string.IsNullOrEmpty(handle)) {
				throw new ArgumentNullException("handle", "Tag handle must not be empty.");
			}
			
			if(!tagHandleValidator.IsMatch(handle)) {
				throw new ArgumentException("Tag handle must start and end with '!' and contain alphanumerical characters only.", "handle");
			}
			
			this.handle = handle;

			if(string.IsNullOrEmpty(prefix)) {
				throw new ArgumentNullException("prefix", "Tag prefix must not be empty.");
			}
			
			this.prefix = prefix;
		}
Example #2
0
		/// <summary>
		/// Initializes a new instance of the <see cref="NodeEvent"/> class.
		/// </summary>
		/// <param name="anchor">The anchor.</param>
		/// <param name="tag">The tag.</param>
		/// <param name="start">The start position of the event.</param>
		/// <param name="end">The end position of the event.</param>
		protected NodeEvent(string anchor, string tag, Mark start, Mark end)
			: base(start, end)
		{
			if(anchor != null) {
				if(anchor.Length == 0) {
					throw new ArgumentException("Anchor value must not be empty.", "anchor");
				}

				if(!anchorValidator.IsMatch(anchor)) {
					throw new ArgumentException("Anchor value must contain alphanumerical characters only.", "anchor");
				}
			}
				
			if(tag != null && tag.Length == 0) {
				throw new ArgumentException("Tag value must not be empty.", "tag");
			}
			
			this.anchor = anchor;
			this.tag = tag;
		}
		private int CreateMark (int previous) {
			if (mark_end == marks.Length) {
				Mark [] dest = new Mark [marks.Length * 2];
				marks.CopyTo (dest, 0);
				marks = dest;
			}

			int m = mark_end ++;
			marks [m].Start = marks [m].End = -1;
			marks [m].Previous = previous;

			return m;
		}
		private void ResetGroups () {
			int n = groups.Length;
			if (marks == null)
				marks = new Mark [n * 10];

			for (int i = 0; i < n; ++ i) {
				groups [i] = i;

				marks [i].Start = -1;
				marks [i].End = -1;
				marks [i].Previous = -1;
			}
			
			mark_start = 0;
			mark_end = n;
		}