Lab11 solutions (UCB CS61A@2021 Fall)
Context
Problem 1
Important: Your code for this part should go in
buffer.py
.Your job in this part is to implement the
current
andpop_first
methods of theBuffer
class.
current
should return the current token of the current line we’re on in theBuffer
instance without removing it. If there are no more tokens in the current line, thencurrent
should move onto the next valid line, and return the first token of this line. If there are no more tokens left to return from the entire source (we’ve reached the end of all input lines), thencurrent
should returnNone
(this logic is already provided for you in theexcept StopIteration
block).