Iframe

From Esolang
Jump to navigation Jump to search

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

Syntax

Programs are made from multiple lines, each line being a separate "HTML file". Lines are 0-indexed, so the first line is line 0, the second line is line 1, etc.

Links are represented with (X|Y), X being the target, and Y being the line number/link destination.

Iframes are represented with [X|Y], where X is the name of the iframe, and Y is the initial source. Iframes can also omit Y, in which case they will be considered blank.

Special targets

Just like in HTML, there are special targets that refer to special iframes.

# - Current iframe
^ - Parent iframe
* - Top iframe

Iframes cannot be named any of these.

How it runs

At the beginning, it starts at line 0.

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 source 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

(This is based on how they behave on Firefox, other browsers have not been tested)

  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 c and b

[a|1] [b|2] [c|3]
[d|4]
[e]
[f]
(b|6) (f|0) (a|-1)
(e|0) (a|-1)
(d|5)

This program shows how control flow might work in iframe.