Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Malluscript V1.1.0 #34

Merged
merged 18 commits into from
Jan 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
[package]
name = "malluscript"
version = "1.0.0"
version = "1.1.0"
authors = ["SyS <[email protected]>"]
edition = "2018"
build = "build.rs"
description = "Scripting language based on manglish and malayalam memes"
description = "An esoteric scripting language that lets to write computer programs in Malayalam"

[dependencies]
serde = "1.0.117"
lalrpop-util = "0.20.0"
clap = "2.33"
rustyline = "6.1"
Expand Down
31 changes: 25 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
# Mallu Script
# Malluscript
<p align="center">
<img alt="Malluscript" src="images/poster-transparent.png" height=500 width=500><br/>
<a href="https://github.com/actions/toolkit"><img alt="GitHub Actions status" src="https://github.com/sreyas-sreelal/malluscript/workflows/build/badge.svg"></a>
<a href="https://github.com/Sreyas-Sreelal/malluscript/pulls"><img alt="GitHub pull requests" src="https://img.shields.io/github/issues-pr/sreyas-sreelal/malluscript"></a>
<a href="https://github.com/Sreyas-Sreelal/malluscript/issues"><img alt="GitHub issues" src="https://img.shields.io/github/issues/sreyas-sreelal/malluscript"></a>
<a href="https://github.com/Sreyas-Sreelal/malluscript/blob/master/LICENSE"><img alt="GitHub issues" src="https://img.shields.io/github/license/sreyas-sreelal/malluscript"></a>
<p align="center">
<a href="https://discord.gg/5CMMf4ckuk"><img alt="Malluscript" src="https://dcbadge.vercel.app/api/server/5CMMf4ckuk"></a>
<a href="https://patreon.com/sreyas_sreelal"><img src="https://img.shields.io/endpoint.svg?url=https%3A%2F%2Fshieldsio-patreon.vercel.app%2Fapi%3Fusername%3Dsreyas_sreelal%26type%3Dpatrons&style=for-the-badge" /> </a>
<p align="center">
<a href='https://ko-fi.com/sreyas' target='_blank'><img height='40' src='https://az743702.vo.msecnd.net/cdn/kofi3.png?v=0' border='0' alt='Buy Me a Coffee at ko-fi.com' />
</p></p>
<p align="center">
<a href="https://discord.gg/9GDUE4hRcW"><img alt="Malluscript" src="https://dcbadge.vercel.app/api/server/9GDUE4hRcW"></a>
</p></p>


Malluscript is an esoteric scripting language based on manglish and malayalam memes. The language uses trending Malayalam memetic words as keywords. The language is not strictly type-safe and uses only two datatypes strings and integers. Currently, malluscript is on the development phase and undergoing vigorous changes. Always check the release section for pre-built binaries for the interpreter.
Malluscript is an esoteric scripting language that allows one to write computer programs in Malayalam. The concept of Malluscript stems from the idea of promoting inclusivity and linguistic diversity within the world of coding. By enabling programmers to express their ideas and algorithms in Malayalam, Malluscript serves as a bridge between traditional programming languages and the rich linguistic heritage of the Malayalam-speaking community. Currently, Malluscript is on the development phase and undergoing vigorous changes. Always check the release section for pre-built binaries for the interpreter.

**Note:** For support please join our [Discord](https://discord.gg/5CMMf4ckuk).

Expand All @@ -26,7 +31,7 @@ The interpreter can be compiled as follows
cd malluscript
cargo build --release
```
Note: You require rust compiler installed on your machine in order to compile the interpreter
Note: You require Rust compiler installed on your machine in order to compile the interpreter

## Executing malluscript programs
Malluscript can be used in two ways
Expand Down Expand Up @@ -93,7 +98,7 @@ Basic arithmetic operations can be done using `+`,`-`,`*`,`/`,`%` (modulo). Ever
* `വാചകംവാങ്ങിക്കുക`

### Datatypes and Storage
Malluscript is not strictly type-safe.The language, currently, supports only integer,float and string literals as datatypes.
Malluscript is not strictly type-safe.The language supports integer,float and string literals as primary datatypes and it also support compound datatype called List.

To assign it some value and declare a variable

Expand All @@ -102,6 +107,19 @@ variable_name = 1;
second_var = "ente string";
```

Lists in Malluscript are similar to compound types in other mainstream programming languages. A list can have different type of primary data in it. An example usage of List would be:

```
x = [1,4,5,6,"malluscript"];
x = x + "more data";
i = 0;
i um 6 um onnallenkil avarthikuga {
ezhuthuga x[i] + " ";
i = i+1;
}
```
Using `+` operator along side a list data, will append the other operand into that list. List data can be accessed using subscript operators `[]`. Also unlike other datatypes when passed as an argument to a function, it will be *passed as reference* instead of *passed as value*.

## Conditional Statements And Expressions
The conditional expression has the following syntax

Expand Down Expand Up @@ -223,6 +241,7 @@ Same in pure Malayalam would be
More examples can be found in [examples](examples)

## Notes
The language as mentioned above is under the development phase and its structure can change overnight, suddenly. This language is not meant to disrespect anyone and wrote just for fun.
The language as mentioned above is under the development phase and its structure can change overnight, suddenly.

Any kind of contribution is always welcome. If you have any ideas or improvements to provide for this project open a pull request or if you have any difficulties using this language open an issue :)

7 changes: 7 additions & 0 deletions examples/array.ms
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
x = [1,4,5,6,"malluscript"];
x = x + "more data";
i = 0;
i um 6 um onnallenkil avarthikuga {
ezhuthuga x[i] + " ";
i = i+1;
}
34 changes: 34 additions & 0 deletions examples/selectionsort.ms
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
അടുക്കുക(അറ,വലിപ്പം) {
ക = 0;
ത = 0;
ക ഉം (വലിപ്പം - 1) ഉം തുല്യമല്ലെങ്കിൽ ആവർത്തിക്കുക {
ത = ക + 1;
ത ഉം വലിപ്പം ഉം തുല്യമല്ലെങ്കിൽ ആവർത്തിക്കുക {
അറ[ക] നെകാൾ അറ[ത] ചെറുതാണെങ്കിൽ {
താല്‍കാലികം = അറ[ക];
അറ[ക] = അറ[ത];
അറ[ത] = താല്‍കാലികം;
}
ത = ത + 1;
}
ക = ക + 1;
}
}

എഴുതുക "വലിപ്പം പറയുക: ";
വലിപ്പം = അക്കംവാങ്ങിക്കുക;

അണി = [];

ക = 0;

എഴുതുക "ഘടകം നിക്ഷേപിക്കുക:\n";
ക ഉം വലിപ്പം ഉം തുല്യമല്ലെങ്കിൽ ആവർത്തിക്കുക {
അണി = അണി + അക്കംവാങ്ങിക്കുക;
ക = ക + 1;
}

എഴുതുക അണി;
എഴുതുക "\nഅടുക്കുക അറ:\n";
അടുക്കുക<അണി,വലിപ്പം>;
എഴുതുക അണി;
Binary file modified images/poster-transparent.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/executor/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,7 @@
InputNumber((usize, usize)),

FunctionCall((usize, usize), Box<Expression>, Vec<Expression>),

ListExpression((usize, usize), Vec<Expression>),

Check warning on line 45 in src/executor/ast.rs

View workflow job for this annotation

GitHub Actions / clippy

variant name ends with the enum's name

warning: variant name ends with the enum's name --> src/executor/ast.rs:45:5 | 45 | ListExpression((usize, usize), Vec<Expression>), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#enum_variant_names = note: `#[warn(clippy::enum_variant_names)]` on by default
ListSubScript((usize, usize), Box<Expression>, Box<Expression>),
}
23 changes: 23 additions & 0 deletions src/executor/datatype.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ pub enum DataTypes {
Integer(i64),
Bool(bool),
Float(f64),
List(Vec<DataTypes>),
Ref((i64, usize)),
Unknown,
}

Expand All @@ -55,6 +57,23 @@ impl fmt::Display for DataTypes {
DataTypes::String(s) => write!(f, "{}", literal_eval(s)),
DataTypes::Integer(i) => write!(f, "{}", i),
DataTypes::Float(n) => write!(f, "{}", n),
DataTypes::List(list) => {
let mut string = String::from("[");
let mut iter = list.iter().peekable();
while let Some(x) = iter.next() {
if let DataTypes::String(_) = x {
string += &("\"".to_owned() + &x.to_string() + "\"");
} else {
string += &x.to_string();
}

if iter.peek().is_some() {
string += ",";
}
}
string += "]";
write!(f, "{}", string)
}
_ => write!(f, "<Garbage:UnintialisedMemorySpace>"),
}
}
Expand All @@ -75,6 +94,10 @@ impl ops::Add for DataTypes {
(DataTypes::Float(l), DataTypes::String(r)) => DataTypes::String(l.to_string() + &r),
(DataTypes::String(l), DataTypes::Float(r)) => DataTypes::String(l + &r.to_string()),
(DataTypes::String(l), DataTypes::String(r)) => DataTypes::String(l + &r),
(DataTypes::List(mut l), r) => {
l.push(r);
DataTypes::List(l)
}
_ => raise_error(RunTimeErrors::IncompatibleOperation),
}
}
Expand Down
7 changes: 5 additions & 2 deletions src/executor/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use std::process;
pub enum RunTimeErrors {
UndefinedSymbol(String),
SymbolAlreadyDefined(String),
UnInitialzedData(String),
InvalidAssignment,
DivisionByZero,
IncompatibleOperation,
Expand All @@ -15,6 +14,7 @@ pub enum RunTimeErrors {
InvalidFunctionDeclaration,
ArgumentCountMismatch,
IntegerOverFlow,
IndexOutOfBounds(i64, i64),
}

impl fmt::Display for RunTimeErrors {
Expand All @@ -26,7 +26,6 @@ impl fmt::Display for RunTimeErrors {
RunTimeErrors::SymbolAlreadyDefined(symbol) => {
write!(f, "[Error]: Symbol {} already defined", symbol)
}
RunTimeErrors::UnInitialzedData(data) => write!(f, "Uninitialised variable {}", data),
RunTimeErrors::DivisionByZero => write!(f, "[Error]: Division by Zero"),
RunTimeErrors::IncompatibleOperation => {
write!(f, "[Error]: Incompatible operation between datatypes")
Expand All @@ -49,6 +48,10 @@ impl fmt::Display for RunTimeErrors {
f,
"[Error]: Integer OverFlow, attempt to arithmetic operation that leads to overflow"
),
RunTimeErrors::IndexOutOfBounds(index,limit) => write!(
f,
"[Error]: Index Out Of Bounds, attempted to read/write at index {index} on {limit} sized data"
),
}
}
}
Expand Down
Loading
Loading