From 1a755ddee807fe4e1b683f32b21d710dc78600a2 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Wed, 9 May 2018 13:34:33 -0700 Subject: Added tentative support for luajit (depends on pure-lua LPEG implementation). --- core/operators.nom | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'core/operators.nom') diff --git a/core/operators.nom b/core/operators.nom index 88b0374..fca56d5 100644 --- a/core/operators.nom +++ b/core/operators.nom @@ -163,7 +163,14 @@ immediately # Unary operators compile [- %] to: Lua value "(- \(% as lua expr))" compile [not %] to: Lua value "(not \(% as lua expr))" - compile [length of %list] to: Lua value "(#\(%list as lua expr))" + compile [length of %list] to + # A bit of a hack so that luajit works properly. + Lua value ".." + (function(l) + local mt = getmetatable(l); + if mt and mt.__len then return mt.__len(l) end + return #l + end)(\(%list as lua expr)) # Update operators immediately -- cgit v1.2.3