As a guy who writes compiler the answer for this is it depends on the type of parser you are using.
LL and LR parser generates different derivation, and as such it is deterministically non-deterministic, hence UB.
LL and LR parser generates different derivation, and as such it is deterministically non-deterministic, hence UB.