Hi,

although the second solution is simpler, I'd go with the first one.
As soon as you plan to extend the grammar, for example by allowing user
defined types or expressions as initialization-value, you'll run into
trouble:

    // parser has no idea if `mytype` requires an INT_CONST
    mytype x = 23
 
    // ensuring type-compatibility makes grammar quite complicated
    float f = 23.5 + 'a'

It's a good practice to keep grammar rather general and deal with the
semantics (like type-compatibility) in a later semantic-phase.

Cheers,
Matthias


_______________________________________________
help-bison@gnu.org https://lists.gnu.org/mailman/listinfo/help-bison

Reply via email to