This commit is contained in:
reverend 2021-01-15 01:28:34 +01:00
parent fdb770fe71
commit fac6fb4da5

View File

@ -1,186 +1,135 @@
_state = {
_block = {
stack: {}
elements: {}
block_modifiers: {}
element_aliases: {}
element_modifier_aliases: {}
block_modifier_aliases: {}
element_stack: () ()
element_modifier_stack: () ()
block_modifier_stack: () ()
element_alias_stack: () ()
element_modifier_alias_stack: () ()
block_modifier_alias_stack: () ()
current_elements: () ()
current_element_modifiers: () ()
current_block_modifiers: () ()
}
reset_state()
_state.stack = {}
reset_block()
_block.stack = {}
_block.elements = {}
_block.block_modifiers = {}
_state.element_aliases = {}
_state.element_modifier_aliases = {}
_state.block_modifier_aliases ={}
_block.element_stack = {}
_block.element_modifier_stack = {}
_block.block_modifier_stack = {}
_state.element_alias_stack = () ()
_state.element_modifier_alias_stack = () ()
_state.block_modifier_alias_stack = () ()
push_level(level)
push(_state.stack, level)
set_element_alias(name, alias)
_state.element_aliases[name] = alias
get_element_alias(name)
if name in _state.element_aliases
return _state.element_aliases[name]
else
return name
_block.current_elements = () ()
_block.current_element_modifiers = () ()
_block.current_block_modifiers = () ()
set_element_modifier_alias(name, alias)
_state.element_modifier_aliases[name] = alias
_include = {
elements: {}
element_modifires: {}
block_modifiers: {}
get_element_modifier_alias(name)
if name in _state.element_modifier_aliases
return _state.element_modifier_aliases[name]
else
return name
element_stack: {}
element_modifier_stack: {}
block_modifier_stack: {}
set_block_modifier_alias(name, alias)
_state.block_modifier_aliases[name] = alias
get_block_modifier_alias(name)
if name in _state.block_modifier_aliases
return _state.block_modifier_aliases[name]
else
return name
}
reset_include()
_aliases.element_aliases = {}
_aliases.element_modifires_aliases = {}
_aliases.block_modifiers_aliases = {}
_aliases.element_alias_stack = {}
_aliases.element_modifires_alias_stack = {}
_aliases.block_modifiers_alias_stack = {}
_block_map = {}
RV-Include(block_name, alias = null)
RV-Squash()
{block}
RV-Block(block_name)
{block}
push(_block_name_stack, block_name)
push(_block.elements, _block.current_elements)
push(_block.block_modifiers, _block.current_block_modifiers)
last_element_selector = null
last_element_name = null
last_bock_modifier_selector = null
last_bock_modifier_name = null
_block_map[block_name] = _block
selector_list = () ()
.{block_name}
{block}
for level in _state.stack
if level.type == 'RV-Block__Modifier'
last_bock_modifier_name = block_name + '--' + level.name
last_bock_modifier_selector = '.' + block_name + '.' + last_bock_modifier_name
push(selector_list, {
selector: last_bock_modifier_selector
block_list: level.block_list
})
else
if level.type == 'RV-Element'
name = get_element_alias(level.name)
last_element_name = block_name + '__' + name
element_selector = '.' + last_element_name
if last_bock_modifier_selector != null
element_selector = last_bock_modifier_selector + ' ' + element_selector
last_element_selector = element_selector
push(selector_list, {
selector: last_element_selector
block_list: level.block_list
})
else
if level.type == 'RV-Element__Modifier'
if last_element_selector != null && last_element_name != null
modifier_selector = '.' + last_element_name + '--' + level.name
push(selector_list, {
selector: last_element_selector + modifier_selector
block_list: level.block_list
})
reset_state()
.{block_name}
for item in selector_list
if item != ()
& {item.selector}
for block in item.block_list
{block}
reset_block()
RV-Element(element_name)
if 'RV-Include' in called-from
if 'RV-Element' in called-from
push(_include.element_stack, element_name)
else
for alias in _include.element_stack
_include.elements[alias] = element_name
_include.elements[element_name] = element_name
if 'RV-Element' in called-from
if lookup('block') != null
push(_state.element_alias_stack, {
name: element_name,
block: block
})
push(_state.element_stack, block)
else
element = {
type: 'RV-Element'
name: element_name
blocks: (block)
modifiers: _block.current_element_modifiers
}
_block.current_element_modifiers = () ()
for child in _block.element_stack
if child != ()
push(element.blocks, child)
_block.element_stack = () ()
for alias in _state.element_alias_stack
set_element_alias(alias.name, element_name)
push(element.block_list, alias.block)
_state.element_alias_stack = () ()
push_level(element)
if 'RV-Block__Modifier' in called-from
push(_block.current_elements, element)
else
_block.elements[elemante_name] = element
RV-Element__Modifier(modifier_name)
if 'RV-Element__Modifier' in called-from
if lookup('block') != null
push(_state.element_modifier_alias_stack, {
name: modifier_name,
block: block
})
push(_state.element_modifier_stack, block)
else
modifier = {
type: 'RV-Element__Modifier'
name: modifier_name
block_list: ()
blocks: (block)
}
if lookup('block') != null
push(modifier.block_list, block)
for child in _block.element_modifier_stack
if child != ()
push(modifier.blocks, child)
_block.element_modifier_stack = () ()
for alias in _state.element_modifier_alias_stack
if alias != ()
set_element_modifier_alias(alias.name, modifier_name)
push(modifier.block_list, alias.block)
_state.element_modifier_alias_stack = () ()
push_level(modifier)
push(_block.current_element_modifiers, modifier)
RV-Block__Modifier(modifier_name)
if 'RV-Block__Modifier' in called-from
if lookup('block') != null
push(_state.block_modifier_alias_stack, {
name: modifier_name,
block: block
})
push(_block.block_modifier_stack, block)
else
modifier = {
type: 'RV-Block__Modifier'
name: modifier_name
block_list: ()
blocks: (block)
elements: _block.current_elements
}
_block.current_elements = () ()
if lookup('block') != null
push(modifier.block_list, block)
for child in _block.block_modifier_stack
if child != ()
push(modifier.blocks, child)
_block.block_modifier_stack = () ()
for alias in _state.block_modifier_alias_stack
if alias != ()
set_block_modifier_alias(alias.name, modifier_name)
push(modifier.block_list, alias.block)
_state.block_modifier_alias_stack = () ()
push_level(modifier)
_block.block_modifiers[modifier_name] = modifier