Mercurial > pub > ImplabNet
comparison Implab/Automaton/RegularExpressions/Token.cs @ 165:e227e78d72e4 ref20160224
DFA refactoring
author | cin |
---|---|
date | Mon, 29 Feb 2016 02:02:17 +0300 |
parents | 0526412bbb26 |
children | a0ff6a0e9c44 |
comparison
equal
deleted
inserted
replaced
164:ec35731ae299 | 165:e227e78d72e4 |
---|---|
8 | 8 |
9 public Token<TTag> Extend() { | 9 public Token<TTag> Extend() { |
10 return Cat(new EndToken<TTag>()); | 10 return Cat(new EndToken<TTag>()); |
11 } | 11 } |
12 | 12 |
13 public Token<TTag> Tag<T>(T tag) where T : IConvertible { | 13 public Token<TTag> Tag(TTag tag) { |
14 return Cat(new EndToken<TTag>(tag)); | 14 return Cat(new EndToken<TTag>(tag)); |
15 } | 15 } |
16 | 16 |
17 public Token<TTag> Cat(Token<TTag> right) { | 17 public Token<TTag> Cat(Token<TTag> right) { |
18 return new CatToken<TTag>(this, right); | 18 return new CatToken<TTag>(this, right); |
46 if (min > max || min < 1) | 46 if (min > max || min < 1) |
47 throw new ArgumentOutOfRangeException(); | 47 throw new ArgumentOutOfRangeException(); |
48 var token = Repeat(min); | 48 var token = Repeat(min); |
49 | 49 |
50 for (int i = min; i < max; i++) | 50 for (int i = min; i < max; i++) |
51 token = token.Cat( this.Optional() ); | 51 token = token.Cat( Optional() ); |
52 return token; | 52 return token; |
53 } | 53 } |
54 | 54 |
55 public static Token<TTag> New<T>(params T[] set) where T : struct, IConvertible { | 55 public static Token<TTag> New(params int[] set) { |
56 Safe.ArgumentNotNull(set, "set"); | 56 Safe.ArgumentNotNull(set, "set"); |
57 Token<TTag> token = null; | 57 Token<TTag> token = null; |
58 foreach(var c in set.Distinct()) | 58 foreach(var c in set.Distinct()) |
59 token = token == null ? new SymbolToken<TTag>(c) : token.Or(new SymbolToken<TTag>(c)); | 59 token = token == null ? new SymbolToken<TTag>(c) : token.Or(new SymbolToken<TTag>(c)); |
60 return token; | 60 return token; |