From d865925d050f13e1097721d2b1f3ae352b49c484 Mon Sep 17 00:00:00 2001 From: SoniEx2 Date: Thu, 6 Jun 2024 03:09:00 -0300 Subject: Fix long string parsing --- src/cratera/luatokens.lua | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/cratera') diff --git a/src/cratera/luatokens.lua b/src/cratera/luatokens.lua index 90d0c61..632cf27 100644 --- a/src/cratera/luatokens.lua +++ b/src/cratera/luatokens.lua @@ -1,6 +1,6 @@ --[[ This file is part of Cratera Compiler - Copyright (C) 2019 Soni L. + Copyright (C) 2019, 2024 Soni L. This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by @@ -387,7 +387,12 @@ end do local tlongstring = {} defs.longstring = tlongstring do local tllongstring_proper = selfify({[parser.FALLBACK] = "self", ["]"] = function(state, token) state.longstring_close = 0 return "maybe_end" end}) - tllongstring_proper[1] = false -- placeholder for newline handling + tlongstring[1] = false -- first newline is skipped(!) + tllongstring_proper[1] = function(state, token, rule) + if token == "\n" or token == "\r" then + collect_fallback(state, "\n") + end + end tllongstring_proper[2] = collect_fallback do local tllmaybe_end = selfify({defs = defs}, "maybe_end") @@ -425,7 +430,7 @@ do local tlongstring = {} end tlongstring.longstring_proper = tllongstring_proper - mknewline(tlongstring, 1, tllongstring_proper) + mknewline(tllongstring_proper, 1) setmetatable(tlongstring, {__index=tllongstring_proper}) end end -- cgit 1.4.1