_lanes = {} _stacks = {} _last_name = {} _being_towed = {} _reset_last_name(block_type=null) if block_type == null block_type = called-from[1] if block_type in _last_name remove(_last_name, block_type) _set_last_name(name, block_type=null) if block_type == null block_type = called-from[1] _last_name[block_type] = name _get_last_name(block_type) if block_type == null block_type = called-from[1] if block_type in _last_name return _last_name[block_type] else return null _current_block_type() return called-from[1] _call_stack_till_first(block_type) striped = slice(called-from, 2) block_index = (index(striped, block_type)) if block_index == null if length(striped) <= 1 return (striped ()) return slice(striped, 1) stack = () for i in (0..block_index) push(stack, striped[i]) return stack _push_onto_stack(block, block_type=null) if block_type == null block_type = called-from[1] if block_type in _stacks stack = _stacks[block_type] else stack = () push(stack, block) _stacks[block_type] = stack _pop_from_stack(block_type=null) if block_type == null block_type = called-from[1] if block_type in _stacks stack = _stacks[block_type] b = pop(stack) if length(stack) > 0 _stacks[block_type] else remove(_stacks, block_type) return b return null _pop_stack(block_type=null) if block_type == null block_type = called-from[1] if block_type in _stacks stack = _stacks[block_type] remove(_stacks, block_type) return stack else return () _put_into_lane(key, value, block_type=null) if block_type == null block_type = called-from[1] if block_type in _lanes lane = _lanes[block_type] else lane = {} lane[key] = value _lanes[block_type] = lane _pop_lane(block_type=null) if block_type == null block_type = called-from[1] if block_type in _lanes lane = _lanes[block_type] remove(_lanes, block_type) return lane else return {} attach(parent_type, suffix, block) _being_towed[_current_block_type()] = true call_stack = _call_stack_till_first(parent_type) if parent_type in call_stack // We are called inside a block _push_onto_stack(block) //Detect if the selector will be generated //by an earlier call of RV-Element if not _current_block_type() in (call_stack) block_list = _pop_stack() _put_into_lane(suffix, block_list, parent_type) else // We are not called inside a block // Is there a block to attach to _last_parent_name = _get_last_name(parent_type) if _last_parent_name != null &.{_last_parent_name}{suffix} --attach 'blubb' {block} tow(name, block, block_type=null) if block_type == null // Determining if we are inside a block or after a block block_type = called-from[0] if not block_type in _being_towed prefix = '.'+name {prefix} {block} else prefix = '' {prefix} if block_type in _lanes for suffix, block_list in _pop_lane(block_type) p('name' name 'suffix' suffix) & {name}{suffix} for current_block in block_list {current_block} _set_last_name(name, block_type)