From 56eb8c36b5b408e08760fa18cf893e5e8a613b7a Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 19 Oct 2016 15:01:36 +0200 Subject: Implement pre-parsing mode for subset of buildfile parsing functions --- build2/parser | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'build2/parser') diff --git a/build2/parser b/build2/parser index c51f18f..59cdac2 100644 --- a/build2/parser +++ b/build2/parser @@ -134,14 +134,19 @@ namespace build2 // parse the attribute sequence until ']' setting the 'has' flag and // storing the result on the stack. Then get the next token and, if // standalone is false, verify it is not newline/eos (i.e., there is - // something after it). Return the top of the stack. + // something after it). Return the indication of whether there are + // any attributes and their location. // - attributes& + // Note that during pre-parsing nothing is pushed into the stack and + // the returned attributes object indicates there are no attributes. + // + pair attributes_push (token&, token_type&, bool standalone = false); attributes attributes_pop () { + assert (!pre_parse_); attributes r (move (attributes_.top ())); attributes_.pop (); return r; @@ -157,6 +162,8 @@ namespace build2 // The what argument is used in diagnostics (e.g., "expected // instead of ...". // + // In pre-parse mode always return empty list of names. + // names parse_names (token& t, token_type& tt, bool chunk = false, @@ -400,6 +407,7 @@ namespace build2 assert (replay_ == replay::stop); replay_data_ = move (d); + replay_i_ = 0; replay_ = replay::play; } -- cgit v1.1