/* --------------------------------------------------------- *
* __________ D E L T A S C R I P T *
* (_________() *
* / === / - A fast, dynamic scripting language *
* | == | - Version 4.13.11.0 *
* / === / - Developed by Adam R. Nelson *
* | = = | - 2011-2013 *
* / === / - Distributed under GNU LGPL v3 *
* (________() - http://github.com/ar-nelson/deltascript *
* *
* --------------------------------------------------------- */
package com.sector91.delta.script.parser;
import java.io.IOException;
public class LexToken
{
private final TokenType type;
private final String value;
private final int start;
private final int end;
LexToken(TokenType type, int start, int end)
{this(type, null, start, end);}
LexToken(TokenType type, String value, int start, int end)
{
this.type = type;
this.value = value;
this.start = start;
this.end = end;
}
public TokenType type() throws DScriptLexerException, IOException
{return type;}
public String value() throws DScriptLexerException, IOException
{return value;}
public int start()
{return start;}
public int end()
{return end;}
@Override public String toString()
{
if (value == null)
return type.friendlyDesc;
else if (type == TokenType.SEPARATOR)
return type.friendlyDesc + " (" +
("\n".equals(value) ? "newline" : value) + ")";
else
return type.friendlyDesc + " '" + value + "'";
}
}