aboutsummaryrefslogtreecommitdiff
path: root/build/lexer
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-09-10 11:10:15 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-09-10 11:10:15 +0200
commitc5c880e5627d88ab2f7dd7596d59cf34ebba1ebb (patch)
tree806bb87344acee3bb1da454849178d9d86a10062 /build/lexer
parent5243f5b2dcfc5608bf7827454e80a16c0ce10329 (diff)
Add support for token pre-processing in lexer
Diffstat (limited to 'build/lexer')
-rw-r--r--build/lexer14
1 files changed, 12 insertions, 2 deletions
diff --git a/build/lexer b/build/lexer
index 13f28cb..6880d39 100644
--- a/build/lexer
+++ b/build/lexer
@@ -40,8 +40,13 @@ namespace build
class lexer: protected butl::char_scanner
{
public:
- lexer (std::istream& is, const std::string& name)
- : char_scanner (is), fail (name) {mode_.push (lexer_mode::normal);}
+ lexer (std::istream& is,
+ const std::string& name,
+ void (*processor) (token&, const lexer&) = nullptr)
+ : char_scanner (is), fail (name), processor_ (processor)
+ {
+ mode_.push (lexer_mode::normal);
+ }
const std::string&
name () const {return fail.name_;}
@@ -74,6 +79,9 @@ namespace build
private:
token
+ next_impl ();
+
+ token
next_eval ();
token
@@ -109,6 +117,8 @@ namespace build
private:
fail_mark fail;
+ void (*processor_) (token&, const lexer&);
+
std::stack<lexer_mode> mode_;
char pair_separator_;
};