Jaune

From Esolang
Jump to navigation Jump to search

Jaune is an esoteric programming language with a vocabulary of 16 symbols and the digits 0-9.

The language consists of an array of data cells, similar to brainfuck, with the addition of one "hold" cell, which is used to hold the value of the currently pointed cell. This makes it possible to add the value of one cell to another one easily.

Syntax

This language consists of the 16 symbols: !@#$%^&:;.?+-v<>, as well as the digits 0123456789. Their meaning is described by the following table.

Character Result
^ Outputs the content of the current cell.
v Reads user input to the number.
> Moves pointer to the next cell.
< Moves pointer to the previous cell.
(number)+ Adds the number to the current cell.
(number)- Subtracts the number from the current cell.
# Copies the value of the current cell to the dedicated hold cell.
& Adds the value of the hold cell to the current cell.
(number): Sets a goto label referenced to as the number.
(number)? If the value of the current cell is non-zero, then the reader cursor goes to the label named as the number.
(number)! If the value of the current cell is zero, then the cursor goes to the label named as the number.
. End of main program. Basically separates the part of the code which is read with the definitions of the subroutines.
(number)$ Set a subroutine with the name of number. All subroutines must be defined after the . end of main program operator.
(number)@ Use the subroutine of name number.
; Separate subroutines.
% Erases the content of the current cell, i.e. makes it 0.

The following EBNF description represents the grammar:

program        := mainProgram, [ subroutines ] ;
mainProgram    := "."
                | command, { command }, "." ;
subroutines    := subroutine, { subroutine } ;
subroutine     := command, { command }, ";" ;
command        := "^"
                | ">"
                | "<"
                | "#"
                | "&"
                | "%"
                | numericCommand ;
numericCommand := number, "+"
                | number, "-"
                | number, ":"
                | number, "?"
                | number, "!"
                | number, "$"
                | number, "@" ;
number         := literalNumber | "v" ;
literalNumber  := [ "+" | "-" ], digit, { digit } ;
digit          := "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" ;

To explain further, look at some examples below.

Example

Adder

The adder is pretty simple: v+v+^.

But we'll take a more complicated example to understand more commands: v+>v+#<&^..

v+>: Asks for user input, then adds it to the cell (default value of the cells is 0), then moves pointer to the next cell.

v+: Asks for user input, then adds it to the cell.

#: Copies value of current cell.

<: Moves the pointer to the previous cell.

&: Adds the value of the hold cell to the current cell.

^: Outputs the value of the current cell.

.: End of program.

In case the adder is needed to be used multiple times, we can define it as a subroutine: v+>v+1@^.1$#<&;

1@: The code cursor looks for the subroutine 1$, defined after the . in the list of subroutines. Then executes the code of the subroutine, then as soon as it reaches the ; it jumps back to the main program and executes the rest of the code till it reaches the . in this case, the rest of the code is just the ^ output operator.

Loop version

v+>v+1:1-<1+>1?<^.

1?: If the current cell is non-zero, goto label 1:

1:: Label 1:

So basically this is equivalent to the brainfuck adder: ,>,[-<+>]<.

Multiplier

v+1->v+#<1:2!>&<1-1?2:>^.

You can figure it out =]

Name

Jaune is yellow in French. And I like yellow, that's all =)

Interpreters

GitHub Common Lisp implementation with thorough documentation.

GitHub A simple JavaScript implementation of Jaune for the Rhino engine.