A scope of a SRON's code starts with a function and it is started with an open curly brace '{' and ended with a close curly brace '}'.
Almost all instructions inside a function are written in the below format:
attribute : statement
Attribute defines the types of statement. There are many attributes given in SRON like :
1) name : this attribute is used to declare a function name.
{
name : function_name
}
2) args : this attribute is used to declare a function arguments.
{
name : fnc
args : (Int a, String b)
}
{
name : MAIN
args : (List arglist)
}
3) console : this attribute is used to print variables.
{
name : MAIN
console : ("Hello, World!")
}
4) type : this attribute is used to set the return type of the function
{
name : get_int
type : Int
return : 3.141578
}
5) return : this attribute is used to return a value from a function
{
name : get_pi
return : PI
}
6) for : this attribute is used to declare a for-loop.
{
name : MAIN
for : {
range : (Int i = 0, 5)
println(i)
}
}
7) range : this attribute is used to declare the range of for-loop.
{
name : MAIN
for : {
range : (Int i = 0, 5)
}
}
8) while : this attribute is used to declare a while loop.
{
name : MAIN
while : {
condition : true
}
}
9) condition : this attribute is used to check if the given condition is true or false. This attribute is used with 'while', 'if' and 'elif' attributes.
{
name : MAIN
while : {
condition : false
@ the statement of condition attribute only requires a 'Bool' type value.
}
}
10) if : this attribute is used to declare a if statement.
{
name : MAIN
Any val = 10
if : {
@ the integer value can be converted to boolean type value
condition : val
println(val)
}
}
11) elif : this attribute is used to declare an elif statement.
{
name : MAIN
Int val = 9
if : {
condition : ~{ val%2 == 0 }~
println("Even")
}
elif : {
condition : ~{ val%3 == 0 }~
@ the control flow will come here only if the code within the 'if'
@ attribute will not be executed.
println("Divisible by Three")
}
}
12) else : this attribute is used to declare a else statement.
{
name : MAIN
variables : Int val = 7
if : {
condition : ~{ val%2 == 0 }~
println("Even")
}
else : {
println("Odd")
@ this statement will execute only if the above
@ if-attribute is not executed.
}
}
13) free : this attribute is used to release a variable from memory.
{
name : MAIN
Int val = 27
@ printing the variable 'val'
println(val)
free : val
@ accessing the value after deallocation. This
@ will throw an exception (runtime error).
println(val)
}
14) foreach : this attribute is used to iterate linearly over String or List.
{
name : main
foreach : {
@ 'on' attribute is used to specify on what value
@ will the foreach will iterate with what variable
on : Any val, [1,2,3,4,5]
println(val)
}
}
15) rotate : this attribute is used to rotate value or swap value.