From 1ea33ab70f88fcfebf388a9a438e3c1e56fbdf0f Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 10 Jun 2020 10:01:45 +0200 Subject: Handle special variable names when spelled as $() rather than $ --- libbuild2/parser.hxx | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'libbuild2/parser.hxx') diff --git a/libbuild2/parser.hxx b/libbuild2/parser.hxx index 78c7d17..2db7ade 100644 --- a/libbuild2/parser.hxx +++ b/libbuild2/parser.hxx @@ -611,8 +611,9 @@ namespace build2 lexer_->mode (m, ps, nullopt, d); else // As a sanity check, make sure the mode matches the next token. Note - // that we don't check the attributes flags or the pair separator - // since they can be overridden by the lexer's mode() implementation. + // that we don't check the attributes flags, the pair separator, or + // the mode data since they can be overridden by the lexer's mode() + // implementation. // assert (replay_i_ != replay_data_.size () && replay_data_[replay_i_].mode == m); @@ -630,6 +631,18 @@ namespace build2 } } + uintptr_t + mode_data () const + { + if (replay_ != replay::play) + return lexer_->mode_data (); + else + { + assert (replay_i_ != replay_data_.size ()); + return replay_data_[replay_i_].mode_data; + } + } + void enable_attributes () { @@ -753,8 +766,12 @@ namespace build2 replay_token lexer_next () { - lexer_mode m (lexer_->mode ()); // Get it first since it may expire. - return replay_token {lexer_->next (), path_, m}; + // Get these first since the mode may expire. + // + lexer_mode m (lexer_->mode ()); + uintptr_t d (lexer_->mode_data ()); + + return replay_token {lexer_->next (), path_, m, d}; } const replay_token& -- cgit v1.1