Skip to content

ramsy0dev/manv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

ManV, an other compiled programming language intended for writing algorithms.

Development plan

  • Make ManV a compiled language (By generating assembly code)
  • Implement Constant/Variable declaration
  • Implement basic math operations (mul, div, add, sub)
  • Implement syscall keyword for interacting the system
  • Implement a basic pointer
  • Implement binary operations like right shift, left shift ...etc
  • Implement memory manipulation
  • Implement if-else conditions
  • Implement while loops
  • Implement functions
  • Implement the 'include' keyword
  • Write the ManV stdlib
  • Port some C libraries (raylib) to ManV

Syntax

  • Basic data types

int     // Integer type
float   // Float type
str     // String sequence
char    // Char
  • Declare variables

const x[10]: int = 1;      // Variable named 'x' of type int, with the value of '1'
const y[10]: float = 0.1;  // Variable named 'y' of type float, with the value of '0.1'
const c: int;              // Variable named 'c' of type int, with a dynamic size and with no value assigned

// If we want to increase or decrease the variable's size
// we do the following:

size_inc x, 10;  // Increase the size by 10
size_dec y, 10; // Decrease the size by 10

// To empty or delete a variable from memory
emt x // Empty the variable x from its value
del x // Delete the variable x from memory
  • Basic operations

const x: int = 10;
const y: int = 2;

var mul_res: int;
var add_res: int;
var div_res: float;
var sub_res: int;

mul (x, y) into mul_res;     // Multiplication
add (x, y) into add_res;     // Addition
div (x, y) into div_res;     // Division
sub (x, y) into sub_res;     // Subtraction
  • Pointers

to create a pointer, you can use the ptr keyword:

ptr x: int;

All pointers are zero-initialized by default. Pointers don't accept size.

  • Direct syscalls

ManV provides a keyword called syscall which you can use to directly make syscalls. the syntax for syscall is the following:

syscall $RAX, $RSI, $RDI, ..., $ERR;

An example usage, this is a simple call to sys_exit:

const SYS_EXIT: int = 60;   // sys_exit
const EXIT_OK: int = 0;     // Exit code 0
var errno: int;             // Error reporting

syscall SYS_EXIT, EXIT_OK, errno;

  • if-else condition

Conditions in ManV work the same in any other language.

// Constants
const STDOUT: int = 1;
const SYS_WRITE: int = 1;
const SYS_EXIT: int = 60;
const EXIT_CODE_OK: int = 0;

var ERRNO: int; // Error handler

// Log messages
ptr are_equal_text: str = "equal!";
const are_equal_len: int = 7;

ptr are_not_equal_text: str =  "not equal!";
const are_not_equal_len: int = 11;

if (10 == 5) {
    syscall SYS_WRITE, STDOUT, are_equal_text, are_equal_len, ERRNO;
} else {
    syscall SYS_WRITE, STDOUT, are_not_equal_text, are_not_equal_len, ERRNO;
}

About

An other compiled programming language.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published