⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ctoken.java

📁 it is a basic java browser
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
   * get the ID number of this token   *    * @return the id number of the token   */  public int getID(){  	return ID;  }  /**    * get the contents of this token   *    * @return A string representing the text of the token   */  public String getContents(){  	return (new String(contents));  }  /**    * get the line number of the input on which this token started   *    * @return the line number of the input on which this token started   */  public int getLineNumber(){  	return lineNumber;  }  /**    * get the offset into the input in characters at which this token started   *   * @return the offset into the input in characters at which this token started   */  public int getCharBegin(){  	return charBegin;  }  /**    * get the offset into the input in characters at which this token ended   *   * @return the offset into the input in characters at which this token ended   */  public int getCharEnd(){ 	return charEnd;  }  /**    * Checks this token to see if it is a reserved word.   *   * @return true if this token is a reserved word, false otherwise   */  public boolean isReservedWord(){  	return((ID >> 8) == 0x1);  }  /**    * Checks this token to see if it is an identifier.   *   * @return true if this token is an identifier, false otherwise   */  public boolean isIdentifier(){  	return((ID >> 8) == 0x2);  }  /**    * Checks this token to see if it is a literal.   *   * @return true if this token is a literal, false otherwise   */  public boolean isLiteral(){  	return((ID >> 8) == 0x3);  }    /**    * Checks this token to see if it is a Separator.   *   * @return true if this token is a Separator, false otherwise   */  public boolean isSeparator(){  	return((ID >> 8) == 0x4);  }  /**    * Checks this token to see if it is a Operator.   *   * @return true if this token is a Operator, false otherwise   */  public boolean isOperator(){  	return((ID >> 8) == 0x5);  }  /**    * Checks this token to see if it should be handled by the preprocessor.   *    * @return true if this token should be handled by the preprocessor, false otherwise   */  public boolean isPreProcessor(){  	return((ID >> 8) == 0xC);  }  /**    * Checks this token to see if it is a comment.   *    * @return true if this token is a comment, false otherwise   */  public boolean isComment(){  	return((ID >> 8) == 0xD);  }  /**    * Checks this token to see if it is White Space.   * Usually tabs, line breaks, form feed, spaces, etc.   *    * @return true if this token is White Space, false otherwise   */  public boolean isWhiteSpace(){  	return((ID >> 8) == 0xE);  }  /**    * Checks this token to see if it is an Error.   * Unfinished comments, numbers that are too big, unclosed strings, etc.   *    * @return true if this token is an Error, false otherwise   */  public boolean isError(){  	return((ID >> 8) == 0xF);  }	/**	 * A description of this token.  The description should	 * be appropriate for syntax highlighting.  For example	 * "comment" is returned for a comment.     *	 * @return a description of this token.	 */	public String getDescription(){		if (isReservedWord()){			return("reservedWord");		} else if (isIdentifier()){			return("identifier");		} else if (isLiteral()){			return("literal");		} else if (isSeparator()){			return("separator");		} else if (isOperator()){			return("operator");		} else if (isComment()){					return("comment");		} else if (isPreProcessor()){			return("preprocessor");		} else if (isWhiteSpace()){			return("whitespace");		} else if (isError()){		 	return("error");		} else {			return("unknown");		}	}  /**   * get a String that explains the error, if this token is an error.   *    * @return a  String that explains the error, if this token is an error, null otherwise.   */  public String errorString(){  	String s;  	if (isError()){  		s = "Error on line " + lineNumber + ": ";  		switch (ID){  		case ERROR_IDENTIFIER:  			s += "Unrecognized Identifier: " + contents;  		break; 		case ERROR_UNCLOSED_STRING:  			s += "'\"' expected after " + contents;  		break; 				case ERROR_MALFORMED_STRING:		case ERROR_MALFORMED_UNCLOSED_STRING:  			s += "Illegal character in " + contents;  		break;		case ERROR_UNCLOSED_CHARACTER:  			s += "\"'\" expected after " + contents;  		break; 				case ERROR_MALFORMED_CHARACTER:		case ERROR_MALFORMED_UNCLOSED_CHARACTER:  			s += "Illegal character in " + contents;  		break;		case ERROR_INTEGER_DECIMIAL_SIZE:		case ERROR_INTEGER_OCTAL_SIZE:		case ERROR_FLOAT:  			s += "Illegal character in " + contents;  		break;		case ERROR_INTEGER_HEXIDECIMAL_SIZE:		case ERROR_LONG_DECIMIAL_SIZE:		case ERROR_LONG_OCTAL_SIZE:		case ERROR_LONG_HEXIDECIMAL_SIZE:		case ERROR_FLOAT_SIZE:		case ERROR_DOUBLE_SIZE:  			s += "Literal out of bounds: " + contents;  		break;				case ERROR_UNCLOSED_COMMENT:  			s += "*/ expected after " + contents;  		break;  		case ERROR_MALFORMED_PREPROCESSOR_DIRECTIVE:  			s += "Unrecognized preprocessor command " + contents;  		break;		}  			  	} else {  		s = null;  	}  	return (s);  }  /**    * get a representation of this token as a human readable string.   * The format of this string is subject to change and should only be used   * for debugging purposes.   *   * @return a string representation of this token   */    public String toString() {      return ("Token #" + Integer.toHexString(ID) + ": " + getDescription() + " Line " +       	lineNumber + " from " +charBegin + " to " + charEnd + " : " + contents);  }  }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -