def end_rule_definition(self): """End defining a rule.""" # Make sure a rule is being defined at the moment. if not self._current_rule_name: raise CompilerError("Cannot end defining a rule when" \ " no rule is being defined.") # Make sure that no other rule has been defined with this name. if self._current_rule_name in self._rule_definitions: raise CompilerError("Rule '%s' defined more than once." % \ self._current_rule_name) # If this rule has not been used before, register it. if self._current_rule_name not in self._rules: self._rules.append(self._current_rule_name) if self._current_rule_export: self._export_rules.append(self._current_rule_name) self._rule_definitions[self._current_rule_name] = \ self._current_rule_definition self._current_rule_name = None self._current_rule_export = None self._current_rule_definition = None