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:
parent
13ce7a2efa
commit
d04344e9ff
3 changed files with 9 additions and 3 deletions
|
|
@ -12,10 +12,10 @@ Source = class {
|
||||||
self.line = line
|
self.line = line
|
||||||
self.position = position
|
self.position = position
|
||||||
end,
|
end,
|
||||||
increment = function(self, n, ...)
|
increment = function(self, n)
|
||||||
self.position = self.position + n
|
self.position = self.position + n
|
||||||
end,
|
end,
|
||||||
increment_line = function(self, n, ...)
|
increment_line = function(self, n)
|
||||||
self.line = self.line + n
|
self.line = self.line + n
|
||||||
end,
|
end,
|
||||||
count = function(self, capture, ...)
|
count = function(self, capture, ...)
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ return {
|
||||||
-- returns exp, rem if expression found
|
-- returns exp, rem if expression found
|
||||||
-- returns nil if no expression found
|
-- returns nil if no expression found
|
||||||
search = function(self, source, options, str)
|
search = function(self, source, options, str)
|
||||||
|
local start_source = source:clone()
|
||||||
str = source:consume_leading_whitespace(options, str)
|
str = source:consume_leading_whitespace(options, str)
|
||||||
-- if there is a comment, restart the parsing after the comment ends
|
-- if there is a comment, restart the parsing after the comment ends
|
||||||
local c, c_rem = comment:search(source, options, str)
|
local c, c_rem = comment:search(source, options, str)
|
||||||
|
|
@ -45,5 +46,7 @@ return {
|
||||||
local exp, rem = primary:search(source, options, str)
|
local exp, rem = primary:search(source, options, str)
|
||||||
if exp then return exp, rem end
|
if exp then return exp, rem end
|
||||||
end
|
end
|
||||||
|
-- nothing found, revert state change
|
||||||
|
source:set(start_source)
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,8 @@ return {
|
||||||
-- returns exp, rem if expression found
|
-- returns exp, rem if expression found
|
||||||
-- returns nil if no expression found
|
-- returns nil if no expression found
|
||||||
search = function(self, source, options, str, current_priority, primary)
|
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
|
-- if there is a comment, restart the parsing after the comment ends
|
||||||
local c, c_rem = comment:search(source, options, str)
|
local c, c_rem = comment:search(source, options, str)
|
||||||
if c then
|
if c then
|
||||||
|
|
@ -64,5 +65,7 @@ return {
|
||||||
local exp, rem = secondary:search(source, options, str, current_priority, primary)
|
local exp, rem = secondary:search(source, options, str, current_priority, primary)
|
||||||
if exp then return exp, rem end
|
if exp then return exp, rem end
|
||||||
end
|
end
|
||||||
|
-- nothing found, revert state change
|
||||||
|
source:set(start_source)
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue