Auo

From Esolang
Jump to navigation Jump to search

Auo by User:XFire35 mixes ideas and changes some conventions, and may be quite logically random in its implementation. It utilises a stack which is symbolised by the '@' sign within the language. It also uses strict typing, so there is no automatic conversion of strings into numbers. Auo strictly uses lines as the ending point of an expression or command, therefore leaking onto another line will result in the new line being evaluated separately from its parent. Auo has three stacks, a normal stack, a variable stack and the jump stack.

The language's interpreter is written in Lua.

Notes

Auo uses the "" marks to encapsulate quotes which run to the end of the line.

Variables

Contrary to most programming languages, the value of a variable comes before the variable, also instead of an equal sign to show the relation, a '>' is used instead. A '>' was shown to continue the theme of the flow of the program. When creating and subsequently referencing a variable, the program must use the '$' sign followed by the variable name, which may contain alphanumeric characters with an underscore. In all functions, a variable may be used.

5 > $foo
'foo' > $bar

When a function requires the use of []. The variable name, prefixed with a '$', following the standard can be used to insert the variable's value into the string.

The following method can be used to destroy any variable:

$nil > $foo

Where '$foo' is the variable to be destroyed.

As currently implemented there are string and number variables (both floating point and negative), with the intention of implementing lists at a later date.

Stack Related

Commands for manipulating the stack:

x>@                 Pushes x to stack
<@                  Pops value from stack
-@                  Discards top item from stack
*@                  Duplicates top item on stack 
+@                  Merges the top two items on stack
~@                  Reverses the order of the top two objects on stack
/@                  Clears the stack

Mathematical Commands

For an arbitrary reason, the math commands in Auo do not use any common math symbols, instead they use Polish Notation commands. The commands have an 'm.' prefix to signify that they are math-based.

m.a:x,y             Add x and y
m.s:x,y             Subtract y from x
m.m:x,y             Multiply x by y
m.d:x,y             Divide x by y

Comparison Commands

As the following are questions, they have a 'q.' prefix.

q.e:x,y             Equal?
q.n:x,y             Not equal?
q.l:x,y             x less than y?
q.s:x,y             x less than, equal to y?
q.g:x,y             x greater than y?
q.r:x,y             x greater than, equal to y?

The above return 'true' or 'false' according to the question's truth value. Note: The 'Equal' and 'Not Equal' commands may be used on a string in addition to being used on numbers, the others are to be used on numbers only.

String Commands

String Commands, 's.' prefix:

s.l:x               Length of string x
s.a:x,y             Add strings x and y together
s.s:x,n             Split string x at position n

Jump

A function is called a Jump in Auo, as it was originally planned to be as such. Jumps are created in the following way:

%foo:{
 i.o:['What is your name?']
 i.i:$name
 i.o:['Hello, $name']
}

The '}' needs to be on a separate line, or the function will not work.

To use a function, simply type the function name. Due to how the interpreter works, it is not a requirement to have the function defined before its use.

IO Commands

Input/output commands, 'i.' prefix:

i.o:['Hello']       Prints 'Hello'
i.i:$x              Takes user input and assigns it to the variable x
i.r:['file']        Runs the file named 'file'

Control Flow Statements

The conditional statements are follow the function naming convention of the language, they have a 'c.' prefix.

If Statement:

c.i:[%true],[%false] > q.l:$x,10

The above will return true if '$x' is less than 10, then the '%true' jump will be run, if false, then the false part will be run. The value is obtained from the stack.

For Statement:

1 > $x
c.f:[m.a:$x,1],[%body] > q.l:$x,10

The above will run the '%body' jump whilst '$x' is less than 10. After each pass, '$x' will increase by one. '$x' must be initialised first before use.

While Statement:

c.w:[%body] > q.l:$x,10

The above will run '%body' jump whilst '$x' is less than 10

External resources

Lua interpreter is available here: http://esolangs.org/wiki/User:XFire35/auo.lua under the ISC License