clusterfuck of declaration grammar with patterns