Mercurial > pub > ImplabNet
diff Implab/Automaton/RegularExpressions/Token.cs @ 177:a0ff6a0e9c44 ref20160224
refactoring
author | cin |
---|---|
date | Wed, 23 Mar 2016 01:42:00 +0300 |
parents | e227e78d72e4 |
children | d5c5db0335ee |
line wrap: on
line diff
--- a/Implab/Automaton/RegularExpressions/Token.cs Tue Mar 22 18:58:40 2016 +0300 +++ b/Implab/Automaton/RegularExpressions/Token.cs Wed Mar 23 01:42:00 2016 +0300 @@ -3,46 +3,46 @@ using System.Linq; namespace Implab.Automaton.RegularExpressions { - public abstract class Token<TTag> { - public abstract void Accept(IVisitor<TTag> visitor); + public abstract class Token { + public abstract void Accept(IVisitor visitor); - public Token<TTag> Extend() { - return Cat(new EndToken<TTag>()); + public Token Extend() { + return Cat(new EndToken()); } - public Token<TTag> Tag(TTag tag) { + public Token Tag<TTag>(TTag tag) { return Cat(new EndToken<TTag>(tag)); } - public Token<TTag> Cat(Token<TTag> right) { - return new CatToken<TTag>(this, right); + public Token Cat(Token right) { + return new CatToken(this, right); } - public Token<TTag> Or(Token<TTag> right) { - return new AltToken<TTag>(this, right); + public Token Or(Token right) { + return new AltToken(this, right); } - public Token<TTag> Optional() { - return Or(new EmptyToken<TTag>()); + public Token Optional() { + return Or(new EmptyToken()); } - public Token<TTag> EClosure() { - return new StarToken<TTag>(this); + public Token EClosure() { + return new StarToken(this); } - public Token<TTag> Closure() { - return Cat(new StarToken<TTag>(this)); + public Token Closure() { + return Cat(new StarToken(this)); } - public Token<TTag> Repeat(int count) { - Token<TTag> token = null; + public Token Repeat(int count) { + Token token = null; for (int i = 0; i < count; i++) token = token != null ? token.Cat(this) : this; - return token ?? new EmptyToken<TTag>(); + return token ?? new EmptyToken(); } - public Token<TTag> Repeat(int min, int max) { + public Token Repeat(int min, int max) { if (min > max || min < 1) throw new ArgumentOutOfRangeException(); var token = Repeat(min); @@ -52,11 +52,11 @@ return token; } - public static Token<TTag> New(params int[] set) { + public static Token New(params int[] set) { Safe.ArgumentNotNull(set, "set"); - Token<TTag> token = null; + Token token = null; foreach(var c in set.Distinct()) - token = token == null ? new SymbolToken<TTag>(c) : token.Or(new SymbolToken<TTag>(c)); + token = token == null ? new SymbolToken(c) : token.Or(new SymbolToken(c)); return token; } }