This program evaluates logic expressions out of a textfile with Reveresed Polish Notation (RPN) syntax.
Example world file:
wind and red have the value of 1, sun and rain 0 since they are prefixed by "/".
Here's the syntax to run the program: "python log.py myworld.world".
It quits when an empty expression occurs.
C:\Python26>python log.py myworld.world
Logical Expression: rain sun &
Logical Expression: sun red |
Logical Expression: sun wind ^
Logical Expression: winter sun &
*** Error while evaluating: Bad name: 'winter'.
Logical Expression: sun red
*** Error while evaluating: Unbalanced expression: 'sun red'.
Logical Expression: sun red red |
*** Error while evaluating: Unbalanced expression: 'sun red red |'.
Find the source code here.