From fa717b42574fe1a7c0c07393f6790595d39c33ae Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 6 May 2020 06:58:11 +0200 Subject: Add lexer mode data --- libbuild2/lexer.cxx | 4 ++-- libbuild2/lexer.hxx | 4 +++- libbuild2/test/script/lexer.cxx | 4 ++-- libbuild2/test/script/lexer.hxx | 3 ++- 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 esc) + mode (lexer_mode m, char ps, optional 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 escapes = nullopt); + optional 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 esc) + mode (base_mode m, char ps, optional 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 = nullopt) override; + optional = nullopt, + uintptr_t = 0) override; // Number of quoted (double or single) tokens since last reset. // -- cgit v1.1