[Zope-Checkins] CVS: Zope/lib/python/Products/PluginIndexes/TextIndexNG/queryparser - Stack.py:1.1.2.1

Andreas Jung andreas@digicool.com
Tue, 15 Jan 2002 21:57:32 -0500


Update of /cvs-repository/Zope/lib/python/Products/PluginIndexes/TextIndexNG/queryparser
In directory cvs.zope.org:/tmp/cvs-serv19348

Added Files:
      Tag: ajung-textindexng-branch
	Stack.py 
Log Message:
added


=== Added File Zope/lib/python/Products/PluginIndexes/TextIndexNG/queryparser/Stack.py ===
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# 
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# 
##############################################################################


class StackException(Exception): pass

class Stack:
    """ dumb stack implementation for queryparser """

    def __init__(self):
        self.lst = []

    def push(self,item):
        self.lst.append(item)

    def pop(self):

        if len(self.lst) == 0:
            raise StackException,'stack empty'

        item = self.lst[-1]
        self.lst = self.lst[:-1]

        return item

def test():

    s = Stack()
    s.push('a')
    s.push('b')

    while 1:
        print s.pop()



if __name__=='__main__':
    test()