Version of the generator that still does not work as intended

This commit is contained in:
reverend 2021-01-13 23:03:32 +01:00
parent fb5fa8ce6c
commit fdb770fe71

View File

@ -0,0 +1,186 @@
_state = {
stack: {}
element_aliases: {}
element_modifier_aliases: {}
block_modifier_aliases: {}
element_alias_stack: () ()
element_modifier_alias_stack: () ()
block_modifier_alias_stack: () ()
}
reset_state()
_state.stack = {}
_state.element_aliases = {}
_state.element_modifier_aliases = {}
_state.block_modifier_aliases ={}
_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
set_element_modifier_alias(name, alias)
_state.element_modifier_aliases[name] = alias
get_element_modifier_alias(name)
if name in _state.element_modifier_aliases
return _state.element_modifier_aliases[name]
else
return name
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
RV-Squash()
{block}
RV-Block(block_name)
push(_block_name_stack, block_name)
last_element_selector = null
last_element_name = null
last_bock_modifier_selector = null
last_bock_modifier_name = null
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}
RV-Element(element_name)
if 'RV-Element' in called-from
if lookup('block') != null
push(_state.element_alias_stack, {
name: element_name,
block: block
})
else
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)
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
})
else
modifier = {
type: 'RV-Element__Modifier'
name: modifier_name
block_list: ()
}
if lookup('block') != null
push(modifier.block_list, block)
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)
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
})
else
modifier = {
type: 'RV-Block__Modifier'
name: modifier_name
block_list: ()
}
if lookup('block') != null
push(modifier.block_list, block)
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)