[Tutor] Intro to CS (boolean.py)
Sun, 14 Oct 2001 17:39:30 -0700 (PDT)
I've written a small "propositional logic" parser class that you might
I wrote it as an experiment with the Spark parser-generator a month ago. I
haven't been working on it for a while now, and you're welcome to use the
parser if it's useful for you.
Here's a small sample of what it does:
[dyoo@tesuque propositions-0.2]$ python parser.py
This is a small test of the propositional parser.
Enter propositional phrases at the prompt. To quit, type "quit" at
Examples of some phrases:
jack and jill
rock and rolling implies not moss
[ParserTest] >>> a and not b or c
or[and[a, not[b]], c]
The parser tries to be nice by allowing both English and "C"-ish syntax,
and sticks with precedence rules to reduce the number of parentheses
needed to disambiguate the expressions.
I actually have an updated version 0.3 on my laptop that should work
better than what's on the web site, and I'll put it up tonight when I get
the chance. (Version 0.2 is actually a little broken: it has a logic bug
that I should investigate.)
Hope this helps!