1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
from tokens import *
import sys
from collections import namedtuple
FuncImpl = namedtuple("FuncImpl", ("func", "impl"))
STD = {}
def std_exit(status=0):
sys.exit(status)
return NebLiteral(NebType.BOOL, True)
def std_print(arg):
print(arg.value)
#return [] # TODO this should return empty list
return NebLiteral(NebType.BOOL, True)
def build_std():
print_string = FuncImpl(NebFunction("print", [NebType.STRING], NebType.BOOL), std_print)
STD["print"] = {
print_string.func.in_sig(): print_string
}
exit_ = FuncImpl(NebFunction("exit", [], NebType.BOOL), std_exit)
exit_int = FuncImpl(NebFunction("exit", [NebType.INT], NebType.BOOL), std_exit)
STD["exit"] = {
exit_.func.in_sig(): exit_,
exit_int.func.in_sig(): exit_int
}
build_std()
|