Added grammar rule-detection and generation