diff --git a/TODO b/TODO index e1bcb8d1..b857199a 100644 --- a/TODO +++ b/TODO @@ -202,6 +202,9 @@ parser::location_type. Undefine YYSTYPE and YYLTYPE. Currently all the assertions are enabled. Once we are confident in glr2.cc, let parse.assert use the same approach as in lalr1.cc. +*** debug_stream +Stop using std::cerr everywhere. + *** glr.c When glr2.cc fully replaces glr.cc, get rid of the glr.cc scaffolding in glr.c. diff --git a/data/skeletons/glr2.cc b/data/skeletons/glr2.cc index 895bf8e3..0bd51fe0 100644 --- a/data/skeletons/glr2.cc +++ b/data/skeletons/glr2.cc @@ -877,6 +877,14 @@ public: static glr_stack_item* asItem(T* state) { return reinterpret_cast(state); } + static const char *as_pointer_ (const glr_state *state) + { + return reinterpret_cast(state); + } + static char *as_pointer_ (glr_state *state) + { + return reinterpret_cast(state); + } /** Preceding state in this stack */ std::ptrdiff_t yypred; union { @@ -1285,7 +1293,7 @@ glr_state* glr_state::pred () {]b4_parse_assert_if([[ check_ ();]])[ YY_IGNORE_NULL_DEREFERENCE_BEGIN - return yypred ? &(asItem (this) - yypred)->getState () : YY_NULLPTR; + return yypred ? &asItem (as_pointer_ (this) - yypred)->getState () : YY_NULLPTR; YY_IGNORE_NULL_DEREFERENCE_END } @@ -1293,14 +1301,14 @@ const glr_state* glr_state::pred () const {]b4_parse_assert_if([[ check_ ();]])[ YY_IGNORE_NULL_DEREFERENCE_BEGIN - return yypred ? &(asItem (this) - yypred)->getState () : YY_NULLPTR; + return yypred ? &asItem (as_pointer_ (this) - yypred)->getState () : YY_NULLPTR; YY_IGNORE_NULL_DEREFERENCE_END } void glr_state::setPred (const glr_state* state) {]b4_parse_assert_if([[ check_ ();]])[ - yypred = state ? asItem(this) - asItem(state) : 0; + yypred = state ? as_pointer_ (this) - as_pointer_ (state) : 0; } semantic_option* glr_state::firstVal () diff --git a/examples/c++/glr/c++-types.test b/examples/c++/glr/c++-types.test index 6f55c8ab..a814d363 100644 --- a/examples/c++/glr/c++-types.test +++ b/examples/c++/glr/c++-types.test @@ -30,8 +30,6 @@ run 0 "\ 5.0-6: (T, x, y) 7.0-4: =(x, y)" -exit 77 - cat >input <