KalkatiaLang

Kalkatia Programming Language Documentation.

Install as npm

npm install -g kalkatia-lang 📋

npm

npm installation

npm install -g kalkatia-lang

Write a .kalkatia Script

Create a file test.kalkatia:

mama x = 10;
chakallas(x);

Usage in Project

Use KalkatiaLang in a JavaScript project.

import KalkatiaLang from "kalkatia-lang";

const code = `
  mama x = 20;
  chakallas(x);
`;

const translatedCode = KalkatiaLang.translate(code);
console.log("Translated JavaScript Code:");
console.log(translatedCode);
eval(translatedCode);

Variable Declaration

In KPL, variables are declared using the keyword 'mama' followed by the variable name.

mama x = 5;
chakallas(x);

Array Declaration

Arrays are declared using 'aasteLadees'. This is how you declare an array with multiple values.

mama y = aasteLadees(1, 2, 3, 4, 5);
chakallas(y);

Print Statement

To print values to the console, use 'chakallas'.

chakallas("Hello, MamaLog");

Basic Loop (For Loop)

KPL provides a loop structure using 'ayiChakkar'. The loop consists of variable assignment, condition, and increment/decrement operation.

mama i = 0;
ayiChakkar(i = 0; i < 5; i++) {
chakallas("Tumra value: " + i);
}

If-Else Block

KPL has a straightforward if-else block, where 'mamaAgar' represents the if condition and 'naiTohMama' represents the else.

mama z = 4;
mamaAgar(z > 5) {
chakallas("z bada hai");
}
naiTohMama {
chakallas("z chota h");
}

Function Definition

In KPL, functions are defined using 'dhabbaji'. The function definition starts with 'dhabbaji', followed by the function name and parameters.

dhabbaji add(a, b) {
khuljao(a + b);
}
mama result = add(5, 10);
chakallas(result);

Logical Operators

KPL uses 'aar' for logical AND and 'ya' for logical OR.

mama x = 5;
mama y = 10;
mamaAgar(x > 3 aar y < 20) {
chakallas("Both conditions are true");
}
naiTohMama {
chakallas("One or both conditions are false");
}

Switch-Case (jaundice)

For switch-case functionality, we use 'jaundice', instead of break we use 'dharlis'.

mama day = 2;
jaundice(day) {
case 1:
chakallas("Soombaar");
dharlis;
case 2:
chakallas("Mangal");
dharlis;
default:
chakallas("itwaaar");
}

Return (khuljao)

For returning values, we use 'khuljao'.

dhabbaji add(a, b) {
khuljao(a + b);
}
mama result = add(5, 10);
chakallas(result);

A walkthrough example

BubbleSort Algo


    // Bubble Sort in KolkataLang
    dhabbaji bubbleSort(arr) {
      mama n = arr.length;
      mama i = 0; // Declare 'i' outside the loop
      mama j = 0; // Declare 'j' outside the loop
      ayiChakkar(i = 0; i < n - 1; i++) { // Initialize 'i' without redeclaring
        ayiChakkar(j = 0; j < n - i - 1; j++) { // Initialize 'j' without redeclaring
          mamaAgar(arr[j] > arr[j + 1]) {
            // Swap elements
            mama temp = arr[j];
            arr[j] = arr[j + 1];
            arr[j + 1] = temp;
          }
        }
      }
      khuljao(arr); // Return the sorted array
    }

    // Test the bubbleSort function
    mama arr = aasteLadees(64, 34, 25, 12, 22, 11, 90); // Create an array
    chakallas("Unsorted array:");
    chakallas(arr);

    mama sortedArr = bubbleSort(arr); // Sort the array
    chakallas("Sorted array:");
    chakallas(sortedArr);
  
LAUNCH BYTEYARD