aboutsummaryrefslogtreecommitdiff
path: root/build/lexer.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-03-02 14:48:21 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-03-02 14:48:21 +0200
commit65664ba5a6241e9c58d846cde6ed9fcbbe53d2cd (patch)
treea76f83398335b58e5043d4efe3f2e5748a3a1f56 /build/lexer.cxx
parent4a9ee48613cf5c59e071400280b62358eb79987e (diff)
Implement variable expansion
Diffstat (limited to 'build/lexer.cxx')
-rw-r--r--build/lexer.cxx37
1 files changed, 37 insertions, 0 deletions
diff --git a/build/lexer.cxx b/build/lexer.cxx
index 4e29b43..5f394fc 100644
--- a/build/lexer.cxx
+++ b/build/lexer.cxx
@@ -40,6 +40,19 @@ namespace build
{
return token (token_type::rcbrace, sep, ln, cn);
}
+ case '$':
+ {
+ mode_ = mode::variable; // The next name is lexed in the var mode.
+ return token (token_type::dollar, sep, ln, cn);
+ }
+ case '(':
+ {
+ return token (token_type::lparen, sep, ln, cn);
+ }
+ case ')':
+ {
+ return token (token_type::rparen, sep, ln, cn);
+ }
}
// The following characters are not treated as special in the
@@ -107,6 +120,24 @@ namespace build
break;
}
+ // While these extra characters are treated as the name end in
+ // the variable mode.
+ //
+ if (mode_ == mode::variable)
+ {
+ switch (c)
+ {
+ case '/':
+ {
+ done = true;
+ break;
+ }
+ }
+
+ if (done)
+ break;
+ }
+
switch (c)
{
case ' ':
@@ -115,6 +146,9 @@ namespace build
case '#':
case '{':
case '}':
+ case '$':
+ case '(':
+ case ')':
{
done = true;
break;
@@ -137,6 +171,9 @@ namespace build
break;
}
+ if (mode_ == mode::variable)
+ mode_ = mode::normal;
+
return token (lexeme, sep, ln, cn);
}