see AS_LongFormula.php -- unfinished, untested