• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

zeroflag / equinox / 15710923822

17 Jun 2025 03:02PM UTC coverage: 89.584% (-0.3%) from 89.918%
15710923822

push

github

zeroflag
cli improvements

14 of 25 new or added lines in 1 file covered. (56.0%)

1875 of 2093 relevant lines covered (89.58%)

7822.36 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

80.25
/src/equinox.lua
1
__VERSION__=nil
73✔
2

3
local Compiler = require("compiler")
73✔
4
local Optimizer = require("ast_optimizer")
73✔
5
local CodeGen = require("codegen")
73✔
6
local Repl = require("repl")
73✔
7

8
local equinox = {}
73✔
9
local optimizer = Optimizer:new()
73✔
10
local compiler = Compiler:new(optimizer, CodeGen:new())
73✔
11
local repl = Repl:new(compiler, optimizer)
73✔
12

13
local lua_require = require
73✔
14

15
function require(module_name)
73✔
16
  if module_name:lower():match("%.eqx$") then
307✔
17
    return equinox.eval_file(module_name, false)
4✔
18
  else
19
    return lua_require(module_name)
303✔
20
  end
21
end
22

23
local lib = [[
24
alias: append #( table.insert 2 0 )
25
alias: insert #( table.insert 3 0 )
26
alias: remove #( table.remove 2 0 )
27
alias: >str #( tostring 1 1 )
28
alias: >num #( tonumber 1 1 )
29
alias: need #( require 1 1 )
30
alias: type #( type 1 1 )
31
alias: max  #( math.max 2 1 )
32
alias: min  #( math.min 2 1 )
33
alias: pow  #( math.pow 2 1 )
34
alias: # size
35
alias: emit #( string.char 1 1 ) #( io.write 1 0 )
36

37
: assert-true #( assert 1 0 ) ;
38
: assert-false not assert-true ;
39
: =assert = assert-true ;
40

41
: [ depth >a ;
42
: ]
43
  []
44
  depth a> - 1 - 0
45
  do
46
    dup >a
47
    1 rot insert ( tbl idx value )
48
    a>
49
  loop ;
50

51
: { depth >a ;
52
: }
53
    {}
54
    depth a> - 1 -
55
    dup 2 % 0 != if
56
      "Table needs even number of items" #( error 1 )
57
    then
58
    2 / 0 do
59
      dup >a -rot ! a>
60
    loop ;
61
]]
73✔
62

63
local function version()
64
  if __VERSION__ then
1✔
65
    return __VERSION__
×
66
  else
67
    version = require("version/version")
1✔
68
    version.load()
1✔
69
    return version.current
1✔
70
  end
71
end
72

73
local function start_repl()
74
  repl:welcome(version())
1✔
75
  repl:start()
1✔
76
end
77

78
local function print_usage()
NEW
79
  print(string.format("Equinox %s Usage: equinox [FILE.EQX] [OPTIONS]", version()))
×
NEW
80
  print("Options:")
×
NEW
81
  print("\t-e\tEvaluate CLI parameter. E.g.: equinox -e '1 2 + .'")
×
NEW
82
  print("\t-d\tEnable debug mode.")
×
NEW
83
  print("\t-o0\tDisable optimizer.")
×
NEW
84
  print("\t-o1\tEnable optimizer (default).")
×
NEW
85
  print("\t-od\tDebug optimizer.")
×
NEW
86
  print("\t-repl\tStart REPL after evaluating a script.")
×
NEW
87
  print("To start the REPL run equinox with no parameters.")
×
88
end
89

90
function equinox.eval_files(files, log_result)
73✔
91
  local result = nil
92
  for i, filename in ipairs(files) do
136✔
93
    if log_result then
71✔
94
      print("Loading " .. filename)
×
95
    end
96
    result = equinox.eval_file(filename, log_result)
71✔
97
  end
98
  return result
65✔
99
end
100

101
function equinox.init()
73✔
102
  compiler:eval_text(lib)
73✔
103
end
104

105
function equinox.main(args)
73✔
106
  if #args < 1 then
73✔
107
    equinox.init()
1✔
108
    start_repl()
1✔
109
  else
110
    local log_result, repl = false, false
72✔
111
    local code, files = nil, {}
72✔
112
    local i = 1
72✔
113
    while i <= #args do
215✔
114
      param = args[i]
143✔
115
      if param == "-d" then
143✔
116
        log_result = true
×
117
      elseif param == "-o0" then
143✔
118
        optimizer:enable(false)
35✔
119
      elseif param == "-o1" then
108✔
120
        optimizer:enable(true)
35✔
121
      elseif param == "-od" then
73✔
122
        optimizer:enable_logging(true)
1✔
123
      elseif param == "-repl" then
72✔
124
        repl = true
×
125
      elseif param == "-e" then
72✔
126
        code = args[i + 1]
1✔
127
        i = i + 1
1✔
128
      elseif param == "-h" or param == "--help" then
71✔
NEW
129
        print_usage()
×
NEW
130
        os.exit(1)
×
131
      else
132
        table.insert(files, param)
71✔
133
      end
134
      i = i + 1
143✔
135
    end
136
    equinox.init()
72✔
137
    if code then
72✔
138
      equinox.eval_text(code, log_result)
1✔
139
    else
140
      equinox.eval_files(files, log_result)
71✔
141
    end
142
    if repl then start_repl() end
66✔
143
  end
144
end
145

146
function equinox.eval_text(str, log_result)
73✔
147
  return compiler:eval_text(str, log_result)
1✔
148
end
149

150
function equinox.eval_file(str, log_result)
73✔
151
  return compiler:eval_file(str, log_result)
75✔
152
end
153

154
equinox.traceback = function(err)
155
  return compiler:traceback(err)
×
156
end
157

158
if arg and arg[0] and
73✔
159
  (arg[0]:match("equinox.lua$") or
73✔
160
   arg[0]:match("equinox_bundle.lua$")) then
1✔
161
  equinox.main(arg)
72✔
162
end
163

164
return equinox
66✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc