Skip to content

ricardomongza99/typeton

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🦭 TYPETON

An object oriented language developed by two rockstar engineering students at Tec de Monterrey.

⭐️ FEATURES

  • Local and global variables
  • Shorthand assign operators (+=, -=, *=, /=)
  • Arrays (with primitives)
  • Conditionals
  • Loops
  • Functions
  • Classes
  • Input/Output

🚗 GETTING STARTED

To install dependencies run pip install .

To run the compiler simply execute python3 -m src.main

To run custom programs, make sure the program is inside the programs folder and run python3 -m src.main #program_name

Add -debug flag at the end to display extra information such as quads, function data and symbol tables


Start

func main() -> {
    // Program starts here
}

Variable declaration

var myString: String
var myNumber: Int
var myDog: Dog

Arrays

var items: Int[10]
items[0] = 1

var Cube: Int[4][4][4]
cube[1][2][3] = 10

Conditionals

if ( 4 + 1 < 5 && true) {
    print("First")
} else if (2 == 3) {
    print("Second")
} else {
    print("Third")
}

Loops

var i = 0
while (i < 10) {
    print(i)
    i += 1
}

Functions func name (param_name: type, ...) -> return type

func sum(num1: Int, num2: Int) -> Int {
    return num1 + num2
}

func main() -> {
    var sum = sum(5, 2)
}

Classes

class Animal {
    // Declare properties
    name: String
    age: Int
}

func main() -> {
    var dog: Animal
    dog = new Dog()
    dog.name = "Albert"
    dog.age = 18
    
    print(dog.name)
}

Input

age = input("Enter age: ")

Output

print(userAge)

👨‍💻 CODE EXAMPLES

Program 1: Iterate over an array of integers

func main() {
    var items: Int[5]
    var i: Int
    
    i = 0
    while (i < 5) {
        items[i] = i + 10
        i += 1
    }
    
    i = 0
    while (i < 5) {
        print(items[i])
        i += 1
    }
}

Program 2: Input

func main() {
    var age: Int
    age = input("What is Jason's age?")
    print("Jason's age is ")
    print(age)

    var color: String
    color = input("What is Jason's favorite color?")
    print("Jason's favorite color is...")
    print(color)
}

📝 TODO

  • 💍 Project proposal
    • Documentation
    • Syntax diagram
  • 🪙 Lexical analysis
  • 📖 Syntax analysis
  • 🧠 Semantic analysis
    • Functions directory
    • Variable tables
    • Semantics cube
    • Heap Allocator
  • 🏭 Code generation
    • Arithmetic expressions
    • Short Hand Assignments (+=, -=, *=, /=)
    • Sequential blocks (ASSIGN, INPUT, ETC.)
    • Conditional blocks (IF, ELSE, WHILE, WHILE)
    • Functions
    • Arrays
    • Classes
  • 🖥 Virtual Machine
    • Memory for execution (Global memory, temporal memory, execution stack)
    • Arithmetic expressions execution
    • Sequential blocks execution
    • Conditional blocks execution
  • 🏁 Documentation review

🔍 SYNTAX DIAGRAM

Program Top level Params Type Blocks Classes Statements Expressions Variables

About

An object oriented language

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages