Skip to content

Commit

Permalink
Oops, forgot to update the croc interpreter code with all the languag…
Browse files Browse the repository at this point in the history
…e changes.
  • Loading branch information
JarrettBillingsley committed Nov 12, 2014
1 parent 418fdce commit 696e62f
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions croc.cpp
Expand Up @@ -28,8 +28,8 @@ local namespace ExitCode
OtherError = 2
}
local ShortUsage =
@`Usage:
local ShortUsage = [=[
Usage:
croc [options] [filename [args]] run file with args, or enter REPL
croc [options] -e "string" run "string"
croc --compile outpath filename compile module to bytecode
Expand All @@ -42,10 +42,10 @@ local ShortUsage =
--docs=<on|off|default> doc comment mode
-I "path" add import path
-l dotted.module.name import module
--safe safe libs only (overrides -d)`
--safe safe libs only (overrides -d)]=]
local LongUsage =
@`This is the Croc standalone interpreter. It can be run in several different
local LongUsage = [=[
This is the Croc standalone interpreter. It can be run in several different
modes, and the modes in which code is executed can also take options.
The execution options are as follows:
Expand Down Expand Up @@ -125,10 +125,12 @@ Exit codes:
1 means there was an invalid program argument.
2 means there was some error during execution.
3 is reserved for something really bad happening.
`
]=]
local function printVersion()
{
writeln(Version)
}
local function printUsage(full: bool)
{
Expand Down Expand Up @@ -419,10 +421,14 @@ local class ReplInout : repl.ConsoleInout
_thread
function init()
{
:_thread = null
}
function cleanup()
{
:_thread = null
}
function run(fd: funcdef)
{
Expand All @@ -447,7 +453,7 @@ local class ReplInout : repl.ConsoleInout
{
local runEntry = #e.traceback
for(i: 0 .. #e.traceback)
for(i; 0 .. #e.traceback)
{
if(e.traceback[i].file.startsWith("<croc>.run"))
{
Expand Down Expand Up @@ -705,7 +711,14 @@ int main(int argc, char** argv)
}
else
{
fprintf(stderr, "Fatal error\n");
fprintf(stderr, "-------- Fatal Error --------\n");
croc_pushToString(t, -1);
fprintf(stderr, "%s\n", croc_getString(t, -1));
croc_popTop(t);
croc_dupTop(t);
croc_pushNull(t);
croc_methodCall(t, -2, "tracebackString", 1);
fprintf(stderr, "%s\n", croc_getString(t, -1));
return 3;
}
}

0 comments on commit 696e62f

Please sign in to comment.