This is a language that was made for fun. It is completely written in python.
Latest Version: 1.8.3
Stable Release: pip install swas
Working Version: pip install git+https://github.com/CodeWithSwastik/swas.git
This is all that you need to do to start writing in swas lang.
python -m swas [filename]
The filename is optional, if no filename is provided it will run the shell.
If you don't want to use swas on your local machine you can try it out on the Online IDE: https://codewithswastik.github.io/swas/
output "Hello, World!"
Variables are containers for storing data.
Swas has no command for declaring a variable.
A variable is created the moment you first assign a value to it.
x = 5
y = "Mark"
To use the variables, simply reference them
output x
output y
Note: Variables names are case sensitive i.e. a = 5
is not the same as A = 5
A Comment starts with a //, and anything after them will be ignored:
//This is a comment
output "Hello, World!"
Operators are used to perform operations on variables and values.
Operator | Name | Example |
---|---|---|
+ | Addition | x + y |
- | Subtraction | x - y |
* | Multiplication | x * y |
/ | Division | x / y |
% | Modulus | x % y |
inc | Increment | inc x |
dec | Decrement | dec x |
^ | Exponent | x ^ y |
Operator | Name | Example |
---|---|---|
== | Equals | x == y |
!= | Not Equals | x != y |
> | Greater than | x > y |
>= | Greater than or equal to | x >= y |
< | Lesser than | x < y |
<= | Lesser than or equal to | x <= y |
The Assignment Operator ( = ) is used to assign a variable to a value.
An "if else statement" is written by using the if and else keywords.
Syntax
if condition {
statement
}
else {
statement
}
Note: The indentation isn't needed, it has been used here for readability
Example
name = input "Enter your name: "
if name == "John" {
output "hi," + name
}
else {
output "bye," + name
}
With the while loop you can execute a set of statements as long as a condition is true.
Syntax
while condition
do {
statement
}
Note: The indentation isn't needed, it has been used here for readability
Example
start = 1
end = 10
while start != end
do {
output start
inc start
}
List/Array is a data structure consisting of a collection of values or variables. A list can be created using square brackets ([])
Example
list = [1,2,3,4,5]