  Automatic programming (AP) is an important area of Machine Learning (ML)
where computer programs are generated automatically. Swarm Programming (SP), a
newly emerging research area in AP, automatically generates the computer
programs using Swarm Intelligence (SI) algorithms. This paper presents two
grammar-based SP methods named as Grammatical Moth-Flame Optimizer (GMFO) and
Grammatical Whale Optimizer (GWO). The Moth-Flame Optimizer and Whale
Optimization algorithm are used as search engines or learning algorithms in
GMFO and GWO respectively. The proposed methods are tested on Santa Fe Ant
Trail, quartic symbolic regression, and 3-input multiplexer problems. The
results are compared with Grammatical Bee Colony (GBC) and Grammatical
Fireworks algorithm (GFWA). The experimental results demonstrate that the
proposed SP methods can be used in automatic computer program generation.
