Iframe

From Esolang
Jump to navigation Jump to search

Iframe is an esolang based on HTML iframes and the a tag target attribute.

Syntax

Each line of the program encodes a page. The line starts with a sequence of alphanumeric characters that will be used as the name of the page, followed by a colon, then a sequence of elements. Each element can be either an iframe or a link.

  • An iframe is specified by its name (which also only consists of alphanumeric characters) and optionally an equal sign followed the page it starts as. For example an initially blank iframe named "a" is simply a, and an iframe named "a" initialized to the page "b" is a=b.
  • A link is specified by its target, then an arrow, followed by the page it links to. For example, a link that changes the source of an iframe named "a" to the page "b" is a->b

An undefined page is treated as a blank page.

Special targets

Just like in HTML, there are special targets that refer to special iframes, namely _self, _parent, and _top. Iframe can also be extended with output using _out, where the only valid pages consist only of digits which are interpreted as a Unicode codepoint in decimal and outputted.

How it runs

At the beginning, it starts at the page named "index".

The "instruction pointer" goes through every element. If it's a link, it clicks that link. If it's an iframe, it goes inside the current page of that iframe. If there are no more elements in the current iframe, the instruction pointer continues in the parent iframe. If the instruction pointer is already on the top iframe, the program halts.

If the current iframe's (or one of its parents') source is changed, the instruction pointer starts from the beginning of whichever iframe was updated.

If an iframe's source is a non-existent line, the iframe is considered blank.

How iframes are targeted

  1. If the current iframe's name is the same as the target, set this iframe's source to the destination and stop.
  2. For each iframe in the current iframe, repeat the first 2 steps.
  3. Go up one iframe and go back to step 1.

Examples

Alternating between B and C

index: A=initA B=initB C=initC
initA: subA=nextB
initB: subB
initC: subC
nextB: _out->66 subB->index a->
nextC: _out->67 b->switcheroo subC->index a->
switcheroo: subA->nextB

This program shows how control flow might work in iframe.