3. Rule Normalization

The next step would be ordinarily to look for extractable subrules but one additional step is helpful here. The rules often have a few alternatives whose rule structure is a special case of the rule structure of the other alternatives. The best is to make those special cases equal in rule structure to the alternatives to achieve a better subrule extraction.

Of course, the change of the grammar results in the recognition of a different language. To prevent this one can either use actions like shown with pointer_type to disallow invalid structures. Or one can use 2-pass compiler and check in the next pass specifically for correctness. This approach permits to turn the rules in the first pass even more uniformous, so maybe only one superset rule remains. An additional advantage are also the already mentioned improved error messages.

Sections

My siblings (including me):