Bob Rossi <[EMAIL PROTECTED]> writes:
>> Why the #ifdef on YYLTYPE_IS_TRIVIAL? YYLTYPE_IS_TRIVIAL tells
>> us whether yyltype is trivial (i.e., does not need attention by
>> C++ storage managers), not whether it exists.
>
> OK, I need to determine if YYLTYPE is exists. What's the best way
> to do that?
b4_locations_if.
>> status = yypushparse (ctx, ch, yylval, yylloc);
> ...
> I'm not sure that I like passing all the values into yypushparse though.
> The problem is, not everyone wants to pass all the values in. We would
> force them to pass values in that they don't care about which could
> be confusing.
They always need to pass in ctx, ch, right? And the ", yylloc"
will be required if b4_locations_if says you're using locations.
So the only questionable argument will be yylval.
One way to address this issue would be to have two entry points:
status = yypushparse (ctx, ch, yylloc);
for tokens that have no semantic value, and
status = yypushparseval (ctx, ch, yylval, yylloc);
for tokens that do.
Another possibility, which will avoid a copy in some cases if semantic
values are large, is to pass a pointer:
status = yypushparse (ctx, ch, &yylval, yylloc);
where you pass a NULL pointer if the token has no semantic value. If
the copying issue is of concern, it may also make sense to pass yylloc's
address too:
status = yypushparse (ctx, ch, &yylval, &yylloc);
I don't know whether the copying concern is enough to affect
performance, though.