diff options
Diffstat (limited to 'std.py')
| -rw-r--r-- | std.py | 32 | 
1 files changed, 32 insertions, 0 deletions
| @@ -73,6 +73,30 @@ def std_is_string(arg):      else:          return NebBool(False) +def std_is_int(arg): +    if isinstance(arg, NebInt): +        return NebBool(True) +    else: +        return NebBool(False) + +def std_is_float(arg): +    if isinstance(arg, NebFloat): +        return NebBool(True) +    else: +        return NebBool(False) + +def std_is_number(arg): +    if isinstance(arg, NebNumber): +        return NebBool(True) +    else: +        return NebBool(False) + +def std_is_bool(arg): +    if isinstance(arg, NebBool): +        return NebBool(True) +    else: +        return NebBool(False) +  def evaluate_expression(expr):      if not expr.symbol.name in STD:          raise Exception(f"no such symbol: {expr.symbol.name}") @@ -136,5 +160,13 @@ def build_std():      # type checking      is_string = FuncImpl(NebFunction("string?", [NebAny], NebBool), std_is_string)      STD["string?"] = [is_string] +    is_int = FuncImpl(NebFunction("string?", [NebAny], NebBool), std_is_int) +    STD["int?"] = [is_int] +    is_float = FuncImpl(NebFunction("string?", [NebAny], NebBool), std_is_float) +    STD["float?"] = [is_float] +    is_number = FuncImpl(NebFunction("string?", [NebAny], NebBool), std_is_number) +    STD["number?"] = [is_number] +    is_bool = FuncImpl(NebFunction("string?", [NebAny], NebBool), std_is_bool) +    STD["bool?"] = [is_bool]  build_std() | 
