Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding support for arrays #275

Open
wants to merge 5 commits into
base: feat/basic-array
Choose a base branch
from

Conversation

aditya87
Copy link

@aditya87 aditya87 commented Jan 29, 2023

What does this PR do?

Adds support for arrays and. basic array operations.

What packages have been affected by this PR?

parser, interpreter

Types of changes

Adds the following features.

  • Declaring arrays
  • Assigning array values at index
  • Access array values at index, and using them in expressions.

Some examples:

  1. basic arrays
      hi bhai
        bhai ye hai b = 2;
        bhai ye hai a = [1, b + 2, 3];
        bol bhai a;
        bol bhai a[0];
        bol bhai a[1];
        bol bhai a[2];
        bol bhai a[3];
      bye bhai

output:

[1, 4, 3]
 1
 4
 3
  1. array access and length loop (new bhai-lang keyword ka lambai)
      hi bhai
        bhai ye hai a = [-1, 0, 3, 5];
        a[3] = -5;

        bol bhai a;
        bol bhai a[1];

        bhai ye hai i = 0;
        jab tak bhai (i < a ka lambai) {
          a[i] += 2;
          i += 1;
        }
        bol bhai a;
      bye bhai

output:

[-1, 0, 3, 5]
0
[1, 2, 5, -3]
  1. inner arrays
hi bhai
        bhai ye hai a = [-1, 0, 3, [1, 2]];
        bhai ye hai k = a[3];
        k[0] = -5;
        bol bhai a;
      bye bhai

output:

[-1, 0, 3, [-5, 2]]

What types of changes does your code introduce to this project?

Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)

  • New feature (non-breaking change which adds functionality)

  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Package version increase in cli package?

No

Checklist before merging

Put an x in the boxes that apply

  • These changes have been thoroughly tested.

  • Changes need to be immediately published on npm.

@netlify
Copy link

netlify bot commented Jan 29, 2023

Deploy Preview for bhailang-preview failed.

Name Link
🔨 Latest commit 0270adb
🔍 Latest deploy log https://app.netlify.com/sites/bhailang-preview/deploys/63d7047d48486c000a3fd9bc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant