Giter Site home page Giter Site logo

spydr06 / cspydr Goto Github PK

View Code? Open in Web Editor NEW
81.0 5.0 2.0 4.6 MB

A static typed low-level compiled programming language inspired by Rust and C

License: MIT License

C 98.59% Shell 0.67% C++ 0.03% Lua 0.02% Vim Script 0.26% Makefile 0.42%
low-level cspydr compiler static-typed programming-language c rust language csp compilation standard-library stdlib syntax assembly x86-64-linux-gnu x86-64 assembly-x86-64 compiler-construction proglangs-discord hacktoberfest

cspydr's Introduction

CSpydr is a low-level, static typed, free and open-source, compiled programming language inspired by Rust and C. This repository contains cspc (the CSpydr Programming Language Compiler), as well as CSpydr's Standard Library, a code-linting utility, some code examples and unit tests.

Code Examples

Hello World

Fibonacci

Lambda Functions

Read File

Random Number Generator

Time & Timer API

More examples can be found in the examples directory

Current State

A list of all the features, that are already implemented or planned.

cspc Compiler features:
  • Assembly code generator for x86_64 linux
  • LLVM codegen target (maybe even WASM?)
  • move to an intermediate bytecode compiler
  • AST to JSON converter (in progress)
  • C transpiler
  • lexing tokens
  • macro and import preprocessor
  • parsing an AST, validation of syntax and semantics
  • type evaluator & checking
  • implicit type casts
  • "projects" - prebuild libraries such as the stdlib
  • CLI and error handling
  • memory management
CSpydr Language features:
  • primitive data types i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 f80 bool char void
  • pointers, arrays and c-like arrays & [] 'c[]
  • custom data types struct union enum {} (tuples)
  • control statements if match for while loop ret break continue noop with do-while do-unless defer
  • different loop types: for, while, do-while and loop
  • expressions
  • extern functions and globals
  • type-related keywords sizeof typeof alignof len
  • file imports
  • macros and macro-overloading
  • default macros __version__ __system__ __architecture__ __time__ __compile_type__ __main_file__ __file__ __line__ __func__
  • namespaces, functions, globals, typedefs
  • inline asm code blocks
  • lambda expressions
  • templates in fuctions and structs
  • va lists
  • functions as struct members
CSpydr Standard library features
  • basic c17 libc-header implementation
  • glfw and OpenGL/GLU header files
  • cURL header implementation
  • from-the-ground custom written stdlib based on linux syscalls (in progress)

Installation

Please refer to INSTALL.md for installation instructions and information about compatability

Hello, World!

A simple hello-world program:

import "io.csp";

fn main(): i32
{
    std::io::puts("Hello, World!");
    <- 0;
}

Running this program is as easy as entering the following command:

$ cspc run hello-world.csp

Examples

For more examples, please refer to the examples/ directory in this repository.

Usage

To compile a CSpydr program use the following command:

$ cspc build <your file>

To directly run a program use this command:

$ cspc run <your file>

To launch a special debug shell, start your program using the debug action:
(not finished yet!)

$ cspc debug <your file>

Get help using this command:

$ cspc --help

(I will write a proper documentation in the future!)

Editor support

Editor support is found in the editors/ subdirectory.

Supported editors include:

Note For quick installation, use the install.sh script in the respective subdirectory.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update the unit tests as appropriate.

View CONTRIBUTING.md for more information

License

CSpydr is licensed under the MIT License.

Resources | Reference | Inspiration

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.