mirror of
https://github.com/luau-lang/luau.git
synced 2025-04-19 19:23:49 +01:00
Move shebang skip to readFile
This commit is contained in:
parent
2c509692ba
commit
b37e6b7db8
2 changed files with 11 additions and 3 deletions
|
@ -160,9 +160,6 @@ ParseResult Parser::parse(const char* buffer, size_t bufferSize, AstNameTable& n
|
||||||
{
|
{
|
||||||
std::vector<std::string> hotcomments;
|
std::vector<std::string> hotcomments;
|
||||||
|
|
||||||
if (p.lexer.current().type == '#' && p.lexer.lookahead().type == '!')
|
|
||||||
p.lexer.nextline();
|
|
||||||
|
|
||||||
while (isComment(p.lexer.current()) || (FFlag::LuauCaptureBrokenCommentSpans && p.lexer.current().type == Lexeme::BrokenComment))
|
while (isComment(p.lexer.current()) || (FFlag::LuauCaptureBrokenCommentSpans && p.lexer.current().type == Lexeme::BrokenComment))
|
||||||
{
|
{
|
||||||
const char* text = p.lexer.current().data;
|
const char* text = p.lexer.current().data;
|
||||||
|
|
|
@ -67,6 +67,17 @@ std::optional<std::string> readFile(const std::string& name)
|
||||||
if (read != size_t(length))
|
if (read != size_t(length))
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
|
|
||||||
|
// Skip first line if it's a comment
|
||||||
|
if (length != 0 && result[0] == '#')
|
||||||
|
{
|
||||||
|
auto newLine = result.find('\n');
|
||||||
|
|
||||||
|
if (newLine != std::string::npos)
|
||||||
|
result.erase(0, newLine);
|
||||||
|
else
|
||||||
|
result.clear();
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue