Skip to main content

A Progamming Language.

Project description

The Swas programming language

This is a language that was made for fun. It is completely written in python.

Latest Version: 1.8.3

Installation

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.

Running

python -m swas [filename]

The filename is optional, if no filename is provided it will run the shell.

Online IDE

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/

Getting Started

Hello World

output "Hello, World!"

Variables

Variables are containers for storing data.

Creating Variables

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"

Using Variables

To use the variables, simply reference them

output x
output y

Case Sensitive

Note: Variables names are case sensitive i.e. a = 5 is not the same as A = 5

Comments

A Comment starts with a //, and anything after them will be ignored:

//This is a comment
output "Hello, World!"

Operators

Operators are used to perform operations on variables and values.

Arithmetic Operators

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

Logical Operators

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 ( = )

The Assignment Operator ( = ) is used to assign a variable to a value.

If Else

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 
}

While Do

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 
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

swas-1.8.3.tar.gz (7.6 kB view details)

Uploaded Source

File details

Details for the file swas-1.8.3.tar.gz.

File metadata

  • Download URL: swas-1.8.3.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.8.5

File hashes

Hashes for swas-1.8.3.tar.gz
Algorithm Hash digest
SHA256 896f1b659935538ac0da70e0d8e0559b633cff617106d1cf6b1892fe9540dc06
MD5 4baebcdfd6b4bf685432dad4a7ed6b78
BLAKE2b-256 d20c49950add6739d149a373f5463c5cf38060acec247b83e4c532f697ff1623

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page