Package io.pebbletemplates.pebble.lexer
Class TokenStream
java.lang.Object
io.pebbletemplates.pebble.lexer.TokenStream
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionTokenStream
(Collection<Token> tokens, String name) Constructor for a Token Stream -
Method Summary
Modifier and TypeMethodDescriptioncurrent()
Looks at the current token.expect
(Token.Type type) Checks the current token to see if it matches the provided type.expect
(Token.Type type, String value) Checks the current token to see if it matches the provided type.used for testing purposesboolean
isEOF()
next()
Consumes and returns the next token in the stream.peek()
Returns the next token in the stream without consuming it.peek
(int number) Returns a future token in the stream without consuming any.toString()
-
Field Details
-
tokens
-
current
private int current -
filename
-
-
Constructor Details
-
TokenStream
Constructor for a Token Stream- Parameters:
tokens
- A collection of tokensname
- The filename of the template that these tokens came from
-
-
Method Details
-
next
Consumes and returns the next token in the stream.- Returns:
- The next token
-
expect
Checks the current token to see if it matches the provided type. If it doesn't match this will throw a SyntaxException. This will consume a token.- Parameters:
type
- The type of token that we expect- Returns:
- Token The current token
-
expect
Checks the current token to see if it matches the provided type. If it doesn't match this will throw a SyntaxException. This will consume a token.- Parameters:
type
- The type of token that we expectvalue
- The expected value of the token- Returns:
- Token The current token
-
peek
Returns the next token in the stream without consuming it.- Returns:
- The next token
-
peek
Returns a future token in the stream without consuming any.- Parameters:
number
- How many tokens to lookahead- Returns:
- The token we are peeking at
-
isEOF
public boolean isEOF() -
toString
-
current
Looks at the current token. Does not consume the token.- Returns:
- Token The current token
-
getFilename
-
getTokens
used for testing purposes- Returns:
- List of tokens
-