Logo Search packages:      
Sourcecode: yapps2 version File versions  Download package

def runtime::Scanner::token (   self,
  i,
  restrict = None 
)

Get the i'th token in the input.

If i is one past the end, then scan for another token.

Args:

restrict : [token, ...] or None; if restrict is None, then any
token is allowed.  You may call token(i) more than once.
However, the restrict set may never be larger than what was
passed in on the first call to token(i).

Definition at line 109 of file runtime.py.

00109                                      :
        """Get the i'th token in the input.

        If i is one past the end, then scan for another token.
        
        Args:

        restrict : [token, ...] or None; if restrict is None, then any
        token is allowed.  You may call token(i) more than once.
        However, the restrict set may never be larger than what was
        passed in on the first call to token(i).
        
        """
        if i == len(self.tokens):
            self.scan(restrict)
        if i < len(self.tokens):
            # Make sure the restriction is more restricted.  This
            # invariant is needed to avoid ruining tokenization at
            # position i+1 and higher.
            if restrict and self.restrictions[i]:
                for r in restrict:
                    if r not in self.restrictions[i]:
                        raise NotImplementedError("Unimplemented: restriction set changed")
            return self.tokens[i]
        raise NoMoreTokens()
    
    def __repr__(self):


Generated by  Doxygen 1.6.0   Back to index