示例#1
0
def _process_quasiquote_list_item(obj):
    # TODO: could we invoke (list) directly?
    if is_list(obj) and first(obj) == Symbol('unquote'):
        return List([Symbol('list', ns='kaa.core'), first(rest(obj))])
    if is_list(obj) and first(obj) == Symbol('unquote-splice'):
        return first(rest(obj))
    return List([Symbol('list', ns='kaa.core'), _process_quasiquote(obj)])
示例#2
0
文件: reader.py 项目: harto/kaa
def _process_quasiquote_list_item(obj):
    if first(obj) == Symbol('unquote'):
        return List([Symbol('list'), first(rest(obj))])
    elif first(obj) == Symbol('unquote-splice'):
        return first(rest(obj))
    else:
        return List([Symbol('list'), _process_quasiquote(obj)])
示例#3
0
文件: reader.py 项目: harto/kaa
def _process_quasiquote(obj):
    # `a -> 'a
    if not is_list(obj) or empty(obj):
        return List([Symbol('quote'), obj])
    # `~a -> a
    if first(obj) == Symbol('unquote'):
        return obj
    # `(a ~b ~@c) -> (concat (list 'a) (list b) c)
    return List([Symbol('concat')] +
                [_process_quasiquote_list_item(o) for o in obj])
示例#4
0
def _process_quasiquote(obj):
    # `a -> 'a
    if not is_list(obj) or not obj:
        return List([Symbol('quote'), obj])
    # `~a -> a
    if first(obj) == Symbol('unquote'):
        return obj
    # `(a ~b ~@c) -> (concat (list 'a) (list b) c)
    # TODO: could we invoke (concat) directly?
    return List([Symbol('concat', ns='kaa.core')] +
                [_process_quasiquote_list_item(o) for o in obj])