1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Text;
5

6
namespace TurnerSoftware.RobotsExclusionTools.Tokenization.Validators
7
{
8
	public class RobotsFileTokenPatternValidator : TokenPatternValidatorBase
9
	{
10 1
		private static readonly Dictionary<TokenType, IEnumerable<TokenPattern>> TokenPatterns = new Dictionary<TokenType, IEnumerable<TokenPattern>>
11 1
		{
12 1
			{
13 1
				TokenType.Comment,
14 1
				new[]
15 1
				{
16 1
					new TokenPattern(TokenType.Comment, null, new [] { TokenType.NewLine })
17 1
				}
18 1
			},
19 1
			{
20 1
				TokenType.Field,
21 1
				new[]
22 1
				{
23 1
					new TokenPattern(TokenType.Field, new[]{ TokenType.NewLine }, new [] { TokenType.FieldValueDelimiter })
24 1
				}
25 1
			},
26 1
			{
27 1
				TokenType.Value,
28 1
				new[]
29 1
				{
30 1
					new TokenPattern(TokenType.Value, new[]{ TokenType.FieldValueDelimiter, TokenType.Field }, null)
31 1
				}
32 1
			},
33 1
			{
34 1
				TokenType.FieldValueDelimiter,
35 1
				new[]
36 1
				{
37 1
					new TokenPattern(TokenType.FieldValueDelimiter, new[] { TokenType.Field }, null)
38 1
				}
39 1
			}
40 1
		};
41

42
		protected override IEnumerable<TokenPattern> LookupTokenPatterns(TokenType tokenType)
43 1
		{
44 1
			if (TokenPatterns.ContainsKey(tokenType))
45 1
			{
46 1
				return TokenPatterns[tokenType];
47
			}
48
			
49 1
			return Enumerable.Empty<TokenPattern>();
50 1
		}
51
	}
52
}

Read our documentation on viewing source code .

Loading