From 70256514a09e4692c6839f5c2b21b7ec9c1055bd Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 30 Mar 2015 12:19:44 +0200 Subject: Add support for configurable pair separator, use @ instead of = in buildspec --- build/lexer | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'build/lexer') diff --git a/build/lexer b/build/lexer index 98a1390..5f91dc4 100644 --- a/build/lexer +++ b/build/lexer @@ -20,8 +20,8 @@ namespace build // them in the variable values, e.g., 'foo = g++'. In contrast, // in the variable mode, we restrict certain character (e.g., /) // from appearing in the name. The pairs mode is just like value - // except that we split names separated by '='. The pairs mode must - // be set manually. + // except that we split names separated by the pair character. + // The pairs mode must be set manually. // enum class lexer_mode {normal, value, variable, pairs}; @@ -30,10 +30,15 @@ namespace build public: lexer (std::istream& is, const std::string& name): is_ (is), fail (name) {} - // Note: sets mode for the next token. + // Note: sets mode for the next token. If mode is pairs, then + // the second argument specifies the separator character. // void - mode (lexer_mode m) {next_mode_ = m;} + mode (lexer_mode m, char pair_separator = '=') + { + next_mode_ = m; + pair_separator_ = pair_separator; + } lexer_mode mode () const {return mode_;} @@ -127,6 +132,7 @@ namespace build bool eos_ {false}; lexer_mode mode_ {lexer_mode::normal}; + char pair_separator_; lexer_mode next_mode_ {lexer_mode::normal}; // Switch to for next token. lexer_mode prev_mode_; // Return to after current mode expires. }; -- cgit v1.1