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.
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! ๐
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! ๐๐จโ๐ป
npm install -g mama-lang
Create a new file (boltesi.mama)
bol toh mama ("kire mama!");
mama boltesi.mama
kire mama!
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;
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;
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);
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!");
}
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");
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))
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.