/* A truth table builder using modern compiler technology */ public class truthtable { /* Abstract Syntax Tree Classes: */ /* Each propositional sentence is represented using the following structures */ public static abstract class proposition { String syntax; // original text proposition p1, p2; // sub propositions (descendent nodes in tree) abstract boolean eval(assignment a); // SEMANTIC "evaluation" action } // end of abstract class proposition /* You define the rest of the classes here .....*/ /* --------------------------------------------------------------- */ /* semantic structures: */ /* an assignment associates a list of letters with a list of booleans */ public static class assignment { private strlst letters; // propositional letters private vallst values; // corresponding values /* the constructor takes a string such as "1011", adds leading "0"'s so the length of the string is same as number of letters, then builds a list of corresponding booleans: */ assignment(strlst l, String binseq) { letters = l; int llength = letters.length(); /* fill string with leading 0's: */ while (binseq.length() < llength) binseq = "0" + binseq; strlst tracker1 = letters; vallst tracker2 = new vallst(false,null); // dummy header values = tracker2; // rememeber where it starts! int len = binseq.length(); for(int i=0; i