KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jfun > parsec > String2TokenWord


1 package jfun.parsec;
2
3 import jfun.parsec.tokens.TokenType;
4 import jfun.parsec.tokens.Tokens;
5 import jfun.parsec.tokens.TypedToken;
6
7 /**
8  * This implementation of FromString creates a {@link jfun.parsec.tokens.TypedToken} instance
9  * from the string.
10  * <p>
11  * @author Ben Yu
12  * Mar 29, 2006 9:54:23 PM
13  */

14 public class String2TokenWord implements FromString<TypedToken<TokenType>> {
15   public TypedToken<TokenType> fromString(int from, int len, String JavaDoc s) {
16     return Tokens.word(s);
17   }
18   public String JavaDoc toString(){
19     return getClass().getName();
20   }
21   private String2TokenWord(){}
22   private static final String2TokenWord singleton = new String2TokenWord();
23   /**
24    * Get an instance of this implementation.
25    */

26   public static FromString<TypedToken<TokenType>> instance(){
27     return singleton;
28   }
29 }
30
Popular Tags