Skip to content

pacosw1/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

This project requires pip and json-pickle.

If you don't have pip make sure to download it before continuing.

Windows: https://www.liquidweb.com/kb/install-pip-windows/ Mac: https://phoenixnap.com/kb/install-pip-mac

To install dependencies simply run pip install . or pip3 install .

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

To Execute Specific Files: python3 -m src.{directory}.{fileName}

To run the syntax highlighter (only for vscode) head to typeton-lange/ and hit F5 on windows or FN+F5 on mac. A new window should pop up with the syntax highlighter extension running locally

To run the compliler, add or use a file in programs/ and run python3 -m src.main


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
}

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
    • Objects
  • 🖥 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

  • Python 100.0%