diff options
author | Ted Kremenek <kremenek@apple.com> | 2008-11-20 16:32:22 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2008-11-20 16:32:22 +0000 |
commit | 31aba425a01c8c957e662ccfaa71f923d0f0932a (patch) | |
tree | 8992bb562cddd652a7744c1e47002d8c36570264 /lib/Lex/PTHLexer.cpp | |
parent | 8ba10745f525467e91bbaec21044bf4d9017a988 (diff) |
PTHLexer:
- Rename 'CurToken' and 'LastToken' to 'CurTokenIdx' and 'LastTokenIdx'
respectively.
- Add helper methods GetToken(), AdvanceToken(), AtLastToken() to abstract away
details of the token stream. This also allows us to easily replace their
implementation later.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59733 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/PTHLexer.cpp')
-rw-r--r-- | lib/Lex/PTHLexer.cpp | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/lib/Lex/PTHLexer.cpp b/lib/Lex/PTHLexer.cpp index 4e975d9f48..16aca4aacb 100644 --- a/lib/Lex/PTHLexer.cpp +++ b/lib/Lex/PTHLexer.cpp @@ -20,19 +20,19 @@ PTHLexer::PTHLexer(Preprocessor& pp, SourceLocation fileloc, const Token *TokArray, unsigned NumTokens) : PreprocessorLexer(&pp, fileloc), Tokens(TokArray), - LastToken(NumTokens - 1), - CurToken(0) { + LastTokenIdx(NumTokens - 1), + CurTokenIdx(0) { assert(NumTokens >= 1); - assert(Tokens[LastToken].is(tok::eof)); + assert(Tokens[LastTokenIdx].is(tok::eof)); } void PTHLexer::Lex(Token& Tok) { LexNextToken: - if (CurToken == LastToken) { + if (AtLastToken()) { if (ParsingPreprocessorDirective) { ParsingPreprocessorDirective = false; - Tok = Tokens[LastToken]; + Tok = GetToken(); Tok.setKind(tok::eom); MIOpt.ReadToken(); return; @@ -45,7 +45,7 @@ LexNextToken: return; } - Tok = Tokens[CurToken]; + Tok = GetToken(); // Don't advance to the next token yet. Check if we are at the // start of a new line and we're processing a directive. If so, we @@ -58,7 +58,7 @@ LexNextToken: } // Advance to the next token. - ++CurToken; + AdvanceToken(); if (Tok.is(tok::hash)) { if (Tok.isAtStartOfLine() && !LexingRawMode) { @@ -80,7 +80,7 @@ LexNextToken: } void PTHLexer::setEOF(Token& Tok) { - Tok = Tokens[LastToken]; + Tok = Tokens[LastTokenIdx]; } void PTHLexer::DiscardToEndOfLine() { @@ -88,19 +88,11 @@ void PTHLexer::DiscardToEndOfLine() { "Must be in a preprocessing directive!"); // Already at end-of-file? - if (CurToken == LastToken) + if (AtLastToken()) return; // Find the first token that is not the start of the *current* line. - for ( ++CurToken; CurToken != LastToken ; ++CurToken ) - if (Tokens[CurToken].isAtStartOfLine()) + for (AdvanceToken(); !AtLastToken(); AdvanceToken()) + if (GetToken().isAtStartOfLine()) return; } - -unsigned PTHLexer::isNextPPTokenLParen() { - if (CurToken == LastToken) - return 2; - - return Tokens[CurToken].is(tok::l_paren); -} - |