Пример #1
0
    def _interpret(interpreter: Interpreter,
                   actual_params: tp.List[ast.AST]) -> d.List:
        evaluated_params = []
        for idx, param in enumerate(actual_params):
            param_value = interpreter.visit(param)

            evaluated_params.append(param_value)

        result = d.List(evaluated_params)
        return result
Пример #2
0
    def _interpret(interpreter: Interpreter,
                   actual_params: tp.List[ast.AST]) -> d.List:
        first = interpreter.visit(actual_params[0])

        rest = param_value = interpreter.visit(actual_params[1])
        param_type = type(param_value)

        if not issubclass(param_type, d.List):
            message = f'cons: second argument must be a list, but received {str(first)} and {str(rest)}'
            raise err.CustomBuiltinProcError(message=message)

        result = d.List([first] + list(rest))
        return result
Пример #3
0
    def _interpret(interpreter: Interpreter,
                   actual_params: tp.List[ast.AST]) -> d.List:
        count = param_value = interpreter.visit(actual_params[0])
        param_type = type(param_value)

        if not issubclass(param_type, d.Integer) or param_value < d.Integer(0):
            raise err.ArgumentTypeError(expected=d.NaturalNum,
                                        given=param_value)

        data = interpreter.visit(actual_params[1])

        result = d.List(int(count) * [data])
        return result
Пример #4
0
    def _interpret(interpreter: Interpreter,
                   actual_params: tp.List[ast.AST]) -> d.List:
        evaluated_params = []
        for idx, param in enumerate(actual_params):
            param_value = interpreter.visit(param)
            param_type = type(param_value)

            if not issubclass(param_type, d.List):
                raise err.ArgumentTypeError(idx=idx,
                                            expected=d.List,
                                            given=param_value)

            evaluated_params.append(param_value)

        result = d.List([])

        for param in evaluated_params:
            result.extend(param)

        return result
Пример #5
0
    # 'string-ci=?': StringCiSymEqualHuh(),
    # 'string-ci>=?': StringCiSymGreaterEqualHuh(),
    # 'string-ci>?': StringCiSymGreaterHuh(),
    # 'string-contains-ci?': StringContainsCiHuh(),
    'string-contains?': StringContainsHuh(),
    'string-copy': StringCopy(),
    'string-downcase': StringDowncase(),
    'string-ith': StringIth(),
    'string-length': StringLength(),
    'string-lower-case?': StringLowerCaseHuh(),
    'string-numeric?': StringNumericHuh(),
    'string-upcase': StringUpcase(),
    'string-upper-case?': StringUpperCaseHuh(),
    'string-whitespace?': StringWhitespaceHuh(),
    # 'string<=?': StringSymbolLessEqualHuh(),
    # 'string<?': StringSymbolLessHuh(),
    # 'string=?': StringSymEqualHuh(),
    # 'string>=?': StringSymGreaterEqualHuh(),
    # 'string>?': StringSymGreaterHuh(),
    'string?': StringHuh(),
    # 'substring': Substring()
    # ========== ========== ==========
    #              symbol
    # ========== ========== ==========
    'symbol->string': SymbolToString(),
    'symbol=?': SymbolSymEqualHuh(),
    'symbol?': SymbolHuh()
}

BUILT_IN_CONSTANTS = {'empty': d.List([]), 'null': d.List([])}
Пример #6
0
 def visit_List(self, node: ast.List) -> d.List:
     return d.List(list(map(self.visit, node.value)))