Shader/SourceLocation: Fix column index
This commit is contained in:
@@ -79,7 +79,7 @@ namespace Nz::ShaderLang
|
|||||||
|
|
||||||
inline bool SourceLocation::IsValid() const
|
inline bool SourceLocation::IsValid() const
|
||||||
{
|
{
|
||||||
return startLine != 0 && endLine != 0 && endColumn != 0 && startColumn != 0;
|
return startLine != 0 || endLine != 0 || endColumn != 0 || startColumn != 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ namespace Nz::ShaderLang
|
|||||||
return std::isalnum(c) || c == '_';
|
return std::isalnum(c) || c == '_';
|
||||||
};
|
};
|
||||||
|
|
||||||
unsigned int lineNumber = 1;
|
UInt32 currentLine = 1;
|
||||||
std::size_t lastLineFeed = 0;
|
std::size_t lastLineFeed = 0;
|
||||||
std::vector<Token> tokens;
|
std::vector<Token> tokens;
|
||||||
|
|
||||||
@@ -91,8 +91,8 @@ namespace Nz::ShaderLang
|
|||||||
char c = Peek(0);
|
char c = Peek(0);
|
||||||
|
|
||||||
Token token;
|
Token token;
|
||||||
token.location.startColumn = static_cast<unsigned int>(currentPos - lastLineFeed);
|
token.location.startColumn = SafeCast<UInt32>(currentPos - lastLineFeed) + 1;
|
||||||
token.location.startLine = lineNumber;
|
token.location.startLine = currentLine;
|
||||||
token.location.file = currentFile;
|
token.location.file = currentFile;
|
||||||
|
|
||||||
if (c == '\0')
|
if (c == '\0')
|
||||||
@@ -112,7 +112,7 @@ namespace Nz::ShaderLang
|
|||||||
|
|
||||||
case '\n':
|
case '\n':
|
||||||
{
|
{
|
||||||
lineNumber++;
|
currentLine++;
|
||||||
lastLineFeed = currentPos;
|
lastLineFeed = currentPos;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -169,7 +169,7 @@ namespace Nz::ShaderLang
|
|||||||
}
|
}
|
||||||
else if (next == '\n')
|
else if (next == '\n')
|
||||||
{
|
{
|
||||||
lineNumber++;
|
currentLine++;
|
||||||
lastLineFeed = currentPos + 1;
|
lastLineFeed = currentPos + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -223,7 +223,7 @@ namespace Nz::ShaderLang
|
|||||||
currentPos++;
|
currentPos++;
|
||||||
}
|
}
|
||||||
|
|
||||||
token.location.endColumn = static_cast<unsigned int>(currentPos - lastLineFeed);
|
token.location.endColumn = SafeCast<UInt32>(currentPos - lastLineFeed) + 1;
|
||||||
|
|
||||||
if (floatingPoint)
|
if (floatingPoint)
|
||||||
{
|
{
|
||||||
@@ -413,7 +413,7 @@ namespace Nz::ShaderLang
|
|||||||
case '\0':
|
case '\0':
|
||||||
case '\n':
|
case '\n':
|
||||||
case '\r':
|
case '\r':
|
||||||
token.location.endColumn = static_cast<unsigned int>(currentPos - lastLineFeed);
|
token.location.endColumn = SafeCast<UInt32>(currentPos - lastLineFeed) + 1;
|
||||||
throw LexerUnfinishedStringError{ token.location };
|
throw LexerUnfinishedStringError{ token.location };
|
||||||
|
|
||||||
case '\\':
|
case '\\':
|
||||||
@@ -428,7 +428,7 @@ namespace Nz::ShaderLang
|
|||||||
case '"': character = '"'; break;
|
case '"': character = '"'; break;
|
||||||
case '\\': character = '\\'; break;
|
case '\\': character = '\\'; break;
|
||||||
default:
|
default:
|
||||||
token.location.endColumn = static_cast<unsigned int>(currentPos - lastLineFeed);
|
token.location.endColumn = SafeCast<UInt32>(currentPos - lastLineFeed) + 1;
|
||||||
throw LexerUnrecognizedCharError{ token.location };
|
throw LexerUnrecognizedCharError{ token.location };
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -475,8 +475,8 @@ namespace Nz::ShaderLang
|
|||||||
|
|
||||||
if (tokenType)
|
if (tokenType)
|
||||||
{
|
{
|
||||||
token.location.endColumn = static_cast<unsigned int>(currentPos - lastLineFeed);
|
token.location.endColumn = SafeCast<UInt32>(currentPos - lastLineFeed) + 1;
|
||||||
token.location.endLine = lineNumber;
|
token.location.endLine = currentLine;
|
||||||
token.type = *tokenType;
|
token.type = *tokenType;
|
||||||
|
|
||||||
tokens.push_back(std::move(token));
|
tokens.push_back(std::move(token));
|
||||||
|
|||||||
Reference in New Issue
Block a user