aboutsummaryrefslogtreecommitdiff
path: root/build/lexer
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-12-07 12:16:29 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-12-07 12:16:29 +0200
commit8b55e8151bd69e4ef11a67aff57618193f559618 (patch)
treee420000affbf3c6d7016470649d2cc711b883c7a /build/lexer
parentc092793e74d0778b0aff653860f274c8cc31c374 (diff)
Add support for specifying minimum required build2 version
The syntax is: using build@0.1.0-a1 The idea is that we will later also use it for modules and 'build' is a special, the "build system itself" module. Also fix a problem with peeking and lexer mode switching.
Diffstat (limited to 'build/lexer')
-rw-r--r--build/lexer13
1 files changed, 12 insertions, 1 deletions
diff --git a/build/lexer b/build/lexer
index 6880d39..4a50e2a 100644
--- a/build/lexer
+++ b/build/lexer
@@ -15,6 +15,9 @@
#include <butl/char-scanner>
+#include <build/types>
+#include <build/utility>
+
#include <build/token>
#include <build/diagnostics>
@@ -43,7 +46,7 @@ namespace build
lexer (std::istream& is,
const std::string& name,
void (*processor) (token&, const lexer&) = nullptr)
- : char_scanner (is), fail (name), processor_ (processor)
+ : char_scanner (is), fail (name), processor_ (processor), sep_ (false)
{
mode_.push (lexer_mode::normal);
}
@@ -77,6 +80,13 @@ namespace build
token
next ();
+ // Peek at the first character of the next token. Return the character
+ // or 0 if the next token will be eos. Also return an indicator of
+ // whether the next token will be separated.
+ //
+ pair<char, bool>
+ peek_char ();
+
private:
token
next_impl ();
@@ -121,6 +131,7 @@ namespace build
std::stack<lexer_mode> mode_;
char pair_separator_;
+ bool sep_; // True if we skipped spaces in peek().
};
}