diff options
| author | Chris Lattner <sabre@nondot.org> | 2007-11-19 07:43:52 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2007-11-19 07:43:52 +0000 |
| commit | 4205d25f06ba465c3e90fedf29dabfe2852e8853 (patch) | |
| tree | af2bc4de39881b6a00354eb19f79724b956d2191 /llvm/utils/TableGen/TGLexer.cpp | |
| parent | 1a26296453020edc1902b08ba121c03de9ca4692 (diff) | |
| download | bcm5719-llvm-4205d25f06ba465c3e90fedf29dabfe2852e8853.tar.gz bcm5719-llvm-4205d25f06ba465c3e90fedf29dabfe2852e8853.zip | |
Record the start of the current token, for use in error reporting.
llvm-svn: 44227
Diffstat (limited to 'llvm/utils/TableGen/TGLexer.cpp')
| -rw-r--r-- | llvm/utils/TableGen/TGLexer.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/llvm/utils/TableGen/TGLexer.cpp b/llvm/utils/TableGen/TGLexer.cpp index dd7ad6ceb10..c859604b55a 100644 --- a/llvm/utils/TableGen/TGLexer.cpp +++ b/llvm/utils/TableGen/TGLexer.cpp @@ -27,6 +27,7 @@ using namespace llvm; TGLexer::TGLexer(MemoryBuffer *StartBuf) : CurLineNo(1), CurBuf(StartBuf) { CurPtr = CurBuf->getBufferStart(); + TokStart = 0; } TGLexer::~TGLexer() { @@ -76,8 +77,7 @@ void TGLexer::PrintError(const char *ErrorLoc, const std::string &Msg) const { // Print out the line. cerr << std::string(LineStart, LineEnd) << "\n"; // Print out spaces before the carat. - const char *Pos = LineStart; - while (Pos != ErrorLoc) + for (const char *Pos = LineStart; Pos != ErrorLoc; ++Pos) cerr << (*Pos == '\t' ? '\t' : ' '); cerr << "^\n"; } @@ -122,6 +122,7 @@ int TGLexer::getNextChar() { } int TGLexer::LexToken() { + TokStart = CurPtr; // This always consumes at least one character. int CurChar = getNextChar(); @@ -238,11 +239,10 @@ int TGLexer::LexIdentifier() { /// comes next and enter the include. bool TGLexer::LexInclude() { // The token after the include must be a string. - const char *TokStart = CurPtr-7; int Tok = LexToken(); if (Tok == YYERROR) return true; if (Tok != STRVAL) { - PrintError(TokStart, "Expected filename after include"); + PrintError(getTokenStart(), "Expected filename after include"); return true; } @@ -260,7 +260,8 @@ bool TGLexer::LexInclude() { } if (NewBuf == 0) { - PrintError(TokStart, "Could not find include file '" + Filename + "'"); + PrintError(getTokenStart(), + "Could not find include file '" + Filename + "'"); return true; } |

