diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2017-07-22 17:43:09 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2017-07-22 17:43:09 +0200 |
commit | 8b98a6b3fae40487ac529a7118865df6a71159ee (patch) | |
tree | dcdc0a13ccec81c087ed05a9ebfe5cac3d56b955 /build2/cc/lexer.hxx | |
parent | ade763571a19b5e222ac626a6b3bc10685e542a1 (diff) |
Implement detection of ignorable changes (whitespaces, comments)
Diffstat (limited to 'build2/cc/lexer.hxx')
-rw-r--r-- | build2/cc/lexer.hxx | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/build2/cc/lexer.hxx b/build2/cc/lexer.hxx index 65e9012..1869344 100644 --- a/build2/cc/lexer.hxx +++ b/build2/cc/lexer.hxx @@ -5,6 +5,7 @@ #ifndef BUILD2_CC_LEXER_HXX #define BUILD2_CC_LEXER_HXX +#include <libbutl/sha256.hxx> #include <libbutl/char-scanner.hxx> #include <build2/types.hxx> @@ -27,6 +28,10 @@ namespace build2 // saved from literals. The #line directive (and its shorthand notation) // is recognized to provide the logical token location. // + // While at it we also calculate the checksum of the input ignoring + // comments, whitespaces, etc. This is used to detect changes that do not + // alter the resulting token stream. + // enum class token_type { // NOTE: remember to update operator<<() if changing anything here! @@ -82,6 +87,9 @@ namespace build2 const path& name () const {return name_;} + string + checksum () const {return cs_.string ();} + // Note that it is ok to call next() again after getting eos. // token @@ -137,13 +145,21 @@ namespace build2 using base = char_scanner; xchar + peek (bool escape = true); + + xchar get (bool escape = true); void get (const xchar& peeked); + // Hashing versions. + // xchar - peek (bool escape = true); + geth (bool escape = true); + + void + geth (const xchar& peeked); private: const path name_; @@ -154,6 +170,8 @@ namespace build2 // path log_file_; optional<uint64_t> log_line_; + + sha256 cs_; }; // Diagnostics plumbing. |