improve tree parsing with grammar rule mask