From 435f7b3b72157e884344adbc7b62033bd08bb51c Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Thu, 29 Nov 2018 01:58:15 +0100 Subject: liblangutil: Scanner: remove superfluous sourceName field (it's in CharStream already) Also, ParserBase::sourceName() was dead code. Eliminating it should increase test coverage (how sneaky) :-) --- liblangutil/ParserBase.cpp | 5 ----- liblangutil/ParserBase.h | 1 - liblangutil/Scanner.cpp | 3 +-- liblangutil/Scanner.h | 9 +++------ 4 files changed, 4 insertions(+), 14 deletions(-) (limited to 'liblangutil') diff --git a/liblangutil/ParserBase.cpp b/liblangutil/ParserBase.cpp index c103475a..391af291 100644 --- a/liblangutil/ParserBase.cpp +++ b/liblangutil/ParserBase.cpp @@ -27,11 +27,6 @@ using namespace std; using namespace langutil; -std::shared_ptr const& ParserBase::sourceName() const -{ - return m_scanner->sourceName(); -} - int ParserBase::position() const { return m_scanner->currentLocation().start; diff --git a/liblangutil/ParserBase.h b/liblangutil/ParserBase.h index f6315351..855201e2 100644 --- a/liblangutil/ParserBase.h +++ b/liblangutil/ParserBase.h @@ -38,7 +38,6 @@ class ParserBase public: explicit ParserBase(ErrorReporter& errorReporter): m_errorReporter(errorReporter) {} - std::shared_ptr const& sourceName() const; std::shared_ptr source() const { return m_scanner->charStream(); } protected: diff --git a/liblangutil/Scanner.cpp b/liblangutil/Scanner.cpp index 5c0f356e..ac298bd5 100644 --- a/liblangutil/Scanner.cpp +++ b/liblangutil/Scanner.cpp @@ -167,10 +167,9 @@ private: }; // end of LiteralScope class -void Scanner::reset(CharStream _source, string _sourceName) +void Scanner::reset(CharStream _source) { m_source = make_shared(std::move(_source)); - m_sourceName = make_shared(std::move(_sourceName)); reset(); } diff --git a/liblangutil/Scanner.h b/liblangutil/Scanner.h index dc37745f..a1185369 100644 --- a/liblangutil/Scanner.h +++ b/liblangutil/Scanner.h @@ -91,14 +91,14 @@ class Scanner friend class LiteralScope; public: explicit Scanner(std::shared_ptr _source) { reset(std::move(_source)); } - explicit Scanner(CharStream _source = CharStream(), std::string _sourceName = "") { reset(std::move(_source), std::move(_sourceName)); } + explicit Scanner(CharStream _source = CharStream()) { reset(std::move(_source)); } std::string source() const { return m_source->source(); } std::shared_ptr charStream() noexcept { return m_source; } - /// Resets the scanner as if newly constructed with _source and _sourceName as input. - void reset(CharStream _source, std::string _sourceName); + /// Resets the scanner as if newly constructed with _source as input. + void reset(CharStream _source); void reset(std::shared_ptr _source); /// Resets scanner to the start of input. void reset(); @@ -150,8 +150,6 @@ public: std::string const& peekLiteral() const { return m_nextToken.literal; } ///@} - std::shared_ptr const& sourceName() const { return m_sourceName; } - ///@{ ///@name Error printing helper functions /// Functions that help pretty-printing parse errors @@ -242,7 +240,6 @@ private: TokenDesc m_nextToken; // desc for next token (one token look-ahead) std::shared_ptr m_source; - std::shared_ptr m_sourceName; /// one character look-ahead, equals 0 at end of input char m_char; -- cgit v1.2.3