implement ast_waitfordigit() and ast_readstring() in terms