Acrostic

From Esolang
Jump to navigation Jump to search

Acrostic is a stack-based esoteric programming language written by User:Mercerenies, designed to have the visual appearance of a crossword puzzle.

Overview

Below is a brief overview of Acrostic. A more in-depth description of the language's semantics can be found on the official wiki.

Acrostic code occupies a two-dimensional grid. The instructions are specific words, which intersect at specific letters as they might in a simple crossword puzzle. Instructions can be placed either horizontally or vertically.

There are two stacks available to the programmer: the value stack and the storage stack. Most instructions operate on the value stack, and the storage stack is used, as the name implies, to store values for later use.

Instructions typically have several words associated with them, so that you can choose whichever is most agreeable with the words around it in the crossword.

Every program begins with a starting word, such as START, BEGIN, etc. For instance, your program could begin at

B
E
G
I
N

or

BEGIN

The program starts by "executing" the starting word from start to finish. Then, starting at the back of the word, it looks for another word to execute and performs that one. For instance, what follows is a simple program that pushes the literal number 90 to the value stack.

B
E
G
I
NINETY

The word BEGIN executes, then the word NINETY executes. We could have also written this as

 B
 E
 G
NINETY
 N

and it will have the same behavior. The interpreter will execute BEGIN. When it fails to find a new word at "N", it will backtrack through the word BEGIN looking for a new word to execute. Note, in particular, that the interpreter will always alternate between horizontal and vertical words.

Most instructions in Acrostic have a backward form as well. If the word is executed from back-to-front instead of front-to-back, it will have a different effect. For numerical literal words, this will push the negative of the word to the stack. So the following will push 15 to the stack.

 B
 E
 G
FIFTEEN
 N

While the following will push -15 to the stack.

      B
      E
      G
      I
FIFTEEN

An Acrostic program terminates when it runs the starting word backwards. This means your program must end up back at the starting word; you are not permitted to have multiple starting words.

Sample Programs

Infinite Loop

A simple infinite loop. Hangs indefinitely.

BEGINNING
       O
     NOTHING
       H  U
       I  L
       NULL
       G

Hello World

Print "Hello World!" to stdout and then exit.


                                                 P
                                                 R
                                             NOTHING
                                             U   N
                                             M   T
                                           D B   I
                F                        WAITED  NOTHING
               NILS         I              F R   G  U
                N E      S  NOTHINGNESS  V F        N
       V        I V      U  P      O     ONE        D   I
      NOTHINGNESS E      B  U      T     I R        R   N
     N I        H N N    TEXTUALLY HUNDRED          EIGHT
    VOID        I TWO    R         I                D   E
     T          N Y TEXTUALLY      N                    G
     H          G   H    C         G                    E
     I              I    T                         DIFFER
     NOTHING        N                              U
     G    O         G                              P
          T                           I            L
          H                    NOTHINGNESS         I   P
          I                    U      P            C   R   P
          N                    L      U            ASCII   R
    NOTHING             TEXTUALLY  WAIT            T   NOTHING
    U                   E          I               E   T   N   H
    L                C  X      V   T               D       TEXTUALLY
    L           T    EMPTY     O   H                           N
VOIDS           H    N         I   O                           D
  N             INPUTTED       D   U                           R
  P             R    U         EIGHT                           ELEVEN
  U             T    R   HUNDRED                               D    O
  T       STANDBY    Y     O                                        T
  T        H               T                           V            H
  E        R               H                          NOTHING    T  I
  DIFFERENCE               I                           I   O DIFFERENCE
           E               NOTHING                  VOID   T     X  G
                           G    U                   O      H     T
                                L                   I      I     U
                            DISPLAY              VOID      N DISCARD
                            I                    O   NOTHING E   L
                            F                    I     H  O  P   L
                       V    F                    D     I  T  O   Y
                      FOURTEEN         NOTHINGNESS     R  H  S
                   I   I    R            W             T  I  I
                 HUNDRED             WITHOUT           Y INPUT
                   P                 A                    G
                   U   I         N   I
                  STORING    N   INPUT
                       P     O   N
                       U     THREE
                       T     H   T
                       T     I   Y
                      DIFFERENCE
                       N     G
                       G

Factorial

Takes an integer input on standard in and prints its factorial to standard out.

   BEGINNING                           N
        U U                            O
        L M                            T      N
        L E                            H      O
    NULLS R                        NOTHING  NOTHINGNESS
    U    SINGULAR                  U   N      H    O
    L     C     E                  L   G      I    T
    L     A     A                  L   NOTHINGNESS H
NULLS     L     D              VOIDS   E      G    I
O               I              O       S     R     N
T               NOTHINGNESS    I       S     E     G
H               G      O       D             S     N
I                    NOTHINGNESS           NOTHINGNESS
NOTHING     N     D    H                     E     S
G    O      O     U    I                  VOID     S
     T      T     P    N                  O
     H      H     L    G                  I
     I      INPUTTING  NOTHINGNESS        DIFFERS
     N      N     C    E       M                I
     G      G   BRANCHES       P                N
     NOTHINGNESS  T    S       T  S   WITHDRAWING
     E      E     E        DUPLICATING    I     L
     S      S                  N  O       V     E
     S      S                  E  R       I
                               S  I       D
                               S  NOTHINGNESS
                                  G       D

Implementation

Links