|
terp - the Codemesh Modular Template Interpreter v1.3.309 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.codemesh.terp.eval.TokenStream
public abstract class TokenStream
The baseclass for token-producing streams.
This class contains most of the functionality for terp token
streams. There are different subtypes because we have slightly
different tokenization rules depending on the text contents.
Normal, general text should be tokenized using a TextTokenStream.
Paths, i.e. sequences of file/directory names, should be tokenized
using a PathTokenStream. While TextTokenStreams treat path
separator characters as a regular, plain-text character, PathTokenStreams treat path
separators as a different token type.
| Field Summary | |
|---|---|
protected int |
collectionDepth
|
protected int |
index
|
protected java.util.Stack<java.lang.Integer> |
indexStack
|
protected CharacterStream |
input
|
protected TokenizerState |
state
|
protected java.util.List<Token> |
tokenList
|
| Fields inherited from interface com.codemesh.terp.api.TokenTypes |
|---|
AMPER, ASS, AT, BACKSLASH, BEGIN_EMBEDDED, BOOLEAN, CHAR_LITERAL, CIRCON, COLON, COMMA, DIV, DIV_ASS, DOT, DOT2, DQUOTE, END_EMBEDDED, EOF, EQUALS, ERROR, EXCLAM, FILESEP, GE, GT, HASH, HIDDEN, ID, LBRACE, LCURLY, LE, LOG_AND, LOG_OR, LPAREN, LT, MATCH, MINUS, MINUS_ASS, MINUS2, MOD, MOD_ASS, MULT, MULT_ASS, NORMAL, NOT_EQ, NOT_MATCH, NULL, NUMERIC_LITERAL, PATHSEP, PLUS, PLUS_ASS, PLUS2, QUEST, QUOTE, RBRACE, RCURLY, RPAREN, SEMI, STATE_EMBEDDED, STATE_START, STRING_LITERAL, TEXT, TILDE, VERT, WS |
| Constructor Summary | |
|---|---|
protected |
TokenStream(CharacterStream input)
Creates a stream that reads from the given CharacterStream instance and starts out in TokenizerState.TEXT state. |
protected |
TokenStream(CharacterStream input,
TokenizerState state)
Creates a stream that reads from the given CharacterStream instance. |
protected |
TokenStream(java.io.File source)
Creates a stream that reads from the given file and starts out in TokenizerState.TEXT state. |
protected |
TokenStream(java.io.File source,
java.lang.String encoding)
Creates a stream that reads from the given file in the given encoding and starts out in TokenizerState.TEXT state. |
protected |
TokenStream(java.io.File source,
java.lang.String encoding,
TokenizerState state)
Creates a stream that reads from the given file in the given encoding. |
protected |
TokenStream(java.io.File source,
TokenizerState state)
Creates a stream that reads from the given file. |
protected |
TokenStream(java.io.InputStream is)
Creates a stream that reads from the given stream and starts out in TokenizerState.TEXT state. |
protected |
TokenStream(java.io.InputStream is,
java.lang.String encoding)
Creates a stream that reads from the given stream in the given encoding and starts out in TokenizerState.TEXT state. |
protected |
TokenStream(java.io.InputStream is,
java.lang.String encoding,
TokenizerState state)
Creates a stream that reads from the given stream in the given encoding. |
protected |
TokenStream(java.io.InputStream is,
TokenizerState state)
Creates a stream that reads from the given stream. |
protected |
TokenStream(java.lang.Object theSource,
java.lang.String encoding,
boolean bBuiltin)
Creates a stream that reads from the given reader and starts out in TokenizerState.TEXT state. |
protected |
TokenStream(java.io.Reader r)
Creates a stream that reads from the given reader and starts out in TokenizerState.TEXT state. |
protected |
TokenStream(java.io.Reader r,
TokenizerState state)
Creates a stream that reads from the given reader. |
protected |
TokenStream(java.lang.String input)
Creates a stream that reads from the given string and starts out in TokenizerState.TEXT state. |
protected |
TokenStream(java.lang.String input,
TokenizerState state)
Creates a stream that reads from the given string and starts out in the given tokenizer state. |
protected |
TokenStream(java.net.URI sourceUri)
Creates a stream that reads from the given uri and starts out in TokenizerState.TEXT state. |
protected |
TokenStream(java.net.URI sourceUri,
java.lang.String encoding)
Creates a stream that reads from the given uri in the given encoding and starts out in TokenizerState.TEXT state. |
protected |
TokenStream(java.net.URI sourceUri,
java.lang.String encoding,
TokenizerState state)
Creates a stream that reads from the given uri in the given encoding. |
protected |
TokenStream(java.net.URI sourceUri,
TokenizerState state)
Creates a stream that reads from the given uri. |
protected |
TokenStream(java.net.URL sourceUrl)
Creates a stream that reads from the given url and starts out in TokenizerState.TEXT state. |
protected |
TokenStream(java.net.URL sourceUrl,
java.lang.String encoding)
Creates a stream that reads from the given url in the given encoding and starts out in TokenizerState.TEXT state. |
protected |
TokenStream(java.net.URL sourceUrl,
java.lang.String encoding,
TokenizerState state)
Creates a stream that reads from the given url in the given encoding. |
protected |
TokenStream(java.net.URL sourceUrl,
TokenizerState state)
Creates a stream that reads from the given url. |
| Method Summary | |
|---|---|
protected int |
character_value()
|
protected int |
character(char terminator)
|
protected Token |
createEmbedded()
Returns a token for an embedded expression. |
abstract Token |
createToken()
The token factory method. |
protected int |
dec_digit()
|
protected java.lang.Integer |
exponent()
|
int |
getColumn()
The current column. |
int |
getLine()
The current line. |
InputSource |
getSource()
|
TokenizerState |
getStartingState()
Returns the tokenizer state that this stream was started in. |
protected int |
hex_digit()
|
Token |
LA(int offset)
Returns the token at the specified offset or null if there is no such token. |
void |
mark()
Marks the current position in the stream. |
Token |
match(int tokenType)
Returns the next token if it matches the given toekn type. |
Token |
next()
Returns the next non-hidden token in the stream or null if there are no more tokens. |
protected java.lang.Number |
numericLiteral(int firstDigit)
|
protected int |
oct_digit()
|
void |
reset()
Returns the stream to its initial state. |
void |
rewind()
Restores the current stream position to the last remembered value. |
protected java.lang.String |
string(char terminator,
boolean bUseEscape)
Returns the string value with all escape sequences resolved, if so desired. |
void |
unmark()
Forget a remembered position without readjusting the current stream position. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected final CharacterStream input
protected final java.util.List<Token> tokenList
protected final java.util.Stack<java.lang.Integer> indexStack
protected TokenizerState state
protected int index
protected int collectionDepth
| Constructor Detail |
|---|
protected TokenStream(java.lang.String input)
TokenizerState.TEXT state.
input - the string to read from.
protected TokenStream(java.lang.String input,
TokenizerState state)
input - the string to read from.state - the tokenizer state to start in.protected TokenStream(java.io.File source)
TokenizerState.TEXT state.
source - the file to read from.
protected TokenStream(java.io.File source,
TokenizerState state)
source - the file to read from.state - the tokenizer state to start in.
protected TokenStream(java.io.File source,
java.lang.String encoding)
TokenizerState.TEXT state.
source - the file to read from.encoding - the file encoding.
protected TokenStream(java.io.File source,
java.lang.String encoding,
TokenizerState state)
source - the file to read from.encoding - the file encoding.state - the tokenizer state to start in.protected TokenStream(java.net.URI sourceUri)
TokenizerState.TEXT state.
sourceUri - the URI to read from.
protected TokenStream(java.net.URI sourceUri,
TokenizerState state)
sourceUri - the URI to read from.state - the tokenizer state to start in.
protected TokenStream(java.net.URI sourceUri,
java.lang.String encoding)
TokenizerState.TEXT state.
sourceUri - the URI to read from.encoding - the content encoding.
protected TokenStream(java.net.URI sourceUri,
java.lang.String encoding,
TokenizerState state)
sourceUri - the URI to read from.encoding - the content encoding.state - the tokenizer state to start in.protected TokenStream(java.net.URL sourceUrl)
TokenizerState.TEXT state.
sourceUrl - the URL to read from.
protected TokenStream(java.net.URL sourceUrl,
TokenizerState state)
sourceUrl - the URL to read from.state - the tokenizer state to start in.
protected TokenStream(java.net.URL sourceUrl,
java.lang.String encoding)
TokenizerState.TEXT state.
sourceUrl - the URL to read from.encoding - the content encoding.
protected TokenStream(java.net.URL sourceUrl,
java.lang.String encoding,
TokenizerState state)
sourceUrl - the URL to read from.encoding - the content encoding.state - the tokenizer state to start in.protected TokenStream(java.io.InputStream is)
TokenizerState.TEXT state.
is - the stream to read from.
protected TokenStream(java.io.InputStream is,
TokenizerState state)
is - the stream to read from.state - the tokenizer state to start in.
protected TokenStream(java.io.InputStream is,
java.lang.String encoding)
TokenizerState.TEXT state.
is - the stream to read from.encoding - the content encoding.
protected TokenStream(java.io.InputStream is,
java.lang.String encoding,
TokenizerState state)
is - the stream to read from.encoding - the content encoding.state - the tokenizer state to start in.protected TokenStream(java.io.Reader r)
TokenizerState.TEXT state.
r - the reader to read from.
protected TokenStream(java.io.Reader r,
TokenizerState state)
r - the reader to read from.state - the tokenizer state to start in.
protected TokenStream(java.lang.Object theSource,
java.lang.String encoding,
boolean bBuiltin)
TokenizerState.TEXT state.
theSource - the source to read from.encoding - the content encoding.bBuiltin - true if we;re being called from one of the builtin
constructors.protected TokenStream(CharacterStream input)
TokenizerState.TEXT state.
input - the CharacterStream to read from.
protected TokenStream(CharacterStream input,
TokenizerState state)
input - the CharacterStream to read from.state - the tokenizer state to start in.| Method Detail |
|---|
public TokenizerState getStartingState()
reset() is called.
public void reset()
public abstract Token createToken()
public int getLine()
public int getColumn()
public Token next()
public Token LA(int offset)
offset - the offset from the current position.
public Token match(int tokenType)
tokenType - the expected token type.
public void mark()
public void unmark()
public void rewind()
protected Token createEmbedded()
protected java.lang.String string(char terminator,
boolean bUseEscape)
terminator - the temrination character.bUseEscape - true if escape sequences should be processed.
protected int character(char terminator)
protected int character_value()
protected int oct_digit()
protected int dec_digit()
protected int hex_digit()
protected java.lang.Integer exponent()
protected java.lang.Number numericLiteral(int firstDigit)
public InputSource getSource()
|
terp - the Codemesh Modular Template Interpreter v1.3.309 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||