# Oraset B-5

A modern, C++-style scripting language designed for ease of use and powerful functionality.

## Features

### Core Language Features
- **Variables**: `let x = 10;`
- **Strings**: `let name = "Hello World";`
- **Arrays**: `let arr = [1, 2, 3, 4, 5];`
- **Functions**: `proc add(a, b) { return a + b; }`
- **Control Flow**: `if`, `else`, `while`, `for`, `switch`, `case`, `default`
- **Loops**: `do-while`, `while`, `for`

### C++ Style Features
- **Structures**: `struct Point { x; y; };`
- **Enums**: `enum Color { Red, Green, Blue };`
- **Typedef**: `typedef Point Pnt;`
- **Pointers**: Support for pointer operations
- **goto**: `goto label;`
- **Dynamic Memory**: `new`, `delete`, `malloc`
- **Exception Handling**: `try`, `catch`, `throw`

### Operators
- Arithmetic: `+`, `-`, `*`, `/`, `%`
- Bitwise: `&`, `|`, `^`, `~`, `<<`, `>>`
- Comparison: `==`, `!=`, `<`, `>`, `<=`, `>=`
- Logical: `&&`, `||`, `!`
- Compound: `+=`, `-=`, `*=`, `/=`, `%=`
- Increment/Decrement: `++`, `--`

### Built-in Functions
- **Mathematical**: `abs`, `sqrt`, `sin`, `cos`, `tan`, `pow`, `log`, `floor`, `ceil`, `round`
- **String**: `strcmp`, `strcpy`, `strcat`, `sizeof`
- **Array**: `arrlen`, `memcpy`, `memcmp`, `malloc`
- **Utility**: `echo`, `input`, `time`, `random`, `exit`, `assert`

## Getting Started

### Prerequisites
- GCC compiler (C11 standard)
- Make (optional)

### Compilation

```bash
# Windows
gcc -Wall -Wextra -O2 -std=c11 -o bin/oraset src/main.c -lm -lwininet

# Linux/Mac
gcc -Wall -Wextra -O2 -std=c11 -o bin/oraset src/main.c -lm
```

Or use the Makefile:
```bash
make
```

### Running

```bash
# Run a script
./oraset script.ora

# REPL mode
./oraset
```

## Example Code

```oraset
// Hello World
echo("Hello, Oraset!");

// Variables and arithmetic
let x = 10;
let y = 20;
echo("x + y =", x + y);

// Arrays
let arr = [1, 2, 3];
echo("arr[0] =", arr[0]);
echo("array length =", arrlen(arr));

// Functions
proc factorial(n) {
    let result = 1;
    for (let i = 1; i <= n; i++) {
        result *= i;
    }
    return result;
}
echo("5! =", factorial(5));

// Structures
struct Point {
    x;
    y;
};

// Loops
let i = 0;
while (i < 5) {
    echo("i =", i);
    i++;
}

// Switch statement
let color = 2;
switch (color) {
    case 1: echo("Red"); break;
    case 2: echo("Green"); break;
    default: echo("Blue");
}
```

## Syntax Reference

### Variables
```oraset
let name = value;
```

### Arrays
```oraset
let arr = [1, 2, 3];
arr[0] = 10;
echo(arr[0]);
```

### Functions
```oraset
proc func_name(param1, param2) {
    // body
    return value;
}

func_name(arg1, arg2);
```

### Control Structures
```oraset
if (condition) {
    // code
} else if (condition) {
    // code
} else {
    // code
}

while (condition) {
    // code
}

for (let i = 0; i < 10; i++) {
    // code
}

do {
    // code
} while (condition);

switch (value) {
    case 1: // code; break;
    case 2: // code; break;
    default: // code;
}
```

### Structures and Enums
```oraset
struct Name {
    field1;
    field2;
};

enum Name {
    Value1,
    Value2,
    Value3
};

typedef OriginalType NewTypeName;
```

## Version History

- **B-5**: Current version with C++ style features
- **Re+4**: Previous version
- **Re+3**: Earlier version

## License

GNU General Public License v3.0

## Contributing

Feel free to fork and contribute!