rewrite scfg decoding