aboutsummaryrefslogtreecommitdiff
path: root/build/lexer
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-03-30 12:19:44 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-03-30 12:19:44 +0200
commit70256514a09e4692c6839f5c2b21b7ec9c1055bd (patch)
tree453000060d5180b5ab85a4add1187a826b9289c1 /build/lexer
parentc699c956d75dfaaded5bb24c5ea16edc73588649 (diff)
Add support for configurable pair separator, use @ instead of = in buildspec
Diffstat (limited to 'build/lexer')
-rw-r--r--build/lexer14
1 files changed, 10 insertions, 4 deletions
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.
};