The CSpydr Programming Language
CSpydr is a low-level, static typed, compiled programming language inspired by Rust and C. This repository contains cspc
(the CSpydr Programming Language Compiler), as well as CSpydr's Standard Libraray, some code examples and unit tests.
Current Status
A list of all the features, that are/will be implemented.
cspc Compiler features:
- Assembly compiler (only missing: va_lists, returnign of large structs) (only
x86_64-linux
platform) - LLVM codegen target (maybe even WASM?)
- move to an intermediate bytecode compiler
- C transpiler (deprecated)
- lexing tokens
-
macro
andimport
preprocessor - parsing an AST
- validating the code
- type evaluator
- type checking (1/2 done)
- scope validation
- 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 and arrays
&
[]
- custom data types
struct
union
enum
{}
(tuples) - control statements
if
match
for
while
loop
ret
break
continue
noop
- different loop types:
for
,while
andloop
- 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 (not asynchronous)
- templates in fuctions and structs
- va lists
- functions as struct members
CSpydr Standard library features
- basic
c17
libc
-header implementation -
glfw
andOpenGL
/GLU
header files - from-the-ground custom written
stdlib
based on linux syscalls (in progress) - control- and safety-structs and -functions (like in Rust) (in progress)
Building | Installation
Currently, CSpydr is only available for Linux. Once a first major release is in sight I will create an AUR repository for Arch Linux, but at the moment Installation is done via CMake. To build CSpydr on your computer enter these following commands in a terminal
git clone https://github.com/spydr06/cspydr.git --recursive
cd ./cspydr
cmake .
make
To install CSpydr with all of it's components (cspc - The CSpydr Compiler and the CSpydr Standard Library), enter this command (with root privileges):
sudo make install
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
The CSpydr Syntax
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.
(I will write a proper documentation in the future!)
Editor support
CSpydr currently only supports Visual Studio Code, since thats the code editor I personally use for developing. I will add support for other editors later on.
Check out the Visual Studio Code extension here.
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.
License
CSpydr is licensed under the MIT License
Resources | Reference | Inspiration
- chibicc C compiler: https://github.com/rui314/chibicc.git
- tac programming language: https://github.com/sebbekarlsson/tac.git
- summus programming language: https://github.com/igor84/summus.git
- porth programming language: https://gitlab.com/tsoding/porth.git