Skip to content

Commit 206ab81

Browse files
committed
Add support for compound statements
1 parent 64212e3 commit 206ab81

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/prometheus/visitast.lua

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,16 @@ function visitAst(ast, previsit, postvisit, data)
3939
return ast;
4040
end
4141

42+
local compundStats = lookupify{
43+
AstKind.CompoundAddStatement,
44+
AstKind.CompoundSubStatement,
45+
AstKind.CompoundMulStatement,
46+
AstKind.CompoundDivStatement,
47+
AstKind.CompoundModStatement,
48+
AstKind.CompoundPowStatement,
49+
AstKind.CompoundConcatStatement,
50+
}
51+
4252
function visitBlock(block, previsit, postvisit, data, isFunctionBlock)
4353
block.isBlock = true;
4454
block.isFunctionBlock = isFunctionBlock or false;
@@ -143,6 +153,9 @@ function visitStatement(statement, previsit, postvisit, data)
143153
for i, expression in ipairs(statement.expressions) do
144154
statement.expressions[i] = visitExpression(expression, previsit, postvisit, data);
145155
end
156+
elseif compundStats[statement.kind] then
157+
statement.lhs = visitExpression(statement.lhs, previsit, postvisit, data);
158+
statement.rhs = visitExpression(statement.rhs, previsit, postvisit, data);
146159
end
147160

148161
if(type(postvisit) == "function") then

0 commit comments

Comments
 (0)