> For the complete documentation index, see [llms.txt](https://sron.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sron.gitbook.io/docs/attribute-in-sron.md).

# Syntax of SRON

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:

```js
    attribute : statement
```

Attribute defines the types of statement and is used to tell the compiler that this statement is written with XYZ intention. There are many attributes provides in SRON:

**1) name** : this attribute is used to declare a function name.

```js
{
    name : functionName
}
```

***

**2) args** : this attribute is used to declare a function arguments.

```js
{
    name : fnc
    args : (Int a, String b)
}

{
    name : Main
    args : (List arglist)
}
```

***

**3) console** : this attribute is used to print values on the terminal/command line.

```js
{
    name : Main
    console : ("Hello, World!")
}
```

***

**4) type** : this attribute is used to set the return type of the function

```js
{
    name : getInt
    type : Int
    return : 27062003
}
```

***

**5) return** : this attribute is used to return a value from a function

```js
{
    name : getPi
    return : PI
}
```

***

**6) for** : this attribute is used to declare a for-loop.

```js
{
    name : Main
    for : {
        range : (Int i = 0, 5)
        console : ( i , '\n')
    }
}
```

***

**7) range** : this attribute is used to declare the range of for-loop.

```js
{
    name : Main
    for : {
        range : (Int i = 0, 10 , 2)
        console : ( i , '\n' )
    }
}
```

***

**8) while** : this attribute is used to declare a while loop.

```js
{
    name : Main
    while : {
        condition : true
        console : ( "SRON\n" )
    }
}
```

***

**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.

```js
{
    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.

```js
{
    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.

```js
{
    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.

```js
{
    name : Main
    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) foreach** : this attribute is used to iterate linearly over String or List.

```javascript
{
    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)
    }
}
```

**14) rotate** : this attribute is used to rotate value or swap value.

```javascript
{
    name : Main
    
    Int val1 = 91
    Double val2 = 1001.27112
    String val3 = "SRON"
    
    console : (val1, ' ', val2 , ' ' , val3)
    
    rotate : (val1 , val2, val3)
    
    console : (val1, ' ', val2 , ' ' , val3)
}
```

**15) windows** : this attribute is used to execute a certain block of code which will only execute if the code is being running on windows systems.

```javascript
{
    name : Main
    
    windows : {
        println("This is a windows system")
    }
}
```

**16) linux** : this attribute is used to execute a certain block of code which will only execute if the code is being running on linux systems.

```javascript
{
    name : Main
    
    linux : {
        println("This is a Linux system")
    }
}
```
