Generate regex from any context-free grammar (with limited nesting level)