aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/cc/lexer.hxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2019-11-12 15:59:58 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2019-11-13 17:30:25 +0300
commit861555876837449fd8fc480845f642dab4a68b1e (patch)
tree737992e719b5b5bee5574d3cba18e21b2ecbd912 /libbuild2/cc/lexer.hxx
parent1dc4b29bb57b14bfd8f700be80224b6d865f0184 (diff)
Use path_name in cc::lexer class
Diffstat (limited to 'libbuild2/cc/lexer.hxx')
-rw-r--r--libbuild2/cc/lexer.hxx23
1 files changed, 14 insertions, 9 deletions
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<uint64_t> 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);
}
}
}