partially working ruby rewrite of a recursive scheme regex parser