Giter Site home page Giter Site logo

lacus's Introduction

Lacus

a strongly typed, procedual, compiled programming language. right now MIPS 32 Assembly and LLVM

syntax was strongly inspired by rust, Ada and C

why i choose the name, lacus is latin for lake, and I chose lake to honor my favorite enby-coded character in Animation. I cant name it lake because lean4 has a build system with the name of lake.

Langauge definition

//% -> mod
//* -> multiply
// / -> divison
// +,- -> addition and subtraction

// <, > greater than less than
// >= <=, GTE, LTE
//  /= not equal
fn main(args: string) returns int { //this is how you call the main method (this is how you do comments), returns for return
    const float pi = 3.1415; // floats
    int random_var = 100; //integer
    bool turringComplete = true; //i think lol 
    random_var = (int)(pi + random_var * ((pi + random_var) % 2)/10); 
    //if statemnets
    if(random_var == 100){
        print("%d", random_var);
    }else if(random_var == 200){
        random_var = random_var + 1;
        print("%d", random_var);
    }else{
        random_var = 0;
        print("%d", random_var);
    }
    //loops 
    while random_var < 1000 do random_var = random_var + 1;
    for(int i = 0; i < 10; step i, 1) ->  print("%d",i); 
    for(int i = 10; i > 0; step i, -1) ->  print("%d",i); //step is "i++" in C. (step VAR, NUM)
    print("%f",random_var); // %f -> float %d -> integer. this is a temp system until I add something better :3
    exit(1); //exit
    return 0;
    
}
fn f(x: int) : int -> x + 1; //new feature i been thinking of. for a while >:3

CLI commands

1st arg is the file name

-d : runs a demo of this dir, the file is test.txt and the out file is MIPSTarget/MipsTargetASM/out.s

-token : outputs the token list

-o file: output file if none specified its going to be MipsTarget/MipsTargetASM/out.s

-m: specify MIPS 32 target

-l: specify LLVM target (coming soon)

-v : version (coming soon)

Build Instructions

if you have linux as your primary OS

use the ./setUpCMake.sh script to setup the CMake code.

and from then on

./build.sh to build your code. the exe name should be called "output"

./clean.sh to clean all the objs and exe.

else just create a build dir and do

cmake ..

Run Compilation

MIPS

if you dont have a MIPS CPU on hand just do this

  1. install QTSpim https://spimsimulator.sourceforge.net/

  1. the if you didnt specify a file name. its out.s the location is MipsTarget/MipsTargetASM

  1. locate file in QTSPim by going to file->Reinitialize and load file

  1. Before running, I recomend pressing clear registers, and then run


LLVM

WARNING: this is in the very early stages of development so there is a huge version discrepancy between MIPS32 target and the LLVM target

LLVM IR version is 14.0.0 (the best OS to run this on is Ubuntu linux)

and the generated LLVM IR files are located in out/out.ll

how to run LLVM IR code

llc out/out.ll
clang out/out.s
./a.out

Test Programs

Try some test programs. using the MIPS32 target

Test programs

lacus's People

Contributors

theow03 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

gmh5225

lacus's Issues

better floating point nums

20*3 causes an overflow

so i must switch to Floating point registers. instead of using general purpose with ints

Type system

stronger type system.

right now
my language is in an awkward phase of

being strongly typed.
but at the same time being weakly typed

need to implement more stronger typed systems.

arrays

Implement MIPS 32 back end for arrays.

function names in asm

some function names are similar to that of Assembly instructions.

like "add" this is a MIPS 32 instruction

what I must implement is something that concats the name of the function
like this

lacus_add.

so the assembler doesn't get confused with this.

Memory

switch to smart pointers.
instead of using raw pointers.

and optimise pointer usage in code.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.