mirror of
https://github.com/notwa/lips
synced 2024-05-05 02:43:24 -07:00
improve variable name checks
This commit is contained in:
parent
635621de0d
commit
e5cc5fd068
|
@ -393,10 +393,10 @@ function Lexer:lex(_yield)
|
||||||
yield('SEP', ',')
|
yield('SEP', ',')
|
||||||
elseif self.chr == '[' then
|
elseif self.chr == '[' then
|
||||||
self:nextc()
|
self:nextc()
|
||||||
local buff = self:read_chars('[%w_]')
|
if self.chr:find('%d') then
|
||||||
if buff:match('^%d') then
|
|
||||||
self:error('variable names cannot begin with a number')
|
self:error('variable names cannot begin with a number')
|
||||||
end
|
end
|
||||||
|
local buff = self:read_chars('[%w_]')
|
||||||
if self.chr ~= ']' then
|
if self.chr ~= ']' then
|
||||||
self:error('invalid variable name')
|
self:error('invalid variable name')
|
||||||
end
|
end
|
||||||
|
@ -444,6 +444,9 @@ function Lexer:lex(_yield)
|
||||||
self:lex_string(yield)
|
self:lex_string(yield)
|
||||||
elseif self.chr == '@' then
|
elseif self.chr == '@' then
|
||||||
self:nextc()
|
self:nextc()
|
||||||
|
if self.chr:find('%d') then
|
||||||
|
self:error('variable names cannot begin with a number')
|
||||||
|
end
|
||||||
local buff = self:read_chars('[%w_]')
|
local buff = self:read_chars('[%w_]')
|
||||||
yield('VARSYM', buff)
|
yield('VARSYM', buff)
|
||||||
elseif self.chr == '%' then
|
elseif self.chr == '%' then
|
||||||
|
|
Loading…
Reference in New Issue
Block a user