Definer

From Esolang
Jump to navigation Jump to search

Definer is a programming language that is based on defining what things do. It is not complete yet. A program is split into three sections, the constants section, the definition section and the code section.

Syntax

The syntax looks like this:

  definer = constants definitions code
  constants = "constants:" constant*
  constant = <name> "=" valueOrParameter
  definitions = "definitions:" definition*
  definition = (<defname>? valueOrParameter?)* "=" (<name>? valueOrParameter?)*
  code = <<anything>>
  valueOrParameter = "0" | <name> "(" valueOrParamter ")" | <name>
  <name> = ("a" ~ "z" | "A" ~ "Z")*
  <defName> = ("a" ~ "z" | "A" ~ "Z" | "-" | "+" | "*" | "/" | "%" | "<" | ">" | "1" ~ "9" | "(" | ")" | "&" | "|" | ":" ... <<a lot more>>*

(subject to change)

The way it works

When the program is started, all constants in the code section are replaced by the values declared in the constants section. Then the rules of the definition section are constantly applied. When the rules don't change anything anymore, everything that can get changed back into one of the constants is changed back. Then the result is outputted to the screen.

Examples

Addition:

  constants:
     1 = s(0)
     2 = s(s(0))
     3 = s(s(s(0)))
     4 = s(s(s(s(0))))
  definitions:
     x + 0 = x
     x + s(y) = s(x + y)
  code:
     2 + 2
  output:
     4

Subtraction:

 constants:
    1 = (0)
    2 = ((0))
    3 = (((0)))
    4 = ((((0))))
 definitions:
    x - 0 = x
    (x) - (y) = x - y
 code:
    4 - 1
 output:
    3

Infinite loop:

 constants:
 definitions:
    z = z
 code:
    z
 output:
    z (loops forever)

Looping counter:
Somehow it will not print the process out. It will print an infinite number of asterisks.

 constants:
 definitions:
    * = **
 code:
    *
 output:
    ***************************...

Hello World:

  constants:
  definitions:
  code:
     Hello world
  output:
     Hello world

Truth-machine without input/output:

 constants:
    1 = 11
 definitions:
 code:
    Here is where your input goes...
 output:
     0 (when the code is not 1)
     111111111111111111111111111... (when the code is 1)

The language idea is currently under development. If you got any ideas, please add to the talk page.