Taurus

From Esolang
Jump to navigation Jump to search

Taurus is an Esoteric Programming Language designed by PrySigneToFry.

It will be presented to all users with a sci-fi, cool, Turing-complete, powerful, and efficient look.

Basic syntax overview

Taurus is inspired by Swift, Python, and Javascript.

Comment

# The one line comment
#** Document comment block **#

Data types

In this language, there are 8 types.

Numeric type

Number

Any valid number can be considered a number type. Note that the range of values for this type is a set of real numbers, not a set of complex numbers.

Complex

Any number with an imaginary part is considered a complex type. Format: a+bi. Note that 1i cannot be represented as i.

String

The string is basically a flow of bytes, quote by ""(\" for "). A non-ASCII will encode as UTF-8 by default except you wrote <code>#`` encoding:YourEncoding ``#</code>. '' is also accepted, \' for '. """""" and '''''' are accepted as document string.

Array

An array is a series of numerical values enclosed in parentheses and separated by a comma. The index starts at 0 and the out-of-bounds index throws an error, but the negative index (starting at -1) means taking the absolute value of the index and then taking the element that is at that value from right to left. An array of key-value pair can be treat as a dictionary.

Slice of an array is written like this:

a[start:stop:step]

Omit the step means 1, omit start means 0, omit stop means len(a)-1.

Boolean

A Boolean is a logical variable that has both TRUE and FALSE properties (either TRUE or FALSE). 0, 0.0000000000, 0i, empty strings, NUL characters(its ASCII is zero), empty lists, empty pairs, empty objects (meaning objects that only have __init__ methods, and the only way is an empty function), undefined behaviours, and blank variables will all return FALSE. All other values(including true) return TRUE. The initialized value is FALSE.

Pair

A pair is a "tuple" with only two values: One former and one latter(inspired from islptng's SLet). Former value can be a string that make it into key-value pair.

Undefined behaviour

Occurs when you're doing things that make a weird consequence, such as divide 5 candies among 0 people(5/0), which returns infinity, and 0/0 is NaN.

Void

Void value is simply represented with None.

Variables and Constants

Variables are identified by a sign(Which must be legal, such as h_h, myIterator, or jNugjE8_jR_820, but not keywords, or illegal characters in it. We don't recommend you to use variable in other language, although it is legal).

To define a variable, you can write this:

var_type var_name = var_value

Constant is just add constant before the variable type.

Conditions

In order to minimize the Taurus programming language, we only use two conditional expression trees, and do not provide label definitions and label transformations.

If-else_if-else statement

Unlike Python, Taurus have no elif keyword, so you write the conditional tree as this:

if cond
{
    code
}
else if cond
{
    code
}
...
else
{
    code
}

Code can be put in braces and seperates with semicolons.

Switch statement

I don't want to speak nonsense, just see at C++. This is just an example.

switch(variable)
{
    case 1: //TODO; break;
    case 2: //TODO; break;
    ...
    default: //TODO;
}
When the code done, you must break it, or other cases will also did.

== Loops ==
In order to minimize the Taurus programming language, we eliminated the do-while loop.

This is THE only two loop structures:
<pre style="color:lime;background:black;">
while condition:
{
    code
}
for iterator in iteracontainer:
{
    code
}

Preprocessors

Preprocessors are defined with @.

Preprocessors often let you contains an import of library, etc.

If you want to make an initialization code block, use @@, and they'll be executed first, then is the main program.

Importing a library

To import a library, you may write this, for import a library:

@import<library_name>

If you wan't only import several module, use this:

@import<library_name> module1, module2, module3, ...

Also, * means all module that public.

Subroutines

Subroutines means a program have not to long so it is useful when golfing.

To defune a subroutine, write this:

function (function_type) function_name(parameter_list)
{
    function_body
    return return_value
}

To call a subroutine, write this:

function_name(*argument_list, **keyword_argument_list);

Pointer

A pointer can point to a specific value by an address. To call a pointer, write this:

*p

To get address of a value, write this:

\value

But wait! The value must be a variable, a constant, or an index of an array. Point to an array means double-point, so *a(a is an array) is equal to these:

[**a[0], **a[1], ............, **a[n-1]]

Class and Struct

This language is OOP, so we have both class and custom data structure:

# Define class
class YourClassName
{
    attributes
    
    def __init__(self)
    {
        # initialization
    }
    
    methods
}

# Make object
YourClassName obj_name = YourClassName.__init__(*args)
# Call object
attrib = obj_name.attribute_name;
obj_name.method_name(*args, **kwargs);

As for struct,

struct YourStructName
{
    attributes
    
    methods
};
YourStructName object_name;

Note: Struct are represented as array.

I/O

With all that said, it's time to talk about inputs and outputs.

Output

print(*args, **kwargs, sep = ' ', end = '\n', file = sys.stdout)

Print a serie of arguments. sep is seperator(normal a space), end is terminator(normal a linebreak), file is file to output.

Input

input(__prompt, file = sys.stdin)

Input a string and return it. __prompt is prompt that output before input, file is file to read.

Evaluated input

There is no evaluated input. However there is a self-evaluating function:

eval(expr)

Thus you can write this for evaluated input:

eval(input())

Error Handling

NOP

pass

This is a keyword that means no operation.

Error Handling

Taurus can also handle errors:

try
{
    #TODO
}
catch(Exception) # Throws an error called Exception
{
    #TODO
}
else catch(Exception) # Throws another error called Exception
{
    #TODO
}
else # Success
{
    #TODO
}
finally
{
    #TODO
}

In its predecessor(Aries, which not documented), errors passes silently, but Taurus is strict(Gemini will even stricter). Taurus halts and output the information of the error while catched an error.

Regex

I don't want to speak nonsense.

Example programs

I don't want to write them anymore.

Categories, Notes, and References

I don't want to categorize it anymore.