From b808c255b6a9ddba085bf5646e7d20ec344f2e2d Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 28 Apr 2020 08:48:53 +0200 Subject: Initial support for ad hoc recipes (still work in progress) --- libbuild2/test/script/lexer.hxx | 40 +++++++++++++++------------------------- 1 file changed, 15 insertions(+), 25 deletions(-) (limited to 'libbuild2/test/script/lexer.hxx') diff --git a/libbuild2/test/script/lexer.hxx b/libbuild2/test/script/lexer.hxx index 5763e3b..452e794 100644 --- a/libbuild2/test/script/lexer.hxx +++ b/libbuild2/test/script/lexer.hxx @@ -7,7 +7,7 @@ #include #include -#include +#include #include @@ -17,9 +17,9 @@ namespace build2 { namespace script { - struct lexer_mode: build2::lexer_mode + struct lexer_mode: build2::script::lexer_mode { - using base_type = build2::lexer_mode; + using base_type = build2::script::lexer_mode; enum { @@ -27,22 +27,18 @@ namespace build2 first_token, // Expires at the end of the token. second_token, // Expires at the end of the token. variable_line, // Expires at the end of the line. - command_expansion, - here_line_single, - here_line_double, description_line // Expires at the end of the line. }; lexer_mode () = default; lexer_mode (value_type v): base_type (v) {} - lexer_mode (base_type v): base_type (v) {} + lexer_mode (build2::lexer_mode v): base_type (v) {} }; - class lexer: public build2::lexer + class lexer: public build2::script::lexer { public: - using base_lexer = build2::lexer; - using base_mode = build2::lexer_mode; + using base_lexer = build2::script::lexer; // Note that neither the name nor escape arguments are copied. // @@ -52,28 +48,25 @@ namespace build2 const char* escapes = nullptr) : base_lexer (is, name, 1 /* line */, nullptr /* escapes */, - false /* set_mode */) + false /* set_mode */, + redirect_aliases) { mode (m, '\0', escapes); } virtual void - mode (base_mode, + mode (build2::lexer_mode, char = '\0', - optional = nullopt) override; - - // Number of quoted (double or single) tokens since last reset. - // - size_t - quoted () const {return quoted_;} - - void - reset_quoted (size_t q) {quoted_ = q;} + optional = nullopt, + uintptr_t = 0) override; virtual token next () override; - protected: + public: + static redirect_aliases_type redirect_aliases; + + private: token next_line (); @@ -82,9 +75,6 @@ namespace build2 virtual token word (state, bool) override; - - protected: - size_t quoted_; }; } } -- cgit v1.1