1 //===- ScriptLexer.h --------------------------------------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #ifndef LLD_ELF_SCRIPT_LEXER_H
10 #define LLD_ELF_SCRIPT_LEXER_H
12 #include "lld/Common/LLVM.h"
13 #include "llvm/ADT/StringRef.h"
14 #include "llvm/Support/MemoryBufferRef.h"
21 explicit ScriptLexer(MemoryBufferRef mb
);
23 void setError(const Twine
&msg
);
24 void tokenize(MemoryBufferRef mb
);
25 StringRef
skipSpace(StringRef s
);
31 bool consume(StringRef tok
);
32 void expect(StringRef expect
);
33 bool consumeLabel(StringRef tok
);
34 std::string
getCurrentLocation();
35 MemoryBufferRef
getCurrentMB();
37 std::vector
<MemoryBufferRef
> mbs
;
38 std::vector
<StringRef
> tokens
;
42 size_t lastLineNumber
= 0;
43 size_t lastLineNumberOffset
= 0;
46 void maybeSplitExpr();
48 size_t getLineNumber();
49 size_t getColumnNumber();
52 } // namespace lld::elf