home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Club Amiga de Montreal - CAM
/
CAM_CD_1.iso
/
files
/
488.lha
/
Bool_Parser
/
Boolean_Parse.Doc
< prev
next >
Wrap
Text File
|
1991-03-05
|
2KB
|
92 lines
Boolean.c Source code for boolean expression parser.
Boolean Executable ...
Truth.c Source code for Truth Table Generator
Truth Executable ...
Boolean: A recursive descent boolean expression parser.
Boolean accepts literal arguments such as 1|1, 0&1&(1|-1) etc...
It will parse and evaluate them.
Run boolean with "boolean [expression_1] [expression_2] ..."
Example: To evaluate (-1&0) type:
boolean (-1&0)
--------------------------------------------------------------------
Valid Operations:
The following are supported:
- Not
& And
| Or
@ X-Or
* Nand
+ Nor
====================================================================
Truth: A recursive descent boolean expression parser & truth table
generator.
Truth functions like boolean except for the fact that truth generates
a truth table. Integer literals are valid but nothing meaningful
will be generated if there are no variables in the expression.
Truth A Should generate:
A Value
-------------------------------------
0 0
1 1
Truth -A Should generate:
A Value
-------------------------------------
0 1
1 0
Valid Operations:
Same as for boolean with the inclusion of variables as valid arguments.
Names like ABCDEF are valid but the program sees this variable as 'A'
thus ABCDEF = ANOTHERVAR. Also, everything is shifted to uppercase
so a = A. I would suggest sticking to the 26 alphabetical variables.
======================================================================
Credit:
Herbert Schildt's"C The Complete Reference" has a section on
^^^^^^^^^^^^^^^
(Now that's a programmer's name if I ever saw one)
Expression parsing that I found to be useful. I structured some of
the code after his mathematical expression parser but not too much
of it. His parser seemed the most straightforward I had seen so
hopefully this rubbed off into mine somewhat.
Recompile the program with:
lc -L boolean
or
lc -L truth
People using compilers other than Lattice are on their own but there
should not be too many problems since none of the code is all that
tricky.
Anyways if any questions arise about anything then simply send mail
to 'pm0@beach.cis.ufl.edu'.
Hope these programs help do stuff like generate Karnaugh maps and
such. Maybe the next version will actually generate the Karnaugh
Map for you... Who knows, no promises.
Patrick Martin