aboutsummaryrefslogtreecommitdiff
path: root/build/lexer
diff options
context:
space:
mode:
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.
};