Skip to content

Instantly share code, notes, and snippets.

@schas002
Last active April 10, 2016 11:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save schas002/03da208c75b79aa0125edc7935f143a7 to your computer and use it in GitHub Desktop.
Save schas002/03da208c75b79aa0125edc7935f143a7 to your computer and use it in GitHub Desktop.
Shifty Eyes, an esoteric language.

Shifty Eyes

Shifty Eyes is an esoteric language inspired by this comment: http://codegolf.stackexchange.com/questions/74719/#comment181322_74719

The syntax

The program is an arbitrary list of these four ASCII emoticons, either space or newline separated:

>_> <_< >_< <_>

Pairs of emoticons are taken and parsed into instructions shown below. There may be an odd number of emoticons, see Nested Structures.

Instructions

I/O

>_< >_< - input an integer into the stack
<_> <_> - pop the top of stack and output an integer

The top of stack is implicitly output when the program ends.

Push/Pop

>_> <_< - push a 0 into the stack
<_< >_> - DROP the top of stack

Increment/Decrement

>_> >_> - increment the top of stack
<_< <_< - decrement the top of stack

Arithmetic

>_< <_< - add the top of stack and second-to-top of stack
>_< >_> - subtract from the top of stack the second-to-top of stack
<_> <_< - multiply the top of stack and second-to-top of stack
<_> >_> - divmod - divide the top of stack by second-to-top of stack, push the quotient and remainder (quotient to top of stack)

Stack Primitives

>_> >_< - DUP - push a copy of the top of stack (1 2 ==> 1 2 2)
>_> <_> - SWAP - swap the top of stack and second-to-top of stack (1 2 3 ==> 1 3 2)
<_< >_< - ROLL - roll the stack upward (1 2 3 4 ==> 4 1 2 3)
<_< <_> - PICK - push a copy of the second-to-top of stack (1 2 ==> 1 2 1)

Nested Structures

<_> >_< - start a nested structure
>_< <_> - end a nested structure

The sole shifty-eyes emoticon right after the end of the nested structure will determine which type the structure was.

>_> or >_< - if: the nested structure runs if and only if the top of stack is nonzero
<_< or <_> - while: the nested structure runs while the top of stack is nonzero

Example

Count down from n to 1:
>_< >_< <_> >_< >_> >_< <_> <_> <_< <_< >_< <_> <_<
Explanation:
>_< >_<                                             - input
        <_> >_<                                     - start n.s.
                >_> >_<                             - dup
                        <_> <_>                     - output
                                <_< <_<             - decrement
                                        >_< <_>     - end n.s.
                                                <_< - n.s. was while
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment