From 6bae5647c8c4f21aa94346ed5fe5a64b121f5e88 Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Sun, 27 Nov 2016 21:25:57 -0800 Subject: [PATCH] fix parsing of 0 in expressions --- lips/Expression.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lips/Expression.lua b/lips/Expression.lua index 46ed0bb..022c765 100644 --- a/lips/Expression.lua +++ b/lips/Expression.lua @@ -154,9 +154,12 @@ function Expression:lex1(str, tokens) num = tonumber(considered, 2) elseif consider('0x[0-9A-Fa-f]+') then num = tonumber(considered, 16) - elseif consider('0[0-7]+') then + elseif consider('0[0-9]+') then + if considered:match('[89]') then + return "bad octal number: "..considered..here + end num = tonumber(considered, 8) - elseif consider('[1-9][0-9]*') then + elseif consider('[0-9]*') then num = tonumber(considered) end if num == nil then