Skip to content

Commit 409f9de

Browse files
Move syntax library from batteries to std (#350)
1 parent f523ee5 commit 409f9de

File tree

5 files changed

+16
-3
lines changed

5 files changed

+16
-3
lines changed

tests/testAstSerializer.spec.luau

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
local luau = require("@lute/luau")
22
local fs = require("@lute/fs")
33

4-
local parser = require("@batteries/syntax/parser")
5-
local printer = require("@batteries/syntax/printer")
4+
local parser = require("@std/syntax/parser")
5+
local printer = require("@std/syntax/printer")
66
local T = require("@lute/luau")
77

88
local function assertEqualsLocation(

tools/luthier.luau

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,20 @@ local function generateStdLibFilesIfNeeded()
288288

289289
if safeFsType(path) == "file" then
290290
local libSrc = fs.readfiletostring(path)
291-
fs.write(cpp, `\n \{"{aliasedPath}", R"({libSrc})"},\n`)
291+
if #libSrc > 16_000 then
292+
-- https://learn.microsoft.com/en-us/cpp/error-messages/compiler-errors-1/compiler-error-c2026
293+
-- MSVC can't handle a single string literal being over 16380 single-byte characters,
294+
-- but can if they are adjacent contatenated strings. So, we split the string line-by-line into
295+
-- adjacent substrings.
296+
local lines = string.split(libSrc, "\n")
297+
local generatedLines = table.create(#lines)
298+
for _, line in lines do
299+
table.insert(generatedLines, `"{string.gsub(line, '"', '\\"')}\\n"`)
300+
end
301+
fs.write(cpp, `\n \{"{aliasedPath}", {table.concat(generatedLines, "\n")}},\n`)
302+
else
303+
fs.write(cpp, `\n \{"{aliasedPath}", R"({libSrc})"},\n`)
304+
end
292305
end
293306

294307
if safeFsType(path) == "dir" then

0 commit comments

Comments
 (0)