aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-06-29 21:58:22 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-06-29 21:58:22 +0000
commit383a4a8db04456b8e5a59a35b3f967c4aa9c90cf (patch)
tree9ee6e10aeace05240e9201e81b5394480075c8c2 /tools
parent099879687f898bdad5d5ff4d74efe0c2e5e284d1 (diff)
downloadexternal_llvm-383a4a8db04456b8e5a59a35b3f967c4aa9c90cf.zip
external_llvm-383a4a8db04456b8e5a59a35b3f967c4aa9c90cf.tar.gz
external_llvm-383a4a8db04456b8e5a59a35b3f967c4aa9c90cf.tar.bz2
llvm-mc: Recognize C++ style comments.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74462 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r--tools/llvm-mc/AsmLexer.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/tools/llvm-mc/AsmLexer.cpp b/tools/llvm-mc/AsmLexer.cpp
index f871d06..931f3b2 100644
--- a/tools/llvm-mc/AsmLexer.cpp
+++ b/tools/llvm-mc/AsmLexer.cpp
@@ -109,8 +109,11 @@ asmtok::TokKind AsmLexer::LexPercent() {
/// LexSlash: Slash: /
/// C-Style Comment: /* ... */
asmtok::TokKind AsmLexer::LexSlash() {
- if (*CurPtr != '*')
- return asmtok::Slash;
+ switch (*CurPtr) {
+ case '*': break; // C style comment.
+ case '/': return ++CurPtr, LexLineComment();
+ default: return asmtok::Slash;
+ }
// C Style comment.
++CurPtr; // skip the star.
@@ -129,8 +132,9 @@ asmtok::TokKind AsmLexer::LexSlash() {
}
}
-/// LexHash: Comment: #[^\n]*
-asmtok::TokKind AsmLexer::LexHash() {
+/// LexLineComment: Comment: #[^\n]*
+/// : //[^\n]*
+asmtok::TokKind AsmLexer::LexLineComment() {
int CurChar = getNextChar();
while (CurChar != '\n' && CurChar != '\n' && CurChar != EOF)
CurChar = getNextChar();
@@ -281,7 +285,7 @@ asmtok::TokKind AsmLexer::LexToken() {
return asmtok::Exclaim;
case '%': return LexPercent();
case '/': return LexSlash();
- case '#': return LexHash();
+ case '#': return LexLineComment();
case '"': return LexQuote();
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':