Skip to content

Commit

Permalink
fix: backward compatibility for lua 5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
pgagnidze committed Jul 31, 2023
1 parent bb57f11 commit 454aaf1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions ena/helper/common.lua
@@ -1,3 +1,4 @@
---@diagnostic disable: duplicate-set-field
local common = {}
local lpeg = require "lpeg"
local literals = require "ena.lang.literals"
Expand All @@ -7,6 +8,14 @@ local V = lpeg.V

common.endToken = V "endToken"

if not table.pack then
function common.tablePack(...)
return { n = select('#', ...), ... }
end
else
common.tablePack = table.pack
end

function common.I(tag)
return P(
function()
Expand Down
2 changes: 1 addition & 1 deletion ena/parser.lua
Expand Up @@ -152,7 +152,7 @@ local stringLiteral = doubleQuoteString + singleQuoteString

-- abstract syntax tree --
local function node(tag, ...)
local labels = table.pack(...)
local labels = common.tablePack(...)
local params = table.concat(labels, ", ")
local fields = string.gsub(params, "(%w+)", "%1 = %1")
local code = string.format("return function (%s) return {tag = '%s', %s} end", params, tag, fields)
Expand Down

0 comments on commit 454aaf1

Please sign in to comment.