You do not have permission to edit this page, for the following reason:
You can view and copy the source of this page.
local string_find, string_match, string_sub =
string.find, string.match, string.sub
local scanner = {}
-- Returns `true` if the tail is empty (end of string).
function scanner:eos()
return self.tail == ""
end
-- Tries to match the given regular expression at the current position.
-- Returns the matched text if it can match, `null` otherwise.
function scanner:scan(pattern)
local match = string_match(self.tail, pattern)
if match and string_find(self.tail, pattern) == 1 then
self.tail = string_sub(self.tail, #match + 1)
self.pos = self.pos + #match
return match
000
1:0
Template used on this page:
Return to Module:Lustache/Scanner.