AST: add grep

Works the same as map, it seems. Added base class for them under "Term",
which seems to make sense, but I am not sold on the naming.