1
0
Fork 0
mirror of https://github.com/Reuh/anselme.git synced 2025-10-27 08:39:30 +00:00

[internal] fix incorrect source tracking when reaching end of multiline expresssion

This commit is contained in:
Étienne Fildadut 2024-05-16 17:16:01 +02:00
parent 13ce7a2efa
commit d04344e9ff
3 changed files with 9 additions and 3 deletions

View file

@ -12,10 +12,10 @@ Source = class {
self.line = line
self.position = position
end,
increment = function(self, n, ...)
increment = function(self, n)
self.position = self.position + n
end,
increment_line = function(self, n, ...)
increment_line = function(self, n)
self.line = self.line + n
end,
count = function(self, capture, ...)

View file

@ -36,6 +36,7 @@ return {
-- returns exp, rem if expression found
-- returns nil if no expression found
search = function(self, source, options, str)
local start_source = source:clone()
str = source:consume_leading_whitespace(options, str)
-- if there is a comment, restart the parsing after the comment ends
local c, c_rem = comment:search(source, options, str)
@ -45,5 +46,7 @@ return {
local exp, rem = primary:search(source, options, str)
if exp then return exp, rem end
end
-- nothing found, revert state change
source:set(start_source)
end
}

View file

@ -51,7 +51,8 @@ return {
-- returns exp, rem if expression found
-- returns nil if no expression found
search = function(self, source, options, str, current_priority, primary)
str = source:consume_leading_whitespace( options,str)
local start_source = source:clone()
str = source:consume_leading_whitespace(options, str)
-- if there is a comment, restart the parsing after the comment ends
local c, c_rem = comment:search(source, options, str)
if c then
@ -64,5 +65,7 @@ return {
local exp, rem = secondary:search(source, options, str, current_priority, primary)
if exp then return exp, rem end
end
-- nothing found, revert state change
source:set(start_source)
end
}