aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--neb/__init__.py4
-rw-r--r--neb/parser.py2
-rw-r--r--neb/std/core.py2
-rw-r--r--neb/std/types.py13
4 files changed, 4 insertions, 17 deletions
diff --git a/neb/__init__.py b/neb/__init__.py
index cf51ed6..3ba9172 100644
--- a/neb/__init__.py
+++ b/neb/__init__.py
@@ -14,7 +14,7 @@ def interpret(exprs, env, ns=None):
def evaluate(expr, env, ns=None):
if isinstance(expr, Literal) or isinstance(expr, Function) or isinstance(expr, TypeWrap) or isinstance(expr, List):
return expr
- elif isinstance(expr, Symbol) or isinstance(expr, Type) or isinstance(expr, MultiType):
+ elif isinstance(expr, Symbol) or isinstance(expr, Type):
if env.contains(expr.name):
return evaluate(env.get(expr.name), env, ns)
elif ns is not None and env.contains(f"{ns}/{expr.name}"):
@@ -149,7 +149,7 @@ class UserFunction(Function):
newparams.append(param)
args.append(Arg(param.name, TypeEnum.ANY))
prev_type = False
- elif (isinstance(param, Type) or isinstance(param, MultiType)) and not prev_type and not first:
+ elif isinstance(param, Type) and not prev_type and not first:
if many is None:
#args[-1].type_ = param.name
args[-1].type_ = param
diff --git a/neb/parser.py b/neb/parser.py
index 9a73ef7..d5712d2 100644
--- a/neb/parser.py
+++ b/neb/parser.py
@@ -45,7 +45,7 @@ def parseLiteral(token, prev, tokens):
def parseType(token, prev, tokens):
# if the next token is a symbol, combine for a type
- if tokens[0].type_ == TokenType.SYMBOL:
+ if len(tokens) > 0 and tokens[0].type_ == TokenType.SYMBOL:
return Type(f":{tokens[0].text}"), 2
elif tokens[0].type_ == TokenType.OPEN_BRACKET:
# only format currently supported:
diff --git a/neb/std/core.py b/neb/std/core.py
index 750594e..1c3c4b4 100644
--- a/neb/std/core.py
+++ b/neb/std/core.py
@@ -47,7 +47,7 @@ CORE.register("redef", Builtin("redef", interpretRedef, [def_name_arg, def_val_a
def interpretLambda(symbol, args, env, ns):
new_args = args
return_type = Type(":any")
- if isinstance(args[0], Type) or isinstance(args[0], MultiType):
+ if isinstance(args[0], Type):
return_type = args[0]
new_args = args[1:]
diff --git a/neb/std/types.py b/neb/std/types.py
index 80288fa..3517384 100644
--- a/neb/std/types.py
+++ b/neb/std/types.py
@@ -91,16 +91,6 @@ def interpretIsLiteral(symbol, args, env, ns):
TYPES.register("literal?", Builtin("literal?", interpretIsLiteral, [Arg("arg", TypeEnum.ANY)], return_type=Type(":bool")))
-def interpretIsListOfString(symbol, args, env, ns):
- if not isinstance(args[0], List):
- return Bool(False)
- for arg in args[0].args:
- if not isinstance(arg, String):
- return Bool(False)
- return Bool(True)
-
-TYPES.register("list-of-string?", Builtin("list-of-string?", interpretIsListOfString, [Arg("arg", TypeEnum.ANY)], return_type=Type(":bool")))
-
# add types to env
any_type = NebType(":any", None, interpretIsAny)
literal_type = NebType(":literal", any_type, interpretIsLiteral)
@@ -112,8 +102,6 @@ number_type = NebType(":number", literal_type, interpretIsNumber)
int_type = NebType(":int", number_type, interpretIsInt)
float_type = NebType(":float", number_type, interpretIsFloat)
-#list_of_string_type = NebType(":[:string]", list_type, interpretIsListOfString)
-
TYPES.register(":any", any_type)
TYPES.register(":literal", literal_type)
TYPES.register(":string", string_type)
@@ -123,4 +111,3 @@ TYPES.register(":bool", bool_type)
TYPES.register(":number", number_type)
TYPES.register(":int", int_type)
TYPES.register(":float", float_type)
-#TYPES.register(":[:string]", list_of_string_type)