lib: fix cloning of ast nodes (support regexps)

Introduce maps.