Skip to content

Commit

Permalink
Add new AST node type StatementsGroup
Browse files Browse the repository at this point in the history
Used to group statements without creating a new lexical scope.
  • Loading branch information
franko committed Feb 25, 2016
1 parent fd9ed8b commit 639fe24
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lang/ast-validate.lua
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,16 @@ local syntax = {
}
}
},
StatementsGroup = {
kind = "StatementsGroup",
base = "Statement",
properties = {
statements = {
type = "list",
kind = "Statement",
}
}
},
EmptyStatement = {
kind = "EmptyStatement",
base = "Statement",
Expand Down
6 changes: 6 additions & 0 deletions lang/generator.lua
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,12 @@ function TestRule:LogicalExpression(node, jmp, jreg, negate, store, dest)
end
end

function StatementRule:StatementsGroup(node)
for i = 1, #node.statements do
self:emit(node.statements[i])
end
end

function StatementRule:CallExpression(node)
self:expr_tomultireg(node, 0, false)
end
Expand Down
6 changes: 6 additions & 0 deletions lang/luacode-generator.lua
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,12 @@ function ExpressionRule:SendExpression(node)
return exp, operator.ident_priority
end

function StatementRule:StatementsGroup(node)
for i = 1, #node.statements do
self:emit(node.statements[i])
end
end

function StatementRule:FunctionDeclaration(node)
self:proto_enter(0)
local name = self:expr_emit(node.id)
Expand Down

0 comments on commit 639fe24

Please sign in to comment.