1 8 13 package jfun.parsec.tokens; 14 15 import jfun.parsec.Tokenizer; 16 17 25 @Deprecated 26 public class MyToken extends TokenWord 27 implements java.io.Serializable { 28 private final int kind; 29 30 public boolean equals(Object v) { 31 if(v instanceof MyToken){ 32 final MyToken mt2 = (MyToken)v; 33 return kind == mt2.kind && getWord().equals(mt2.getWord()); 34 } 35 else return false; 36 } 37 public String toString() { 38 return super.toString() + ":" + kind; 39 } 40 public int hashCode() { 41 return super.hashCode() * 31 + kind; 42 } 43 47 MyToken(final String text, int kind) { 48 super(text); 49 this.kind = kind; 50 } 51 55 public final int getKind(){return kind;} 56 61 public static Tokenizer getTokenizer(final int k){ 62 return new Tokenizer(){ 63 public Object toToken(final CharSequence cs, final int from, final int len){ 64 return new MyToken(cs.subSequence(from, from+len).toString(), k); 65 } 66 }; 67 } 68 } 69 | Popular Tags |