Path: blob/main/contrib/llvm-project/lld/ELF/ScriptLexer.h
34878 views
//===- ScriptLexer.h --------------------------------------------*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#ifndef LLD_ELF_SCRIPT_LEXER_H9#define LLD_ELF_SCRIPT_LEXER_H1011#include "lld/Common/LLVM.h"12#include "llvm/ADT/StringRef.h"13#include "llvm/Support/MemoryBufferRef.h"14#include <vector>1516namespace lld::elf {1718class ScriptLexer {19public:20explicit ScriptLexer(MemoryBufferRef mb);2122void setError(const Twine &msg);23void tokenize(MemoryBufferRef mb);24StringRef skipSpace(StringRef s);25bool atEOF();26StringRef next();27StringRef peek();28void skip();29bool consume(StringRef tok);30void expect(StringRef expect);31bool consumeLabel(StringRef tok);32std::string getCurrentLocation();33MemoryBufferRef getCurrentMB();3435std::vector<MemoryBufferRef> mbs;36std::vector<StringRef> tokens;37bool inExpr = false;38size_t pos = 0;3940size_t lastLineNumber = 0;41size_t lastLineNumberOffset = 0;4243private:44void maybeSplitExpr();45StringRef getLine();46size_t getLineNumber();47size_t getColumnNumber();48};4950} // namespace lld::elf5152#endif535455