Skip to content

Yield Containers

icefapper edited this page Feb 12, 2017 · 9 revisions

#Introduction A "yield container", or YC for short, is a node containing a yield expression. a yield container could either be a "simple" container, or a "non-simple" one; either way, it can have an array of "container elements".

#Container elements A container element, or contelem, is either:

  • a statement without a yield expression
  • a yield container
  • a yield expression container elements are treated much like a statement while emitting.

#Simple Containers A simple container is a YC whose children are not yield containers. a yield expression, if any, is always the last container element they may contain.

#Non-simple Containers A non-simple container is a YC whose children are other yield containers.

#Container attributes ##State range A container's state range is the range of state values in which that container is in effect.

it takes the form [minState, maxState]; for simple containers, minState is equal to maxState; for non-simple containers, [minState, maxState] is set by the container; in most cases, minState is the minState of the first descendant container, and maxState is the maxState of the last descendant container.

##Successor A container's successor is the container that will execute after it; succ(container) is the value of its next attribute (if it has one), or succ(container.parent) if it has no next attribute; for example,

if (yield 'test') 
  yield 'if'
else 
  yield 'else'

yield 'succ'

becomes:

<!-- next: l -->
<if entry='a' next='l'>
  <!-- next: 'b' -->
  <simple id='a' next='b'>yield 'test'</simple>

  <!-- next: (irrelevant, but next(b) -> next(b.parent) -> l) -->
  <test id='b'>sent</test>

  <!-- succ(this) -> succ(this.parent) -> l -->
  <consequent entry='c'>
    <!-- succ(this) -> succ(this.parent) -->
    <simple id='c'>yield 'if'</simple>
  </consequent>

  <!-- succ(this) -> succ(this.parent) -> l -->
  <alternate entry='e'>
    <!-- succ(this) -> succ(this.parent) -> l -->
    <simple id='e'>yield 'else'</simple>
  </alternate>
</if>
<simple id='l'>yield 'succ'</simple>

##Container sets A container set is a facility to keep a linked list of the containers added to it, where the most recently added container's next is set to the current container getting added.