change project structure
This commit is contained in:
parent
45e22d9fed
commit
13da52ad24
|
@ -1,4 +1,5 @@
|
|||
nds
|
||||
*.txt
|
||||
callgrind*
|
||||
.vscode
|
||||
.vscode
|
||||
bin/nds
|
|
@ -1,13 +0,0 @@
|
|||
|
||||
var a = 0;
|
||||
var b = 1;
|
||||
var i = 1;
|
||||
|
||||
while (i < 300) {
|
||||
var c = a + b;
|
||||
a = b;
|
||||
b = c;
|
||||
i = i + 1;
|
||||
};
|
||||
|
||||
print b;
|
|
@ -1,13 +0,0 @@
|
|||
|
||||
a = 0
|
||||
b = 1
|
||||
i = 1
|
||||
|
||||
while i < 300:
|
||||
c = a + b
|
||||
a = b
|
||||
b = c
|
||||
i = i + 1
|
||||
|
||||
|
||||
print (b)
|
|
@ -1,13 +0,0 @@
|
|||
x=0
|
||||
y=1
|
||||
i=2
|
||||
|
||||
while [ $i -lt 300 ]
|
||||
do
|
||||
i=$(( $i + 1 ))
|
||||
z=$(( $x + $y ))
|
||||
x=$y
|
||||
y=$z
|
||||
done
|
||||
|
||||
echo "$y"
|
|
@ -1,9 +0,0 @@
|
|||
local function fib(n)
|
||||
if n < 2 then
|
||||
return 1.5
|
||||
else
|
||||
return fib(n-1) + fib(n-2)
|
||||
end
|
||||
end
|
||||
|
||||
print(fib(37.2))
|
|
@ -1,7 +0,0 @@
|
|||
def fib(n):
|
||||
if n < 2:
|
||||
return 1.5
|
||||
else:
|
||||
return fib(n-1) + fib(n-2)
|
||||
|
||||
print(fib(37.2))
|
|
@ -0,0 +1,25 @@
|
|||
# Package
|
||||
|
||||
version = "0.1.0"
|
||||
author = "prod2"
|
||||
description = "A simple scripting language."
|
||||
license = "Apache-2.0"
|
||||
srcDir = "src"
|
||||
skipDirs = @["tests", "examples"]
|
||||
binDir = "bin"
|
||||
installExt = @["nim"]
|
||||
bin = @["nds"]
|
||||
|
||||
# Dependencies
|
||||
|
||||
requires "nim >= 1.6.2"
|
||||
|
||||
task test, "run tests":
|
||||
exec "nim c --gc:arc -d:debug --skipProjCfg --skipParentCfg -r tests/test.nim"
|
||||
exec "rm tests/test"
|
||||
|
||||
task debug, "build nds for debugging":
|
||||
exec "nim c --gc:arc -d:debug --skipProjCfg --skipParentCfg --out:bin/nds src/nds.nim"
|
||||
|
||||
task profile, "build nds with internal profiler":
|
||||
exec "nim c --gc:arc -d:danger -d:ndsprofile --out:bin/nds src/nds.nim"
|
|
@ -1,13 +1,10 @@
|
|||
import vm
|
||||
import compiler
|
||||
import config
|
||||
import ndspkg/vm
|
||||
import ndspkg/compiler
|
||||
import ndspkg/config
|
||||
|
||||
import os
|
||||
import strformat
|
||||
|
||||
when compileTests:
|
||||
import tests/hashtable
|
||||
|
||||
type Result = enum
|
||||
rsOK, rsCompileError, rsRuntimeError
|
||||
|
||||
|
@ -41,13 +38,6 @@ proc runFile(path: string) =
|
|||
of rsOK:
|
||||
quit 0
|
||||
|
||||
proc runTests =
|
||||
when compileTests:
|
||||
testHashtables()
|
||||
else:
|
||||
echo "Nds was compiled without nim tests. Please change the flag and recompile, then tests will be available."
|
||||
quit 1
|
||||
|
||||
proc printUsage =
|
||||
echo """Usage:
|
||||
- Start a repl: nds
|
||||
|
@ -69,10 +59,6 @@ elif paramCount() == 1:
|
|||
runFile(paramStr(1))
|
||||
else:
|
||||
case arg:
|
||||
of "--test":
|
||||
when defined(danger) or defined(release):
|
||||
echo "WARNING: nds was compiled with -d:danger or -d:release, tests are only supported on -d:debug!"
|
||||
runTests()
|
||||
of "--help":
|
||||
printUsage()
|
||||
quit 0
|
||||
|
@ -81,6 +67,7 @@ elif paramCount() == 1:
|
|||
printUsage()
|
||||
quit 1
|
||||
else:
|
||||
echo "Maximum param count is 1"
|
||||
echo "Maximum param count is 1."
|
||||
printUsage()
|
||||
quit 1
|
||||
|
|
@ -11,11 +11,7 @@ const assertionsCompiler* = true # sanity checks in the compiler
|
|||
# vm debug options (setting any to true will slow runtime down!)
|
||||
const debugVM* = defined(debug)
|
||||
const assertionsVM* = defined(debug) # sanity checks in the VM, such as the stack being empty at the end
|
||||
const profileInstructions* = false # if true, the time spent on every opcode is measured
|
||||
|
||||
const compileTests* = defined(debug)
|
||||
# if true, the nim part of the test suite will be compiled in main
|
||||
# it will be possible to start it using ./nds --test
|
||||
const profileInstructions* = defined(ndsprofile) # if true, the time spent on every opcode is measured
|
||||
|
||||
# choose a line editor for the repl
|
||||
const lineEditor = leRdstdin
|
|
@ -0,0 +1,3 @@
|
|||
import hashtable
|
||||
|
||||
testHashtables()
|
Loading…
Reference in New Issue