Require 'grammar' in a more appropriate place.
Decrease duplication by extracting common code into module.
Correct correlation of tokens to grammar paths for modifiers.
Refactored for improved clarity and/or less code.