Token.java
Upload User: afrynkmhm
Upload Date: 2007-01-06
Package Size: 1262k
Code Size: 1k
Development Platform:

Others

  1. package antlr;
  2. /* ANTLR Translator Generator
  3.  * Project led by Terence Parr at http://www.jGuru.com
  4.  * Software rights: http://www.antlr.org/RIGHTS.html
  5.  *
  6.  * $Id: //depot/code/org.antlr/release/antlr-2.7.0/antlr/Token.java#1 $
  7.  */
  8. /** A token is minimally a token type.  Subclasses can add the text matched
  9.  *  for the token and line info. 
  10.  */
  11. public class Token implements Cloneable {
  12. // constants
  13. public static final int MIN_USER_TYPE = 4;
  14. public static final int NULL_TREE_LOOKAHEAD = 3;
  15. public static final int INVALID_TYPE = 0;
  16. public static final int EOF_TYPE = 1;
  17. public static final int SKIP = -1;
  18. // each Token has at least a token type
  19. int type=INVALID_TYPE;
  20. // the illegal token object
  21. public static Token badToken = new Token(INVALID_TYPE, "<no text>");
  22. public Token() {;}
  23. public Token(int t) { type = t; }
  24. public Token(int t, String txt) { type = t; setText(txt); }
  25. public int getColumn() { return 0; }
  26. public int getLine() { return 0; }
  27. public String getText() { return "<no text>"; }
  28. public int getType() { return type; }
  29. public void setColumn(int c) {;}
  30. public void setLine(int l) {;}
  31. public void setText(String t) {;}
  32. public void setType(int t) { type = t; }
  33. public String toString() {
  34. return "[""+getText()+"",<"+type+">]";
  35. }
  36. }