public class Token extends Object
The token holds the resulting value of the input, the input buffer, and the start and stop position in the input buffer. It provides many convenience methods to access the state of the token.
| Modifier and Type | Field | Description |
|---|---|---|
static Parser |
NEWLINE_PARSER |
Returns a parser for that detects newlines platform independently.
|
| Constructor | Description |
|---|---|
Token(String buffer,
int start,
int stop,
Object value) |
Constructs a token from the parsed value, the input buffer, and the start and stop position in
the input buffer.
|
| Modifier and Type | Method | Description |
|---|---|---|
boolean |
equals(Object other) |
|
String |
getBuffer() |
The backing buffer of the token.
|
int |
getColumn() |
The column number of this token.
|
String |
getInput() |
The consumed input of the token.
|
int |
getLength() |
The consumed input length of the token.
|
int |
getLine() |
The line number of the token.
|
int |
getStart() |
The start position of the token in the buffer.
|
int |
getStop() |
The stop position of the token in the buffer.
|
<T> T |
getValue() |
The resulting value of the token.
|
int |
hashCode() |
|
static int[] |
lineAndColumnOf(String buffer,
int position) |
Converts the
position index in a buffer to a line and column tuple. |
String |
toString() |
public static final Parser NEWLINE_PARSER
public String getBuffer()
public String getInput()
public int getLength()
public int getStart()
public int getStop()
public <T> T getValue()
public int getLine()
public int getColumn()
public static int[] lineAndColumnOf(String buffer, int position)
position index in a buffer to a line and column tuple.Copyright © 2018 PetitParser. All rights reserved.