Dave Jenkins wrote:
It seems that any placeholder will match, not just the one you specify in the grammar.
Below is an example program showing what I mean. I would expect that only placeholder1 would match, but both placeholder1 and placeholder2 match and produce the same output. I even tried using proto::exact to get the program to reject placeholder2, but that made no difference.
<snip> Hi Dave, You're passing an expression to a grammar to be evaluated with its transforms. That expression must match the grammar. It's undefined behavior if it doesn't, and in this case, it doesn't. "Performing the transform" falls withing UB. It would be possible to add a compile-time check to all grammars function call operators to catch this error, but that comes with a compile-time cost. -- Eric Niebler BoostPro Computing http://www.boostpro.com