aboutsummaryrefslogtreecommitdiff
path: root/build2/lexer
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-04-02 12:28:56 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-04-02 12:28:56 +0200
commit4bf42322fdd5dd7e01a3f61272bccc4a66a5585f (patch)
tree158d5f6c960b94923f573bf95d4ee970e87487b6 /build2/lexer
parent1214dffc272f6f0ffee4e8ec203804b21023930d (diff)
Add attribute syntax infrastructure
Diffstat (limited to 'build2/lexer')
-rw-r--r--build2/lexer26
1 files changed, 15 insertions, 11 deletions
diff --git a/build2/lexer b/build2/lexer
index 001d52c..c856344 100644
--- a/build2/lexer
+++ b/build2/lexer
@@ -42,32 +42,31 @@ namespace build2
void (*processor) (token&, const lexer&) = nullptr)
: char_scanner (is), fail (name), processor_ (processor), sep_ (false)
{
- mode_.push (lexer_mode::normal);
+ mode (lexer_mode::normal);
}
const path&
name () const {return fail.name_;}
- // Note: sets mode for the next token. If mode is pairs, then
- // the second argument specifies the separator character.
+ // Note: sets mode for the next token. If mode is pairs, then the second
+ // argument specifies the separator character.
//
void
- mode (lexer_mode m, char pair_separator = '=')
+ mode (lexer_mode m, char pair_separator = '\0')
{
- mode_.push (m);
- pair_separator_ = pair_separator;
+ state_.push (state{m, pair_separator});
}
// Expire the current mode early.
//
void
- expire_mode () {mode_.pop ();}
+ expire_mode () {state_.pop ();}
lexer_mode
- mode () const {return mode_.top ();}
+ mode () const {return state_.top ().mode;}
char
- pair_separator () const {return pair_separator_;}
+ pair_separator () const {return state_.top ().pair_separator;}
// Scanner. Note that it is ok to call next() again after getting eos.
//
@@ -123,8 +122,13 @@ namespace build2
void (*processor_) (token&, const lexer&);
- std::stack<lexer_mode> mode_;
- char pair_separator_;
+ struct state
+ {
+ lexer_mode mode;
+ char pair_separator;
+ };
+ std::stack<state> state_;
+
bool sep_; // True if we skipped spaces in peek().
};
}