1
0
Fork 0
mirror of https://github.com/notwa/lips synced 2024-11-14 14:49:03 -08:00

improve variable name checks

This commit is contained in:
Connor Olding 2016-11-27 21:59:42 -08:00
parent 635621de0d
commit e5cc5fd068

View file

@ -393,10 +393,10 @@ function Lexer:lex(_yield)
yield('SEP', ',')
elseif self.chr == '[' then
self:nextc()
local buff = self:read_chars('[%w_]')
if buff:match('^%d') then
if self.chr:find('%d') then
self:error('variable names cannot begin with a number')
end
local buff = self:read_chars('[%w_]')
if self.chr ~= ']' then
self:error('invalid variable name')
end
@ -444,6 +444,9 @@ function Lexer:lex(_yield)
self:lex_string(yield)
elseif self.chr == '@' then
self:nextc()
if self.chr:find('%d') then
self:error('variable names cannot begin with a number')
end
local buff = self:read_chars('[%w_]')
yield('VARSYM', buff)
elseif self.chr == '%' then