aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2020-05-06 06:58:11 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2020-05-27 08:35:29 +0200
commitfa717b42574fe1a7c0c07393f6790595d39c33ae (patch)
treeecd90d87656526d83acd45aaaeb56c3d4ef6aa98
parentca7db0a1b856909efe127d3b47b50a0144e5c2c9 (diff)
Add lexer mode data
-rw-r--r--libbuild2/lexer.cxx4
-rw-r--r--libbuild2/lexer.hxx4
-rw-r--r--libbuild2/test/script/lexer.cxx4
-rw-r--r--libbuild2/test/script/lexer.hxx3
4 files changed, 9 insertions, 6 deletions
diff --git a/libbuild2/lexer.cxx b/libbuild2/lexer.cxx
index 1e400e3..e970437 100644
--- a/libbuild2/lexer.cxx
+++ b/libbuild2/lexer.cxx
@@ -37,7 +37,7 @@ namespace build2
}
void lexer::
- mode (lexer_mode m, char ps, optional<const char*> esc)
+ mode (lexer_mode m, char ps, optional<const char*> esc, uintptr_t data)
{
bool a (false); // attributes
@@ -141,7 +141,7 @@ namespace build2
default: assert (false); // Unhandled custom mode.
}
- state_.push (state {m, a, ps, s, n, q, *esc, s1, s2});
+ state_.push (state {m, data, a, ps, s, n, q, *esc, s1, s2});
}
token lexer::
diff --git a/libbuild2/lexer.hxx b/libbuild2/lexer.hxx
index c7e96fb..6dc5027 100644
--- a/libbuild2/lexer.hxx
+++ b/libbuild2/lexer.hxx
@@ -121,7 +121,8 @@ namespace build2
virtual void
mode (lexer_mode,
char pair_separator = '\0',
- optional<const char*> escapes = nullopt);
+ optional<const char*> escapes = nullopt,
+ uintptr_t data = 0);
// Enable attributes recognition for the next token.
//
@@ -163,6 +164,7 @@ namespace build2
struct state
{
lexer_mode mode;
+ uintptr_t data;
bool attributes;
char sep_pair;
diff --git a/libbuild2/test/script/lexer.cxx b/libbuild2/test/script/lexer.cxx
index 4683bc7..1eeb0be 100644
--- a/libbuild2/test/script/lexer.cxx
+++ b/libbuild2/test/script/lexer.cxx
@@ -16,7 +16,7 @@ namespace build2
using type = token_type;
void lexer::
- mode (base_mode m, char ps, optional<const char*> esc)
+ mode (base_mode m, char ps, optional<const char*> esc, uintptr_t data)
{
bool a (false); // attributes
@@ -138,7 +138,7 @@ namespace build2
}
assert (ps == '\0');
- state_.push (state {m, a, ps, s, n, q, *esc, s1, s2});
+ state_.push (state {m, data, a, ps, s, n, q, *esc, s1, s2});
}
token lexer::
diff --git a/libbuild2/test/script/lexer.hxx b/libbuild2/test/script/lexer.hxx
index 5763e3b..4c51303 100644
--- a/libbuild2/test/script/lexer.hxx
+++ b/libbuild2/test/script/lexer.hxx
@@ -60,7 +60,8 @@ namespace build2
virtual void
mode (base_mode,
char = '\0',
- optional<const char*> = nullopt) override;
+ optional<const char*> = nullopt,
+ uintptr_t = 0) override;
// Number of quoted (double or single) tokens since last reset.
//