c++: clean a few issues wrt special tokens

The C++ implementation of LAC did not skip the $undefined token,
probably because it was not exposed.  Expose it, and use clearer
names.

* data/skeletons/c++.m4: Don't define undef_token_ in yytranslate_,
but...
* data/skeletons/lalr1.cc (yy_undef_token_): here.
Use a more precise type to define yy_undef_token_ and yy_error_token_.
Unfortunately we move from a compile-time value defined via an enum to
a static const member.  Eventually we should make it constexpr.
Make LAC implementation more alike yacc.c's one.
This commit is contained in:
Akim Demaille
2019-12-01 08:03:29 +01:00
parent 9b4f0970fe
commit 94f70bd861
2 changed files with 10 additions and 7 deletions

View File

@@ -543,14 +543,13 @@ m4_define([b4_yytranslate_define],
]b4_translate[
};
const int user_token_number_max_ = ]b4_user_token_number_max[;
const token_number_type undef_token_ = ]b4_undef_token_number[;
if (t <= 0)
return yyeof_;
else if (static_cast<int> (t) <= user_token_number_max_)
return translate_table[t];
else
return undef_token_;]])[
return yy_undef_token_;]])[
}
]])