IKeywords throws error

Issue #28 new
Michel Pelletier
created an issue
from pypeg2 import Keyword, IKeyword, K, IK, Enum, parse

class Operator(Keyword):
    grammar = Enum(K('and'), K('or'), K('not'))

class IOperator(IKeyword):
    grammar = Enum(IK('and'), IK('or'), IK('not'))

parse('or', Operator)   # works
parse('or', IOperator)  # fails


(.virt)michel@lev:~/dev/idealist$ python parser.py
Traceback (most recent call last):
  File "parser.py", line 11, in <module>
    parse('or', IOperator)  # fails
  File "/home/michel/dev/idealist/.virt/local/lib/python2.7/site-packages/pypeg2/__init__.py", line 663, in parse
    t, r = parser.parse(text, thing)
  File "/home/michel/dev/idealist/.virt/local/lib/python2.7/site-packages/pypeg2/__init__.py", line 788, in parse
    t, r = self._parse(t, thing, pos)
  File "/home/michel/dev/idealist/.virt/local/lib/python2.7/site-packages/pypeg2/__init__.py", line 881, in _parse
    t, r = thing.parse(self, text, pos)
TypeError: unbound method parse() must be called with IOperator instance as first argument (got Parser instance instead)