We present Hierarchical Grammatical Evolution (HGE) and its variant WHGE, two novel genotype-phenotype mapping procedures to be used in the Grammatical Evolution (GE) framework. HGE/WHGE are designed to exhibit better variational inheritance than standard GE without imposing any constraint on the structure of the genotype nor on the genetic operators. Our proposal considers the phenotype as a hierarchy of non-terminal expansions and is based on two key ideas: (i) the closer the non-terminal to be expanded to the root of the hierarchy, the larger the genotype substring determining its expansion, and
(ii) upon expansion, a non-terminal divides its genotype substring among the resulting non-terminals. We experimentally evaluate our proposals on a set of benchmark problems and show that for the majority of them WHGE outperforms GE (and its variant piGE).