Skip to content
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
42 changes: 42 additions & 0 deletions Documentation/app/docs/functions/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,48 @@ export default function Functions() {
or "task"). Functions are first-class values and support closures.
</p>

<h2>New Utility Methods</h2>

<p>
BanglaCode now includes additional JavaScript-style helpers for arrays, strings, number parsing,
and URI encoding.
</p>

<CodeBlock
code={`// Array search helpers
dhoro first = khojo_prothom([1, 3, 8, 10], kaj(x) { ferao x > 5; }); // 8
dhoro idx = khojo_index([1, 3, 8, 10], kaj(x) { ferao x > 5; }); // 2
dhoro last = khojo_shesh([1, 3, 8, 10], kaj(x) { ferao x % 2 == 0; }); // 10

// String helpers
ache_text("banglacode", "code"); // sotti
shuru_diye("banglacode", "bang"); // sotti
shesh_diye("banglacode", "code"); // sotti
baro("ha", 3); // "hahaha"
text_at("bangla", -1); // "a"

// Number + URI helpers
purno_sonkhya("42"); // 42
doshomik_sonkhya("3.14abc"); // 3.14
sonkhya_na("abc"); // sotti
uri_ongsho_encode("hello world"); // "hello%20world"

// Date + Regex helpers
dhoro ts = tarikh_ekhon();
tarikh_format(ts, "2006-01-02");
regex_test("[a-z]+", "bangla"); // sotti
regex_search("la", "bangla"); // 4

// Object helpers
nijer_ache({a: 1}, "a"); // sotti
jora_theke([["x", 10], ["y", 20]]); // {x: 10, y: 20}
ekoi_ki(1, 1); // sotti

// Timers
dhoro id = setInterval(kaj() { dekho("tick"); }, 1000);
clearInterval(id);`}
/>

<h2>Defining Functions</h2>

<p>
Expand Down
18 changes: 18 additions & 0 deletions Documentation/app/docs/syntax/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@ export default function Syntax() {
{ k: "dhoro", m: "hold/var", e: "var/let" },
{ k: "jodi", m: "if", e: "if" },
{ k: "nahole", m: "else", e: "else" },
{ k: "jotokkhon", m: "while", e: "while" },
{ k: "do", m: "do once then loop", e: "do...while" },
{ k: "ghuriye", m: "loop", e: "for" },
{ k: "of", m: "iterate values", e: "of" },
{ k: "in", m: "property/index check", e: "in" },
{ k: "instanceof", m: "instance check", e: "instanceof" },
{ k: "delete", m: "delete key/index", e: "delete" },
{ k: "kaj", m: "work", e: "function" },
{ k: "ferao", m: "return", e: "return" },
{ k: "dekho", m: "see/print", e: "print" },
Expand All @@ -47,6 +53,18 @@ export default function Syntax() {
dhoro isStudent = sotti; <span className="text-muted-foreground">// true</span>
</div>

<h2>New Core Syntax</h2>
<div className="bg-secondary/50 p-4 rounded-lg font-mono text-sm border border-border">
do {"{"}<br />
&nbsp;&nbsp;dekho("run once");<br />
{"}"} jotokkhon (mittha);<br /><br />
dhoro obj = {"{"}a: 1{"}"};<br />
dekho("a" in obj);<br />
delete obj.a;<br /><br />
dhoro double = x =&gt; x * 2;<br />
dhoro [a, b] = [10, 20];
</div>

<div className="pt-8">
<Link
href="/docs/control-flow"
Expand Down
2 changes: 1 addition & 1 deletion Documentation/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "documentation",
"version": "7.1.0",
"version": "8.0.0",
"private": true,
"scripts": {
"dev": "next dev --turbopack",
Expand Down
2 changes: 1 addition & 1 deletion Extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "banglacode",
"displayName": "BanglaCode",
"description": "Language support for BanglaCode (.bang, .bangla, .bong) - Bengali Programming Language created by Ankan from West Bengal, India",
"version": "7.1.0",
"version": "8.0.0",
"publisher": "AnkanSaha",
"author": {
"name": "AnkanSaha"
Expand Down
168 changes: 168 additions & 0 deletions Extension/snippets/banglacode.json
Original file line number Diff line number Diff line change
Expand Up @@ -1351,5 +1351,173 @@
"$0"
],
"description": "Complete .env usage example"
},
"Array Find First": {
"prefix": "khojo-prothom",
"body": [
"dhoro ${1:item} = khojo_prothom(${2:arr}, kaj(${3:x}) {",
"\tferao ${3:x} > ${4:0};",
"});",
"$0"
],
"description": "Find first matching element in array"
},
"Array FlatMap": {
"prefix": "somtol-manchitro",
"body": [
"dhoro ${1:result} = somtol_manchitro(${2:arr}, kaj(${3:x}) {",
"\tferao [${3:x}, ${3:x} * ${4:2}];",
"});",
"$0"
],
"description": "Map then flatten one level"
},
"String Includes": {
"prefix": "ache-text",
"body": [
"jodi (ache_text(${1:text}, ${2:query})) {",
"\t${3:// found}",
"}",
"$0"
],
"description": "Check if string contains substring"
},
"Parse Int": {
"prefix": "purno-sonkhya",
"body": [
"dhoro ${1:value} = purno_sonkhya(${2:text});",
"$0"
],
"description": "Parse integer from string"
},
"URI Encode Component": {
"prefix": "uri-encode",
"body": [
"dhoro ${1:encoded} = uri_ongsho_encode(${2:text});",
"$0"
],
"description": "Encode URI component"
},
"Do-While Loop": {
"prefix": "do-jotokkhon",
"body": [
"do {",
"\t${1:// code}",
"} jotokkhon (${2:condition});",
"$0"
],
"description": "Do-while loop"
},
"Delete Property": {
"prefix": "delete",
"body": [
"delete ${1:obj}.${2:prop};",
"$0"
],
"description": "Delete object property"
},
"Array Flat": {
"prefix": "somtol",
"body": [
"dhoro ${1:flat} = somtol(${2:arr}, ${3:1});",
"$0"
],
"description": "Flatten nested array"
},
"String Compare": {
"prefix": "tulona-text",
"body": [
"dhoro ${1:cmp} = tulona_text(${2:left}, ${3:right});",
"$0"
],
"description": "Compare two strings"
},
"Arrow Function": {
"prefix": "arrow",
"body": [
"dhoro ${1:fn} = ${2:x} => ${3:x};",
"$0"
],
"description": "Arrow function with implicit return"
},
"For Of Loop": {
"prefix": "for-of",
"body": [
"ghuriye (${1:item} of ${2:array}) {",
"\t${3:// code}",
"}",
"$0"
],
"description": "for...of loop"
},
"For In Loop": {
"prefix": "for-in",
"body": [
"ghuriye (${1:key} in ${2:obj}) {",
"\t${3:// code}",
"}",
"$0"
],
"description": "for...in loop"
},
"Date Now": {
"prefix": "date-now",
"body": [
"dhoro ${1:ts} = tarikh_ekhon();",
"$0"
],
"description": "Current timestamp in milliseconds"
},
"Regex Test": {
"prefix": "regex-test",
"body": [
"dhoro ${1:ok} = regex_test(\"${2:pattern}\", ${3:text});",
"$0"
],
"description": "Regex test against text"
},
"Object HasOwn": {
"prefix": "nijer-ache",
"body": [
"dhoro ${1:has} = nijer_ache(${2:obj}, ${3:\"key\"});",
"$0"
],
"description": "Check own property existence on map"
},
"Array Destructuring": {
"prefix": "dhoro-array",
"body": [
"dhoro [${1:a}, ${2:b}] = ${3:arr};",
"$0"
],
"description": "Array destructuring declaration"
},
"Object Destructuring": {
"prefix": "dhoro-obj",
"body": [
"dhoro {${1:x}, ${2:y}} = ${3:obj};",
"$0"
],
"description": "Object destructuring declaration"
},
"Set Timeout": {
"prefix": "set-timeout",
"body": [
"setTimeout(kaj() {",
"\t${1:// callback}",
"}, ${2:1000});",
"$0"
],
"description": "Schedule callback once"
},
"Set Interval": {
"prefix": "set-interval",
"body": [
"dhoro ${1:id} = setInterval(kaj() {",
"\t${2:// repeated callback}",
"}, ${3:1000});",
"$0"
],
"description": "Schedule repeated callback"
}
}
32 changes: 28 additions & 4 deletions Extension/syntaxes/banglacode.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
},
{
"name": "keyword.control.loop.js",
"match": "\\b(jotokkhon|ghuriye|thamo|chharo)\\b"
"match": "\\b(jotokkhon|ghuriye|thamo|chharo|do)\\b"
},
{
"name": "storage.type.function.js",
Expand Down Expand Up @@ -163,6 +163,10 @@
"name": "keyword.operator.logical.js",
"match": "\\b(ebong|ba|na)\\b"
},
{
"name": "keyword.operator.js",
"match": "\\b(in|of|instanceof|delete)\\b"
},
{
"name": "keyword.control.switch.js",
"match": "\\b(bikolpo|khetre|manchito)\\b"
Expand All @@ -177,7 +181,7 @@
},
{
"name": "keyword.control.loop.js",
"match": "\\b(jotokkhon|ghuriye|thamo|chharo)\\b"
"match": "\\b(jotokkhon|ghuriye|thamo|chharo|do)\\b"
},
{
"name": "keyword.control.trycatch.js",
Expand Down Expand Up @@ -206,6 +210,10 @@
{
"name": "keyword.operator.assignment.js",
"match": "="
},
{
"name": "keyword.operator.arrow.js",
"match": "=>"
}
]
},
Expand All @@ -219,18 +227,34 @@
"name": "support.function.js",
"match": "\\b(dhoron|lipi|sonkha|dorghyo)\\b"
},
{
"name": "support.function.js",
"match": "\\b(purno_sonkhya|doshomik_sonkhya|sonkhya_na|sonkhya_shimito|uri_encode|uri_decode|uri_ongsho_encode|uri_ongsho_decode)\\b"
},
{
"name": "support.function.js",
"match": "\\b(tarikh_ekhon|tarikh_parse|tarikh_format|regex_test|regex_match|regex_match_all|regex_search|regex_replace|match|matchAll|search)\\b"
},
{
"name": "support.function.array.js",
"match": "\\b(manchitro|chhanno|sonkuchito|proti)\\b"
},
{
"name": "support.function.array.js",
"match": "\\b(khojo_prothom|khojo_index|khojo_shesh|khojo_shesh_index|prottek|kono|somtol_manchitro|array_at|shesh_index_of|joro_array|somtol|sonkuchito_dan)\\b"
},
{
"name": "support.function.object.js",
"match": "\\b(maan|jora|mishra)\\b"
"match": "\\b(maan|jora|mishra|nijer_ache|jora_theke|ekoi_ki|notun_map|joma)\\b"
},
{
"name": "support.function.js",
"match": "\\b(boroHater|chotoHater|chhanto|bhag|joro|khojo|angsho|bodlo)\\b"
},
{
"name": "support.function.js",
"match": "\\b(ache_text|shuru_diye|shesh_diye|baro|agey_bhoro|pichoney_bhoro|okkhor|text_at|okkhor_code|codepoint_at|tulona_text|shadharon_text|chhanto_shuru|chhanto_shesh|shesh_khojo)\\b"
},
{
"name": "support.function.js",
"match": "\\b(dhokao|berKoro|kato|ulto|saja|ache|chabi)\\b"
Expand All @@ -241,7 +265,7 @@
},
{
"name": "support.function.js",
"match": "\\b(somoy|ghum|nao|bondho|poro|lekho)\\b"
"match": "\\b(somoy|ghum|nao|bondho|poro|lekho|setTimeout|setInterval|clearTimeout|clearInterval)\\b"
},
{
"name": "support.function.js",
Expand Down
Loading