#!/usr/bin/perl while (<>) { s/\(= /(EQ /g; s/\b(and|or|not|forall|exists|iff|distinct)\b/\U$1\E/g; s/\$\@true\b/|\@true|/g; while (s/(.*?)([^\s()]+)//) { print $1; $x = $2; if ($x =~ /^([\*\%\-\+]|<=|NOT|EQ|AND|OR|IFF|FORALL|EXISTS|DISTINCT|\|\@true\||\d+)$/) { print "$x"; } else { $x =~ s/\|//g; print "|$x|"; } } print; }