Sir. Cut

From Esolang
Jump to: navigation, search

Sir. Cut is an esoteric programming language created by poiuy_qwert. The name is actually a play on the word Circuit, which is what the language is based on. You have wires, current, logic gates, and I/O to create programs.

Commands

Command Name Description
[ Battery At the beginning of the program, a wire with current 1 starts here. The higher a battery is in the program, the more priority its wire gets.
] Empty Battery The same as [, but the current starts as 0.
@ Light Bulb Pushes the current onto the output stack. Once the output stack reaches 8 values, it is output as a character.
/ Switch Gets a character and puts its binary representation into the input memory.
+ Get Input Pops the top 0/1 off the input memory and sets the current to it.
 ! Not Gate Performs a logical not on the current.
 % Or Gate Performs a logical or on the currents of the wires coming from the left and top, then continues toward the right.
& And Gate Same as % but using a logical and.
X Xor Gate Same as % but using a logical exclusive or.
0/1 Set Current Sets the current to 0 or 1.
= Split wire Splits a horizontal wire into 2 wires with the same current, one above and one below. The wire above gets priority over the wire below.
# Ground Stops the current wire.
~ Repeat If the current is 1, its flow will jump back to the current wire's inital battery.
- Horizontal Wire A path for the current to follow. If a vertical wire hits a horizontal one, its current continues toward the right.
| Vertical Wire A path for the current to follow. If a horizontal wire hits a vertical wire, its current continues upward unless there is no wire above, in which case it continues downward.
< Right Bridge When the current is heading toward the right, this skips the next command, as if the wire passes over it.
v Up Bridge Same as < but for current heading upward.
^ Down Bridge Same as < but for current heading downward.

Semantics

When the program starts, the interpreter looks throught every line of the code finding every ] and [. The ones found first are given more priority than the ones behind them. Program flow then moves the current to the next command on the right. Program flow can only go upward, downward, and toward the right. The commands -, |, =, <, v, and ^ are considered to execute with no loss of time. What that means is that in this program:

]--@
[-@

even though the top line has a longer wire, its @ executes first because it has a higher priority, being the first line.

Examples

Hello, World!

This program will output "Hello, World!" to the screen, then stop.

]@!@!@@!@!@@@@!@@!@@!@!@!@!@!@@!@!@@!@@@!@@!@!@@!@@@!@@!@!@@@@!@@!@!@!@@!@@@@!@!@@@@@@!@!@!@!@!@@@!@!@@!@!@@@@!@!@@@!@@!@!@@!@@!@!@@!@@@!@@!@@!@!@@@@!@!@@@@!@#

Cat

This program takes its input and outputs it to the screen, repeating forever.

]/+@+@+@+@+@+@+@+@1~

For a more complex program, you can instead do it like this.

   -/+@#
  -=
  |-+@1~
 -=-+@#
 |-=
 | -+@#
]=
 | -+@#
 |-=
 -=-+@#
  |-+@#
  -=
   -+@#