0.1.6 โ€ข Published 4 months ago

mama-lang v0.1.6

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
4 months ago

Mama Lang ๐Ÿš€

Mama Lang Playground Mama Npm Package

I grew up in Dhaka, Bangladesh ๐Ÿ‡ง๐Ÿ‡ฉ, where "Mama" ๐Ÿ—ฃ๏ธ, which literally translates to your mom's brother, is often used by friends as a form of endearment. The closest comparison I can find is how some people would use the word "homie" ๐Ÿค in the US. I spent countless days and nights โ˜•๐ŸŒ™, sipping tea in the stands of Abahani Field in Dhanmondi 4 or at Paribagh with friends when I was in high school ๐Ÿซ๐Ÿ‘ฅ. During these gatherings, if we had kept a tally, I believe collectively we must have uttered the word mama well over a hundred times.

So when I saw this: bhai-lang https://github.com/DulLabs/bhai-lang ๐Ÿ’ก, I was inspired to write my own implementation! To start with right now we just convert .mama files to .js and then run them with node and so anything that you could do in javascript land you can do it in mama lang.

Future State ๐Ÿš€

I am however playing around with the idea of making its own lexer, interpreter and parser so it can just be its own thing! If you want to work on it the code is inside mama-lang_v2 directory!

Feel free to open up PR(s) and contribute! ๐Ÿ˜„

Playground ๐Ÿš€๐ŸŽฎ

Check out the Mama Lang Playground to write and run your .mama code in a fun and interactive environment! Whether you're taking your first steps into programming or just want to have a laugh with friends, the playground makes it easy to experiment with Mama Lang right in your browser. No installation required, just code and go! ๐Ÿ˜„๐Ÿ‘จโ€๐Ÿ’ป

Installation ๐Ÿ’ป

npm install -g mama-lang

Usage ๐Ÿ“

Create a new file (boltesi.mama)

bol toh mama ("kire mama!");

Run ๐Ÿš€

mama boltesi.mama

Output ๐Ÿ–จ๏ธ

kire mama!

Documentation ๐Ÿ“š

Variables ๐Ÿ“Š

Variables can be declared using mama aida hoilo;

mama aida hoilo day = "Sunday";
mama aida hoilo temperature = 25;
mama aida hoilo isSunny = haw mama;
mama aida hoilo counter = 0;

Types ๐Ÿ” 

Numbers and strings are like other languages. Null values can be denoted using kisuina mama. haw mama and nah mama are the boolean values.

 mama aida hoilo a = 10;
 mama aida hoilo b = 10 + (15*20);
 mama aida hoilo c = "duita";
 mama aida hoilo d = 'acha thikasey';
 mama aida hoilo e = kisuina mama;
 mama aida hoilo f = haw mama;
 mama aida hoilo g = nah mama;

Built-ins ๐Ÿ› ๏ธ

Use bol toh mama to print anything to the console.

bol toh mama ("Hello World");
mama aida hoilo manushJon = 5;
mama aida hoilo koiGhontaKoraLagbe = 8;
mama aida hoilo shobMilayaKotoKhonLagbe = manushJon * koiGhontaKoraLagbe;
bol toh mama("Shob miliya koto ghonta kamla khatesi amra hoilo = " + shobMilayaKotoKhonLagbe);

Conditionals ๐Ÿ”„

mama-lang supports the if-else-if ladder construct, jodi mama block will execute if the condition is haw mama, otherwise one of the subsequently added nah hoile mama blocks will execute if their respective condition is haw mama, and the akdom e nah hoile block will eventually execute if all of the above conditions are nah mama.

jodi mama (temperature > 30) {
  bol toh mama ("Gorom lagtese mama, AC chalao mama!");
} nah hoile mama (temperature < 20) {
  bol toh mama ("Thanda lagtese mama, sweater porum mama!");
} akdom e nah hoile {
  bol toh mama ("Aajke weather besh comfortable, mama!");
}

Loops ๐Ÿ”

Statements inside jotokhon porjonto mama blocks are executed as long as a specified condition evaluates to haw mama. If the condition becomes nah mama, the statement within the loop stops executing and control passes to the statement following the loop. Use thamis mama to break the loop and tarpor er tah dekh mama to continue within the loop.

โ€ƒโ€ƒmama aida hoilo a = 0;
โ€ƒโ€ƒjotokhon porjonto mama (a < 10) {
โ€ƒโ€ƒโ€ƒa += 1;
โ€ƒโ€ƒโ€ƒjodi mama (a == 5) {
โ€ƒโ€ƒโ€ƒโ€ƒbol toh mama("loop er bhitor theke boltesi mama ", a);
โ€ƒโ€ƒโ€ƒโ€ƒtarpor er tah dekh mama;
โ€ƒโ€ƒโ€ƒ}
โ€ƒโ€ƒโ€ƒjodi mama (a == 6) {
โ€ƒโ€ƒโ€ƒโ€ƒthamis mama;
โ€ƒโ€ƒโ€ƒ}
โ€ƒโ€ƒโ€ƒbol toh mama(a);
โ€ƒโ€ƒ}
โ€ƒโ€ƒbol toh mama("done");

Functions โš™๏ธ

You can define a function using the mama kam da hoilo syntax, followed by the function name and parameters in parentheses. The function body is enclosed in curly braces.

mama kam da hoilo jog(a,b){
    de toh mama (a+b);
}

In this example, a function named jog is defined with two parameters, a and b. The function body adds these parameters and returns the result using de toh mama.

bol toh mama(jog(5,7))

Function Output ๐Ÿ”„

Functions in Mama Lang can return values using the de toh mama statement. The returned value can be assigned to a variable or used directly in expressions.

mama kam da hoilo multiply(x, y) {
    de toh mama (x * y);
}

mama aida hoilo result = multiply(3, 4);
bol toh mama("The result is: " + result);

In this example, the multiply function returns the product of its parameters, and the result is assigned to the result variable and printed.

0.1.6

4 months ago

0.1.5

4 months ago

0.1.4

5 months ago

0.1.3

5 months ago

0.1.2

5 months ago

0.1.1

5 months ago

0.1.0

5 months ago

0.0.1

5 months ago