aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/lexer.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2020-03-20 08:40:59 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2020-03-20 08:40:59 +0200
commitce29e3d72ded432b9ac9354ac92c588142de9b89 (patch)
treefd7acd2d0e34b10315b5572f98619dbbf285c177 /libbuild2/lexer.cxx
parentaeda0dedb2cdb0980d976ae92e1672476b62d7ed (diff)
Lexer support for default value assignment (?=)
Note: not yet supported in the parser.
Diffstat (limited to 'libbuild2/lexer.cxx')
-rw-r--r--libbuild2/lexer.cxx23
1 files changed, 17 insertions, 6 deletions
diff --git a/libbuild2/lexer.cxx b/libbuild2/lexer.cxx
index 9989d1e..5ffac54 100644
--- a/libbuild2/lexer.cxx
+++ b/libbuild2/lexer.cxx
@@ -43,8 +43,8 @@ namespace build2
case lexer_mode::normal:
{
a = true;
- s1 = ":<>=+ $(){}#\t\n";
- s2 = " = ";
+ s1 = ":<>=+? $(){}#\t\n";
+ s2 = " == ";
break;
}
case lexer_mode::value:
@@ -182,6 +182,8 @@ namespace build2
// NOTE: remember to update mode(), next_eval() if adding any new special
// characters.
+ // These are special in all the modes handled by this function.
+ //
switch (c)
{
case '\n':
@@ -248,11 +250,10 @@ namespace build2
}
}
- // The following characters are special in the normal, variable, and
+ // The following characters are special in the normal and
// switch_expressions modes.
//
if (m == lexer_mode::normal ||
- m == lexer_mode::variable ||
m == lexer_mode::switch_expressions ||
m == lexer_mode::case_patterns)
{
@@ -262,9 +263,9 @@ namespace build2
}
}
- // The following characters are special in the normal and variable modes.
+ // The following characters are special in the normal mode.
//
- if (m == lexer_mode::normal || m == lexer_mode::variable)
+ if (m == lexer_mode::normal)
{
switch (c)
{
@@ -285,6 +286,16 @@ namespace build2
get ();
return make_token (type::append);
}
+ break;
+ }
+ case '?':
+ {
+ if (peek () == '=')
+ {
+ get ();
+ return make_token (type::default_assign);
+ }
+ break;
}
}
}