The swas programming language

Overview

The Swas programming language

This is a language that was made for fun.

Installation

Step 0: Make sure you have python installed
Step 1. Clone this repo or download it as a zip
Step 2. Run pip install -r requirements.txt

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.

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

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

Join Operator ( & )

The Join Operator ( & ) lets you join 2 statements into 1.

Example

output "Hi" & output "Bye"

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 
}
You might also like...
LegalNLP - Natural Language Processing Methods for the Brazilian Legal Language

LegalNLP - Natural Language Processing Methods for the Brazilian Legal Language ⚖️ The library of Natural Language Processing for Brazilian legal lang

A design of MIDI language for music generation task, specifically for Natural Language Processing (NLP) models.

MIDI Language Introduction Reference Paper: Pop Music Transformer: Beat-based Modeling and Generation of Expressive Pop Piano Compositions: code This

This is the Alpha of Nutte language, she is not complete yet / Essa é a Alpha da Nutte language, não está completa ainda

nutte-language This is the Alpha of Nutte language, it is not complete yet / Essa é a Alpha da Nutte language, não está completa ainda My language was

Simple Python script to scrape youtube channles of "Parity Technologies and Web3 Foundation" and translate them to well-known braille language or any language

Simple Python script to scrape youtube channles of "Parity Technologies and Web3 Foundation" and translate them to well-known braille language or any

Share constant definitions between programming languages and make your constants constant again

Introduction Reconstant lets you share constant and enum definitions between programming languages. Constants are defined in a yaml file and converted

Linear programming solver for paper-reviewer matching and mind-matching
Linear programming solver for paper-reviewer matching and mind-matching

Paper-Reviewer Matcher A python package for paper-reviewer matching algorithm based on topic modeling and linear programming. The algorithm is impleme

Tools and data for measuring the popularity & growth of various programming languages.

growth-data Tools and data for measuring the popularity & growth of various programming languages. Install the dependencies $ pip install -r requireme

Contains descriptions and code of the mini-projects developed in various programming languages

TexttoSpeechAndLanguageTranslator-project introduction A pleasant application where the client will be given buttons like play,reset and exit. The cli

Web mining module for Python, with tools for scraping, natural language processing, machine learning, network analysis and visualization.
Web mining module for Python, with tools for scraping, natural language processing, machine learning, network analysis and visualization.

Pattern Pattern is a web mining module for Python. It has tools for: Data Mining: web services (Google, Twitter, Wikipedia), web crawler, HTML DOM par

Comments
  • Swas Online IDE Outdated

    Swas Online IDE Outdated

    I tried executing a basic application in the Online IDE, which gave an error:

    hello = "world"
    output hello
    

    the error:

    Illegal character '='
    Swas says: hello hasn't been defined!
    None
    sly: Syntax error at line 1, token=STRING
    

    Meanwhile I tried the v1.5 version of my own code:

    hello => "world" &
    output hello
    

    which you've probably guessed, returned:

    world
    

    I also tried v1.8's new error handling in the Online IDE

    "foo" % "bar"
    

    which returned a different error than I expected .... (it's supposed to catch the TypeError)

    Traceback (most recent call last):
    File "/var/lang/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
    File "/var/lang/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
    File "/var/task/swas/__main__.py", line 13, in <module>
    main()
    File "/var/task/swas/__main__.py", line 10, in main
    execute(fp)
    File "/var/task/swas/executor.py", line 133, in execute
    evaluate(tree)
    File "/var/task/swas/executor.py", line 18, in evaluate
    value = evaluate(tree[1])
    File "/var/task/swas/executor.py", line 35, in evaluate
    return evaluate(tree[1]) % evaluate(tree[2])
    TypeError: not all arguments converted during string formatting
    
    opened by Makiyu-py 5
  • terminal-problem

    terminal-problem

    when i was using this programming language for fun a problem came out its very hard to write if else condition in terminal hope you can do something for it

    opened by Tech-with-anmol 0
  • Use click for CLI and implement the -c argument

    Use click for CLI and implement the -c argument

    click is a cool package that makes CLI commands easy. This PR uses click for commands and adds the -c argument.

    Usage:

    $ python -m swas
    Swas 1.8.3
    swas > output "Hello, World!"
    Hello, World!
    
    $ python -m swas test.swas
    Hello, World!
    
    $ python -m swas -c "output 'Hello, World!'"
    Hello, World!
    
    opened by ToxicKidz 0
  • To Do

    To Do

    Here's a list of things I'll be adding to Swas lang soon-

    • [ ] For loops
    • [x] A Pass Keyword named "nothing"
    • [ ] Better error handling
    • [ ] Bool data type
    • [ ] Other data types
    enhancement 
    opened by CodeWithSwastik 0
Owner
Swas.py
Swas.py
Implementation of Natural Language Code Search in the project CodeBERT: A Pre-Trained Model for Programming and Natural Languages.

CodeBERT-Implementation In this repo we have replicated the paper CodeBERT: A Pre-Trained Model for Programming and Natural Languages. We are interest

Tanuj Sur 4 Jul 1, 2022
Knowledge Oriented Programming Language

KoPL: 面向知识的推理问答编程语言 安装 | 快速开始 | 文档 KoPL全称 Knowledge oriented Programing Language, 是一个为复杂推理问答而设计的编程语言。我们可以将自然语言问题表示为由基本函数组合而成的KoPL程序,程序运行的结果就是问题的答案。目前,

THU-KEG 62 Dec 12, 2022
A programming language with logic of Python, and syntax of all languages.

Pytov The idea was to take all well known syntaxes, and combine them into one programming language with many posabilities. Installation Install using

Yuval Rosen 14 Dec 7, 2022
PUA Programming Language written in Python.

pua-lang PUA Programming Language written in Python. Installation git clone https://github.com/zhaoyang97/pua-lang.git cd pua-lang pip install . Try

zy 4 Feb 19, 2022
Stack based programming language that compiles to x86_64 assembly or can alternatively be interpreted in Python

lang lang is a simple stack based programming language written in Python. It can

Christoffer Aakre 1 May 30, 2022
Opal-lang - A WIP programming language based on Python

thanks to aphitorite for the beautiful logo! opal opal is a WIP transcompiled pr

null 3 Nov 4, 2022
A python framework to transform natural language questions to queries in a database query language.

__ _ _ _ ___ _ __ _ _ / _` | | | |/ _ \ '_ \| | | | | (_| | |_| | __/ |_) | |_| | \__, |\__,_|\___| .__/ \__, | |_| |_| |___/

Machinalis 1.2k Dec 18, 2022
A Domain Specific Language (DSL) for building language patterns. These can be later compiled into spaCy patterns, pure regex, or any other format

RITA DSL This is a language, loosely based on language Apache UIMA RUTA, focused on writing manual language rules, which compiles into either spaCy co

Šarūnas Navickas 60 Sep 26, 2022
Indobenchmark are collections of Natural Language Understanding (IndoNLU) and Natural Language Generation (IndoNLG)

Indobenchmark Toolkit Indobenchmark are collections of Natural Language Understanding (IndoNLU) and Natural Language Generation (IndoNLG) resources fo

Samuel Cahyawijaya 11 Aug 26, 2022