public abstract class Token extends Object
A Token is the basic building block of a parser. It denotes something that can be parsed, either by reading from the input or composing other tokens.
Specifies the two fields that all tokens share: name (a
String) and encoding (an Encoding). A Token is parsed
by calling one of the parse methods. Parsing a Token succeeds
if the returned ParseResult's succeeded field is
true, otherwise parsing has failed.
The name field is used during parsing to construct a scope, by
concatenating it to the incoming scope argument as follows:
scope + SEPARATOR + name
The encoding may be null. If it is not, it
overrides outer encoding specifications and is passed to nested tokens
instead. As such it can itself be overridden by explicit specifications in
nested tokens.| Modifier and Type | Field and Description |
|---|---|
Encoding |
encoding |
String |
name |
static String |
NO_NAME |
static String |
SEPARATOR |
| Modifier | Constructor and Description |
|---|---|
protected |
Token(String name,
Encoding encoding) |
| Modifier and Type | Method and Description |
|---|---|
Token |
getCanonical(Environment environment) |
boolean |
isLocal() |
protected String |
makeNameFragment() |
ParseResult |
parse(Environment environment,
Encoding encoding) |
ParseResult |
parse(String scope,
Environment environment,
Encoding encoding) |
protected abstract ParseResult |
parseImpl(String scope,
Environment environment,
Encoding encoding) |
public static final String NO_NAME
public static final String SEPARATOR
public final String name
public final Encoding encoding
public ParseResult parse(String scope, Environment environment, Encoding encoding) throws IOException
IOExceptionpublic ParseResult parse(Environment environment, Encoding encoding) throws IOException
IOExceptionprotected abstract ParseResult parseImpl(String scope, Environment environment, Encoding encoding) throws IOException
IOExceptionpublic boolean isLocal()
public Token getCanonical(Environment environment)
protected String makeNameFragment()
Copyright © 2017. All rights reserved.