Apple Pie

From Esolang
Jump to navigation Jump to search

Apple Pie is a language created by User:Cortex which is designed to be extremely difficult to read and write code in. Its file format is .pie. The command names are often either 1 letter or gibberish, and the letter that terminates commands varies depending on the command before it (Specifically, the letter 9 places after its last letter in the alphabet. If it goes above Z, it wraps back around to A. So to terminate an R command, you would add "A". Also, you must put a space before the terminating character.) To further prevent code from being readable, a newline is a command that prints the program's source code, but also deletes anything else printed. As such, any code with a newline is a quine. Commands are case sensitive.

Syntax

The following Extended Backus-Naur Form (EBNF) formulation shall describe the language's syntactical aspect:

program            := "Good luck reading this lol u" , statementList , "!!!" ;

statementList      := { statement } ;

statement          := print
                   |  comment
                   |  variableDefinition
                   |  loop
                   |  ( binaryOperation , space , "O" )
                   |  HQ9+interpreter
                   |  variableClearance
                   |  ( variableAccess , space , "O" )
                   |  quine
                   ;

print              := "A" , printArgument , space , "J" ;
printArgument      := word | variableAccess ;

comment            := "B" , { nonSpaceCharacter } , space , "K" ;

variableDefinition := "D" , variable , "D" , varAssignedValue
                   ,  space , "M"
                   ;
varAssignedValue   := decimalNumber
                   |  variableAccess
                   |  binaryOperation
                   |  word
                   ;

loop               := "EepbeepQ"
                   ,  loopRepetitions
                   ,  space , "Z"
                   ,  loopBody
                   ,  loopTerminator
                   ;
loopRepetitions    := ternaryNumber
                   |  variableAccess
                   |  binaryOperation
                   ;
loopBody           := statementList ;
loopTerminator     := "C" , space , "L" ;

binaryOperation    := "F" , binaryOperand
                   ,  "F" , binaryOperator
                   ,  "F" , binaryOperand
                   ;
binaryOperand      := decimalNumber
                   |  variableAccess
                   |  binaryOperation
                   ;
binaryOperator     := "+" | "-" | "*" | "/" | "^" ;

HQ9+interpreter    := "G" , HQ9+program , space , "P" ;
HQ9+program        := { HQ9+command } ;
HQ9+command        := "H" | "h" | "Q" | "q" | "9" | "+" ;

variableClearance  := "H44" , variable , "Q" ;

variableAccess     := "$" , variable , "F" ;

quine              := "\n" ;

word               := nonSpaceCharacter , { nonSpaceCharacter } ;
nonSpaceCharacter  := character - space ;
space              := " " ;
variable           := letter ;
letter             := "a" | ... | "z" | "A" | ... | "Z" ;
ternaryNumber      := optionalSign
                   ,  ternaryDigit , { ternaryDigit }
                   ;
ternaryDigit       := "0" | "1" | "2" ;
decimalNumber      := optionalSign
                   ,  decimalDigit , { decimalDigit }
                   ;
decimalDigit       := "0" | "1" | "2" | "3" | "4"
                   |  "5" | "6" | "7" | "8" | "9"
                   ;
optionalSign       := [ "+" | "-" ] ;

Commands

If part of a command in here is a bolded X, then that is the input.

Command Description
Good luck reading this lol u Starts the program. If the first thing in the program
AX Outputs the letter 1 place before the input's first character in the alphabet (the rest of the input is ignored, unless it is a variable, in which case, it prints the variable backwards.
BX Comment (ignored)
C Ends a loop.
DXDX Defines a variable. The first input is the one-letter variable name, and the second is its value. If the variable does not exist, it is created. If it does exist, its value is set to the second input.
EepbeepQX Starts a loop. The input is how many times to repeat the loop. The input, however, must be in base 3.
FXFXFX The first input can be a variable or a number in base 10. The second input is an operator; it can be either +, -, *, /, or ^. The third input is the second number in the equation. For example, this code:
Good luck reading this lol uDXDF5F+F5 MA$XF J!!!

would output 01.

$XF If the input is the name of a variable, it returns the value of that variable. Otherwise, it returns the letter L.
GX HQ9+ interpreter
H44X If the input is a variable name, it will clear the value of that variable.
!!! Terminates the program. It is the only command that does not need to be terminated by a letter.

Examples

Hello, World!

Good luck reading this lol uGH P!!!

or

Good luck reading this lol uAI JAf JAm JAm JAp JAX JAp JAs JAm JAe J!!!

Quine

Any program with a newline (see last few sentences of the first paragraph of this article)

or

Good luck reading this lol uGQ P!!!

Numbers from 1 to 10

Good luck reading this lol uDXD1 MEepbeepQ100 ZA$XF JDXDF$XFF+F1 MC LA2 JA1 J!!!

Set the value of variable X to 0 and then increase it by 1

Good luck reading this lol uDXD0 MDXDF$XFF+F1 M!!!

Loop and print

This program prints the text “HaHaHa” by using a loop.

Good luck reading this lol uEepbeepQ10 ZAI JAb JC L!!!

Interpreter

  • Common Lisp implementation of the Apple Pie programming language.