Simplify logic for extracting tokens from grammar