This commit refactors the PartGenerator to use the newly introduced Token::isLast property. See gh-28006