mirror of
https://github.com/luau-lang/luau.git
synced 2025-05-04 10:33:46 +01:00
Optional ergonomics
This commit is contained in:
parent
8dcbebaa70
commit
310adedc90
1 changed files with 4 additions and 6 deletions
|
@ -595,9 +595,7 @@ const Lexeme Lexer::nextInterpolatedString()
|
||||||
Position start = position();
|
Position start = position();
|
||||||
unsigned int startOffset = offset;
|
unsigned int startOffset = offset;
|
||||||
|
|
||||||
std::optional<Lexeme> readSectionOpt = readInterpolatedStringSection(start, Lexeme::InterpStringMid);
|
if (auto readSection = readInterpolatedStringSection(start, Lexeme::InterpStringMid))
|
||||||
|
|
||||||
if (auto readSection = readSectionOpt)
|
|
||||||
{
|
{
|
||||||
lexeme = *readSection;
|
lexeme = *readSection;
|
||||||
return lexeme;
|
return lexeme;
|
||||||
|
@ -635,7 +633,7 @@ std::optional<Lexeme> Lexer::readInterpolatedStringSection(Position start, Lexem
|
||||||
case 0:
|
case 0:
|
||||||
case '\r':
|
case '\r':
|
||||||
case '\n':
|
case '\n':
|
||||||
return std::optional(Lexeme(Location(start, position()), Lexeme::BrokenString));
|
return Lexeme(Location(start, position()), Lexeme::BrokenString);
|
||||||
|
|
||||||
case '\\':
|
case '\\':
|
||||||
readBackslashInString();
|
readBackslashInString();
|
||||||
|
@ -645,12 +643,12 @@ std::optional<Lexeme> Lexer::readInterpolatedStringSection(Position start, Lexem
|
||||||
{
|
{
|
||||||
if (peekch(1) == '{')
|
if (peekch(1) == '{')
|
||||||
{
|
{
|
||||||
return std::optional(Lexeme(Location(start, position()), Lexeme::BrokenInterpDoubleBrace));
|
return Lexeme(Location(start, position()), Lexeme::BrokenInterpDoubleBrace);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto lexemeOutput = Lexeme(Location(start, position()), Lexeme::InterpStringBegin, &buffer[startOffset], offset - startOffset);
|
auto lexemeOutput = Lexeme(Location(start, position()), Lexeme::InterpStringBegin, &buffer[startOffset], offset - startOffset);
|
||||||
consume();
|
consume();
|
||||||
return std::optional(lexemeOutput);
|
return lexemeOutput;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Add table
Reference in a new issue