From 5910fbb854d7aa957091aa48a248b2de239eb558 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 18 May 2020 14:50:56 +0200 Subject: Integrate buildscript pre-parsing into recipe parsing --- libbuild2/build/script/parser.cxx | 11 +++++++---- libbuild2/build/script/parser.hxx | 4 ++-- 2 files changed, 9 insertions(+), 6 deletions(-) (limited to 'libbuild2/build/script') diff --git a/libbuild2/build/script/parser.cxx b/libbuild2/build/script/parser.cxx index d26b155..c64bcd9 100644 --- a/libbuild2/build/script/parser.cxx +++ b/libbuild2/build/script/parser.cxx @@ -20,8 +20,8 @@ namespace build2 // Pre-parse. // - void parser:: - pre_parse (istream& is, const path_name& pn, uint64_t line, script& s) + script parser:: + pre_parse (istream& is, const path_name& pn, uint64_t line) { path_ = &pn; @@ -30,17 +30,20 @@ namespace build2 lexer l (is, *path_, line, lexer_mode::command_line); set_lexer (&l); + script s; script_ = &s; runner_ = nullptr; environment_ = nullptr; - script_->start_loc = location (*path_, line, 1); + s.start_loc = location (*path_, line, 1); token t (pre_parse_script ()); assert (t.type == type::eos); - script_->end_loc = get_location (t); + s.end_loc = get_location (t); + + return s; } token parser:: diff --git a/libbuild2/build/script/parser.hxx b/libbuild2/build/script/parser.hxx index a8ffb25..c88898b 100644 --- a/libbuild2/build/script/parser.hxx +++ b/libbuild2/build/script/parser.hxx @@ -30,8 +30,8 @@ namespace build2 public: parser (context& c): build2::script::parser (c) {} - void - pre_parse (istream&, const path_name&, uint64_t line, script&); + script + pre_parse (istream&, const path_name&, uint64_t line); // Recursive descent parser. // -- cgit v1.1