def remove_duplicate_templates(self):
    """Remove duplicate templates from the grammar."""
    all_templates = []
    current_templates = []
    for template, rules in self.all_templates:
      if template not in current_templates:
        all_templates.append((template, rules))
        current_templates.append(template)
    self.all_templates = all_templates
Remove duplicate templates from the grammar.
language/gscan/data/grammar.py