Skip to content

Commit 7a35326

Browse files
committed
Fixed bug in Tokenizer
1 parent eb6cf57 commit 7a35326

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/prometheus/tokenizer.lua

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ end
281281
-- Lex the next token as a Number
282282
function Tokenizer:number()
283283
local startPos = self.index;
284-
local source = expect(self, self.NumberCharsLookup);
284+
local source = expect(self, setmetatable({["."] = true}, {__index = self.NumberCharsLookup}));
285285

286286
if source == "0" then
287287
if self.BinaryNums and is(self, lookupify(self.BinaryNums)) then
@@ -299,10 +299,13 @@ function Tokenizer:number()
299299
end
300300
end
301301

302-
source = source .. int(self, self.NumberCharsLookup, lookupify(self.DecimalSeperators or {}));
303-
304-
if(is(self, ".")) then
305-
source = source .. get(self) .. int(self, self.NumberCharsLookup, lookupify(self.DecimalSeperators or {}));
302+
if source == "." then
303+
source = source .. int(self, self.NumberCharsLookup, lookupify(self.DecimalSeperators or {}));
304+
else
305+
source = source .. int(self, self.NumberCharsLookup, lookupify(self.DecimalSeperators or {}));
306+
if(is(self, ".")) then
307+
source = source .. get(self) .. int(self, self.NumberCharsLookup, lookupify(self.DecimalSeperators or {}));
308+
end
306309
end
307310

308311
if(self.DecimalExponent and is(self, lookupify(self.DecimalExponent))) then
@@ -533,6 +536,11 @@ function Tokenizer:next()
533536
return value;
534537
end
535538
end
539+
540+
-- Number starting with dot
541+
if(is(self, ".") and is(self, self.NumberCharsLookup, 1)) then
542+
return self:number();
543+
end
536544

537545
-- Symbols
538546
if(is(self, self.SymbolCharsLookup)) then

0 commit comments

Comments
 (0)