aboutsummaryrefslogtreecommitdiff
path: root/build2/test/script/parser.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-11-02 16:55:57 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-11-04 09:26:37 +0200
commit7e97d8a41f9d7b0fb82742cdd871a18804267c72 (patch)
treefa7a695b348cac0c881d1bbb0c0071fb77f34040 /build2/test/script/parser.cxx
parentd7aeb79c65338320a690b404b613f0671a65e403 (diff)
Restructure testscript parser slightly
Diffstat (limited to 'build2/test/script/parser.cxx')
-rw-r--r--build2/test/script/parser.cxx31
1 files changed, 26 insertions, 5 deletions
diff --git a/build2/test/script/parser.cxx b/build2/test/script/parser.cxx
index 27d8888..6520458 100644
--- a/build2/test/script/parser.cxx
+++ b/build2/test/script/parser.cxx
@@ -17,10 +17,29 @@ namespace build2
{
using type = token_type;
- void parser::
- pre_parse (istream& is, const path& p, script& s)
+ script parser::
+ pre_parse (testscript& ts, target& tg, const dir_path& wd)
{
- path_ = &p;
+ const path& p (ts.path ());
+ assert (!p.empty ()); // Should have been assigned.
+
+ try
+ {
+ ifdstream ifs (p);
+ return pre_parse (ifs, ts, tg, wd);
+ }
+ catch (const io_error& e)
+ {
+ error << "unable to read testscript " << p << ": " << e.what ();
+ throw failed ();
+ }
+ }
+
+ script parser::
+ pre_parse (istream& is, testscript& ts, target& tg, const dir_path& wd)
+ {
+ script s (tg, ts, wd);
+ path_ = &*s.testscripts_.insert (ts.path ()).first;
pre_parse_ = true;
@@ -36,8 +55,8 @@ namespace build2
id_map_ = &idm;
scope_ = nullptr;
- // Start location of the implied script group is the beginning of the
- // file. End location -- end of the file.
+ // Start location of the implied script group is the beginning of
+ // the file. End location -- end of the file.
//
group_->start_loc_ = location (path_, 1, 1);
@@ -47,6 +66,8 @@ namespace build2
fail (t) << "stray " << t;
group_->end_loc_ = get_location (t);
+
+ return s;
}
void parser::