// Copyright 2017-2020 The Verible Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include "common/analysis/command_file_lexer.h"

#include <initializer_list>
#include <utility>

#include "absl/strings/string_view.h"
#include "common/lexer/lexer_test_util.h"
#include "common/text/token_info.h"
#include "gtest/gtest.h"

namespace verible {
namespace {

// Removes non-essential tokens from token output stream, such as spaces.
class FilteredCommandFileLexer : public CommandFileLexer {
 public:
  explicit FilteredCommandFileLexer(absl::string_view code)
      : CommandFileLexer(code) {}

  bool KeepSyntaxTreeTokens(const verible::TokenInfo& t) {
    switch (t.token_enum()) {
      case CFG_TK_NEWLINE:
        return false;
      default:
        return true;
    }
  }

  const verible::TokenInfo& DoNextToken() final {
    do {
      CommandFileLexer::DoNextToken();
    } while (!KeepSyntaxTreeTokens(GetLastToken()));
    return GetLastToken();
  }
};

using LexerTestData = verible::SynthesizedLexerTestData;

// Forwarding function to the template test driver function.
template <typename... Args>
static void TestLexer(Args&&... args) {
  verible::TestLexer<CommandFileLexer>(std::forward<Args>(args)...);
}

// Forwarding function to the template test driver function.
template <typename... Args>
static void TestFilteredLexer(Args&&... args) {
  verible::TestLexer<FilteredCommandFileLexer>(std::forward<Args>(args)...);
}

static const std::initializer_list<LexerTestData> kTokenTests = {
    {{CFG_TK_COMMENT, "#comment"}, {TK_EOF, "\0"}},
    {{CFG_TK_COMMAND, "waive"}, {TK_EOF, "\0"}},
    {{CFG_TK_COMMAND, "waive"},
     {ExpectedTokenInfo::kNoToken, " "},
     {CFG_TK_FLAG_WITH_ARG, "--rule="},
     {CFG_TK_ARG, "rulename"},
     {TK_EOF, "\0"}},
    {{CFG_TK_COMMAND, "waive"},
     {ExpectedTokenInfo::kNoToken, " "},
     {CFG_TK_PARAM, "parameter"},
     {TK_EOF, "\0"}},
    {{CFG_TK_ERROR, "%"}},
};

TEST(CommandLexerTest, Comments) { TestFilteredLexer(kTokenTests); }

}  // namespace
}  // namespace verible
