Refactored interpreter into just functions, added a REPL to the main kraken.

This commit is contained in:
Nathan Braswell
2016-07-03 15:32:45 -07:00
parent 87c2b1d2c1
commit 6fee942756
8 changed files with 846 additions and 896 deletions

View File

@@ -7,7 +7,21 @@ ext fun fprintf(file: *void, format: *char, ...): int
ext fun snprintf(to_str: *char, num: ulong, format: *char, ...): int
ext fun fflush(file: int): int
ext var stderr: *void
ext fun fgets(buff: *char, size: int, file: *void): *char
ext var stdin: *void
// dead simple stdin
fun get_line(prompt: string::string, line_size: int): string::string {
print(prompt)
return get_line(line_size)
}
fun get_line(line_size: int): string::string {
var buff = new<char>(line_size)
fgets(buff, line_size, stdin)
var to_ret = string::string(buff)
delete(buff)
return to_ret.slice(0,-2) // remove '\n'
}
fun printlnerr<T>(toPrint: T) : void {
printerr(toPrint)
printerr("\n")