Skip to content

AntonShvets0/Tengri

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dependencies

  • .NET Framework 4.7.2
  • Newtonsoft.Json

Language

Tengri 2.0

How to use

$ tengri <path to project> <print statistics? (false/true)>

Variable declaration

To declare a variable, you need to write the "var" keyword. Further, when working with a declared variable, you do not need to write it.

var fooBar = "data"
fooBar = 5

And in language exists global variables:

variable = "Test"
program = {
    static {
        main: () {
            console.print(global.variable) // Test
        }
    }
}

Arrays

Arrays are like PHP

var array = [1204, 1368, 1380, 1480]
var object = [ rulers: [
    [
        name: "Temuchin",
        father:  "Yesügei"
    ],
    [
        name: "Ögödei",
        father: "Temuchin"
    ]
] ]
var mixed = [1204, tumens: [
    [
        id: 1,
        peoples: 9986,
        horses: 29958
    ],
    [
        id: 2,
        peoples: 11000,
        horses: 40000
    ]
]]

Classes, fields, methods

Class declaration is like variable assignment. Var is not necessary..

government = {
    name: "Mongol Khaganate",
    
    @private
    ruler: "Temuchin",
    
    setRuler: (name) {
        ruler = name
    }
    
    getName: () {
        return ruler
    }
}

The init method is considered the constructor

people = {
    _name: "",
    
    init: (name) {
        _name = name
    }
}

program = {
    static {
        main: () {
            var peopleClass = people.init("Temuchin")
        }
    }
}

Static methods or fields should be placed in a static block

fooClass = {
    static {
        staticMethod: () {
            // ...
        }
    }
}

Fields or methods that start with _ are automatically considered private. Fields or methods that begin with protected are automatically considered protected. If you need to move away from the language codestyle and change the visibility of a field or method, then use the attributes

foo = {
    _privateField: "This is private field",
    publicField: "This is public field",
    protectedField: "This is protected field",
    
    @private
    privateMethod: () {
        return "This is private method"
    }
}

And in language exists procedure style for functions:

fun test() {
    console.print("Hi!")
}


program = {
    static {
       main: () {
            global.test()
       }
    }
}

Import and export

To access the classes of another file, you should use the import. Like a require from Node.Js:

program.tengri:

program = {
    static {
        main(): {
            var example = import "example"
            example["function"]() // print hello world
        }
    }
}

example.tengri

// another code...

export [
    function: () {
        console.print("Hello world")
    }
]

Conditions

The terms are similar to any other terms in C-like languages. Brackets can be omitted. Else if replaced to "Elif"

if cond {

} elif cond {

} else {

}

Loops

Foreach
array = [name: "Test", age: 18]
array {
    console.print(it.Key + " : " + it.Value)
}

array:item {
    console.print(item.Key + " : " + item.Value)
}
For
for i in 0...array.length {
		
}
While
while cond {
	
}
Do while
do cond {
	
}

Exceptions

To throw exception, use superglobal function throw():

throw(exception.init("Message"))

You can catch it:

try {
    throw(exception.init("Message")) 
}

// or
try {
    throw(exception.init("Message")) 
} catch {
    console.print(ex.message)
}

// or
try {
    throw(exception.init("Message")) 
} catch:exception {
    console.print(exception.message)
}

// or
try {
    throw(exception.init("Message")) 
} catch:exception {
    console.print(exception.message)
} finally {
    console.print("For Tengri!")
}

Threads

var thread = thread.init(() {
console.print("thread func")
})

thread.start()
thread.stop()

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages