Moonscript: support for modules using with statement; optionally ignore colon as part of an identifier
This commit is contained in:
parent
94dc198f4b
commit
b87180996d
|
@ -274,11 +274,13 @@ function Moon:_init()
|
||||||
end
|
end
|
||||||
|
|
||||||
function Moon:item_follows (t,v,tok)
|
function Moon:item_follows (t,v,tok)
|
||||||
|
if t == '.' then -- enclosed in with statement
|
||||||
|
t,v = tnext(tok)
|
||||||
|
end
|
||||||
if t == 'iden' then
|
if t == 'iden' then
|
||||||
local name,t,v = v, tnext(tok) --tools.get_fun_name(tok,v)
|
local name,t,v = tools.get_fun_name(tok,v,'')
|
||||||
if name == 'class' then
|
if name == 'class' then
|
||||||
name = v
|
name,t,v = tools.get_fun_name(tok,v,'')
|
||||||
--name,t,v = tools.get_fun_name(tok,v)
|
|
||||||
-- class!
|
-- class!
|
||||||
return function(tags,tok)
|
return function(tags,tok)
|
||||||
tags:add('class','type')
|
tags:add('class','type')
|
||||||
|
|
|
@ -352,10 +352,12 @@ function M.get_parameters (tok,endtoken,delim)
|
||||||
return args
|
return args
|
||||||
end
|
end
|
||||||
|
|
||||||
-- parse a Lua identifier - contains names separated by . and :.
|
-- parse a Lua identifier - contains names separated by . and (optionally) :.
|
||||||
function M.get_fun_name (tok,first)
|
-- Set `colon` to be the secondary separator, '' for none.
|
||||||
|
function M.get_fun_name (tok,first,colon)
|
||||||
local res = {}
|
local res = {}
|
||||||
local t,name,sep
|
local t,name,sep
|
||||||
|
colon = colon or ':'
|
||||||
if not first then
|
if not first then
|
||||||
t,name = tnext(tok)
|
t,name = tnext(tok)
|
||||||
else
|
else
|
||||||
|
@ -363,7 +365,7 @@ function M.get_fun_name (tok,first)
|
||||||
end
|
end
|
||||||
if t ~= 'iden' then return nil end
|
if t ~= 'iden' then return nil end
|
||||||
t,sep = tnext(tok)
|
t,sep = tnext(tok)
|
||||||
while sep == '.' or sep == ':' do
|
while sep == '.' or sep == colon do
|
||||||
append(res,name)
|
append(res,name)
|
||||||
append(res,sep)
|
append(res,sep)
|
||||||
t,name = tnext(tok)
|
t,name = tnext(tok)
|
||||||
|
|
Loading…
Reference in New Issue