diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2022-10-19 19:56:05 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2022-10-20 11:24:34 +0300 |
commit | b4bcbb30d4c132618bfbc53da088bc9c223daf5c (patch) | |
tree | e11d6bdab4dfcff65fe9171549aad99b2e8ae6c7 | |
parent | d74b2a50c421bd4a0fd8753848d3796029fcff43 (diff) |
Fix parser::mode() so for peeked token on replay it returns its lexing mode
-rw-r--r-- | libbuild2/parser.hxx | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/libbuild2/parser.hxx b/libbuild2/parser.hxx index 0d1e9e2..0d7e900 100644 --- a/libbuild2/parser.hxx +++ b/libbuild2/parser.hxx @@ -696,15 +696,24 @@ namespace build2 replay_data_[replay_i_].mode == m); } + // In the replay mode return the lexing mode of the token returned by the + // subsequent next() or peek() call. + // lexer_mode mode () const { if (replay_ != replay::play) + { return lexer_->mode (); + } else { - assert (replay_i_ != replay_data_.size ()); - return replay_data_[replay_i_].mode; + assert (!peeked_ || replay_i_ != 0); + + size_t i (!peeked_ ? replay_i_ : replay_i_ - 1); + assert (i != replay_data_.size ()); + + return replay_data_[i].mode; } } |