OpenQuizz
Une application de gestion des contenus pédagogiques
TokenStream Class Reference
Inheritance diagram for TokenStream:
Collaboration diagram for TokenStream:

Public Member Functions

def __init__ (self, generator, name, filename)
 
def __iter__ (self)
 
def __bool__ (self)
 
def eos (self)
 
def push (self, token)
 
def look (self)
 
def skip (self, n=1)
 
def next_if (self, expr)
 
def skip_if (self, expr)
 
def __next__ (self)
 
def close (self)
 
def expect (self, expr)
 

Data Fields

 name
 
 filename
 
 closed
 
 current
 

Detailed Description

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`.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  generator,
  name,
  filename 
)

Member Function Documentation

◆ __bool__()

def __bool__ (   self)

◆ __iter__()

def __iter__ (   self)

◆ __next__()

def __next__ (   self)
Go one token ahead and return the old one.

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

◆ close()

def close (   self)
Close the stream.

◆ eos()

def eos (   self)
Are we at the end of the stream?

◆ expect()

def expect (   self,
  expr 
)
Expect a given token type and return it.  This accepts the same
argument as :meth:`jinja2.lexer.Token.test`.

◆ look()

def look (   self)
Look at the next token.

◆ next_if()

def next_if (   self,
  expr 
)
Perform the token test and return the token if it matched.
Otherwise the return value is `None`.

◆ push()

def push (   self,
  token 
)
Push a token back to the stream.

◆ skip()

def skip (   self,
  n = 1 
)
Got n tokens ahead.

◆ skip_if()

def skip_if (   self,
  expr 
)
Like :meth:`next_if` but only returns `True` or `False`.

Field Documentation

◆ closed

closed

◆ current

current

◆ filename

filename

◆ name

name

The documentation for this class was generated from the following file: