Created
January 26, 2019 00:44
-
-
Save bakpakin/961e7d4c9356dca1dbc73ded8889af31 to your computer and use it in GitHub Desktop.
New code injection special
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- (lua "print('hello!')") -> prints hello, evaluates to nil | |
-- (lua "print 'hello!'" "10") -> prints hello, evaluates to the number 10 | |
-- (lua nil "{1,2,3}") -> Evaluates to a table literal | |
SPECIALS['lua'] = function(ast, scope, parent) | |
assertCompile(#ast == 2 or #ast == 3, | |
"expected 2 or 3 arguments in 'lua' special form", ast) | |
if ast[2] ~= nil then | |
table.insert(parent, {leaf = tostring(ast[2]), ast = ast}) | |
end | |
if #ast == 3 then | |
return tostring(ast[3]) | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment