local glob tests and local ^

This commit is contained in:
leaf corcoran 2013-01-12 10:33:12 -08:00
parent 19032214a8
commit 0759cd640e
6 changed files with 89 additions and 9 deletions

View File

@ -404,7 +404,7 @@ do
if self.export_all then
return true
end
if self.export_proper and name:match("^[A-Z]") then
if self.export_proper and name:match("^%u") then
return true
end
end

View File

@ -234,7 +234,7 @@ class Block
has_name: (name, skip_exports) =>
if not skip_exports
return true if @export_all
return true if @export_proper and name\match"^[A-Z]"
return true if @export_proper and name\match"^%u"
yes = @_names[name]
if yes == nil and @parent

View File

@ -40,11 +40,28 @@ local statement_compilers = {
end
end,
declare_glob = function(self, node)
local kind = node[2]
local names = { }
self:set("name_glob", function(name)
insert(names, name)
return true
end)
local fn
local _exp_0 = node[2]
if "*" == _exp_0 then
fn = function(name)
if type(name) == "string" then
insert(names, name)
return true
end
end
elseif "^" == _exp_0 then
fn = function(name)
if type(name) == "string" and name:match("^%u") then
insert(names, name)
return true
end
end
else
fn = error("unknown glob")
end
self:set("name_glob", fn)
return data.DelayedLine(function(buff)
insert(buff, "local ")
local _list_0 = names

View File

@ -21,10 +21,24 @@ statement_compilers =
\append_list [@name name for name in *undeclared], ", "
declare_glob: (node) =>
kind = node[2]
names = {}
@set "name_glob", (name) ->
insert names, name
true
fn = switch node[2]
when "*"
(name) ->
if type(name) == "string"
insert names, name
true
when "^"
(name) ->
if type(name) == "string" and name\match "^%u"
insert names, name
true
else
error "unknown glob"
@set "name_glob", fn
data.DelayedLine (buff) ->
insert buff, "local "

View File

@ -9,3 +9,27 @@ something = ->
x = 1212
do
local *
y = 2323
z = 2323
do
local *
print "Nothing Here!"
do
local ^
x = 3434
y = 3434
X = 3434
Y = "yeah"
do
local ^
x,y = "a", "b"
do
local *
x,y = "a", "b"

View File

@ -5,4 +5,29 @@ local something
something = function()
local x
x = 1212
end
do
local y, z
y = 2323
z = 2323
end
do
print("Nothing Here!")
end
do
local X, Y
x = 3434
local y = 3434
X = 3434
Y = "yeah"
end
do
local y
x, y = "a", "b"
end
do
local x, y
x, y = "a", "b"
end