move setMaxLength into grammar