diff options
| author | mryouse | 2022-05-12 02:32:51 +0000 | 
|---|---|---|
| committer | mryouse | 2022-05-12 02:32:51 +0000 | 
| commit | 9a8324315c74ea102e0fb0ed22c695ce78c221c7 (patch) | |
| tree | 6dc64024529eb702d181aa439e7e167363e5b2ab | |
| parent | bf03d7a6a1c70c1da988b9cb4bb44e77ab3934ce (diff) | |
native type compare methods
| -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() | 
