Building truth tables

andrea kerny404 at gmail.com
Fri Oct 24 12:53:35 CEST 2008


On 26 Set, 20:01, "Aaron \"Castironpi\" Brady" <castiro... at gmail.com>
wrote:
>
> Good idea.  If you want prefixed operators: 'and( a, b )' instead of
> 'a and b', you'll have to write your own.  ('operator.and_' is bitwise
> only.)  It may be confusing to mix prefix with infix: 'impl( a and b,
> c )', so you may want to keep everything prefix, but you can still use
> table( f, n ) like Tim said.

After a while I'm back, thanks a lot, the truth table creator works,
now I just want to parse some strings to make it easier to use.

Like

(P \/ Q) -> S == S

Must return a truth table 2^3 lines...

I'm using pyparsing and this should be really simple, but it doesn't
allow me to recurse and that makes mu stuck.
The grammar BNF is:

Var :: = [A..Z]
Exp ::= Var | !Exp  | Exp \/ Exp | Exp -> Exp | Exp /\ Exp | Exp ==
Exp

I tried different ways but I don't find a smart way to get from the
recursive bnf grammar to the implementation in pyparsing...
Any hint?



More information about the Python-list mailing list