DulLabs / bhai-lang

A toy programming language written in Typescript
https://bhailang.js.org/
MIT License
3.99k stars 498 forks source link

Feature Request: Functions, passing variables, reference variables, inputs and constants #241

Open anuj10x opened 2 years ago

anuj10x commented 2 years ago

Is your feature request related to a problem? Please describe.

We can declare and call functions, pass variables and reference variables, take input from console, support constants

declare function: bhai apun ka naam TaklaFighter(supariAmount, &kitnaTimeLagega) & for passing reference variables bula for calling functions Input variables have a ? in front of them and can be used to take input from console. Keyword mangta for taking input

bhai yeh hai kitniSupari?
bhai kitniSupari mangta

bole to for constants

Describe the solution you'd like.

Example:

HaoNaBhai bole to sahi 
NahiNaBhai bole to galat
PooraHafta bole to 100000

bhai apun ka naam MunnaCircuit(&haftaMilaKya, vasooli)
{
   haftaMilaKya = NahiNaBhai;
   agar bhai (vasooli == PooraHafta) {
       haftaMilaKya = HaoNaBhai;
   }
}

Calling function from main:

hi bhai
  bhai yeh hai haftaMilaKya?
  bhai yeh hai vasooli?
  bol bhai "kitni vasooli hui?"
  bhai vasooli mangta
  bhai bula MunnaCircuit(haftaMilaKya, vasooli)
  agar bhai (haftaMilaKya) {
    bol bhai "Jhakkaaas!!"
  }
  warna {
    bol bhai "Khallaaas!!"
  }
bye bhai

Describe alternatives you've considered

No response

Additional context.

No response

tbhaxor commented 2 years ago

Duplicate of #154 and implemented in #220