From Esolang
Jump to: navigation, search

XMLfuck would simply be an implementation of brainfuck using XML, allowing simple universal transport of brainfuck programs, without the need for complex encodings, as well as allowing it to be processed with a single XSLT to pretty-print or even execute the program.


XMLfuck, being brainfuck, needs only a very minimal set of tags to be fully functional. Proposed tags are:

  • <fuck bits="" wrap="" signed=""></fuck> the root element.
  • <tapes></tapes> similar to the head section in XHTML, can only exist once and contains configuration parameters.
    • <tape name="" type="" length="" start="" /> defines a tape.
  • <ptrinc /> and <ptrdec /> for > and <
  • <inc /> and <dec /> for + and -
  • <print /> and <read /> for . and ,
  • <while></while> for [ and ]

Naturally, matching while loops are enforced by the XML spec. No XMLfuck program with unmatched opening and closing while tags is valid XML, and thus is also invalid XMLfuck. Additionally, the work already done by XML parsers can make looping far easier to code in the interpreter.

All of the basic instructions carried over from brainfuck allow the use of a tape attribute, which corresponds to the <tape /> with the corresponding name, and all but while allow for a by attribute, which simply repeats an instruction that many times, a form of run-length encoding.

<print /> will additionally accept a type attribute, one of "default" (&0xFF and print as a character) "numeric" (print as a base-10 number) and "string" (treat consecutive cells as characters and print until null is hit)

for the root element, bits, wrap, and signed specify cell size, defaulting to "8", "Y", "N". if wrap is no, 255 + 1 = 255 for an unsigned 8-bit cell.

for <tape />, if name is omitted this is the default tape, type can be omitted or "default" (infinite tape), or be "wrap", "pos" (extends to +inf), "neg" (to -inf), or "finite", length only applies to wrap and finite, start only applies to finite. Simulation starts set to the closest valid cell to zero.

See also