Hargfak

From Esolang
Jump to navigation Jump to search

This is like brainfuck, but has main pointer, sub pointer (points to same memory space but may be different position), and one main stack.

These command are same as brainfuck:

+-,.<>[]

These command are new commands:

*{};:()@!&#$=~|`'%

Data types:

  • Number
  • Code-block
  • Pointer
  • Stack

Notes about new commands:

  • * Swap main and sub pointer
  • {} Make a code-block, push to stack
  • ; Push data at pointer to stack
  • : Pop data from stack, put at pointer (if empty stack, no function)
  • ( Move top from main stack to top of stack at sub pointer
  • ) Reverse function of (
  • @ Exit code-block
  • ! Push main pointer to stack
  • & Push empty stack to stack
  • # Push zero to stack
  • $ Swap top 2 values of stack
  • = Saves the entire program state to a program-state stack
  • ~ Discards an entry from program-state stack
  • | Pops an entry from program-state stack and resets the program state to the restored state
  • ` Moves entry from top of main stack of state at top of program-state stack to top of the real main stack
  • ' Reverse function of `
  • % Swap top 2 entry of program-state stack

Notes about old commands:

  • +- To number, +- mod 256, to code-block or stack, nothing, to pointer, + as > and - as <.
  • [] Empty stack, empty code-block, pointer left of main pointer, all are considered as zero.
  • . To number output, to codeblock execute, to pointer to move main pointer to point at same place as this pointer.

Preprocessor:

  • ?name{data} Define a macro (case sensitive!)
  • name Use macro
  • number command Repeated command
  • // Comment until end of line

Example:

?out{;$:.:} // Macro to pop value from stack and output
?in{;,;$:} // Macro to input value and push to stack