fspl/README.md

105 lines
2.8 KiB
Markdown
Raw Normal View History

2023-10-07 05:55:33 +00:00
# FSPL
Freestanding programming language: a high-ish-level language that has absolutely
no need for any runtime support, designed to work well in scenarios where
2023-12-08 05:28:58 +00:00
dragging along a language runtime is either not possible or simply unwanted.
2023-10-07 05:55:33 +00:00
This language is designed for:
- Operating system development
- Embedded software
2023-12-08 05:28:58 +00:00
- Integrating cleanly into existing software
2023-10-07 05:55:33 +00:00
## Design Principles
- Abstractions must happen at compile time unless absolutely necessary
- Compiler must not generate any functions that the user does not write
- Compiler must avoid generating logic that the user does not write
2023-12-08 05:28:58 +00:00
## Installation
You can install the compiler by running:
`go install ./cmd/fsplc`
2023-12-13 08:44:57 +00:00
The `fsplc` program depends on the LLVM IR compiler (`llc`). If it is not found,
it will attempt to use `clang` instead but with some features disabled. Please
ensure either `llc` or `clang` are installed and accessible from your PATH
before using this software.
2023-12-08 05:28:58 +00:00
Note that the compiler is still relatively early in development, and has
numerous bugs. In addition, language features and syntax are not yet set in
stone and may change in the future.
## Usage
The `fsplc` program may be used as follows:
`fsplc [ARGUMENT(S)...] FILE(S)...`
The program compiles all input files into one output. The output file type is
determined by the filename extension of the output file:
| Extension | Type |
| --------- | --------------- |
| .s | Native assembly |
| .o | Object file |
| .ll | LLVM IR |
If no output file is specified, it will default to an object file with the name
of the first input file.
Object files can be linked into an executable binary using the linker of your
choice, or by using a C compiler such as `clang`:
`clang -o OUTPUT INPUT.o`
Using a C compiler will link the C standard library to your program, which may
be useful for building normal user applications.
2023-12-13 08:44:57 +00:00
## Bugs
There are a lot of them. But something to be wary of, especially on Windows:
currently, the compiler only excepts files with a blank line at the end.
2023-10-07 05:55:33 +00:00
## Roadmap
### Late 2023
These have been implemented:
2023-10-07 05:55:33 +00:00
- Top-level entities
- Type definitions
- Methods
- Defined and external functions
- Type system
- Strict, static, bottom-up type inference
- Pointers
- Arrays
- Slices
- Structs
- Interfaces
- Expressions and control structures
- Literals adapt to types via bottom-up type inference
- Assignment
- Variable declaration
- Variable access
- Function calls
- Method calls
- Interface behavior calls
- Operations
- Casting
- Blocks
- If/else
- Loops
### Early 2024
- Union types (carry type information)
- Match statements
- Modules
- Vararg
- Lightweight, modularized (and of course, totally optional) standard library
- Conditional compilation
- Constants
- For loops
- Range loops
### Afterwards
- Generics?
- Ownership system?
- And more!