Definer

From Esolang
Jump to: navigation, 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[edit]

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[edit]

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[edit]

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

Hello World:

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

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