From ecfe33e7994d81620b332715d39ae35de7264e8b Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Thu, 16 Sep 2004 14:41:18 +0000 Subject: [PATCH] * data/lalr1.cc (Stack::Iterator, Stack::ConstIterator): Rename as... (iterator, const_iterator): these, to be more in the C++ spirit. Also, return reverse iterators so that when displaying the stack we display its bottom first. (Parser::stack_print_, Parser::reduce_print_): Match the messages from yacc.c. We should probably use vector here though. --- ChangeLog | 10 ++++++++++ data/lalr1.cc | 15 ++++++++------- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 75df12e..f9818fa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,15 @@ 2004-09-16 Akim Demaille + * data/lalr1.cc (Stack::Iterator, Stack::ConstIterator): Rename as... + (iterator, const_iterator): these, to be more in the C++ spirit. + Also, return reverse iterators so that when displaying the stack + we display its bottom first. + (Parser::stack_print_, Parser::reduce_print_): Match the messages + from yacc.c. + We should probably use vector here though. + +2004-09-16 Akim Demaille + Have more complete shift traces. * data/yacc.c, data/lalr1.c, data/glr.c: Use YY_SYMBOL_PRINT diff --git a/data/lalr1.cc b/data/lalr1.cc index f246d0b..74db24c 100644 --- a/data/lalr1.cc +++ b/data/lalr1.cc @@ -889,8 +889,8 @@ yy::]b4_parser_class_name[::rline_[] = void yy::]b4_parser_class_name[::stack_print_ () { - cdebug_ << "state stack now"; - for (StateStack::ConstIterator i = state_stack_.begin (); + cdebug_ << "Stack now"; + for (StateStack::const_iterator i = state_stack_.begin (); i != state_stack_.end (); ++i) cdebug_ << ' ' << *i; cdebug_ << std::endl; @@ -903,7 +903,7 @@ yy::]b4_parser_class_name[::reduce_print_ (int yyrule) { unsigned int yylno = rline_[yyrule]; /* Print the symbols being reduced, and their result. */ - cdebug_ << "Reducing via rule " << n_ - 1 << " (line " << yylno << "), "; + cdebug_ << "Reducing stack by rule " << n_ - 1 << " (line " << yylno << "), "; for (]b4_int_type_for([b4_prhs])[ i = prhs_[n_]; 0 <= rhs_[i]; ++i) cdebug_ << name_[rhs_[i]] << ' '; @@ -956,8 +956,9 @@ namespace yy { public: - typedef typename S::iterator Iterator; - typedef typename S::const_iterator ConstIterator; + // Hide our reversed order. + typedef typename S::reverse_iterator iterator; + typedef typename S::const_reverse_iterator const_iterator; Stack () : seq_ () { @@ -1003,8 +1004,8 @@ namespace yy return seq_.size (); } - inline ConstIterator begin () const { return seq_.begin (); } - inline ConstIterator end () const { return seq_.end (); } + inline const_iterator begin () const { return seq_.rbegin (); } + inline const_iterator end () const { return seq_.rend (); } private: -- 2.7.4