Refactored interpreter into just functions, added a REPL to the main kraken.
This commit is contained in:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user