CSpydr
CSpydr copied to clipboard
A static typed low-level compiled programming language inspired by Rust and C
The CSpydr Programming Language
📑 Documentation | 💾 Installation | 🤝 Contributing | 📜 License | 🔄 State
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
helloworld.csp

Fibonacci
fibonacci.csp

Lambda Functions
lambda.csp

Read File
read_file.csp

Random Number Generator
random.csp

Time & Timer API
time.csp

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:
- [x] 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)
- [x] C transpiler
- [x] lexing tokens
- [x]
macroandimportpreprocessor - [x] parsing an AST, validation of syntax and semantics
- [x] type evaluator & checking
- [x] implicit type casts
- [ ] "projects" - prebuild libraries such as the
stdlib - [x] CLI and error handling
- [x] memory management
CSpydr Language features:
- [x] primitive data types
i8i16i32i64u8u16u32u64f32f64f80boolcharvoid - [x] pointers, arrays and c-like arrays
&[]'c[] - [x] custom data types
structunionenum{}(tuples) - [x] control statements
ifmatchforwhileloopretbreakcontinuenoopwithdo-whiledo-unlessdefer - [x] different loop types:
for,while,do-whileandloop - [x] expressions
- [x]
externfunctions and globals - [x] type-related keywords
sizeoftypeofalignoflen - [x] file imports
- [x] macros and macro-overloading
- [x] default macros
__version____system____architecture____time____compile_type____main_file____file____line____func__ - [x] namespaces, functions, globals, typedefs
- [x] inline
asmcode blocks - [x] lambda expressions
- [ ] templates in fuctions and structs
- [x] va lists
- [ ] functions as struct members
CSpydr Standard library features
- [x] basic
c17libc-header implementation - [x]
glfwandOpenGL/GLUheader files - [x]
cURLheader implementation - [x] from-the-ground custom written
stdlibbased 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:
- NeoVim/Vim
- VSCode
Note For quick installation, use the
install.shscript 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
- chibicc C compiler: https://github.com/rui314/chibicc.git
- vcc: https://github.com/lemoncmd/vcc.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
- cURL C library for transferring data: https://github.com/curl/curl
- tiny-regex-c as the main inspiration behind
regex.csp: https://github.com/kokke/tiny-regex-c.git - logo inspiration: IntelliJ IDEs (https://www.jetbrains.com/), Haskell-Intellij Plugin (https://plugins.jetbrains.com/plugin/8258-intellij-haskell)