Files
clang-p2996/lld/ELF/ScriptParser.h
Rui Ueyama 9c1112d09a Use ScriptParserBase features to parse linker script expressions.
Previously, we have re-implemented utility functions such as `expect`
or `next` in LinkerScript.cpp. This patch reuses the existing
implementation that is in ScriptParser.cpp.

llvm-svn: 267255
2016-04-23 00:04:03 +00:00

50 lines
1.2 KiB
C++

//===- 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)) {}
ScriptParserBase(std::vector<StringRef> Tokens) : Input(""), Tokens(Tokens) {}
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