Note: I am importing the parsec library, which overloads the >>=
(i.e. - __irshift()__
) operator.
The following Python code:
#! /usr/bin/env python
# irshift_debug.py
from parsec import *
def id(x):
"""Identity parser."""
return string("").result(x)
testp = digit() >>= id
print(testp.parse("5"))
yields:
$ ./irshift_debug.py
File "./irshift_debug.py", line 9
testp = digit() >>= id
^
SyntaxError: invalid syntax
But, if I change the offending line to:
testp = digit().bind(id)
then I get:
$ ./irshift_debug.py
5
as expected.
I thought that >>=
was the infix equivalent of bind()
;
is that incorrect?
It is a design mistake.
I have turned to use >=
as the operator for bind()
and deprecated >>=
. A new release of parsec.py has been upload to pypi.