The mention of "flat namespace" is surprising since the flat namespace went out of style with the introduction of the two-level namespace in Mac OS X 10.3 a long time ago. But maybe that's not the part of the message we should focus on.
It builds and installs and runs fine for me on macOS High Sierra but I see that it links with flex's libfl.dylib though the port doesn't declare a dependency on it. If I use trace mode to hide MacPorts flex, then it builds and installs and runs fine while using "flex 2.5.35 Apple(flex-31)" provided by macOS High Sierra without linking to a flex library. I see that Monterey provides "flex 2.6.4 Apple(flex-34)". Perhaps that's the significant difference.
I'll modify the port to always use MacPorts flex and you can see if that helps.