standalone for in loop

This commit is contained in:
leaf corcoran 2011-07-14 23:46:16 -07:00
parent a57efb3511
commit 1ae3e4e4cc
3 changed files with 40 additions and 1 deletions

View File

@ -240,7 +240,8 @@ local build_grammar = wrap(function()
Block = Ct(Line * (Break^1 * Line)^0), Block = Ct(Line * (Break^1 * Line)^0),
Line = Cmt(Indent, check_indent) * Statement + _Space * Comment, Line = Cmt(Indent, check_indent) * Statement + _Space * Comment,
Statement = (Import + While + With + For + ClassDecl + Export + BreakLoop + Ct(ExpList) / flatten_or_mark"explist" * Space) * ( Statement = (Import + While + With + For + Foreach
+ ClassDecl + Export + BreakLoop + Ct(ExpList) / flatten_or_mark"explist" * Space) * (
-- statement decorators -- statement decorators
key"if" * Exp * (key"else" * Exp)^-1 * Space / mark"if" + key"if" * Exp * (key"else" * Exp)^-1 * Space / mark"if" +
CompInner / mark"comprehension" CompInner / mark"comprehension"
@ -270,6 +271,8 @@ local build_grammar = wrap(function()
For = key"for" * (Name * sym"=" * Ct(Exp * sym"," * Exp * (sym"," * Exp)^-1)) * For = key"for" * (Name * sym"=" * Ct(Exp * sym"," * Exp * (sym"," * Exp)^-1)) *
key"do"^-1 * Body / mark"for", key"do"^-1 * Body / mark"for",
Foreach = key"for" * Ct(NameList) * key"in" * (sym"*" * Exp / mark"unpack" + Exp) * key"do"^-1 * Body / mark"foreach",
Comprehension = sym"[" * Exp * CompInner * sym"]" / mark"comprehension", Comprehension = sym"[" * Exp * CompInner * sym"]" / mark"comprehension",
CompInner = Ct(CompFor * CompClause^0), CompInner = Ct(CompFor * CompClause^0),

View File

@ -14,4 +14,18 @@ for a=1,10
for b = 2,43 for b = 2,43
print a,b print a,b
for i in iter
for j in yeah
x = 343 + i + j
print i, j
for x in *something
print x
for k,v in pairs hello do print k,v
x = ->
for x in y
y

View File

@ -15,3 +15,25 @@ for a = 1, 10 do
print(a, b) print(a, b)
end end
end end
for i in iter do
for j in yeah do
local x = 343 + i + j
print(i, j)
end
end
do
local _item_0 = something
for _index_0 = 1, #_item_0 do
local x = _item_0[_index_0]
print(x)
end
end
for k, v in pairs(hello) do
print(k, v)
end
local x
x = function()
for x in y do
local _ = y
end
end