class documentation
class TokenStream: (source)
A token stream is an iterable that yields :class:`Token`\s. The parser however does not iterate over it but calls :meth:`next` to go one token ahead. The current active token is stored as :attr:`current`.
Method | __bool__ |
Undocumented |
Method | __init__ |
Undocumented |
Method | __iter__ |
Undocumented |
Method | __next__ |
Go one token ahead and return the old one. |
Method | close |
Close the stream. |
Method | expect |
Expect a given token type and return it. This accepts the same argument as :meth:`jinja2.lexer.Token.test`. |
Method | look |
Look at the next token. |
Method | next |
Perform the token test and return the token if it matched. Otherwise the return value is `None`. |
Method | push |
Push a token back to the stream. |
Method | skip |
Got n tokens ahead. |
Method | skip |
Like :meth:`next_if` but only returns `True` or `False`. |
Instance Variable | closed |
Undocumented |
Instance Variable | current |
Undocumented |
Instance Variable | filename |
Undocumented |
Instance Variable | name |
Undocumented |
Property | eos |
Are we at the end of the stream? |
Instance Variable | _iter |
Undocumented |
Instance Variable | _pushed |
Undocumented |
Undocumented
Parameters | |
generator:t.Iterable[ | Undocumented |
name:t.Optional[ | Undocumented |
filename:t.Optional[ | Undocumented |
Go one token ahead and return the old one. Use the built-in :func:`next` instead of calling this directly.
Returns | |
Token | Undocumented |
Perform the token test and return the token if it matched. Otherwise the return value is `None`.
Parameters | |
expr:str | Undocumented |
Returns | |
t.Optional[ | Undocumented |