Git Product home page Git Product logo

tlang's Introduction

tlang

Trying to create an interpreter for my custom dynamically typed language

An algamation of different features from different languages mashed into one language

Variables

Define variables with let

let myVar = 20

Re assign as you would in any C lang

myVar = 24

And some operators

myVar++
myVar--
myVar += 1
myVar -= 1
myVar /= 2
myVar *= 2

Data types

  • string "hello world"
  • number 1337 (all numbers are actually 64 bit floats)
  • bool true false
  • dynamic arrays [1, 2, 3]
  • maps { hello = "world" }
  • null nil

Functions

All functions are variables, define them with let and fn

let sum = fn(a, b) {
    return a + b
}

Call functions like this

let short = sum(20, 42)

let longer = sum(20, b = 42)

let longest = sum(
    a = 20,
    b = 42,
)

We have closures, they are awesome

let createMultiply = fn(by) {
    return fn(num) {
        num * by
    }
}

let multiplyBy3 = createMultiply(3)
let result = multiplyBy3(3) // 9

Functions are first-class served

let callPassed = fn(f) {
    f()
}

callPassed(fn() {
    // what's up
})

Immediately invoke functions for quick computations

let result = fn() {
    return 2 * 2
}()

Comments

As you already have seen, define comments with //

// I am a comment, wow, pretty cool

IFs

Write if statements like you would in rust

let cute = true
let evenMoreCute = true

if cute {
    // ...
} else if evenMoreCute {
    // ...
} else {
    // :(
}

Same line if true return are NOT supported

Loops

For loops are similar to go

for index, value in [1, 2, 3] {

}

for key, value in {key = "value"} {

}

While loops

while true {
    // yes
}

tlang's People

Contributors

tronikelis avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.