Put the following operator strings into a set: & ! != == \ + and
Now dump as a string:
Now let's check to see if this string
contains any of the op strings. String containsDefine opOr, opAnd and opNot functions and then create an op table by adding
opTable.add(new Op("&", "\u2022", 2, opAnd, Op.LEFT)); opTable.add(new Op(".", "\u2022", 2, opAnd, Op.LEFT)); opTable.add(new Op("|", "+", 1, opOr, Op.LEFT)); opTable.add(new Op("+", "+", 1, opOr, Op.LEFT)); opTable.add(new Op("!", "~", 3, opNot, Op.UNARY)); opTable.add(new Op("~", "~", 3, opNot, Op.UNARY));
Now creating a parser using the opTable
This is a test of the parser. Parsing "(C|D&E)&(A&B)&!S"
Check for A, A&C&S, A&B&D&E&S, A&B&D&E&!S
Parsing "(C.D+E).(A+B).~S"
Parsing "George.Fred+Ted.~Alice"