001         package com.croftsoft.core.util.jlex;
002    
003         /*********************************************************************
004         * Token data class for use with JLex.
005         *
006         * <B>Reference:</B>
007         *
008         * <P>
009         *
010         * "JLex: A Lexical Analyzer Generator for Java"<BR>
011         * <A HREF="http://www.cs.princeton.edu/~appel/modern/java/JLex/">
012         * http://www.cs.princeton.edu/~appel/modern/java/JLex/</A>
013         *
014         * @version
015         *   $Id: Token.java,v 1.3 2008/09/20 05:51:55 croft Exp $
016         * @since
017         *   1999-02-10
018         * @author
019         *   <a href="https://www.croftsoft.com/">David Wallace Croft</a>
020         *********************************************************************/
021    
022         public class  Token
023         //////////////////////////////////////////////////////////////////////
024         //////////////////////////////////////////////////////////////////////
025         {
026    
027         /** The token type identifier number. */
028         public int     id        = -1;
029    
030         public String  text      = null;
031    
032         /** Defaults to -1. */
033         public int     line      = -1;
034    
035         /** Defaults to -1. */
036         public int     charBegin = -1;
037    
038         /** Defaults to -1. */
039         public int     charEnd   = -1;
040    
041         //////////////////////////////////////////////////////////////////////
042         //////////////////////////////////////////////////////////////////////
043    
044         public  Token (
045           int     id,
046           String  text,
047           int     line,
048           int     charBegin,
049           int     charEnd )
050         //////////////////////////////////////////////////////////////////////
051         {
052           this.id        = id;
053           this.text      = text;
054           this.line      = line;
055           this.charBegin = charBegin;
056           this.charEnd   = charEnd;
057         }
058    
059         public  Token (
060           int     id,
061           String  text )
062         //////////////////////////////////////////////////////////////////////
063         {
064           this.id   = id;
065           this.text = text;
066         }
067    
068         public  Token ( int  id )
069         //////////////////////////////////////////////////////////////////////
070         {
071           this.id = id;
072         }
073    
074         //////////////////////////////////////////////////////////////////////
075         //////////////////////////////////////////////////////////////////////
076    
077         @Override
078         public String  toString ( )
079         //////////////////////////////////////////////////////////////////////
080         {
081           return
082               "id        = " + id        + "\n"
083             + "text      = " + text      + "\n"
084             + "line      = " + line      + "\n"
085             + "charBegin = " + charBegin + "\n"
086             + "charEnd   = " + charEnd;
087         }
088    
089         //////////////////////////////////////////////////////////////////////
090         //////////////////////////////////////////////////////////////////////
091         }