From 861555876837449fd8fc480845f642dab4a68b1e Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Tue, 12 Nov 2019 15:59:58 +0300 Subject: Use path_name in cc::lexer class --- libbuild2/cc/lexer.hxx | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'libbuild2/cc/lexer.hxx') diff --git a/libbuild2/cc/lexer.hxx b/libbuild2/cc/lexer.hxx index cb2b3a5..c7da135 100644 --- a/libbuild2/cc/lexer.hxx +++ b/libbuild2/cc/lexer.hxx @@ -63,9 +63,12 @@ namespace build2 // Logical position. // - path file; - uint64_t line = 0; - uint64_t column = 0; + // Note that file is a shallow pointer to the state maintained by the + // lexer. + // + const path_name* file = nullptr; + uint64_t line = 0; + uint64_t column = 0; // Physical position in the stream, currently only for identifiers. // @@ -80,13 +83,15 @@ namespace build2 class lexer: protected butl::char_scanner { public: - lexer (ifdstream& is, const path& name) + lexer (ifdstream& is, const path_name& name) : char_scanner (is, false), name_ (name), fail ("error", &name_), - log_file_ (name) {} + log_file_ (name) + { + } - const path& + const path_name& name () const {return name_;} string @@ -164,13 +169,13 @@ namespace build2 geth (const xchar& peeked); private: - const path name_; + const path_name& name_; const fail_mark fail; // Logical file and line as set by the #line directives. Note that the // lexer diagnostics still uses the physical file/lines. // - path log_file_; + path_name_value log_file_; optional log_line_; string tmp_file_; @@ -182,7 +187,7 @@ namespace build2 inline location get_location (const token& t, const void* = nullptr) { - return location (&t.file, t.line, t.column); + return location (*t.file, t.line, t.column); } } } -- cgit v1.1