Skip to content

nmsobri/Kat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

67 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kat Programming Language ( Work In Progress )

First stage, the code will be evaluated at run time ( interpreted )
Second stage would be compile it to custom byte code and then run it
Hopefully it will run the following code

const fmt = import("fmt")

struct User {
    name,
    age,
    job,
}

fn User.setAge(self, age) {
    self.age =  age
}

fn User.info(self) {
    fmt.Printf("Name is %s, age is %d, job is %s", self.name, self.age, self.job)
    fmt.Println()
}

fn say(greet) {
    fmt.Println(greet)
}

fn main() {
    let arr = [1,2,3,4,5]
    let foo = arr[0]
    fmt.Println(foo)

    let map = {name: "sobri", location: "penang"}
    let name = map["name"]
    fmt.Println(name)

    let user = User{name:"Sobri", age:99, job:"Programmer"}
    user.setAge(99)
    user.info()

    say("hello world")

    let i =  1 * 2 + 1

    if 10 > 2 {
        fmt.Println("bigger than 2")
    } else {
        fmt.Println("smaller than 2")
    }

    if i < 3 {
        fmt.Println("lower than 3")
    } else if i < 5 {
        fmt.Println("lower than 5")
    } else if i < 10 {
        fmt.Println("lower than 10")
    }

    for i > 0 {
        fmt.Println(i)
        1 + i--
        1 + --i
        ---3
        --1 + 2
        ++5--
        --6--
    }

    for let j = 0; j < 5; j++ {
        fmt.Println(j)
    }
}

main()

About

Kat Programming Language

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages