mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-28 22:24:28 +00:00
implement .include in the lexer/parser instead of passing it into the streamer.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75896 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -1168,21 +1168,27 @@ bool AsmParser::ParseDirectiveDarwinLsym() {
|
||||
/// ParseDirectiveInclude
|
||||
/// ::= .include "filename"
|
||||
bool AsmParser::ParseDirectiveInclude() {
|
||||
const char *Str;
|
||||
|
||||
if (Lexer.isNot(asmtok::String))
|
||||
return TokError("expected string in '.include' directive");
|
||||
|
||||
Str = Lexer.getCurStrVal();
|
||||
|
||||
std::string Filename = Lexer.getCurStrVal();
|
||||
SMLoc IncludeLoc = Lexer.getLoc();
|
||||
Lexer.Lex();
|
||||
|
||||
if (Lexer.isNot(asmtok::EndOfStatement))
|
||||
return TokError("unexpected token in '.include' directive");
|
||||
|
||||
Lexer.Lex();
|
||||
|
||||
Out.SwitchInputAssemblyFile(Str);
|
||||
// Strip the quotes.
|
||||
Filename = Filename.substr(1, Filename.size()-2);
|
||||
|
||||
// Attempt to switch the lexer to the included file before consuming the end
|
||||
// of statement to avoid losing it when we switch.
|
||||
if (Lexer.EnterIncludeFile(Filename)) {
|
||||
Lexer.PrintMessage(IncludeLoc,
|
||||
"Could not find include file '" + Filename + "'",
|
||||
"error");
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user