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)])
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)])
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])
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])