Old page wikitext, before the edit (old_wikitext) | 'ASTLang is a coding language based off of the style of an abstract syntax tree (hence AST). It uses a fully Python intepreter which is about 31kb in size (at the current release). More information is at the [https://github.com/NTMDev-2/ASTLang github] page, including information about new updates, bugs, and fixed bugs.
It is a turing complete esolang that can actually be learnt and used, with very simple syntax and similar to Python.
Note that this coding language was completely a "for fun" project and is not expected to be actually professionally used (I mean, who uses an esolang efficiently?)
''Please note that this wiki is currently unfinished. If you are a beginner, the information already provided should be enough to give you a start.''
Things you should do:
* If you see a problem or something is not accurate, please update it.
* Fix typos or add/remove words for clarity
Thanks!
'''This documentation is not intended to be read from start to end. Instead, use the table of contents (provided below) to navigate to a section of interest. '''
== Getting Started ==
Obviously, from the description, the ASTLang interpreter and runtime environment needs at least Python 3 or preferably Python 3.12+ from best performance. All other packages like re or pickle will come pre-installed along with Python, so there is no need to go to other websites to find modules to run this program. As said, the main file is about 31kb large with 4100 lines of code (at the current moment, this will change).
Head to the [https://python.org official page] of Python to download it if you do not already have Python installed.
== Code Structure ==
When starting any program, you must wrap all code inside the '''Module''' function. If the program is consists of only one function, it is not necessary to wrap it.
Module(
...
)
All code must go inside the braces (yes I know they are parenthesis but I cannot spell the word "parenthesis" quickly and correctly consistently so bare with me). After that, all functions inside the '''Module''' function should be separated by commas, except for the last one which can be ignored if the programmer wishes.
Module(
foo(),
foobar(),
foobarbar()
)
Inside a function, if a function does need to take arguments, they should also be seperated by commas, except for the last one which is optional. The programmer may also choose optionally to name all arguments, but they should do this consistently or it will cause confusion, and sometimes unexpected errors. This means that if a programmer names one argument, they should name all of them.
foo(
Blah=BlahBlah,
BlahBlah=Blah123
Blah4321=BlahBlahBlah
)
Sometimes, an argument may need a list (an argument with brackets surrounding it) input. To define it, separate all elements inside it, except for the last one optionally (I am saying this a lot!).
Blah = [1, 2, 3, 4]
=== ObjNONE() ===
''ObjNONE()'' is a special function that returns '''None'''. '''None''' means null; it has no value. This is usually an input to an argument when it does not necessarily need an input, or the programmer deliberately chose to not give an input.
=== Raw String ===
Sometimes, you do not actually need an identifier for an argument. This usually occurs when the type of argument doesn't matter, but the text does. Example:
MyFunction(
Mode='On', <--- This doesn't need String()
Text=String('Hi!') <--- This does need String()
)
=== Empty Functions ===
Some functions do not require or do not need arguments to be provided to it to be able to run. However, you should still put two matching parenthesis just like any other function:
MyFunction() <--- This is still needed!
== How To Save ==
If you wish to save a file, press '''Crtl+S''' to save the file. This will save it as a binary file, with the file extension .astlang. Unfortunately, this file can be unexpectedly large and take up storage. A general idea is to save it as a plain text file, then copy+paste it into the IDE. This can save up to 10x the storage. To open a file, press '''Crtl+O'''. A file explorer window will automatically popup, and you must select a file with .astlang. This will open all file contents inside the file.
== Commenting in Code ==
Commenting in your code can make it more readable and allow other programmers catch on to what you are doing. There are two options to do this.
# You can use a hashtag to comment. The interpreter will skip this line.
Comment('You can also use the Comment function. This is only used for raw input')
== Print ==
To print a variable or anything, use '''FuncCall'''. This is a wrapper function used to call simple functions like '''Min, Max, Len and Print'''.
FuncCall(
Function=Print(
Contents=Foo
End=Foo
)
''Contents'' is what is to be printed. ''End'' is what should be added at the end. This is default to a newline. Note that you should use an identifier, not just a plain type. For example, if you just put a string in ''Contents'' without '''String''', it may not produce the desired output.
An example of the Print function in action is the simple Hello World! program.
FuncCall(
Function=Print(
Contents=String('Hello World!')
)
)
Note that we actually do not need to specify the name of the arguments. Check "Code Structure" for more information.
FuncCall(Print(String('Hello World!')))
== Create A Variable ==
When creating a variable, there are two functions involved.
=== Variable Assignment ===
To assign any value to a variable with any valid name as a string (special characters are allowed. Note that characters should be kept as letters or numbers for readability). Use the '''Assignment''' function to do so.
Assignment(
Name='foo',
Val=String('foo')
)
=== Calling A Variable ===
To retrieve the contents of a variable, use '''Variable'''.
Variable(
Name='foo',
)
Note that this will not display the value of the variable in any way. This only returns the value of the variable as an input to an argument.
=== Initializing a Empty Variable ===
When you do not want to directly provide a value to a variable but still want it to be existing in the code context, use '''InitVariable''' to create a variable assigned '''None'''. This variable cannot be used to provide input to an argument.
InitVariable(
Name='foo'
)
== Simple Data Types ==
Simple data types are integers, floats, booleans, and strings. They form up everything a basic programmer would need.
=== Integers ===
To return an integer as an input to an argument, use '''Integer'''.
Integer(
Int=12345
)
=== Strings ===
To return a string as an input to an argument, use '''String'''. Note that a string must be wrapped inside quotation marks to simulate a string. Other data types do not need this.
String(
String='Hello, World!'
)
=== Floats ===
To return a float as an input to an argument, use '''Float'''. A common misconception is that a float CAN be an integer, but the interpreter will automatically add a .0 at the end of the value.
Float(
Flt=1234.5
)
=== Boolean ===
To return a boolean as an input to an argument, use '''Boolean'''. Note that you can actually input a boolean as a string. What this means is you have two ways of representing a boolean inside the '''Boolean''' function.
'''''#1:'''''
Boolean(
Bool='True'
)
''This, in my opinion, looks better.''
'''''#2:'''''
Boolean(
Bool=True
)
''Sometimes this can be better when comparing if the Boolean actually has a value or is true.''
=== PrimitiveWrapper ===
This is a bonus function. If you do not know directly the identifier a variable would need when inputting it into
an argument, you may use '''PrimitiveWrapper''' to identify the primitive value without providing a specific identifier to that value. An example:
PrimitiveWrapper(V=Variable(Name='UnknownIdentifier'))
== Lists ==
A list is a type of container that can hold basically hold infinite items in an array. You can retrieve elements in the list by calling the item's index, which starts at 0.
=== Creating a List ===
To create a list, use '''ListAssignment'''. This is usually used inside '''Variable''' when assigning the variable a list. Inside ListAssignment, you can give it any amount of arguments as long as they follow the rules of spacing (See ''Code Structure'').
ListAssignment(
Integer(1),
String(A),
Integer(2),
String(B)
)
You must provide an identifier for each element in a list if it is a primitive/simple type.
=== Get Element From List ===
To get an element from a list through index, use '''ListCall'''. You must provide an index using '''Integer''', as the interpreter must receive an integer to find the index of an element.
'''''WARNING:''''' ''Most coding languages start their index positions at 0, meaning that a element at "positon" 2 is actually at index position 1. Essentially, it is the "actual position" - 1.''
Module(
Variable(
Name='Foo',
Val=ListAssignment(
Integer(1),
Integer(2)
)
),
ListCall(
Name='Foo',
Index=Integer(1)
)
)
''This will return 2, as an integer''
''Name'' is the name of the variable that contains the list. This must be defined and the list must not contain any definition errors in it. ''Index'' is the index of the element the programmer wishes to examine.
=== Edit a List ===
This is a pretty complex function with a few arguments taking multiple inputs. When you wish to perform some utility functions, use '''ListEdit'''. '''ListEdit''' takes 7 arguments, which are:
Name
EditType
AppendVal (default None)
DelVal (default None)
DelIndex (default None)
PopIndex (default None)
ReversedSort (default Boolean('False'), False)
''Name'' is the name of the variable you are currently wishing to perform actions upon. ''EditType'' is the name of the edit/action you want to perform. ''Edit Type'' takes 6 inputs:
append
del
clear
sort
pop
reverse
'''These names should be typed EXACTLY (including case) for the function to work. This applies to any other function that takes an argument without an identifier (these are called raw string arguments)'. They look like this: 'argument''''
==== append ====
Append '''AppendVal''' to the specified list (''Name''). '''AppendVal''' must be set so that the interpreter can add it to a list.
==== del ====
Delete '''DelVal''' from a list (''name''). '''De;Val''' must be set so that the interpreter can delete it to a list.
==== clear ====
Clears the list
==== sort ====
Sorts the list, from smallest to greatest if the list is entirely numerical, A-Z alphabetically if the entire list is text. If the list is not all the same type of simple data types, '''sort''' cannot be used.
==== reverse ====
Reverses the given list. This basically flips it. If the list is:
[1,2,3]
It will become:
[3,2,1]
=== Special List Functions ===
1.
To insert an element anywhere into a list, use '''InsertElement'''.
InsertElement(
Name
Var
IndexPos
)
''Name'' is the name of the list. ''Var'' is what you want to insert at index ''IndexPos''.
2.
To see if a list contains an element, use '''ListContains'''.
ListContains(
List
Element
)
If element ''Element'' is inside ''List'', this will return true. If not, returns false.
== List Arithmetic ==
To use '''Len, Max, and Min''' you must wrap them inside '''FuncCall''' since they are primitive functions. They all take ''Var'' as an argument (the variable you are applying these functions to).
=== Len, Sum ===
'''Len''' returns the size of the condition. The most applicable version of this is how long a list, tuple or dictionary would be.
Len(Var=Variable(Name='MyList'))
'''Sum''' returns the sum of all the numeric numbers in a list. The list must contain only numbers, nothing else.
=== Max and Min ===
'''Max''' returns the maximum value in a list or tuple, and '''Min''' returns vice versa. However, these two functions are not limited to only numerical values.
''(Note that '''Max''' and '''Min''' both follow these rules)''
{| class="wikitable"
|+ Caption text
|-
! Comparison (Max) !! Output
|-
| [1, 'a'] || [FATAL ERROR AT {...}]: ...
|-
| ['A', 'a']|| 'a' (or 'A')
|-
| [1, 2]|| 2 (or 1)
|}
To summarize, larger numbers are larger than smaller ones (really?!), numbers cannot be compared to strings, and lowercase strings are "larger" than uppercase ones.
== Tuples ==
Tuples are lists, but immutable. Immutable means you cannot change it any way after it is set. Examining an element (calling it) does not count as changing it.
=== Creating a Tuple ===
When you want to create a tuple (like creating a list), use '''TupleAssign'''. TupleAssign also takes a series of elements, just like '''ListAssignment'''.
TupleAssign(
Integer(1),
Integer(2),
Integer(3)
)
=== Inspecting a Tuple ===
When inspecting/editing a tuple, you only have two actions you are allowed to perform since it is immutable.
TupleInspection(
TupleVar
Mode
IndexVar (Default None)
UnpackingTargets (Default None)
)
''TupleVar'' is the name of the variable that contains the tuple. ''Mode'' is the type of action you are performing. If the selected mode is 'index', ''IndexVar'' is the index of the element you are trying to call. If the selected mode is 'unpack', ''UnpackingTargets'' should be a list of elements you want to distribute the tuple to (for more advanced programmers, this is essentially '''enumerating''' the tuple).
== Conditionals (If Statements and more) ==
Conditionals help direct program flow. There are several conditional statements you can use.
=== If Statement Structure ===
This defines the main structure of the if-elif-else statements. When creating an if statement, a expression is always necessary.
IfCondition(
Expression
Body
Elif (Default None)
ElifBody (Default None)
ElseBody (Default None)
)
In more actual code form (Python):
if (Expression):
Body
elif Elif:
ElifBody
else:
ElseBody
Note that ''ElifBody'' must be defined to use ''Elif''.
''Expression'' is the starting comparison. If this evaluates to '''true''', ''Body'' runs. Body should be a list of functions, like this:
Body = [FuncCall(...), ListAssignment(...), Variable(...)]
'''''(This is true for ElifBody and ElseBody)'''''
''Elif'' is evaluated if ''Expression'' evaluates to '''false'''. If ''Elif'' is true, ''ElifBody'' runs. If all are false, the evaluator defaults to ''ElseBody''.
=== Conditions ===
To create a condition, you cannot simply write a string that contains the condition you want (for example, '1 + 1 == 2' is not allowed). You need the '''Condition''' function.
Condition(
Right
Operator
Left
)
''Right'' is the righthand side of the expression. In the case of ''1+1=2'', '''1+1''' would be the righthand side. ''Operator'' is the operation between the two sides of the condition. Currently, operator accepts:
{| class="wikitable"
|-
! Operator!! Definition
|-
| x == y|| x is equal to y
|-
| x != y|| x is not equal to y
|-
| x >= y|| x is greater than OR equal to y (numeric)
|-
| x <= y || x is less than OR equal to y (numeric)
|-
| x > y || x is greater than y (numeric)
|-
| x < y || x is less than y (numeric)
|}
=== LogicalOperation ===
When comparing numeric values or using '==' and '!=' is not enough, using '''LogicalOperation''' allows for boolean operations.
LogicalOperation(
RightOp
Op
LeftOp
)
''RightOp'' and ''LeftOp'' and the right and left hand sides of the condition, respectively. ''Op'' is the boolean operation you are performing.
{| class="wikitable"
|-
! Operation !! Requirement for '''True'''
|-
| x and y|| both true
|-
| x or y|| at least one true
|-
| x contains y|| element y is in x (containers, string)
|-
| not y || inverse
|}
A more detailed ex
==== and ====
If in form:
x and y
''x'' and ''y'' must both be '''true''' for this to return true. If not, returns false.
==== or ====
If in form:
x or y
At least one variable must be '''true''' for this to return true. If not, returns false.
==== contains ====
If in form:
x contains y
We assume that ''x'' would be some arbitrary type of container or string. If ''y'' is in ''x'' (as an element, substring, subelement, etc.) this would return true. If not, returns false.
==== not ====
The inverse of ''LeftOp''. ''RightOp'' is not needed here (Set it to '''ObjNONE()''').
=== Any + AllCondition ===
When you want to find out if a set of objects follow a condition, use '''AllCondition'''. However, if you only need to know if at least one object follows the condition, use '''AnyCondition'''. They both take ''Condition'' as an argument, which should be some type of the '''Condition''' function:
Condition(Right=ListAssignment(Boolean('True'), Boolean('False'), ...))
'''AnyCondition''' returns true if ANY of the values in the given object are true, and '''AllCondition''' return if ALL values are true.
== Switch / Match ==
Instead of using many '''IfStatement''' functions, using '''Switch''' can make code more readable and efficient.
Example (psuedocode):
''What day is it?''
switch (day):
case 1:
print "monday!"
case 2:
print "tuesday!"
{so on...}
case 7:
print "sunday!"
default:
print "hey, that's not in the days of the week!"
In ASTLang, '''Switch''' takes these arguments:
Switch(
SwitchVar
Scenarios
Default (Default None)
)
''SwitchVar'' is the variable you are comparing against the ''Scenarios''. The ''SwitchVar'' in our "days of the week" example would be '''day''', while the ''Scenarios'' would be '''1, 2, 3, 4, etc. to 7'''. ''Default'' would be if all ''Scenarios'' evaluated '''false'''. If this is not set, the interpreter will just skip the '''Switch''' statement.
=== Scenario ===
This is the base function for '''Switch'''. It creates the individual cases for the switch statement.
Scenario(
Var
Body
Fallthrough (Default False)
)
''Var'' is the variable you are comparing against the ''SwitchVar''. In our example, that would be our day numbers. ''Body'' is what you want to execute if the scenario is true. ''Fallthrough'' controls if the code evaluates even after finding a matching scenario.
== Simple statistics and Math Operations ==
This section will cover the functions '''Mean, Median, Mode, Operation, and Calculate'''.
=== Simple Statistics ===
To calculate the mean of a list or tuple (must be numeric), use '''Mean'''. For mode, use '''Mode''', and for the median use '''Median'''. All 3 of these functions take ''List'' as an argument. This is the list or tuple you want to take the mean, mode, or median of.
=== Simple Math operations ===
To calculate an expression using order of operations (simple operations like '*+-/') and other features, use '''Calculate'''. '''Calculate''' takes ''Expression'' as an argument. This argument takes raw string. To assign a primitive operation to a variable or as an input to an argument, use '''Operation'''.
Operation(
Left
Op
Right
)
''Left'', ''Right'', and ''Op'' are the left hand side, right hand side, and operator of the equation. You can input '*', '+', '-', or '/' (strings) as an operator. This argument takes raw string as an input, so you don't need '''String()'''
'''Abs''' returns the absolute value of its argument, ''Val''.
'''Power''' takes two arguments, ''Power'' and ''Base''. It returns ''Base'' raised to the ''Power''.
== Loops ==
Loops are good for repeatedly performing the same task efficiently.
=== Loop structure Function ===
To create the structure of the loop, use '''Loop'''. Note that the argument ''Iterable'' should not be confused with the function of the same name, '''Iteerable'''.
Loop(
LoopType
Body
Iterable (Default None)
Expression (Default None)
ControlVar (Default None)
)
''LoopType'' is the type of loop you want to create (it takes 'for' or 'while'). This takes a raw string. ''Body'' takes a list of functions you want to run each successful iteration ran by ''Iterable''. ''Iterable'' should be some arbitrary object that can be iterated through (this is only needed when the LoopType is 'for'). This is a somewhat complex requirement for beginners (no programming experience). If you do not know if the object you are using is iterable, use THE FUNCTION '''Iterable'''.
'''Iterable''' takes the argument ''Iter''. If the object given to the argument (as input) is indeed iterable (can be used in a loop), the function will return something like this:
<list_iterator object at 0x...>
''This is what you get if you inputted a list. Of course, if it was a string, it would be different.''
''Expression'' is used when the LoopType is 'while'. ''Expression'' should be a condition that evaluates to a boolean. When the ''Expression'' value is '''true''', the loop will execute until the condition is '''false'''.
''ControlVar'' is the variable of which the iterable is being stored.
for x in i:
x
In this case, '''i''' is the iterable and '''x''' is the control variable. Every element of '''i'' is being stored inside '''x''' once every iteration. This is only needed if the LoopType is 'for'.
=== Break and Continue ===
To forcefully exit a loop regardless of the current circumstances, use '''Break'''. You can optionally provide an ''ExitMessage'', which outputs when the loop is exited. To skip an iteration, use '''Continue'''.
=== Enumeration ===
The function '''EnumerateObjects''' returns both the current iteration count and also the element itself. Quote from AI:
"This object can then be used in loops to access both the index and the value of each item in the iterable simultaneously."
When actually using '''EnumerateObjects''', you need to put it in the ''Iterable'' argument as an input (since the '''EnumerateObjects''' function is an iterable).
EnumerateObjects(
Iterable (not to be confused with '''Loop's''' Iterable argument)
Start (Default 0)
)
''Iterable'' is the list you want to enumerate through. ''Start'' is what integer you want to start the iteration counter. This is usually default to 0 (since the first index for a list is also 0).
'''''WARNING! If using iterable that outputs more than one item, you must give ControlVar a list argument, like this: ['element', 'index'] in the case of EnumerateObjects'''''
=== The Range Function ===
When you want to create a numerical list without specifically defining it, you can use '''Range'''. This is usually used when a list containing a geometric sequence (like 1, 2, 3, 4, ...) is too long to be written by hand. Also, it is used as an input to the ''Iterable'' argument for '''Loop'''.
Range(
BoundMin
BoundMax
Step (Default 1)
)
''BoundMin'' is the starting number of the list. ''BoundMax'' is the ending number of the list, and ''Step'' is the common difference between any two consecutive elements (or the incrementor).
A common usage in loops:
Loop(
LoopType='for',
Iterable=Range(BoundMin=Integer(0), BoundMax=Integer(10)),
ControlVar='x',
Body=[FuncCall(Function=Print(Contents=Variable('x')))] <--- You can actually call any control variable using '''Variable'''!
) <--- This outputs 1, 2, 3 ... 10
== Advanced Math Operations ==
This includes trigonometry functions and other functions like '''Gcd''', '''Round''', or '''Factorial'''. All of the functions listed take ''Value'' as their only argument unless otherwise noted.
=== Round ===
Round argument ''Flt'' to ''DecPoints'' decimal points. Example:
Round(
Flt=Float(1.1),
DecPoints=Integer(0)
)
=== Floor, Ceiling ===
'''Floor''' rounds the value provided down regardless of rounding rules, while '''Ceil''' rounds it up.
Floor(Value=Float(1.1)) <--- This outputs 1
Ceil(Value=Float(1.1)) <--- This outputs 2
=== Square root, Logarithm, Factorial ===
For square roots, use '''Sqrt'''. For a logarithm, use '''Log'''. '''Log''' takes an additional argument called ''Base'', which is the base the logarithm will be in. '''Factorial''' calculates the factorial of ''Value'' (really?!).
=== Trig Functions ===
To perform a trigonometric function, use '''Exp, Sin, Cos, or Tan'''. They calculate their corresponding trig function, according to their name.
'''WARNING: The source code for these functions use Python's math package, "math". This is always calculated in RADIANS, not degrees.'''
=== Gcd, Lcm ===
'''Gcd''' and '''Lcm''' stands for ''greatest common divisor'' (or more commonly known as ''greatest common factor'') and ''least common multiple'', respectively. They evaluate this between arguments ''A'' and ''B''. Example:
Gcd(
A=Integer(20),
B=Integer(30)
) <--- This outputs 10
=== Mod, MathConstants ===
'''Mod''' will calculate the remainder when its ''Value'' is divided by ''Divisor''. Example:
Mod(
Value=Integer(5),
Divisor=Integer(2)
) <--- This will return 1
'''MathConstants''' will return some advanced irrational values in math, like ''e'' or ''pi''. It accepts:
pi
e
tau
inf
== String Operations 1 ==
There are many string operations you can use. In this section, it covers mostly on string checkers than modifiers. Basically, these functions do not really change the string itself.
=== Uppercase, Lowercase ===
To automatically convert the case to uppercase or lowercase, use '''StringUpper''' and '''StringLower''', respectively. Both take ''Str'' as an argument. Make sure this is a valid string and also wrapped inside '''String'''.
== String Operations 2 ==
===' |
New page wikitext, after the edit (new_wikitext) | 'ASTLang is a coding language based off of the style of an abstract syntax tree (hence AST). It uses a fully Python intepreter which is about 31kb in size (at the current release). More information is at the [https://github.com/NTMDev-2/ASTLang github] page, including information about new updates, bugs, and fixed bugs.
{{infobox proglang
|name=ASTLang
|author=[[User:NTMDev|NTMDev]]
|year=[[:Category:2025|2025]]
}}
It is a turing complete esolang that can actually be learnt and used, with very simple syntax and similar to Python.
Note that this coding language was completely a "for fun" project and is not expected to be actually professionally used (I mean, who uses an esolang efficiently?)
''Please note that this wiki is currently unfinished. If you are a beginner, the information already provided should be enough to give you a start.''
Things you should do:
* If you see a problem or something is not accurate, please update it.
* Fix typos or add/remove words for clarity
Thanks!
'''This documentation is not intended to be read from start to end. Instead, use the table of contents (provided below) to navigate to a section of interest. '''
== Getting Started ==
Obviously, from the description, the ASTLang interpreter and runtime environment needs at least Python 3 or preferably Python 3.12+ from best performance. All other packages like re or pickle will come pre-installed along with Python, so there is no need to go to other websites to find modules to run this program. As said, the main file is about 31kb large with 4100 lines of code (at the current moment, this will change).
Head to the [https://python.org official page] of Python to download it if you do not already have Python installed.
== Code Structure ==
When starting any program, you must wrap all code inside the '''Module''' function. If the program is consists of only one function, it is not necessary to wrap it.
Module(
...
)
All code must go inside the braces (yes I know they are parenthesis but I cannot spell the word "parenthesis" quickly and correctly consistently so bare with me). After that, all functions inside the '''Module''' function should be separated by commas, except for the last one which can be ignored if the programmer wishes.
Module(
foo(),
foobar(),
foobarbar()
)
Inside a function, if a function does need to take arguments, they should also be seperated by commas, except for the last one which is optional. The programmer may also choose optionally to name all arguments, but they should do this consistently or it will cause confusion, and sometimes unexpected errors. This means that if a programmer names one argument, they should name all of them.
foo(
Blah=BlahBlah,
BlahBlah=Blah123
Blah4321=BlahBlahBlah
)
Sometimes, an argument may need a list (an argument with brackets surrounding it) input. To define it, separate all elements inside it, except for the last one optionally (I am saying this a lot!).
Blah = [1, 2, 3, 4]
=== ObjNONE() ===
''ObjNONE()'' is a special function that returns '''None'''. '''None''' means null; it has no value. This is usually an input to an argument when it does not necessarily need an input, or the programmer deliberately chose to not give an input.
=== Raw String ===
Sometimes, you do not actually need an identifier for an argument. This usually occurs when the type of argument doesn't matter, but the text does. Example:
MyFunction(
Mode='On', <--- This doesn't need String()
Text=String('Hi!') <--- This does need String()
)
=== Empty Functions ===
Some functions do not require or do not need arguments to be provided to it to be able to run. However, you should still put two matching parenthesis just like any other function:
MyFunction() <--- This is still needed!
== How To Save ==
If you wish to save a file, press '''Crtl+S''' to save the file. This will save it as a binary file, with the file extension .astlang. Unfortunately, this file can be unexpectedly large and take up storage. A general idea is to save it as a plain text file, then copy+paste it into the IDE. This can save up to 10x the storage. To open a file, press '''Crtl+O'''. A file explorer window will automatically popup, and you must select a file with .astlang. This will open all file contents inside the file.
== Commenting in Code ==
Commenting in your code can make it more readable and allow other programmers catch on to what you are doing. There are two options to do this.
# You can use a hashtag to comment. The interpreter will skip this line.
Comment('You can also use the Comment function. This is only used for raw input')
== Print ==
To print a variable or anything, use '''FuncCall'''. This is a wrapper function used to call simple functions like '''Min, Max, Len and Print'''.
FuncCall(
Function=Print(
Contents=Foo
End=Foo
)
''Contents'' is what is to be printed. ''End'' is what should be added at the end. This is default to a newline. Note that you should use an identifier, not just a plain type. For example, if you just put a string in ''Contents'' without '''String''', it may not produce the desired output.
An example of the Print function in action is the simple Hello World! program.
FuncCall(
Function=Print(
Contents=String('Hello World!')
)
)
Note that we actually do not need to specify the name of the arguments. Check "Code Structure" for more information.
FuncCall(Print(String('Hello World!')))
== Create A Variable ==
When creating a variable, there are two functions involved.
=== Variable Assignment ===
To assign any value to a variable with any valid name as a string (special characters are allowed. Note that characters should be kept as letters or numbers for readability). Use the '''Assignment''' function to do so.
Assignment(
Name='foo',
Val=String('foo')
)
=== Calling A Variable ===
To retrieve the contents of a variable, use '''Variable'''.
Variable(
Name='foo',
)
Note that this will not display the value of the variable in any way. This only returns the value of the variable as an input to an argument.
=== Initializing a Empty Variable ===
When you do not want to directly provide a value to a variable but still want it to be existing in the code context, use '''InitVariable''' to create a variable assigned '''None'''. This variable cannot be used to provide input to an argument.
InitVariable(
Name='foo'
)
== Simple Data Types ==
Simple data types are integers, floats, booleans, and strings. They form up everything a basic programmer would need.
=== Integers ===
To return an integer as an input to an argument, use '''Integer'''.
Integer(
Int=12345
)
=== Strings ===
To return a string as an input to an argument, use '''String'''. Note that a string must be wrapped inside quotation marks to simulate a string. Other data types do not need this.
String(
String='Hello, World!'
)
=== Floats ===
To return a float as an input to an argument, use '''Float'''. A common misconception is that a float CAN be an integer, but the interpreter will automatically add a .0 at the end of the value.
Float(
Flt=1234.5
)
=== Boolean ===
To return a boolean as an input to an argument, use '''Boolean'''. Note that you can actually input a boolean as a string. What this means is you have two ways of representing a boolean inside the '''Boolean''' function.
'''''#1:'''''
Boolean(
Bool='True'
)
''This, in my opinion, looks better.''
'''''#2:'''''
Boolean(
Bool=True
)
''Sometimes this can be better when comparing if the Boolean actually has a value or is true.''
=== PrimitiveWrapper ===
This is a bonus function. If you do not know directly the identifier a variable would need when inputting it into
an argument, you may use '''PrimitiveWrapper''' to identify the primitive value without providing a specific identifier to that value. An example:
PrimitiveWrapper(V=Variable(Name='UnknownIdentifier'))
== Lists ==
A list is a type of container that can hold basically hold infinite items in an array. You can retrieve elements in the list by calling the item's index, which starts at 0.
=== Creating a List ===
To create a list, use '''ListAssignment'''. This is usually used inside '''Variable''' when assigning the variable a list. Inside ListAssignment, you can give it any amount of arguments as long as they follow the rules of spacing (See ''Code Structure'').
ListAssignment(
Integer(1),
String(A),
Integer(2),
String(B)
)
You must provide an identifier for each element in a list if it is a primitive/simple type.
=== Get Element From List ===
To get an element from a list through index, use '''ListCall'''. You must provide an index using '''Integer''', as the interpreter must receive an integer to find the index of an element.
'''''WARNING:''''' ''Most coding languages start their index positions at 0, meaning that a element at "positon" 2 is actually at index position 1. Essentially, it is the "actual position" - 1.''
Module(
Variable(
Name='Foo',
Val=ListAssignment(
Integer(1),
Integer(2)
)
),
ListCall(
Name='Foo',
Index=Integer(1)
)
)
''This will return 2, as an integer''
''Name'' is the name of the variable that contains the list. This must be defined and the list must not contain any definition errors in it. ''Index'' is the index of the element the programmer wishes to examine.
=== Edit a List ===
This is a pretty complex function with a few arguments taking multiple inputs. When you wish to perform some utility functions, use '''ListEdit'''. '''ListEdit''' takes 7 arguments, which are:
Name
EditType
AppendVal (default None)
DelVal (default None)
DelIndex (default None)
PopIndex (default None)
ReversedSort (default Boolean('False'), False)
''Name'' is the name of the variable you are currently wishing to perform actions upon. ''EditType'' is the name of the edit/action you want to perform. ''Edit Type'' takes 6 inputs:
append
del
clear
sort
pop
reverse
'''These names should be typed EXACTLY (including case) for the function to work. This applies to any other function that takes an argument without an identifier (these are called raw string arguments)'. They look like this: 'argument''''
==== append ====
Append '''AppendVal''' to the specified list (''Name''). '''AppendVal''' must be set so that the interpreter can add it to a list.
==== del ====
Delete '''DelVal''' from a list (''name''). '''De;Val''' must be set so that the interpreter can delete it to a list.
==== clear ====
Clears the list
==== sort ====
Sorts the list, from smallest to greatest if the list is entirely numerical, A-Z alphabetically if the entire list is text. If the list is not all the same type of simple data types, '''sort''' cannot be used.
==== reverse ====
Reverses the given list. This basically flips it. If the list is:
[1,2,3]
It will become:
[3,2,1]
=== Special List Functions ===
1.
To insert an element anywhere into a list, use '''InsertElement'''.
InsertElement(
Name
Var
IndexPos
)
''Name'' is the name of the list. ''Var'' is what you want to insert at index ''IndexPos''.
2.
To see if a list contains an element, use '''ListContains'''.
ListContains(
List
Element
)
If element ''Element'' is inside ''List'', this will return true. If not, returns false.
== List Arithmetic ==
To use '''Len, Max, and Min''' you must wrap them inside '''FuncCall''' since they are primitive functions. They all take ''Var'' as an argument (the variable you are applying these functions to).
=== Len, Sum ===
'''Len''' returns the size of the condition. The most applicable version of this is how long a list, tuple or dictionary would be.
Len(Var=Variable(Name='MyList'))
'''Sum''' returns the sum of all the numeric numbers in a list. The list must contain only numbers, nothing else.
=== Max and Min ===
'''Max''' returns the maximum value in a list or tuple, and '''Min''' returns vice versa. However, these two functions are not limited to only numerical values.
''(Note that '''Max''' and '''Min''' both follow these rules)''
{| class="wikitable"
|+ Caption text
|-
! Comparison (Max) !! Output
|-
| [1, 'a'] || [FATAL ERROR AT {...}]: ...
|-
| ['A', 'a']|| 'a' (or 'A')
|-
| [1, 2]|| 2 (or 1)
|}
To summarize, larger numbers are larger than smaller ones (really?!), numbers cannot be compared to strings, and lowercase strings are "larger" than uppercase ones.
== Tuples ==
Tuples are lists, but immutable. Immutable means you cannot change it any way after it is set. Examining an element (calling it) does not count as changing it.
=== Creating a Tuple ===
When you want to create a tuple (like creating a list), use '''TupleAssign'''. TupleAssign also takes a series of elements, just like '''ListAssignment'''.
TupleAssign(
Integer(1),
Integer(2),
Integer(3)
)
=== Inspecting a Tuple ===
When inspecting/editing a tuple, you only have two actions you are allowed to perform since it is immutable.
TupleInspection(
TupleVar
Mode
IndexVar (Default None)
UnpackingTargets (Default None)
)
''TupleVar'' is the name of the variable that contains the tuple. ''Mode'' is the type of action you are performing. If the selected mode is 'index', ''IndexVar'' is the index of the element you are trying to call. If the selected mode is 'unpack', ''UnpackingTargets'' should be a list of elements you want to distribute the tuple to (for more advanced programmers, this is essentially '''enumerating''' the tuple).
== Conditionals (If Statements and more) ==
Conditionals help direct program flow. There are several conditional statements you can use.
=== If Statement Structure ===
This defines the main structure of the if-elif-else statements. When creating an if statement, a expression is always necessary.
IfCondition(
Expression
Body
Elif (Default None)
ElifBody (Default None)
ElseBody (Default None)
)
In more actual code form (Python):
if (Expression):
Body
elif Elif:
ElifBody
else:
ElseBody
Note that ''ElifBody'' must be defined to use ''Elif''.
''Expression'' is the starting comparison. If this evaluates to '''true''', ''Body'' runs. Body should be a list of functions, like this:
Body = [FuncCall(...), ListAssignment(...), Variable(...)]
'''''(This is true for ElifBody and ElseBody)'''''
''Elif'' is evaluated if ''Expression'' evaluates to '''false'''. If ''Elif'' is true, ''ElifBody'' runs. If all are false, the evaluator defaults to ''ElseBody''.
=== Conditions ===
To create a condition, you cannot simply write a string that contains the condition you want (for example, '1 + 1 == 2' is not allowed). You need the '''Condition''' function.
Condition(
Right
Operator
Left
)
''Right'' is the righthand side of the expression. In the case of ''1+1=2'', '''1+1''' would be the righthand side. ''Operator'' is the operation between the two sides of the condition. Currently, operator accepts:
{| class="wikitable"
|-
! Operator!! Definition
|-
| x == y|| x is equal to y
|-
| x != y|| x is not equal to y
|-
| x >= y|| x is greater than OR equal to y (numeric)
|-
| x <= y || x is less than OR equal to y (numeric)
|-
| x > y || x is greater than y (numeric)
|-
| x < y || x is less than y (numeric)
|}
=== LogicalOperation ===
When comparing numeric values or using '==' and '!=' is not enough, using '''LogicalOperation''' allows for boolean operations.
LogicalOperation(
RightOp
Op
LeftOp
)
''RightOp'' and ''LeftOp'' and the right and left hand sides of the condition, respectively. ''Op'' is the boolean operation you are performing.
{| class="wikitable"
|-
! Operation !! Requirement for '''True'''
|-
| x and y|| both true
|-
| x or y|| at least one true
|-
| x contains y|| element y is in x (containers, string)
|-
| not y || inverse
|}
A more detailed ex
==== and ====
If in form:
x and y
''x'' and ''y'' must both be '''true''' for this to return true. If not, returns false.
==== or ====
If in form:
x or y
At least one variable must be '''true''' for this to return true. If not, returns false.
==== contains ====
If in form:
x contains y
We assume that ''x'' would be some arbitrary type of container or string. If ''y'' is in ''x'' (as an element, substring, subelement, etc.) this would return true. If not, returns false.
==== not ====
The inverse of ''LeftOp''. ''RightOp'' is not needed here (Set it to '''ObjNONE()''').
=== Any + AllCondition ===
When you want to find out if a set of objects follow a condition, use '''AllCondition'''. However, if you only need to know if at least one object follows the condition, use '''AnyCondition'''. They both take ''Condition'' as an argument, which should be some type of the '''Condition''' function:
Condition(Right=ListAssignment(Boolean('True'), Boolean('False'), ...))
'''AnyCondition''' returns true if ANY of the values in the given object are true, and '''AllCondition''' return if ALL values are true.
== Switch / Match ==
Instead of using many '''IfStatement''' functions, using '''Switch''' can make code more readable and efficient.
Example (psuedocode):
''What day is it?''
switch (day):
case 1:
print "monday!"
case 2:
print "tuesday!"
{so on...}
case 7:
print "sunday!"
default:
print "hey, that's not in the days of the week!"
In ASTLang, '''Switch''' takes these arguments:
Switch(
SwitchVar
Scenarios
Default (Default None)
)
''SwitchVar'' is the variable you are comparing against the ''Scenarios''. The ''SwitchVar'' in our "days of the week" example would be '''day''', while the ''Scenarios'' would be '''1, 2, 3, 4, etc. to 7'''. ''Default'' would be if all ''Scenarios'' evaluated '''false'''. If this is not set, the interpreter will just skip the '''Switch''' statement.
=== Scenario ===
This is the base function for '''Switch'''. It creates the individual cases for the switch statement.
Scenario(
Var
Body
Fallthrough (Default False)
)
''Var'' is the variable you are comparing against the ''SwitchVar''. In our example, that would be our day numbers. ''Body'' is what you want to execute if the scenario is true. ''Fallthrough'' controls if the code evaluates even after finding a matching scenario.
== Simple statistics and Math Operations ==
This section will cover the functions '''Mean, Median, Mode, Operation, and Calculate'''.
=== Simple Statistics ===
To calculate the mean of a list or tuple (must be numeric), use '''Mean'''. For mode, use '''Mode''', and for the median use '''Median'''. All 3 of these functions take ''List'' as an argument. This is the list or tuple you want to take the mean, mode, or median of.
=== Simple Math operations ===
To calculate an expression using order of operations (simple operations like '*+-/') and other features, use '''Calculate'''. '''Calculate''' takes ''Expression'' as an argument. This argument takes raw string. To assign a primitive operation to a variable or as an input to an argument, use '''Operation'''.
Operation(
Left
Op
Right
)
''Left'', ''Right'', and ''Op'' are the left hand side, right hand side, and operator of the equation. You can input '*', '+', '-', or '/' (strings) as an operator. This argument takes raw string as an input, so you don't need '''String()'''
'''Abs''' returns the absolute value of its argument, ''Val''.
'''Power''' takes two arguments, ''Power'' and ''Base''. It returns ''Base'' raised to the ''Power''.
== Loops ==
Loops are good for repeatedly performing the same task efficiently.
=== Loop structure Function ===
To create the structure of the loop, use '''Loop'''. Note that the argument ''Iterable'' should not be confused with the function of the same name, '''Iteerable'''.
Loop(
LoopType
Body
Iterable (Default None)
Expression (Default None)
ControlVar (Default None)
)
''LoopType'' is the type of loop you want to create (it takes 'for' or 'while'). This takes a raw string. ''Body'' takes a list of functions you want to run each successful iteration ran by ''Iterable''. ''Iterable'' should be some arbitrary object that can be iterated through (this is only needed when the LoopType is 'for'). This is a somewhat complex requirement for beginners (no programming experience). If you do not know if the object you are using is iterable, use THE FUNCTION '''Iterable'''.
'''Iterable''' takes the argument ''Iter''. If the object given to the argument (as input) is indeed iterable (can be used in a loop), the function will return something like this:
<list_iterator object at 0x...>
''This is what you get if you inputted a list. Of course, if it was a string, it would be different.''
''Expression'' is used when the LoopType is 'while'. ''Expression'' should be a condition that evaluates to a boolean. When the ''Expression'' value is '''true''', the loop will execute until the condition is '''false'''.
''ControlVar'' is the variable of which the iterable is being stored.
for x in i:
x
In this case, '''i''' is the iterable and '''x''' is the control variable. Every element of '''i'' is being stored inside '''x''' once every iteration. This is only needed if the LoopType is 'for'.
=== Break and Continue ===
To forcefully exit a loop regardless of the current circumstances, use '''Break'''. You can optionally provide an ''ExitMessage'', which outputs when the loop is exited. To skip an iteration, use '''Continue'''.
=== Enumeration ===
The function '''EnumerateObjects''' returns both the current iteration count and also the element itself. Quote from AI:
"This object can then be used in loops to access both the index and the value of each item in the iterable simultaneously."
When actually using '''EnumerateObjects''', you need to put it in the ''Iterable'' argument as an input (since the '''EnumerateObjects''' function is an iterable).
EnumerateObjects(
Iterable (not to be confused with '''Loop's''' Iterable argument)
Start (Default 0)
)
''Iterable'' is the list you want to enumerate through. ''Start'' is what integer you want to start the iteration counter. This is usually default to 0 (since the first index for a list is also 0).
'''''WARNING! If using iterable that outputs more than one item, you must give ControlVar a list argument, like this: ['element', 'index'] in the case of EnumerateObjects'''''
=== The Range Function ===
When you want to create a numerical list without specifically defining it, you can use '''Range'''. This is usually used when a list containing a geometric sequence (like 1, 2, 3, 4, ...) is too long to be written by hand. Also, it is used as an input to the ''Iterable'' argument for '''Loop'''.
Range(
BoundMin
BoundMax
Step (Default 1)
)
''BoundMin'' is the starting number of the list. ''BoundMax'' is the ending number of the list, and ''Step'' is the common difference between any two consecutive elements (or the incrementor).
A common usage in loops:
Loop(
LoopType='for',
Iterable=Range(BoundMin=Integer(0), BoundMax=Integer(10)),
ControlVar='x',
Body=[FuncCall(Function=Print(Contents=Variable('x')))] <--- You can actually call any control variable using '''Variable'''!
) <--- This outputs 1, 2, 3 ... 10
== Advanced Math Operations ==
This includes trigonometry functions and other functions like '''Gcd''', '''Round''', or '''Factorial'''. All of the functions listed take ''Value'' as their only argument unless otherwise noted.
=== Round ===
Round argument ''Flt'' to ''DecPoints'' decimal points. Example:
Round(
Flt=Float(1.1),
DecPoints=Integer(0)
)
=== Floor, Ceiling ===
'''Floor''' rounds the value provided down regardless of rounding rules, while '''Ceil''' rounds it up.
Floor(Value=Float(1.1)) <--- This outputs 1
Ceil(Value=Float(1.1)) <--- This outputs 2
=== Square root, Logarithm, Factorial ===
For square roots, use '''Sqrt'''. For a logarithm, use '''Log'''. '''Log''' takes an additional argument called ''Base'', which is the base the logarithm will be in. '''Factorial''' calculates the factorial of ''Value'' (really?!).
=== Trig Functions ===
To perform a trigonometric function, use '''Exp, Sin, Cos, or Tan'''. They calculate their corresponding trig function, according to their name.
'''WARNING: The source code for these functions use Python's math package, "math". This is always calculated in RADIANS, not degrees.'''
=== Gcd, Lcm ===
'''Gcd''' and '''Lcm''' stands for ''greatest common divisor'' (or more commonly known as ''greatest common factor'') and ''least common multiple'', respectively. They evaluate this between arguments ''A'' and ''B''. Example:
Gcd(
A=Integer(20),
B=Integer(30)
) <--- This outputs 10
=== Mod, MathConstants ===
'''Mod''' will calculate the remainder when its ''Value'' is divided by ''Divisor''. Example:
Mod(
Value=Integer(5),
Divisor=Integer(2)
) <--- This will return 1
'''MathConstants''' will return some advanced irrational values in math, like ''e'' or ''pi''. It accepts:
pi
e
tau
inf
== String Operations 1 ==
There are many string operations you can use. In this section, it covers mostly on string checkers than modifiers. Basically, these functions do not really change the string itself.
=== Uppercase, Lowercase ===
To automatically convert the case to uppercase or lowercase, use '''StringUpper''' and '''StringLower''', respectively. Both take ''Str'' as an argument. Make sure this is a valid string and also wrapped inside '''String'''.
== String Operations 2 ==
===' |