Aeon

From Esolang
Jump to navigation Jump to search

Aeon is a Turing-complete more-flexible esoteric language designed by User:Cptx032 in April of 2014. It is based on FALSE and brainfuck.

Overview

Aeon works with two lists: one for string values and other for function values. The functions available are fixed. You can't write, in a script, another function. The default compiler has 5 basic functions (which can increase if you embed the interpreter in your application):

  • 0: print: prints the current value
  • 1: println: prints the current value and puts \n char in the end of line
  • 2: input: gets terminal entry and saves that value in the current position
  • 3: run: interprets the current value like a aeon script.
  • 4: read: read the content of file path in current value and saves your value in the previous position

The only chars available are ., +, -, %, v, ^, >, <, {, =, |, [, ], ( and #. Any other chars are ignored.

Functions

You should use those chars to move in the function list:

  • v: moves down in the list
  • ^: moves up in the list

Its like an vertical list. To run the current function use '.' char.

Variables

The variables are in a horizontal list:

  • >: moves right in the list
  • <: moves left in the list

Others commands:

  • +: tries add +1
  • -: tries add -1
  • %: saves the rest of line in current position

Flow control

Aeon has an if-greater-than, an if-less-than, an if-equal-to, an if-different-of and a while loop flow controls. The 'if' flow control starts with the '{' char. To test if the value of current position is greater than the last value, you can type: '{]'. To test if the value of current position is less than last value, you can type: '{['. If you want know if the current value is equal to last value, you can type '{=', and different '{|'. If the operation returns true the rest of line is interpreted, if not, the line is broken. The while loop works in the same way: if the current value is different of '0' then the rest of line is interpreted.

Error handling

Commands like +, -, {[, {[ can throw errors if the current value can't be casted to float or integer. Aeon hasn't any kind of error handling [although you can do that if you embed the language]. So, be careful.

Embedding the language

c++

To embed aon in c++ you need of the "aeon.cpp" file:

#include "aeon.cpp"
int main(){
AeonInterpreter *i = new AeonInterpreter();
std::string script = "++---->>><"; // example
std::vector<std::string> script_lines;
script_lines.push_back(script);
AeonError::AeonError er = i->run(lines);
if(er == AeonError::SYNTAX_ERROR){
	std::cout << "OPS" << std::endl;
}
return 0;
}

Compile

To compile type:

g++ <yourfile> -O3 -o <out>

Examples

Hello World

%Hello World
.

Simple name program

# 0 : print
# 1 : println
# 2 : input

%Enter your name:
v.v.>%Welcome, 
^.<^.%Press [ENTER] to continue...
v.v.

Simple age program

%In Brazil, you can only drive if you have more than 16 years.
.
%Enter your age:
>%You can drive
>%You can't drive
v<<.>>>v.^^>%16
{[<<<.>>>
{]<<.>>
{=<<<.>>>

List of commands

Char Description
. Runs the current function [vertical list]
+ Tries add +1 to the current value [in the horizontal list]
- Tries add -1 to the current value [in the horizontal list]
% Saves the rest of line to current position [in the horizontal list]
v Moves down [in the vertical list]
^ Moves up [in the vertical list]
> Moves right [in the horizontal list]
< Moves left [in the horizontal list]
{ Starts an 'if-statement'
= Before '{' means 'if-equal'. The rest of line will be runned if current value is equal to last value. If the last char is not '{' it is ignored.
| Before '{' means 'if-different-of'. The rest of line will be runned if current value is different of last value. If the last char is not '{' it is ignored.
[ Before '{' means 'if-less-than'. The rest of line will be runned if current value is less than last value. If the last char is not '{' it is ignored.
] Before '{' means 'if-greater-than'. The rest of line will be runned if current value is greater than last value. If the last char is not '{' it is ignored.
( While the current value is different of '0' the rest of line is runned
# The interpretation is interrupted. So, it works like commentary. After this char you can type any others char [including >, < etc.]

External links