//===- ScriptParser.h -------------------------------------------*- C++ -*-===//
//
//                             The LLVM Linker
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#ifndef LLD_ELF_SCRIPT_PARSER_H
#define LLD_ELF_SCRIPT_PARSER_H

#include "lld/Core/LLVM.h"
#include "llvm/ADT/StringRef.h"

namespace lld {
namespace elf {

class ScriptParserBase {
public:
  ScriptParserBase(StringRef S) : Input(S), Tokens(tokenize(S)) {}
  virtual ~ScriptParserBase() = default;

  virtual void run() = 0;

protected:
  void setError(const Twine &Msg);
  static std::vector<StringRef> tokenize(StringRef S);
  static StringRef skipSpace(StringRef S);
  bool atEOF();
  StringRef next();
  StringRef peek();
  bool skip(StringRef Tok);
  void expect(StringRef Expect);

  size_t getPos();
  void printErrorPos();

  std::vector<uint8_t> parseHex(StringRef S);

  StringRef Input;
  std::vector<StringRef> Tokens;
  size_t Pos = 0;
  bool Error = false;
};

} // namespace elf
} // namespace lld

#endif

//===- ScriptParser.h -------------------------------------------*- C++ -*-===//
//
//                             The LLVM Linker
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#ifndef LLD_ELF_SCRIPT_PARSER_H
#define LLD_ELF_SCRIPT_PARSER_H

#include "lld/Core/LLVM.h"
#include "llvm/ADT/StringRef.h"
#include <vector>

namespace lld {
namespace elf {

class ScriptParserBase {
public:
  ScriptParserBase(StringRef S) : Input(S), Tokens(tokenize(S)) {}
  virtual ~ScriptParserBase() = default;

  virtual void run() = 0;

protected:
  void setError(const Twine &Msg);
  static std::vector<StringRef> tokenize(StringRef S);
  static StringRef skipSpace(StringRef S);
  bool atEOF();
  StringRef next();
  StringRef peek();
  bool skip(StringRef Tok);
  void expect(StringRef Expect);

  size_t getPos();
  void printErrorPos();

  std::vector<uint8_t> parseHex(StringRef S);

  StringRef Input;
  std::vector<StringRef> Tokens;
  size_t Pos = 0;
  bool Error = false;
};

} // namespace elf
} // namespace lld

#endif

Fix build failure from r265600
[lld] Fix build failure from r265600


git-svn-id: f6089bf0e6284f307027cef4f64114ee9ebb0424@265603 91177308-0d34-0410-b5e6-96231b3b80d8
