Added the AsmToken::Hash enum constant to MCAsmLexer.h in preparation of
supporting other targets.  Changed the code to pass MCAsmInfo to the parser
and the lexer.  Then changed the lexer to use CommentString from MCAsmInfo
instead of a literal '#' character.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81046 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/llvm-mc/AsmLexer.cpp b/tools/llvm-mc/AsmLexer.cpp
index 4dafa0e..f6be886 100644
--- a/tools/llvm-mc/AsmLexer.cpp
+++ b/tools/llvm-mc/AsmLexer.cpp
@@ -15,12 +15,14 @@
 #include "llvm/Support/SourceMgr.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Config/config.h"  // for strtoull.
+#include "llvm/MC/MCAsmInfo.h"
 #include <cerrno>
 #include <cstdio>
 #include <cstdlib>
 using namespace llvm;
 
-AsmLexer::AsmLexer(SourceMgr &SM) : SrcMgr(SM)  {
+AsmLexer::AsmLexer(SourceMgr &SM, const MCAsmInfo &_MAI) : SrcMgr(SM),
+                                                           MAI(_MAI)  {
   CurBuffer = 0;
   CurBuf = SrcMgr.getMemoryBuffer(CurBuffer);
   CurPtr = CurBuf->getBufferStart();
@@ -230,12 +232,16 @@
 StringRef AsmLexer::LexUntilEndOfStatement() {
   TokStart = CurPtr;
 
-  while (*CurPtr != '#' &&  // Start of line comment.
-         *CurPtr != ';' &&  // End of statement marker.
+  while (*CurPtr != ';' &&  // End of statement marker.
          *CurPtr != '\n' &&
          *CurPtr != '\r' &&
-         (*CurPtr != 0 || CurPtr != CurBuf->getBufferEnd()))
+         (*CurPtr != 0 || CurPtr != CurBuf->getBufferEnd())) {
+    // check for start of line comment.
+    for (const char *p = MAI.getCommentString(); *p != 0; ++p)
+      if (*CurPtr == *p)
+        break;
     ++CurPtr;
+  }
   return StringRef(TokStart, CurPtr-TokStart);
 }
 
@@ -244,6 +250,10 @@
   // This always consumes at least one character.
   int CurChar = getNextChar();
   
+  for (const char *p = MAI.getCommentString(); *p != 0; ++p)
+    if (CurChar == *p)
+      return LexLineComment();
+
   switch (CurChar) {
   default:
     // Handle identifier: [a-zA-Z_.][a-zA-Z0-9_$.@]*
@@ -289,7 +299,7 @@
     return AsmToken(AsmToken::Exclaim, StringRef(TokStart, 1));
   case '%': return AsmToken(AsmToken::Percent, StringRef(TokStart, 1));
   case '/': return LexSlash();
-  case '#': return LexLineComment();
+  case '#': return AsmToken(AsmToken::Hash, StringRef(TokStart, 1));
   case '"': return LexQuote();
   case '0': case '1': case '2': case '3': case '4':
   case '5': case '6': case '7': case '8': case '9':