Documentation

Welcome to the Ypsilon Script documentation. Here you'll find everything you need to start writing code for microcontrollers with Ypsilon Script.

Installation

To install Ypsilon Script, follow these steps to set up the compiler from source:

Step 1: Clone the Repository

git clone https://github.com/ycharfi09/ypsilon-script.git
cd ypsilon-script

Step 2: Install Dependencies

npm install

Step 3: Link the Compiler Globally

npm link

The npm link command makes the ysc command available globally. If needed, you may have to add npm's global bin directory to your PATH environment variable.

Verify the installation by running:

ysc --version

Basic Syntax

Ypsilon Script uses a modern, clean syntax inspired by Rust and modern languages. Here are some basic syntax rules:

// Variable declarations
mut int counter = 0
let string message = "Hello"

// Function declaration
fn int add(int a, int b) {
    return a + b
}

Hardware Types

Ypsilon Script includes over 100 built-in hardware types for common microcontroller peripherals and sensors. Here are some examples:

Digital I/O

mut Digital pin13 on pin 13
mut Led statusLed on pin 10
mut Button btn on pin 2

Sensors

mut TempSensor temp on pin A0
mut DistanceSensor ultrasonic on pins(trig:7, echo:8)

Communication

mut UART serial on port 0
mut I2C wire on pins(sda:20, scl:21)

Event-Driven Programming

Ypsilon Script supports event-driven programming with special blocks:

on start {
    // Initialization code runs once
    serial.begin(9600 baud)
}

on loop {
    // Main loop code runs repeatedly
    statusLed.toggle()
    wait 500ms
}

Pattern Matching

Use Rust-style pattern matching for control flow:

match value {
    0 => { print("Zero") }
    1...10 => { print("Small") }
    _ => { print("Large") }
}

Further Reading

For complete language reference, advanced features, and more examples, please visit the project's GitHub repository documentation: