From 54b636930b9d782be934c3881b296f971203ced3 Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Mon, 25 Oct 2010 20:18:46 +0000 Subject: llvm-mc: Teach -as-lex to print the raw token string as well. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@117296 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/llvm-mc/llvm-mc.cpp | 91 +++++++++++++++++++++++++---------------------- 1 file changed, 49 insertions(+), 42 deletions(-) (limited to 'tools') diff --git a/tools/llvm-mc/llvm-mc.cpp b/tools/llvm-mc/llvm-mc.cpp index 0e98bca..9515189 100644 --- a/tools/llvm-mc/llvm-mc.cpp +++ b/tools/llvm-mc/llvm-mc.cpp @@ -194,7 +194,9 @@ static int AsLexInput(const char *ProgName) { bool Error = false; while (Lexer.Lex().isNot(AsmToken::Eof)) { - switch (Lexer.getKind()) { + AsmToken Tok = Lexer.getTok(); + + switch (Tok.getKind()) { default: SrcMgr.PrintMessage(Lexer.getLoc(), "unknown token", "warning"); Error = true; @@ -203,58 +205,63 @@ static int AsLexInput(const char *ProgName) { Error = true; // error already printed. break; case AsmToken::Identifier: - Out->os() << "identifier: " << Lexer.getTok().getString() << '\n'; + Out->os() << "identifier: " << Lexer.getTok().getString(); break; case AsmToken::Integer: - Out->os() << "int: " << Lexer.getTok().getString() << '\n'; + Out->os() << "int: " << Lexer.getTok().getString(); break; case AsmToken::Real: - Out->os() << "real: " << Lexer.getTok().getString() << '\n'; + Out->os() << "real: " << Lexer.getTok().getString(); break; case AsmToken::Register: - Out->os() << "register: " << Lexer.getTok().getRegVal() << '\n'; + Out->os() << "register: " << Lexer.getTok().getRegVal(); break; case AsmToken::String: - Out->os() << "string: " << Lexer.getTok().getString() << '\n'; + Out->os() << "string: " << Lexer.getTok().getString(); break; - case AsmToken::Amp: Out->os() << "Amp\n"; break; - case AsmToken::AmpAmp: Out->os() << "AmpAmp\n"; break; - case AsmToken::At: Out->os() << "At\n"; break; - case AsmToken::Caret: Out->os() << "Caret\n"; break; - case AsmToken::Colon: Out->os() << "Colon\n"; break; - case AsmToken::Comma: Out->os() << "Comma\n"; break; - case AsmToken::Dollar: Out->os() << "Dollar\n"; break; - case AsmToken::Dot: Out->os() << "Dot\n"; break; - case AsmToken::EndOfStatement: Out->os() << "EndOfStatement\n"; break; - case AsmToken::Eof: Out->os() << "Eof\n"; break; - case AsmToken::Equal: Out->os() << "Equal\n"; break; - case AsmToken::EqualEqual: Out->os() << "EqualEqual\n"; break; - case AsmToken::Exclaim: Out->os() << "Exclaim\n"; break; - case AsmToken::ExclaimEqual: Out->os() << "ExclaimEqual\n"; break; - case AsmToken::Greater: Out->os() << "Greater\n"; break; - case AsmToken::GreaterEqual: Out->os() << "GreaterEqual\n"; break; - case AsmToken::GreaterGreater: Out->os() << "GreaterGreater\n"; break; - case AsmToken::Hash: Out->os() << "Hash\n"; break; - case AsmToken::LBrac: Out->os() << "LBrac\n"; break; - case AsmToken::LCurly: Out->os() << "LCurly\n"; break; - case AsmToken::LParen: Out->os() << "LParen\n"; break; - case AsmToken::Less: Out->os() << "Less\n"; break; - case AsmToken::LessEqual: Out->os() << "LessEqual\n"; break; - case AsmToken::LessGreater: Out->os() << "LessGreater\n"; break; - case AsmToken::LessLess: Out->os() << "LessLess\n"; break; - case AsmToken::Minus: Out->os() << "Minus\n"; break; - case AsmToken::Percent: Out->os() << "Percent\n"; break; - case AsmToken::Pipe: Out->os() << "Pipe\n"; break; - case AsmToken::PipePipe: Out->os() << "PipePipe\n"; break; - case AsmToken::Plus: Out->os() << "Plus\n"; break; - case AsmToken::RBrac: Out->os() << "RBrac\n"; break; - case AsmToken::RCurly: Out->os() << "RCurly\n"; break; - case AsmToken::RParen: Out->os() << "RParen\n"; break; - case AsmToken::Slash: Out->os() << "Slash\n"; break; - case AsmToken::Star: Out->os() << "Star\n"; break; - case AsmToken::Tilde: Out->os() << "Tilde\n"; break; + case AsmToken::Amp: Out->os() << "Amp"; break; + case AsmToken::AmpAmp: Out->os() << "AmpAmp"; break; + case AsmToken::At: Out->os() << "At"; break; + case AsmToken::Caret: Out->os() << "Caret"; break; + case AsmToken::Colon: Out->os() << "Colon"; break; + case AsmToken::Comma: Out->os() << "Comma"; break; + case AsmToken::Dollar: Out->os() << "Dollar"; break; + case AsmToken::Dot: Out->os() << "Dot"; break; + case AsmToken::EndOfStatement: Out->os() << "EndOfStatement"; break; + case AsmToken::Eof: Out->os() << "Eof"; break; + case AsmToken::Equal: Out->os() << "Equal"; break; + case AsmToken::EqualEqual: Out->os() << "EqualEqual"; break; + case AsmToken::Exclaim: Out->os() << "Exclaim"; break; + case AsmToken::ExclaimEqual: Out->os() << "ExclaimEqual"; break; + case AsmToken::Greater: Out->os() << "Greater"; break; + case AsmToken::GreaterEqual: Out->os() << "GreaterEqual"; break; + case AsmToken::GreaterGreater: Out->os() << "GreaterGreater"; break; + case AsmToken::Hash: Out->os() << "Hash"; break; + case AsmToken::LBrac: Out->os() << "LBrac"; break; + case AsmToken::LCurly: Out->os() << "LCurly"; break; + case AsmToken::LParen: Out->os() << "LParen"; break; + case AsmToken::Less: Out->os() << "Less"; break; + case AsmToken::LessEqual: Out->os() << "LessEqual"; break; + case AsmToken::LessGreater: Out->os() << "LessGreater"; break; + case AsmToken::LessLess: Out->os() << "LessLess"; break; + case AsmToken::Minus: Out->os() << "Minus"; break; + case AsmToken::Percent: Out->os() << "Percent"; break; + case AsmToken::Pipe: Out->os() << "Pipe"; break; + case AsmToken::PipePipe: Out->os() << "PipePipe"; break; + case AsmToken::Plus: Out->os() << "Plus"; break; + case AsmToken::RBrac: Out->os() << "RBrac"; break; + case AsmToken::RCurly: Out->os() << "RCurly"; break; + case AsmToken::RParen: Out->os() << "RParen"; break; + case AsmToken::Slash: Out->os() << "Slash"; break; + case AsmToken::Star: Out->os() << "Star"; break; + case AsmToken::Tilde: Out->os() << "Tilde"; break; } + + // Print the token string. + Out->os() << " (\""; + Out->os().write_escaped(Tok.getString()); + Out->os() << "\")\n"; } // Keep output if no errors. -- cgit v1.1