Global D code blocks

Declaration blocks may appear in a non-terminal body and in the prolog. The declaration blocks in the prolog will be copied to the generated code before any semantic rule code. Declaration blocks start with the keyword APDDeclaration followed by a D code block:

APDDeclaration
{
    import other.stuff;
    
    void main()
    {
        // do something useful
    }
}

Within the body of a non-terminal, a declaration block may appear once, before any rule:

BinFloat(out real value)
{
    APDDeclaration {
        uint p = 0, val;
    }

    BitList {
        BitList(p, val);
        value = val;
    }
}

Everything that is placed in a Declaration block at the beginning of a non-terminal, will be declared and executed for all of the rules.