Skip to content
/ tlang Public

Repo for TLang [Timmy's Programming Language]. An interpreted programming language built while reading Thorsten Ball's Writing an interpreter in Go book

License

Notifications You must be signed in to change notification settings

rafmme/tlang

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tlang

Repo for TLang [Timmy's Programming Language]. An interpreted programming language built while reading Thorsten Ball's Writing an interpreter in Go book

TLang Programming Documentation

Welcome to the official documentation for Timmy's Interpreted Programming Language, a modern and simple programming language. Try it out here More documentation

Author: Timileyin E. Farayola | https://linkedin.com/in/timileyin-farayola | https://github.com/rafmme | timileyin.e.farayola@gmail.com | © APRIL, 2025

Data Types

String: 

make str_one = "string 1";
make str_two = `string 2`;
make str_th = 'string 3';

count(str_two) // Returns the length of the string. //Output: 8

display(str_one * 3) // Output: "string 1string 1string 1"

Integer: 

make num = 26;

Boolean: 

make isCorrect = true;
make notTrue = false;

Null: 

make a = null;

Operators

Supported operators.

Arithmetic Operators: 

make num = 3;

Multiplication "*" display(num * num) //Output: 9

Division "/" display(num / num) //Output: 1

Addition "+" display(num + num) //Output: 6

Subtraction "-" display(num - num) //Output: 0

display(((num * num) + (num + num)) / num) //Output: 5


Logical Operators: 

!true // false

!false // true


Comparison operators: 

3 == 3 // true

3 > 4 // false

4 < 5 // true

Arrays

Arrays store multiple values in a single variable.

make arr = [1, 2, 3, 4]

display(arr[1]) // Output: 2

Hashmaps

Hashmaps (dictionaries) store key-value pairs.

make map = {"name": "Alice", "age": 25}

display(map["name"]) // Output: Alice

Built-in Functions

TLang provides several built-in functions for handling data andcomputations.

display(element) // Outputs the element value.

count(arr) // Returns the number of elements in an array.

push(arr, element) //Adds a new element to an array. Returns a new array with the added element.

first(arr) // Returns the first element in an array.

last(arr)  // Returns the last element in an array.

rest(arr) // Returns a new array without the first element.



TODOS:  // To be added!

keys(map)  // Returns all keys in a hashmap

values(map) // Returns all values in a hashmap

Functions

Functions are reusable blocks of code. Supports High-Order functions & Closures.

make greet = fxn(name) {
  return "Hello, " + name;
}

display(greet("Bob")); // Output: Hello, Bob

A recursive function that loops through an array and print all its element: 

make loopThroughArray = fxn(arr) {
  if(count(arr) == 0){
    return null;
  } else {
      display(first(arr));

      loopThroughArray(rest(arr));
      return null;
  }
}

make a = [74,0,1,2,3,4,5,6,7,8,9];

loopThroughArray(a);

If-Else Conditional

Conditional statements control program flow.

make x = 10;

if (x > 5) {
    display("x is greater than 5");
} else {
    display("x is less than or equal to 5");
}

More features to be added soon. [WIP]

About

Repo for TLang [Timmy's Programming Language]. An interpreted programming language built while reading Thorsten Ball's Writing an interpreter in Go book

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published