# Path: pycell/peekablestream.py
# class PeekableStream:
# 
#     def __init__(self, iterator):
#         self.iterator = iter(iterator)
#         self._fill()
# 
#     def _fill(self):
#         try:
#             self.next = next(self.iterator)
#         except StopIteration:
#             self.next = None
# 
#     def move_next(self):
#         ret = self.next
#         self._fill()
#         return ret


from pycell.peekablestream import PeekableStream
            if param[0] != "symbol":
                raise Exception(
                    "Only symbols are allowed in function parameter lists."
                    + " I found: " + str(param) + "."
                )
        return ret

    def multiple_expressions(self, sep, end):
        ret = []
        self.fail_if_at_end(end)
        typ = self.tokens.next[0]
        if typ == end:
            self.tokens.move_next()
        else:
            arg_parser = Parser(self.tokens, (sep, end))
            while typ != end:
                p = arg_parser.next_expression(None)
                if p is not None:
                    ret.append(p)
                typ = self.tokens.next[0]
                self.tokens.move_next()
                self.fail_if_at_end(end)
        return ret

    def fail_if_at_end(self, expected):
        if self.tokens.next is None:
            raise Exception("Hit end of file - expected '%s'." % expected)


def parse(tokens_iterator):

# Path: pycell/peekablestream.py
# class PeekableStream:
# 
#     def __init__(self, iterator):
#         self.iterator = iter(iterator)
#         self._fill()
# 
#     def _fill(self):
#         try:
#             self.next = next(self.iterator)
#         except StopIteration:
#             self.next = None
# 
#     def move_next(self):
#         ret = self.next
#         self._fill()
#         return ret


# Path: pycell/parser.py
from pycell.peekablestream import PeekableStream

            if param[0] != "symbol":
                raise Exception(
                    "Only symbols are allowed in function parameter lists."
                    + " I found: " + str(param) + "."
                )
        return ret

    def multiple_expressions(self, sep, end):
        ret = []
        self.fail_if_at_end(end)
        typ = self.tokens.next[0]
        if typ == end:
            self.tokens.move_next()
        else:
            arg_parser = Parser(self.tokens, (sep, end))
            while typ != end:
                p = arg_parser.next_expression(None)
                if p is not None:
                    ret.append(p)
                typ = self.tokens.next[0]
                self.tokens.move_next()
                self.fail_if_at_end(end)
        return ret

    def fail_if_at_end(self, expected):
        if self.tokens.next is None:
            raise Exception("Hit end of file - expected '%s'." % expected)


def parse(tokens_iterator):

    parser = Parser(PeekableStream(tokens_iterator), ";")