ReactionCan

From Esolang
Jump to navigation Jump to search

In ReactionCan by User:Zzo38, there are cans, and subroutines, and macros, and liquid substances to put into the can, some of which are more dense, and some of which can react with others. There is also an accumulator which can store a non-negative integer, and a return stack for returning from subroutine calls.

Each command ends with a semicolon, the commands are:

  • subroutine; Declares the beginning of a subroutine.
  • substance.can; Fill the empty part of the can with the substance.
  • substance.can.subroutine; Fill the empty part of the can with the substance and call the subroutine on a reaction.
  • can.can; Pour the contents of one can to another.
  • can.can.subroutine; Pour the contents of one can to another and call the subroutine on a reaction.
  • can; Make a can empty.
  • ; Return from subroutine call.
  • number; Discard this many top entries from the return stack (but do not return).
  • +number; Add this number to the accumulator.
  • -number; Subtract this number from the accumulator value if the result is not negative. If the result would be negative, instead keep the accumulator how it is.
  • macro; Declares the beginning of a macro definition. You cannot define macros inside of another macro.
  • !; End of a macro definition.
  • macro.parameter; Uses a macro, with this given parameter. Inside of the macro, any $ is replaced by the given parameter. Macros cannot be called recursively.
  • "text"; Output text. A newline is done by omitting the text.

The syntax consists of:

  • subroutine: A name consisting of all lowercase letters.
  • macro: A name with the first letter uppercase and the rest lowercase.
  • substance: A number, followed by zero or more reactants.
  • reactant: A name with the first letter uppercase and the rest lowercase.
  • can: A number and a name of all lowercase letters.
  • number: Any non-negative integer, or an asterisk. An asterisk represents the value stored in the accumulator.
  • parameter: Anything without a semicolon.
  • text: Anything without quotation marks.

Whitespace can be used anywhere and is insignificant. Comments start with a # character and last until the end of the line.

The number at the beginning of the name of a can is the capacity of how much can be stored in this can.

The number of a substance tells the order of stacking according to density. The reactants tell what will make a reaction.