Arrays - o2bblockbusting/cs421_project GitHub Wiki

Arrays in Sulfur are actually all ArrayLists on the backend and can be created using the following BNF syntax.

<array_definition> ::= 'A' <identifier> <data_type_char> "[]V" <expression>

Example:

A arr N[]V {1,2,3}
A arr2 L[]V {}
A arr3 S[]V {"h"+"i","there"}

The property accessor token ('~') can be used to run many different ArrayList functions. The examples below show one example of each available function.

arr~size()
arr3~length()
arr~get(3)
arr3~set(3,'hi')
A arr4 N[]V arr~clone()
arr4~indexof(2)
arr2~contains(6L)
arr~remove(2)
arr2~add(42L)
arr4~clear()
P(arr,'\n',arr2,'\n',arr3,'\n',arr4)
⚠️ **GitHub.com Fallback** ⚠️