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:
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
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]
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)
[X] 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
[X] These changes have been thoroughly tested.
[ ] Changes need to be immediately published on npm.
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.
Some examples:
basic arrays
output:
array access and length loop (new bhai-lang keyword
ka lambai
)output:
inner arrays
output:
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)
[X] 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[X] These changes have been thoroughly tested.
[ ] Changes need to be immediately published on npm.