modify search algorithm

use the stack to record NFA state