Generate NFA from AST.