summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2020-02-07 15:03:30 -0500
committerGitHub <noreply@github.com>2020-02-07 15:03:30 -0500
commit7de90c1e0b42b565a5f46e2f9f7580e1f577d414 (patch)
treed98369135a798e3cb7ca861e24e0a7842ec791ff /source
parent199d1f52b6690843fbdc7a383775396469516e56 (diff)
Code standard changes for Lexer (#1209)
* Upper camel -> lowerCamel m_ prefix members where appropriate _ prefix module local functions * m_ prefix members in Lexer. Fit's standard because type has methods/ctor.
Diffstat (limited to 'source')
-rw-r--r--source/slang/slang-lexer.cpp450
-rw-r--r--source/slang/slang-lexer.h72
-rw-r--r--source/slang/slang-parser.cpp142
-rw-r--r--source/slang/slang-preprocessor.cpp12
4 files changed, 338 insertions, 338 deletions
diff --git a/source/slang/slang-lexer.cpp b/source/slang/slang-lexer.cpp
index 67ad53764..6d13a053d 100644
--- a/source/slang/slang-lexer.cpp
+++ b/source/slang/slang-lexer.cpp
@@ -31,44 +31,44 @@ namespace Slang
}
TokenSpan::TokenSpan()
- : mBegin(NULL)
- , mEnd (NULL)
+ : m_begin(nullptr)
+ , m_end (nullptr)
{}
TokenReader::TokenReader()
- : mCursor(NULL)
- , mEnd (NULL)
+ : m_cursor(nullptr)
+ , m_end (nullptr)
{}
- Token& TokenReader::PeekToken()
+ Token& TokenReader::peekToken()
{
- return nextToken;
+ return m_nextToken;
}
- TokenType TokenReader::PeekTokenType() const
+ TokenType TokenReader::peekTokenType() const
{
- return nextToken.type;
+ return m_nextToken.type;
}
- SourceLoc TokenReader::PeekLoc() const
+ SourceLoc TokenReader::peekLoc() const
{
- return nextToken.loc;
+ return m_nextToken.loc;
}
- Token TokenReader::AdvanceToken()
+ Token TokenReader::advanceToken()
{
- if (!mCursor)
+ if (!m_cursor)
return GetEndOfFileToken();
- Token token = nextToken;
- if (mCursor < mEnd)
+ Token token = m_nextToken;
+ if (m_cursor < m_end)
{
- mCursor++;
- nextToken = *mCursor;
+ m_cursor++;
+ m_nextToken = *m_cursor;
}
else
- nextToken.type = TokenType::EndOfFile;
+ m_nextToken.type = TokenType::EndOfFile;
return token;
}
@@ -80,22 +80,22 @@ namespace Slang
NamePool* inNamePool,
MemoryArena* inMemoryArena)
{
- sourceView = inSourceView;
- sink = inSink;
- namePool = inNamePool;
- memoryArena = inMemoryArena;
+ m_sourceView = inSourceView;
+ m_sink = inSink;
+ m_namePool = inNamePool;
+ m_memoryArena = inMemoryArena;
auto content = inSourceView->getContent();
- begin = content.begin();
- cursor = content.begin();
- end = content.end();
+ m_begin = content.begin();
+ m_cursor = content.begin();
+ m_end = content.end();
// Set the start location
- startLoc = inSourceView->getRange().begin;
+ m_startLoc = inSourceView->getRange().begin;
- tokenFlags = TokenFlag::AtStartOfLine | TokenFlag::AfterWhitespace;
- lexerFlags = 0;
+ m_tokenFlags = TokenFlag::AtStartOfLine | TokenFlag::AfterWhitespace;
+ m_lexerFlags = 0;
}
Lexer::~Lexer()
@@ -106,26 +106,26 @@ namespace Slang
// Get the next input byte, without any handling of
// escaped newlines, non-ASCII code points, source locations, etc.
- static int peekRaw(Lexer* lexer)
+ static int _peekRaw(Lexer* lexer)
{
// If we are at the end of the input, return a designated end-of-file value
- if(lexer->cursor == lexer->end)
+ if(lexer->m_cursor == lexer->m_end)
return kEOF;
// Otherwise, just look at the next byte
- return *lexer->cursor;
+ return *lexer->m_cursor;
}
// Read one input byte without any special handling (similar to `peekRaw`)
- static int advanceRaw(Lexer* lexer)
+ static int _advanceRaw(Lexer* lexer)
{
// The logic here is basically the same as for `peekRaw()`,
// escape we advance `cursor` if we aren't at the end.
- if (lexer->cursor == lexer->end)
+ if (lexer->m_cursor == lexer->m_end)
return kEOF;
- return *lexer->cursor++;
+ return *lexer->m_cursor++;
}
// When the cursor is already at the first byte of an end-of-line sequence,
@@ -140,23 +140,23 @@ namespace Slang
//
// We always look for the longest match possible.
//
- static void handleNewLineInner(Lexer* lexer, int c)
+ static void _handleNewLineInner(Lexer* lexer, int c)
{
SLANG_ASSERT(c == '\n' || c == '\r');
- int d = peekRaw(lexer);
+ int d = _peekRaw(lexer);
if( (c ^ d) == ('\n' ^ '\r') )
{
- advanceRaw(lexer);
+ _advanceRaw(lexer);
}
}
// Look ahead one code point, dealing with complications like
// escaped newlines.
- static int peek(Lexer* lexer)
+ static int _peek(Lexer* lexer)
{
// Look at the next raw byte, and decide what to do
- int c = peekRaw(lexer);
+ int c = _peekRaw(lexer);
if(c == '\\')
{
@@ -165,16 +165,16 @@ namespace Slang
//
// Note(tfoley): We are assuming a null-terminated input here,
// so that we can safely look at the next byte without issue.
- int d = lexer->cursor[1];
+ int d = lexer->m_cursor[1];
switch (d)
{
case '\r': case '\n':
{
// The newline was escaped, so return the code point after *that*
- int e = lexer->cursor[2];
+ int e = lexer->m_cursor[2];
if ((d ^ e) == ('\r' ^ '\n'))
- return lexer->cursor[3];
+ return lexer->m_cursor[3];
return e;
}
@@ -189,18 +189,18 @@ namespace Slang
}
// Get the next code point from the input, and advance the cursor.
- static int advance(Lexer* lexer)
+ static int _advance(Lexer* lexer)
{
// We are going to loop, but only as a way of handling
// escaped line endings.
for (;;)
{
// If we are at the end of the input, then the task is easy.
- if (lexer->cursor == lexer->end)
+ if (lexer->m_cursor == lexer->m_end)
return kEOF;
// Look at the next raw byte, and decide what to do
- int c = *lexer->cursor++;
+ int c = *lexer->m_cursor++;
if (c == '\\')
{
@@ -209,15 +209,15 @@ namespace Slang
//
// Note(tfoley): We are assuming a null-terminated input here,
// so that we can safely look at the next byte without issue.
- int d = *lexer->cursor;
+ int d = *lexer->m_cursor;
switch (d)
{
case '\r': case '\n':
// handle the end-of-line for our source location tracking
- lexer->cursor++;
- handleNewLineInner(lexer, d);
+ lexer->m_cursor++;
+ _handleNewLineInner(lexer, d);
- lexer->tokenFlags |= TokenFlag::ScrubbingNeeded;
+ lexer->m_tokenFlags |= TokenFlag::ScrubbingNeeded;
// Now try again, looking at the character after the
// escaped newline.
@@ -235,48 +235,48 @@ namespace Slang
}
}
- static void handleNewLine(Lexer* lexer)
+ static void _handleNewLine(Lexer* lexer)
{
- int c = advance(lexer);
- handleNewLineInner(lexer, c);
+ int c = _advance(lexer);
+ _handleNewLineInner(lexer, c);
}
- static void lexLineComment(Lexer* lexer)
+ static void _lexLineComment(Lexer* lexer)
{
for(;;)
{
- switch(peek(lexer))
+ switch(_peek(lexer))
{
case '\n': case '\r': case kEOF:
return;
default:
- advance(lexer);
+ _advance(lexer);
continue;
}
}
}
- static void lexBlockComment(Lexer* lexer)
+ static void _lexBlockComment(Lexer* lexer)
{
for(;;)
{
- switch(peek(lexer))
+ switch(_peek(lexer))
{
case kEOF:
// TODO(tfoley) diagnostic!
return;
case '\n': case '\r':
- handleNewLine(lexer);
+ _handleNewLine(lexer);
continue;
case '*':
- advance(lexer);
- switch( peek(lexer) )
+ _advance(lexer);
+ switch( _peek(lexer) )
{
case '/':
- advance(lexer);
+ _advance(lexer);
return;
default:
@@ -284,20 +284,20 @@ namespace Slang
}
default:
- advance(lexer);
+ _advance(lexer);
continue;
}
}
}
- static void lexHorizontalSpace(Lexer* lexer)
+ static void _lexHorizontalSpace(Lexer* lexer)
{
for(;;)
{
- switch(peek(lexer))
+ switch(_peek(lexer))
{
case ' ': case '\t':
- advance(lexer);
+ _advance(lexer);
continue;
default:
@@ -306,17 +306,17 @@ namespace Slang
}
}
- static void lexIdentifier(Lexer* lexer)
+ static void _lexIdentifier(Lexer* lexer)
{
for(;;)
{
- int c = peek(lexer);
+ int c = _peek(lexer);
if(('a' <= c ) && (c <= 'z')
|| ('A' <= c) && (c <= 'Z')
|| ('0' <= c) && (c <= '9')
|| (c == '_'))
{
- advance(lexer);
+ _advance(lexer);
continue;
}
@@ -324,16 +324,16 @@ namespace Slang
}
}
- static SourceLoc getSourceLoc(Lexer* lexer)
+ static SourceLoc _getSourceLoc(Lexer* lexer)
{
- return lexer->startLoc + (lexer->cursor - lexer->begin);
+ return lexer->m_startLoc + (lexer->m_cursor - lexer->m_begin);
}
- static void lexDigits(Lexer* lexer, int base)
+ static void _lexDigits(Lexer* lexer, int base)
{
for(;;)
{
- int c = peek(lexer);
+ int c = _peek(lexer);
int digitVal = 0;
switch(c)
@@ -361,14 +361,14 @@ namespace Slang
if(digitVal >= base)
{
char buffer[] = { (char) c, 0 };
- lexer->sink->diagnose(getSourceLoc(lexer), Diagnostics::invalidDigitForBase, buffer, base);
+ lexer->m_sink->diagnose(_getSourceLoc(lexer), Diagnostics::invalidDigitForBase, buffer, base);
}
- advance(lexer);
+ _advance(lexer);
}
}
- static TokenType maybeLexNumberSuffix(Lexer* lexer, TokenType tokenType)
+ static TokenType _maybeLexNumberSuffix(Lexer* lexer, TokenType tokenType)
{
// Be liberal in what we accept here, so that figuring out
// the semantics of a numeric suffix is left up to the parser
@@ -376,7 +376,7 @@ namespace Slang
//
for( ;;)
{
- int c = peek(lexer);
+ int c = _peek(lexer);
// Accept any alphanumeric character, plus underscores.
if(('a' <= c ) && (c <= 'z')
@@ -384,7 +384,7 @@ namespace Slang
|| ('0' <= c) && (c <= '9')
|| (c == '_'))
{
- advance(lexer);
+ _advance(lexer);
continue;
}
@@ -394,7 +394,7 @@ namespace Slang
}
}
- static bool isNumberExponent(int c, int base)
+ static bool _isNumberExponent(int c, int base)
{
switch( c )
{
@@ -413,64 +413,64 @@ namespace Slang
return true;
}
- static bool maybeLexNumberExponent(Lexer* lexer, int base)
+ static bool _maybeLexNumberExponent(Lexer* lexer, int base)
{
- if(!isNumberExponent(peek(lexer), base))
+ if(!_isNumberExponent(_peek(lexer), base))
return false;
// we saw an exponent marker
- advance(lexer);
+ _advance(lexer);
// Now start to read the exponent
- switch( peek(lexer) )
+ switch( _peek(lexer) )
{
case '+': case '-':
- advance(lexer);
+ _advance(lexer);
break;
}
// TODO(tfoley): it would be an error to not see digits here...
- lexDigits(lexer, 10);
+ _lexDigits(lexer, 10);
return true;
}
- static TokenType lexNumberAfterDecimalPoint(Lexer* lexer, int base)
+ static TokenType _lexNumberAfterDecimalPoint(Lexer* lexer, int base)
{
- lexDigits(lexer, base);
- maybeLexNumberExponent(lexer, base);
+ _lexDigits(lexer, base);
+ _maybeLexNumberExponent(lexer, base);
- return maybeLexNumberSuffix(lexer, TokenType::FloatingPointLiteral);
+ return _maybeLexNumberSuffix(lexer, TokenType::FloatingPointLiteral);
}
- static TokenType lexNumber(Lexer* lexer, int base)
+ static TokenType _lexNumber(Lexer* lexer, int base)
{
// TODO(tfoley): Need to consider whehter to allow any kind of digit separator character.
TokenType tokenType = TokenType::IntegerLiteral;
// At the start of things, we just concern ourselves with digits
- lexDigits(lexer, base);
+ _lexDigits(lexer, base);
- if( peek(lexer) == '.' )
+ if( _peek(lexer) == '.' )
{
tokenType = TokenType::FloatingPointLiteral;
- advance(lexer);
- lexDigits(lexer, base);
+ _advance(lexer);
+ _lexDigits(lexer, base);
}
- if( maybeLexNumberExponent(lexer, base))
+ if( _maybeLexNumberExponent(lexer, base))
{
tokenType = TokenType::FloatingPointLiteral;
}
- maybeLexNumberSuffix(lexer, tokenType);
+ _maybeLexNumberSuffix(lexer, tokenType);
return tokenType;
}
- static int maybeReadDigit(char const** ioCursor, int base)
+ static int _maybeReadDigit(char const** ioCursor, int base)
{
auto& cursor = *ioCursor;
@@ -511,7 +511,7 @@ namespace Slang
}
}
- static int readOptionalBase(char const** ioCursor)
+ static int _readOptionalBase(char const** ioCursor)
{
auto& cursor = *ioCursor;
if( *cursor == '0' )
@@ -548,11 +548,11 @@ namespace Slang
char const* cursor = token.Content.begin();
char const* end = token.Content.end();
- int base = readOptionalBase(&cursor);
+ int base = _readOptionalBase(&cursor);
for( ;;)
{
- int digit = maybeReadDigit(&cursor, base);
+ int digit = _maybeReadDigit(&cursor, base);
if(digit < 0)
break;
@@ -574,7 +574,7 @@ namespace Slang
char const* cursor = token.Content.begin();
char const* end = token.Content.end();
- int radix = readOptionalBase(&cursor);
+ int radix = _readOptionalBase(&cursor);
bool seenDot = false;
FloatingPointLiteralValue divisor = 1;
@@ -587,7 +587,7 @@ namespace Slang
continue;
}
- int digit = maybeReadDigit(&cursor, radix);
+ int digit = _maybeReadDigit(&cursor, radix);
if(digit < 0)
break;
@@ -600,7 +600,7 @@ namespace Slang
}
// Now read optional exponent
- if(isNumberExponent(*cursor, radix))
+ if(_isNumberExponent(*cursor, radix))
{
cursor++;
@@ -625,7 +625,7 @@ namespace Slang
for(;;)
{
- int digit = maybeReadDigit(&cursor, exponentRadix);
+ int digit = _maybeReadDigit(&cursor, exponentRadix);
if(digit < 0)
break;
@@ -660,31 +660,31 @@ namespace Slang
return value;
}
- static void lexStringLiteralBody(Lexer* lexer, char quote)
+ static void _lexStringLiteralBody(Lexer* lexer, char quote)
{
for(;;)
{
- int c = peek(lexer);
+ int c = _peek(lexer);
if(c == quote)
{
- advance(lexer);
+ _advance(lexer);
return;
}
switch(c)
{
case kEOF:
- lexer->sink->diagnose(getSourceLoc(lexer), Diagnostics::endOfFileInLiteral);
+ lexer->m_sink->diagnose(_getSourceLoc(lexer), Diagnostics::endOfFileInLiteral);
return;
case '\n': case '\r':
- lexer->sink->diagnose(getSourceLoc(lexer), Diagnostics::newlineInLiteral);
+ lexer->m_sink->diagnose(_getSourceLoc(lexer), Diagnostics::newlineInLiteral);
return;
case '\\':
// Need to handle various escape sequence cases
- advance(lexer);
- switch(peek(lexer))
+ _advance(lexer);
+ switch(_peek(lexer))
{
case '\'':
case '\"':
@@ -697,19 +697,19 @@ namespace Slang
case 'r':
case 't':
case 'v':
- advance(lexer);
+ _advance(lexer);
break;
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7':
// octal escape: up to 3 characters
- advance(lexer);
+ _advance(lexer);
for(int ii = 0; ii < 3; ++ii)
{
- int d = peek(lexer);
+ int d = _peek(lexer);
if(('0' <= d) && (d <= '7'))
{
- advance(lexer);
+ _advance(lexer);
continue;
}
else
@@ -721,15 +721,15 @@ namespace Slang
case 'x':
// hexadecimal escape: any number of characters
- advance(lexer);
+ _advance(lexer);
for(;;)
{
- int d = peek(lexer);
+ int d = _peek(lexer);
if(('0' <= d) && (d <= '9')
|| ('a' <= d) && (d <= 'f')
|| ('A' <= d) && (d <= 'F'))
{
- advance(lexer);
+ _advance(lexer);
continue;
}
else
@@ -745,7 +745,7 @@ namespace Slang
break;
default:
- advance(lexer);
+ _advance(lexer);
continue;
}
}
@@ -890,16 +890,16 @@ namespace Slang
- static TokenType lexTokenImpl(Lexer* lexer, LexerFlags effectiveFlags)
+ static TokenType _lexTokenImpl(Lexer* lexer, LexerFlags effectiveFlags)
{
if(effectiveFlags & kLexerFlag_ExpectDirectiveMessage)
{
for(;;)
{
- switch(peek(lexer))
+ switch(_peek(lexer))
{
default:
- advance(lexer);
+ _advance(lexer);
continue;
case kEOF: case '\r': case '\n':
@@ -910,7 +910,7 @@ namespace Slang
return TokenType::DirectiveMessage;
}
- switch(peek(lexer))
+ switch(_peek(lexer))
{
default:
break;
@@ -923,20 +923,20 @@ namespace Slang
case '\r': case '\n':
if((effectiveFlags & kLexerFlag_InDirective) != 0)
return TokenType::EndOfDirective;
- handleNewLine(lexer);
+ _handleNewLine(lexer);
return TokenType::NewLine;
case ' ': case '\t':
- lexHorizontalSpace(lexer);
+ _lexHorizontalSpace(lexer);
return TokenType::WhiteSpace;
case '.':
- advance(lexer);
- switch(peek(lexer))
+ _advance(lexer);
+ switch(_peek(lexer))
{
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
- return lexNumberAfterDecimalPoint(lexer, 10);
+ return _lexNumberAfterDecimalPoint(lexer, 10);
// TODO(tfoley): handle ellipsis (`...`)
@@ -946,33 +946,33 @@ namespace Slang
case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
- return lexNumber(lexer, 10);
+ return _lexNumber(lexer, 10);
case '0':
{
- auto loc = getSourceLoc(lexer);
- advance(lexer);
- switch(peek(lexer))
+ auto loc = _getSourceLoc(lexer);
+ _advance(lexer);
+ switch(_peek(lexer))
{
default:
- return maybeLexNumberSuffix(lexer, TokenType::IntegerLiteral);
+ return _maybeLexNumberSuffix(lexer, TokenType::IntegerLiteral);
case '.':
- advance(lexer);
- return lexNumberAfterDecimalPoint(lexer, 10);
+ _advance(lexer);
+ return _lexNumberAfterDecimalPoint(lexer, 10);
case 'x': case 'X':
- advance(lexer);
- return lexNumber(lexer, 16);
+ _advance(lexer);
+ return _lexNumber(lexer, 16);
case 'b': case 'B':
- advance(lexer);
- return lexNumber(lexer, 2);
+ _advance(lexer);
+ return _lexNumber(lexer, 2);
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
- lexer->sink->diagnose(loc, Diagnostics::octalLiteral);
- return lexNumber(lexer, 8);
+ lexer->m_sink->diagnose(loc, Diagnostics::octalLiteral);
+ return _lexNumber(lexer, 8);
}
}
@@ -989,182 +989,182 @@ namespace Slang
case 'U': case 'V': case 'W': case 'X': case 'Y':
case 'Z':
case '_':
- lexIdentifier(lexer);
+ _lexIdentifier(lexer);
return TokenType::Identifier;
case '\"':
- advance(lexer);
- lexStringLiteralBody(lexer, '\"');
+ _advance(lexer);
+ _lexStringLiteralBody(lexer, '\"');
return TokenType::StringLiteral;
case '\'':
- advance(lexer);
- lexStringLiteralBody(lexer, '\'');
+ _advance(lexer);
+ _lexStringLiteralBody(lexer, '\'');
return TokenType::CharLiteral;
case '+':
- advance(lexer);
- switch(peek(lexer))
+ _advance(lexer);
+ switch(_peek(lexer))
{
- case '+': advance(lexer); return TokenType::OpInc;
- case '=': advance(lexer); return TokenType::OpAddAssign;
+ case '+': _advance(lexer); return TokenType::OpInc;
+ case '=': _advance(lexer); return TokenType::OpAddAssign;
default:
return TokenType::OpAdd;
}
case '-':
- advance(lexer);
- switch(peek(lexer))
+ _advance(lexer);
+ switch(_peek(lexer))
{
- case '-': advance(lexer); return TokenType::OpDec;
- case '=': advance(lexer); return TokenType::OpSubAssign;
- case '>': advance(lexer); return TokenType::RightArrow;
+ case '-': _advance(lexer); return TokenType::OpDec;
+ case '=': _advance(lexer); return TokenType::OpSubAssign;
+ case '>': _advance(lexer); return TokenType::RightArrow;
default:
return TokenType::OpSub;
}
case '*':
- advance(lexer);
- switch(peek(lexer))
+ _advance(lexer);
+ switch(_peek(lexer))
{
- case '=': advance(lexer); return TokenType::OpMulAssign;
+ case '=': _advance(lexer); return TokenType::OpMulAssign;
default:
return TokenType::OpMul;
}
case '/':
- advance(lexer);
- switch(peek(lexer))
+ _advance(lexer);
+ switch(_peek(lexer))
{
- case '=': advance(lexer); return TokenType::OpDivAssign;
- case '/': advance(lexer); lexLineComment(lexer); return TokenType::LineComment;
- case '*': advance(lexer); lexBlockComment(lexer); return TokenType::BlockComment;
+ case '=': _advance(lexer); return TokenType::OpDivAssign;
+ case '/': _advance(lexer); _lexLineComment(lexer); return TokenType::LineComment;
+ case '*': _advance(lexer); _lexBlockComment(lexer); return TokenType::BlockComment;
default:
return TokenType::OpDiv;
}
case '%':
- advance(lexer);
- switch(peek(lexer))
+ _advance(lexer);
+ switch(_peek(lexer))
{
- case '=': advance(lexer); return TokenType::OpModAssign;
+ case '=': _advance(lexer); return TokenType::OpModAssign;
default:
return TokenType::OpMod;
}
case '|':
- advance(lexer);
- switch(peek(lexer))
+ _advance(lexer);
+ switch(_peek(lexer))
{
- case '|': advance(lexer); return TokenType::OpOr;
- case '=': advance(lexer); return TokenType::OpOrAssign;
+ case '|': _advance(lexer); return TokenType::OpOr;
+ case '=': _advance(lexer); return TokenType::OpOrAssign;
default:
return TokenType::OpBitOr;
}
case '&':
- advance(lexer);
- switch(peek(lexer))
+ _advance(lexer);
+ switch(_peek(lexer))
{
- case '&': advance(lexer); return TokenType::OpAnd;
- case '=': advance(lexer); return TokenType::OpAndAssign;
+ case '&': _advance(lexer); return TokenType::OpAnd;
+ case '=': _advance(lexer); return TokenType::OpAndAssign;
default:
return TokenType::OpBitAnd;
}
case '^':
- advance(lexer);
- switch(peek(lexer))
+ _advance(lexer);
+ switch(_peek(lexer))
{
- case '=': advance(lexer); return TokenType::OpXorAssign;
+ case '=': _advance(lexer); return TokenType::OpXorAssign;
default:
return TokenType::OpBitXor;
}
case '>':
- advance(lexer);
- switch(peek(lexer))
+ _advance(lexer);
+ switch(_peek(lexer))
{
case '>':
- advance(lexer);
- switch(peek(lexer))
+ _advance(lexer);
+ switch(_peek(lexer))
{
- case '=': advance(lexer); return TokenType::OpShrAssign;
+ case '=': _advance(lexer); return TokenType::OpShrAssign;
default: return TokenType::OpRsh;
}
- case '=': advance(lexer); return TokenType::OpGeq;
+ case '=': _advance(lexer); return TokenType::OpGeq;
default:
return TokenType::OpGreater;
}
case '<':
- advance(lexer);
- switch(peek(lexer))
+ _advance(lexer);
+ switch(_peek(lexer))
{
case '<':
- advance(lexer);
- switch(peek(lexer))
+ _advance(lexer);
+ switch(_peek(lexer))
{
- case '=': advance(lexer); return TokenType::OpShlAssign;
+ case '=': _advance(lexer); return TokenType::OpShlAssign;
default: return TokenType::OpLsh;
}
- case '=': advance(lexer); return TokenType::OpLeq;
+ case '=': _advance(lexer); return TokenType::OpLeq;
default:
return TokenType::OpLess;
}
case '=':
- advance(lexer);
- switch(peek(lexer))
+ _advance(lexer);
+ switch(_peek(lexer))
{
- case '=': advance(lexer); return TokenType::OpEql;
+ case '=': _advance(lexer); return TokenType::OpEql;
default:
return TokenType::OpAssign;
}
case '!':
- advance(lexer);
- switch(peek(lexer))
+ _advance(lexer);
+ switch(_peek(lexer))
{
- case '=': advance(lexer); return TokenType::OpNeq;
+ case '=': _advance(lexer); return TokenType::OpNeq;
default:
return TokenType::OpNot;
}
case '#':
- advance(lexer);
- switch(peek(lexer))
+ _advance(lexer);
+ switch(_peek(lexer))
{
- case '#': advance(lexer); return TokenType::PoundPound;
+ case '#': _advance(lexer); return TokenType::PoundPound;
default:
return TokenType::Pound;
}
- case '~': advance(lexer); return TokenType::OpBitNot;
+ case '~': _advance(lexer); return TokenType::OpBitNot;
case ':':
{
- advance(lexer);
- if (peek(lexer) == ':')
+ _advance(lexer);
+ if (_peek(lexer) == ':')
{
- advance(lexer);
+ _advance(lexer);
return TokenType::Scope;
}
return TokenType::Colon;
}
- case ';': advance(lexer); return TokenType::Semicolon;
- case ',': advance(lexer); return TokenType::Comma;
+ case ';': _advance(lexer); return TokenType::Semicolon;
+ case ',': _advance(lexer); return TokenType::Comma;
- case '{': advance(lexer); return TokenType::LBrace;
- case '}': advance(lexer); return TokenType::RBrace;
- case '[': advance(lexer); return TokenType::LBracket;
- case ']': advance(lexer); return TokenType::RBracket;
- case '(': advance(lexer); return TokenType::LParent;
- case ')': advance(lexer); return TokenType::RParent;
+ case '{': _advance(lexer); return TokenType::LBrace;
+ case '}': _advance(lexer); return TokenType::RBrace;
+ case '[': _advance(lexer); return TokenType::LBracket;
+ case ']': _advance(lexer); return TokenType::RBracket;
+ case '(': _advance(lexer); return TokenType::LParent;
+ case ')': _advance(lexer); return TokenType::RParent;
- case '?': advance(lexer); return TokenType::QuestionMark;
- case '@': advance(lexer); return TokenType::At;
- case '$': advance(lexer); return TokenType::Dollar;
+ case '?': _advance(lexer); return TokenType::QuestionMark;
+ case '@': _advance(lexer); return TokenType::At;
+ case '$': _advance(lexer); return TokenType::Dollar;
}
@@ -1177,11 +1177,11 @@ namespace Slang
// If none of the above cases matched, then we have an
// unexpected/invalid character.
- auto loc = getSourceLoc(lexer);
- int c = advance(lexer);
+ auto loc = _getSourceLoc(lexer);
+ int c = _advance(lexer);
if(!(effectiveFlags & kLexerFlag_IgnoreInvalid))
{
- auto sink = lexer->sink;
+ auto sink = lexer->m_sink;
if(c >= 0x20 && c <= 0x7E)
{
char buffer[] = { (char) c, 0 };
@@ -1200,15 +1200,15 @@ namespace Slang
Token Lexer::lexToken(LexerFlags extraFlags)
{
- auto& flags = this->tokenFlags;
+ auto& flags = m_tokenFlags;
for(;;)
{
Token token;
- token.loc = getSourceLoc(this);
+ token.loc = _getSourceLoc(this);
- char const* textBegin = cursor;
+ char const* textBegin = m_cursor;
- auto tokenType = lexTokenImpl(this, this->lexerFlags | extraFlags);
+ auto tokenType = _lexTokenImpl(this, m_lexerFlags | extraFlags);
// The low-level lexer produces tokens for things we want
// to ignore, such as white space, so we skip them here.
@@ -1240,14 +1240,14 @@ namespace Slang
// preprocessor directive.
case TokenType::Pound:
if((flags & TokenFlag::AtStartOfLine) != 0)
- lexerFlags |= kLexerFlag_InDirective;
+ m_lexerFlags |= kLexerFlag_InDirective;
break;
//
// And if we saw an end-of-line during a directive, then we are
// now leaving that directive.
//
case TokenType::EndOfDirective:
- lexerFlags &= ~kLexerFlag_InDirective;
+ m_lexerFlags &= ~kLexerFlag_InDirective;
break;
default:
@@ -1256,7 +1256,7 @@ namespace Slang
token.type = tokenType;
- char const* textEnd = cursor;
+ char const* textEnd = m_cursor;
// Note(tfoley): `StringBuilder::Append()` seems to crash when appending zero bytes
if(textEnd != textBegin)
@@ -1266,10 +1266,10 @@ namespace Slang
// Only perform this work if we encountered an escaped newline
// while lexing this token (e.g., keep a flag on the lexer), or
// do it on-demand when the actual value of the token is needed.
- if (tokenFlags & TokenFlag::ScrubbingNeeded)
+ if (m_tokenFlags & TokenFlag::ScrubbingNeeded)
{
// Allocate space that will always be more than enough for stripped contents
- char* startDst = (char*)memoryArena->allocateUnaligned(textEnd - textBegin);
+ char* startDst = (char*)m_memoryArena->allocateUnaligned(textEnd - textBegin);
char* dst = startDst;
auto tt = textBegin;
@@ -1308,11 +1308,11 @@ namespace Slang
token.flags = flags;
- this->tokenFlags = 0;
+ m_tokenFlags = 0;
if (tokenType == TokenType::Identifier)
{
- token.ptrValue = this->namePool->getName(token.Content);
+ token.ptrValue = m_namePool->getName(token.Content);
}
return token;
diff --git a/source/slang/slang-lexer.h b/source/slang/slang-lexer.h
index c707f8461..0d19fe617 100644
--- a/source/slang/slang-lexer.h
+++ b/source/slang/slang-lexer.h
@@ -25,32 +25,32 @@ namespace Slang
TokenSpan();
TokenSpan(
TokenList const& tokenList)
- : mBegin(tokenList.begin())
- , mEnd (tokenList.end ())
+ : m_begin(tokenList.begin())
+ , m_end (tokenList.end ())
{}
- Token* begin() const { return mBegin; }
- Token* end () const { return mEnd ; }
+ Token* begin() const { return m_begin; }
+ Token* end () const { return m_end ; }
- int GetCount() { return (int)(mEnd - mBegin); }
+ int getCount() { return (int)(m_end - m_begin); }
- Token* mBegin;
- Token* mEnd;
+ Token* m_begin;
+ Token* m_end;
};
struct TokenReader
{
- Token nextToken;
+ Token m_nextToken;
TokenReader();
explicit TokenReader(TokenSpan const& tokens)
- : mCursor(tokens.begin())
- , mEnd (tokens.end ())
- , nextToken(tokens.begin() ? *tokens.begin() : GetEndOfFileToken())
+ : m_cursor(tokens.begin())
+ , m_end (tokens.end ())
+ , m_nextToken(tokens.begin() ? *tokens.begin() : GetEndOfFileToken())
{}
explicit TokenReader(TokenList const& tokens)
- : mCursor(tokens.begin())
- , mEnd (tokens.end ())
- , nextToken(tokens.begin() ? *tokens.begin() : GetEndOfFileToken())
+ : m_cursor(tokens.begin())
+ , m_end (tokens.end ())
+ , m_nextToken(tokens.begin() ? *tokens.begin() : GetEndOfFileToken())
{}
struct ParsingCursor
{
@@ -60,26 +60,26 @@ namespace Slang
ParsingCursor getCursor()
{
ParsingCursor rs;
- rs.nextToken = nextToken;
- rs.tokenReaderCursor = mCursor;
+ rs.nextToken = m_nextToken;
+ rs.tokenReaderCursor = m_cursor;
return rs;
}
void setCursor(ParsingCursor cursor)
{
- mCursor = cursor.tokenReaderCursor;
- nextToken = cursor.nextToken;
+ m_cursor = cursor.tokenReaderCursor;
+ m_nextToken = cursor.nextToken;
}
- bool IsAtEnd() const { return mCursor == mEnd; }
- Token& PeekToken();
- TokenType PeekTokenType() const;
- SourceLoc PeekLoc() const;
+ bool isAtEnd() const { return m_cursor == m_end; }
+ Token& peekToken();
+ TokenType peekTokenType() const;
+ SourceLoc peekLoc() const;
- Token AdvanceToken();
+ Token advanceToken();
- int GetCount() { return (int)(mEnd - mCursor); }
+ int getCount() { return (int)(m_end - m_cursor); }
- Token* mCursor;
- Token* mEnd;
+ Token* m_cursor;
+ Token* m_end;
static Token GetEndOfFileToken();
};
@@ -106,22 +106,22 @@ namespace Slang
TokenList lexAllTokens();
- SourceView* sourceView;
- DiagnosticSink* sink;
- NamePool* namePool;
+ SourceView* m_sourceView;
+ DiagnosticSink* m_sink;
+ NamePool* m_namePool;
- char const* cursor;
+ char const* m_cursor;
- char const* begin;
- char const* end;
+ char const* m_begin;
+ char const* m_end;
/// The starting sourceLoc (same as first location of SourceView)
- SourceLoc startLoc;
+ SourceLoc m_startLoc;
- TokenFlags tokenFlags;
- LexerFlags lexerFlags;
+ TokenFlags m_tokenFlags;
+ LexerFlags m_lexerFlags;
- MemoryArena* memoryArena;
+ MemoryArena* m_memoryArena;
};
// Helper routines for extracting values from tokens
diff --git a/source/slang/slang-parser.cpp b/source/slang/slang-parser.cpp
index 17fe792ab..79b74a601 100644
--- a/source/slang/slang-parser.cpp
+++ b/source/slang/slang-parser.cpp
@@ -107,7 +107,7 @@ namespace Slang
void FillPosition(SyntaxNode * node)
{
- node->loc = tokenReader.PeekLoc();
+ node->loc = tokenReader.peekLoc();
}
void PushScope(ContainerDecl* containerDecl)
{
@@ -213,8 +213,8 @@ namespace Slang
// Don't emit "unexpected token" errors if we are in recovering mode
if (!parser->isRecovering)
{
- parser->sink->diagnose(parser->tokenReader.PeekLoc(), Diagnostics::unexpectedToken,
- parser->tokenReader.PeekTokenType());
+ parser->sink->diagnose(parser->tokenReader.peekLoc(), Diagnostics::unexpectedToken,
+ parser->tokenReader.peekTokenType());
// Switch into recovery mode, to suppress additional errors
parser->isRecovering = true;
@@ -228,8 +228,8 @@ namespace Slang
// Don't emit "unexpected token" errors if we are in recovering mode
if (!parser->isRecovering)
{
- parser->sink->diagnose(parser->tokenReader.PeekLoc(), Diagnostics::unexpectedTokenExpectedTokenName,
- parser->tokenReader.PeekTokenType(),
+ parser->sink->diagnose(parser->tokenReader.peekLoc(), Diagnostics::unexpectedTokenExpectedTokenName,
+ parser->tokenReader.peekTokenType(),
expected);
// Switch into recovery mode, to suppress additional errors
@@ -244,8 +244,8 @@ namespace Slang
// Don't emit "unexpected token" errors if we are in recovering mode
if (!parser->isRecovering)
{
- parser->sink->diagnose(parser->tokenReader.PeekLoc(), Diagnostics::unexpectedTokenExpectedTokenType,
- parser->tokenReader.PeekTokenType(),
+ parser->sink->diagnose(parser->tokenReader.peekLoc(), Diagnostics::unexpectedTokenExpectedTokenType,
+ parser->tokenReader.peekTokenType(),
expected);
// Switch into recovery mode, to suppress additional errors
@@ -260,7 +260,7 @@ namespace Slang
static TokenType SkipBalancedToken(
TokenReader* reader)
{
- TokenType tokenType = reader->AdvanceToken().type;
+ TokenType tokenType = reader->advanceToken().type;
switch (tokenType)
{
default:
@@ -280,10 +280,10 @@ namespace Slang
{
for (;;)
{
- if (reader->IsAtEnd()) return TokenType::EndOfFile;
- if (reader->PeekTokenType() == tokenType)
+ if (reader->isAtEnd()) return TokenType::EndOfFile;
+ if (reader->peekTokenType() == tokenType)
{
- reader->AdvanceToken();
+ reader->advanceToken();
return tokenType;
}
SkipBalancedToken(reader);
@@ -311,17 +311,17 @@ namespace Slang
// Expect an identifier token with the given content, and consume it.
Token Parser::ReadToken(const char* expected)
{
- if (tokenReader.PeekTokenType() == TokenType::Identifier
- && tokenReader.PeekToken().Content == expected)
+ if (tokenReader.peekTokenType() == TokenType::Identifier
+ && tokenReader.peekToken().Content == expected)
{
isRecovering = false;
- return tokenReader.AdvanceToken();
+ return tokenReader.advanceToken();
}
if (!isRecovering)
{
Unexpected(this, expected);
- return tokenReader.PeekToken();
+ return tokenReader.peekToken();
}
else
{
@@ -330,18 +330,18 @@ namespace Slang
{
// The token we expected?
// Then exit recovery mode and pretend like all is well.
- if (tokenReader.PeekTokenType() == TokenType::Identifier
- && tokenReader.PeekToken().Content == expected)
+ if (tokenReader.peekTokenType() == TokenType::Identifier
+ && tokenReader.peekToken().Content == expected)
{
isRecovering = false;
- return tokenReader.AdvanceToken();
+ return tokenReader.advanceToken();
}
// Don't skip past any "closing" tokens.
- if (IsClosingToken(tokenReader.PeekTokenType()))
+ if (IsClosingToken(tokenReader.peekTokenType()))
{
- return tokenReader.PeekToken();
+ return tokenReader.peekToken();
}
// Skip balanced tokens and try again.
@@ -352,7 +352,7 @@ namespace Slang
Token Parser::ReadToken()
{
- return tokenReader.AdvanceToken();
+ return tokenReader.advanceToken();
}
static bool TryRecover(
@@ -404,7 +404,7 @@ namespace Slang
TokenReader* tokenReader = &parser->tokenReader;
for (;;)
{
- TokenType peek = tokenReader->PeekTokenType();
+ TokenType peek = tokenReader->peekTokenType();
// Is the next token in our recover-before set?
// If so, then we have recovered successfully!
@@ -423,7 +423,7 @@ namespace Slang
{
if (peek == recoverAfter[ii])
{
- tokenReader->AdvanceToken();
+ tokenReader->advanceToken();
parser->isRecovering = false;
return true;
}
@@ -496,16 +496,16 @@ namespace Slang
Token Parser::ReadToken(TokenType expected)
{
- if (tokenReader.PeekTokenType() == expected)
+ if (tokenReader.peekTokenType() == expected)
{
isRecovering = false;
- return tokenReader.AdvanceToken();
+ return tokenReader.advanceToken();
}
if (!isRecovering)
{
Unexpected(this, expected);
- return tokenReader.PeekToken();
+ return tokenReader.peekToken();
}
else
{
@@ -513,10 +513,10 @@ namespace Slang
if (TryRecoverBefore(this, expected))
{
isRecovering = false;
- return tokenReader.AdvanceToken();
+ return tokenReader.advanceToken();
}
- return tokenReader.PeekToken();
+ return tokenReader.peekToken();
}
}
@@ -524,19 +524,19 @@ namespace Slang
{
TokenReader r = tokenReader;
for (int ii = 0; ii < offset; ++ii)
- r.AdvanceToken();
+ r.advanceToken();
- return r.PeekTokenType() == TokenType::Identifier
- && r.PeekToken().Content == string;
+ return r.peekTokenType() == TokenType::Identifier
+ && r.peekToken().Content == string;
}
bool Parser::LookAheadToken(TokenType type, int offset)
{
TokenReader r = tokenReader;
for (int ii = 0; ii < offset; ++ii)
- r.AdvanceToken();
+ r.advanceToken();
- return r.PeekTokenType() == type;
+ return r.peekTokenType() == type;
}
// Consume a token and return true it if matches, otherwise false
@@ -575,7 +575,7 @@ namespace Slang
}
if (AdvanceIf(parser, tokenType))
return true;
- if (parser->tokenReader.PeekTokenType() == TokenType::EndOfFile)
+ if (parser->tokenReader.peekTokenType() == TokenType::EndOfFile)
{
parser->ReadToken(tokenType);
return true;
@@ -656,17 +656,17 @@ namespace Slang
// '::'? identifier ('::' identifier)*
static Token parseAttributeName(Parser* parser)
{
- const SourceLoc scopedIdSourceLoc = parser->tokenReader.PeekLoc();
+ const SourceLoc scopedIdSourceLoc = parser->tokenReader.peekLoc();
// Strip initial :: if there is one
- const TokenType initialTokenType = parser->tokenReader.PeekTokenType();
+ const TokenType initialTokenType = parser->tokenReader.peekTokenType();
if (initialTokenType == TokenType::Scope)
{
parser->ReadToken(TokenType::Scope);
}
const Token firstIdentifier = parser->ReadToken(TokenType::Identifier);
- if (initialTokenType != TokenType::Scope && parser->tokenReader.PeekTokenType() != TokenType::Scope)
+ if (initialTokenType != TokenType::Scope && parser->tokenReader.peekTokenType() != TokenType::Scope)
{
return firstIdentifier;
}
@@ -679,7 +679,7 @@ namespace Slang
}
scopedIdentifierBuilder.Append(firstIdentifier.Content);
- while (parser->tokenReader.PeekTokenType() == TokenType::Scope)
+ while (parser->tokenReader.peekTokenType() == TokenType::Scope)
{
parser->ReadToken(TokenType::Scope);
scopedIdentifierBuilder.Append('_');
@@ -763,7 +763,7 @@ namespace Slang
static TokenType peekTokenType(Parser* parser)
{
- return parser->tokenReader.PeekTokenType();
+ return parser->tokenReader.peekTokenType();
}
static Token advanceToken(Parser* parser)
@@ -773,7 +773,7 @@ namespace Slang
static Token peekToken(Parser* parser)
{
- return parser->tokenReader.PeekToken();
+ return parser->tokenReader.peekToken();
}
static SyntaxDecl* tryLookUpSyntaxDecl(
@@ -868,7 +868,7 @@ namespace Slang
RefPtr<Modifier>* modifierLink = &modifiers.first;
for (;;)
{
- SourceLoc loc = parser->tokenReader.PeekLoc();
+ SourceLoc loc = parser->tokenReader.peekLoc();
switch (peekTokenType(parser))
{
@@ -1397,7 +1397,7 @@ namespace Slang
Parser* parser)
{
RefPtr<Declarator> declarator;
- switch( parser->tokenReader.PeekTokenType() )
+ switch( parser->tokenReader.peekTokenType() )
{
case TokenType::Identifier:
{
@@ -1437,17 +1437,17 @@ namespace Slang
// postifx additions
for( ;;)
{
- switch( parser->tokenReader.PeekTokenType() )
+ switch( parser->tokenReader.peekTokenType() )
{
case TokenType::LBracket:
{
auto arrayDeclarator = new ArrayDeclarator();
- arrayDeclarator->openBracketLoc = parser->tokenReader.PeekLoc();
+ arrayDeclarator->openBracketLoc = parser->tokenReader.peekLoc();
arrayDeclarator->flavor = Declarator::Flavor::Array;
arrayDeclarator->inner = declarator;
parser->ReadToken(TokenType::LBracket);
- if( parser->tokenReader.PeekTokenType() != TokenType::RBracket )
+ if( parser->tokenReader.peekTokenType() != TokenType::RBracket )
{
arrayDeclarator->elementCountExpr = parser->ParseExpression();
}
@@ -1474,10 +1474,10 @@ namespace Slang
static RefPtr<Declarator> ParseDeclarator(
Parser* parser)
{
- if( parser->tokenReader.PeekTokenType() == TokenType::OpMul )
+ if( parser->tokenReader.peekTokenType() == TokenType::OpMul )
{
auto ptrDeclarator = new PointerDeclarator();
- ptrDeclarator->starLoc = parser->tokenReader.PeekLoc();
+ ptrDeclarator->starLoc = parser->tokenReader.peekLoc();
ptrDeclarator->flavor = Declarator::Flavor::Pointer;
parser->ReadToken(TokenType::OpMul);
@@ -1670,15 +1670,15 @@ namespace Slang
}
parser->genericDepth--;
- if (parser->tokenReader.PeekToken().type == TokenType::OpRsh)
+ if (parser->tokenReader.peekToken().type == TokenType::OpRsh)
{
- parser->tokenReader.PeekToken().type = TokenType::OpGreater;
- parser->tokenReader.PeekToken().loc.setRaw(parser->tokenReader.PeekToken().loc.getRaw() + 1);
+ parser->tokenReader.peekToken().type = TokenType::OpGreater;
+ parser->tokenReader.peekToken().loc.setRaw(parser->tokenReader.peekToken().loc.getRaw() + 1);
}
else if (parser->LookAheadToken(TokenType::OpGreater))
parser->ReadToken(TokenType::OpGreater);
else
- parser->sink->diagnose(parser->tokenReader.PeekToken(), Diagnostics::tokenTypeExpected, "'>'");
+ parser->sink->diagnose(parser->tokenReader.peekToken(), Diagnostics::tokenTypeExpected, "'>'");
return genericApp;
}
@@ -1708,8 +1708,8 @@ namespace Slang
// otherwise, we speculate as generics, and fallback to comparison when parsing failed
TokenSpan tokenSpan;
- tokenSpan.mBegin = parser->tokenReader.mCursor;
- tokenSpan.mEnd = parser->tokenReader.mEnd;
+ tokenSpan.m_begin = parser->tokenReader.m_cursor;
+ tokenSpan.m_end = parser->tokenReader.m_end;
DiagnosticSink newSink(parser->sink->sourceManager);
Parser newParser(*parser);
newParser.sink = &newSink;
@@ -1887,7 +1887,7 @@ namespace Slang
Parser* parser,
ContainerDecl* containerDecl)
{
- SourceLoc startPosition = parser->tokenReader.PeekLoc();
+ SourceLoc startPosition = parser->tokenReader.peekLoc();
auto typeSpec = parseTypeSpec(parser);
@@ -1972,8 +1972,8 @@ namespace Slang
// matter unless we actually decide to support function-type parameters,
// using C syntax.
//
- if ((parser->tokenReader.PeekTokenType() == TokenType::LParent ||
- parser->tokenReader.PeekTokenType() == TokenType::OpLess)
+ if ((parser->tokenReader.peekTokenType() == TokenType::LParent ||
+ parser->tokenReader.peekTokenType() == TokenType::OpLess)
// Only parse as a function if we didn't already see mutually-exclusive
// constructs when parsing the declarator.
@@ -2232,7 +2232,7 @@ namespace Slang
// declaration is made to be "transparent" so that lookup
// will see through it to the members inside.
- auto bufferWrapperTypeNamePos = parser->tokenReader.PeekLoc();
+ auto bufferWrapperTypeNamePos = parser->tokenReader.peekLoc();
// We are going to represent each buffer as a pair of declarations.
// The first is a type declaration that holds all the members, while
@@ -2490,7 +2490,7 @@ namespace Slang
AddModifiers(decl, modifiers.first);
- if( parser->tokenReader.PeekTokenType() == TokenType::LBrace )
+ if( parser->tokenReader.peekTokenType() == TokenType::LBrace )
{
decl->Body = parser->parseBlockStatement();
}
@@ -2881,7 +2881,7 @@ namespace Slang
{
RefPtr<DeclBase> decl;
- auto loc = parser->tokenReader.PeekLoc();
+ auto loc = parser->tokenReader.peekLoc();
switch (peekTokenType(parser))
{
@@ -3027,7 +3027,7 @@ namespace Slang
}
PushScope(program);
- program->loc = tokenReader.PeekLoc();
+ program->loc = tokenReader.peekLoc();
program->scope = currentScope;
ParseDeclBody(this, program, TokenType::EndOfFile);
PopScope();
@@ -3179,7 +3179,7 @@ namespace Slang
if(!parser->LookAheadToken(TokenType::Identifier))
return false;
- auto name = parser->tokenReader.PeekToken().getName();
+ auto name = parser->tokenReader.peekToken().getName();
return isTypeName(parser, name);
}
@@ -3357,7 +3357,7 @@ namespace Slang
RefPtr<Stmt> body;
- if(!tokenReader.IsAtEnd())
+ if(!tokenReader.isAtEnd())
{
FillPosition(blockStatement.Ptr());
}
@@ -3670,7 +3670,7 @@ namespace Slang
static RefPtr<Expr> parseOperator(Parser* parser)
{
Token opToken;
- switch(parser->tokenReader.PeekTokenType())
+ switch(parser->tokenReader.peekTokenType())
{
case TokenType::QuestionMark:
opToken = parser->ReadToken();
@@ -3713,7 +3713,7 @@ namespace Slang
auto expr = inExpr;
for(;;)
{
- auto opTokenType = parser->tokenReader.PeekTokenType();
+ auto opTokenType = parser->tokenReader.peekTokenType();
auto opPrec = GetOpLevel(parser, opTokenType);
if(opPrec < prec)
break;
@@ -3742,7 +3742,7 @@ namespace Slang
for(;;)
{
- auto nextOpPrec = GetOpLevel(parser, parser->tokenReader.PeekTokenType());
+ auto nextOpPrec = GetOpLevel(parser, parser->tokenReader.peekTokenType());
if((GetAssociativityFromLevel(nextOpPrec) == Associativity::Right) ? (nextOpPrec < opPrec) : (nextOpPrec <= opPrec))
break;
@@ -3892,7 +3892,7 @@ namespace Slang
{
default:
// TODO: should this return an error expression instead of NULL?
- parser->sink->diagnose(parser->tokenReader.PeekLoc(), Diagnostics::syntaxError);
+ parser->sink->diagnose(parser->tokenReader.peekLoc(), Diagnostics::syntaxError);
return nullptr;
// Either:
@@ -3966,7 +3966,7 @@ namespace Slang
RefPtr<IntegerLiteralExpr> constExpr = new IntegerLiteralExpr();
parser->FillPosition(constExpr.Ptr());
- auto token = parser->tokenReader.AdvanceToken();
+ auto token = parser->tokenReader.advanceToken();
constExpr->token = token;
UnownedStringSlice suffix;
@@ -4099,7 +4099,7 @@ namespace Slang
RefPtr<FloatingPointLiteralExpr> constExpr = new FloatingPointLiteralExpr();
parser->FillPosition(constExpr.Ptr());
- auto token = parser->tokenReader.AdvanceToken();
+ auto token = parser->tokenReader.advanceToken();
constExpr->token = token;
UnownedStringSlice suffix;
@@ -4250,7 +4250,7 @@ namespace Slang
case TokenType::StringLiteral:
{
RefPtr<StringLiteralExpr> constExpr = new StringLiteralExpr();
- auto token = parser->tokenReader.AdvanceToken();
+ auto token = parser->tokenReader.advanceToken();
constExpr->token = token;
parser->FillPosition(constExpr.Ptr());
@@ -4265,7 +4265,7 @@ namespace Slang
sb << getStringLiteralTokenValue(token);
while (parser->LookAheadToken(TokenType::StringLiteral))
{
- token = parser->tokenReader.AdvanceToken();
+ token = parser->tokenReader.advanceToken();
sb << getStringLiteralTokenValue(token);
}
constExpr->value = sb.ProduceString();
@@ -4356,7 +4356,7 @@ namespace Slang
invokeExpr->FunctionExpr = expr;
parser->FillPosition(invokeExpr.Ptr());
parser->ReadToken(TokenType::LParent);
- while (!parser->tokenReader.IsAtEnd())
+ while (!parser->tokenReader.isAtEnd())
{
if (!parser->LookAheadToken(TokenType::RParent))
invokeExpr->Arguments.add(parser->ParseArgExpr());
diff --git a/source/slang/slang-preprocessor.cpp b/source/slang/slang-preprocessor.cpp
index 9b7a89ddb..2f0ee69a2 100644
--- a/source/slang/slang-preprocessor.cpp
+++ b/source/slang/slang-preprocessor.cpp
@@ -345,7 +345,7 @@ static Token AdvanceRawToken(PreprocessorInputStream* inputStream, LexerFlags le
{
PretokenizedInputStream* pretokenized = dynamic_cast<PretokenizedInputStream*>(inputStream);
SLANG_ASSERT(pretokenized);
- return pretokenized->tokenReader.AdvanceToken();
+ return pretokenized->tokenReader.advanceToken();
}
}
@@ -360,7 +360,7 @@ static Token PeekRawToken(PreprocessorInputStream* inputStream)
{
PretokenizedInputStream* pretokenized = dynamic_cast<PretokenizedInputStream*>(inputStream);
SLANG_ASSERT(pretokenized);
- return pretokenized->tokenReader.PeekToken();
+ return pretokenized->tokenReader.peekToken();
}
}
@@ -375,7 +375,7 @@ static TokenType PeekRawTokenType(PreprocessorInputStream* inputStream)
{
PretokenizedInputStream* pretokenized = dynamic_cast<PretokenizedInputStream*>(inputStream);
SLANG_ASSERT(pretokenized);
- return pretokenized->tokenReader.PeekTokenType();
+ return pretokenized->tokenReader.peekTokenType();
}
}
@@ -1036,7 +1036,7 @@ top:
// We expect the reuslt of lexing to be two tokens: one for the actual value,
// and one for the end-of-input marker.
- if (inputStream->tokenReader.GetCount() != 2)
+ if (inputStream->tokenReader.getCount() != 2)
{
// We expect a token paste to produce a single token
// TODO(tfoley): emit a diagnostic here
@@ -2035,7 +2035,7 @@ static void HandleLineDirective(PreprocessorDirectiveContext* context)
AdvanceToken(context);
// Stop overriding source locations.
- auto sourceView = inputStream->primaryStream->lexer.sourceView;
+ auto sourceView = inputStream->primaryStream->lexer.m_sourceView;
sourceView->addDefaultLineDirective(directiveLoc);
return;
}
@@ -2072,7 +2072,7 @@ static void HandleLineDirective(PreprocessorDirectiveContext* context)
return;
}
- auto sourceView = inputStream->primaryStream->lexer.sourceView;
+ auto sourceView = inputStream->primaryStream->lexer.m_sourceView;
sourceView->addLineDirective(directiveLoc, file, line);
}