class documentation

class TokenStream:

View In Hierarchy

A token stream is an iterable that yields Tokens. The parser however does not iterate over it but calls next to go one token ahead. The current active token is stored as current.
Method __next__ Go one token ahead and return the old one.
Method expect Expect a given token type and return it. This accepts the same argument as jinja2.lexer.Token.test.
Method look Look at the next token.
Method next​_if 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​_if Like next_if but only returns True or False.
Instance Variable current Undocumented
Property eos Are we at the end of the stream?
Method __bool__ Undocumented
Method __init__ Undocumented
Method __iter__ Undocumented
Method close Close the stream.
Instance Variable ​_iter Undocumented
Instance Variable ​_pushed Undocumented
Instance Variable closed Undocumented
Instance Variable filename Undocumented
Instance Variable name Undocumented
def __next__(self):

Go one token ahead and return the old one.

Use the built-in next instead of calling this directly.

Returns
TokenUndocumented
def expect(self, expr):
Expect a given token type and return it. This accepts the same argument as jinja2.lexer.Token.test.
Parameters
expr:strUndocumented
Returns
TokenUndocumented
def look(self):
Look at the next token.
Returns
TokenUndocumented
def next_if(self, expr):
Perform the token test and return the token if it matched. Otherwise the return value is None.
Parameters
expr:strUndocumented
Returns
t.Optional[Token]Undocumented
def push(self, token):
Push a token back to the stream.
Parameters
token:TokenUndocumented
def skip(self, n=1):
Got n tokens ahead.
Parameters
n:intUndocumented
def skip_if(self, expr):
Like next_if but only returns True or False.
Parameters
expr:strUndocumented
Returns
boolUndocumented
current =

Undocumented

@property
eos: bool =
Are we at the end of the stream?
def __bool__(self):

Undocumented

Returns
boolUndocumented
def __init__(self, generator, name, filename):

Undocumented

Parameters
generator:t.Iterable[Token]Undocumented
name:t.Optional[str]Undocumented
filename:t.Optional[str]Undocumented
def __iter__(self):

Undocumented

Returns
TokenStreamIteratorUndocumented
def close(self):
Close the stream.
_iter =

Undocumented

_pushed: te.Deque[Token] =

Undocumented

closed: bool =

Undocumented

filename =

Undocumented

name =

Undocumented