author | Francesco Abbate <francesco.bbt@gmail.com> | 2013年05月12日 23:17:57 +0200 |
---|---|---|
committer | Francesco Abbate <francesco.bbt@gmail.com> | 2013年05月12日 23:17:57 +0200 |
commit | 338fd9e668b582105def249a3be6a377d0160272 (patch) | |
tree | 65f2c2324b85ecb7722b9a517d04764a3774632f /expr-print.lua | |
parent | 204fa404431f9c619f0dfc5ae3efc463749fa8ed (diff) | |
download | gsl-shell-338fd9e668b582105def249a3be6a377d0160272.tar.gz |
-rw-r--r-- | expr-print.lua | 12 |
diff --git a/expr-print.lua b/expr-print.lua index 03b1e185..ebbc6518 100644 --- a/expr-print.lua +++ b/expr-print.lua @@ -67,13 +67,13 @@ local function eval_operator(op, a, b) else error('unkown operation: ' .. op) end end -local function eval(expr, scope, scope_state) +local function eval(expr, scope, ...) if type(expr) == 'number' then return expr elseif type(expr) == 'string' then - return scope.ident(expr, scope_state) + return scope.ident(expr, ...) elseif expr.func then - local arg_value = eval(expr.arg, scope, scope_state) + local arg_value = eval(expr.arg, scope, ...) if arg_value then local f = scope.func(expr) if not f then error('unknown function: ' .. expr.func) end @@ -81,11 +81,11 @@ local function eval(expr, scope, scope_state) end else if #expr == 1 then - local v = eval(expr[1], scope, scope_state) + local v = eval(expr[1], scope, ...) if v then return -v end else - local a = eval(expr[1], scope, scope_state) - local b = eval(expr[2], scope, scope_state) + local a = eval(expr[1], scope, ...) + local b = eval(expr[2], scope, ...) if a and b then return eval_operator(expr.operator, a, b) end |