https://github.com/bichanna/slap
🖐 A dynamically- and strongly-typed, object-oriented programming language
https://github.com/bichanna/slap
compiler interpreter javascript js language lox lox-language programming-language slap transpiler tree-walker
Last synced: about 2 months ago
JSON representation
🖐 A dynamically- and strongly-typed, object-oriented programming language
- Host: GitHub
- URL: https://github.com/bichanna/slap
- Owner: bichanna
- License: mit
- Created: 2022-02-16T01:35:52.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-10-17T13:26:06.000Z (over 3 years ago)
- Last Synced: 2023-03-04T01:48:12.905Z (over 3 years ago)
- Topics: compiler, interpreter, javascript, js, language, lox, lox-language, programming-language, slap, transpiler, tree-walker
- Language: Nim
- Homepage: https://bichanna.github.io/slap/
- Size: 569 KB
- Stars: 17
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://github.com/bichanna/slap/actions/workflows/ubuntu.yml)
[](https://github.com/bichanna/slap/actions/workflows/mac.yml)
[](https://github.com/bichanna/slap/actions/workflows/windows.yml)
**WARNING!! THIS LANGUAGE IS IN DEVELOPMENT (AND FOR LEARNING PURPOSES). ANYTHING CAN CHANGE AT ANY MOMENT.**
🖐 **SLAP** stands for "**SL**ow **A**nd **P**owerless." And I hope to make it "**P**owerful" someday.
**SLAP** is a dynamically- and strongly-typed, object-oriented programming language. Its syntax is a member of the C family with a bit of difference.
## Example
As of March 2022, you can write pretty decent, small programs in SLAP.
>*Note*: The SLAP-to-JS transpiler is in progress (see [compiler branch](https://github.com/bichanna/slap/tree/compiler)).
SLAP-to-JS Compiler Example
https://user-images.githubusercontent.com/60306074/162365051-630e6171-93c0-4af5-a55c-c600ae1efa92.mov
## Installation
On Linux/macOS, you may be able to run the following commands to install SLAP.
```
$ git clone https://github.com/bichanna/slap.git
$ cd slap
$ chmod +x ./build.sh
$ ./build.sh # The SLAP Vim highlighter automatically gets installed
```
For Windows, I haven't written bat version of `build.sh`, so you have to manually compile the source code.
```
$ nimble build --multimethods:on -d:release
```
Then, mark it as an executable file if necessary, and try running `slap --version`.
```
$ slap --version
SLAP 0.0.3
```
You may want to test current SLAP you just built before running your programs.
```
$ nimble test
```
## TODO
*Note:* If you have a feature request, please open an issue.
### Main
- [x] Basic Data Types
- [x] Integer
- [x] Float
- [x] String
- [x] Boolean
- [x] Null
- [x] List
- [x] Map
- [x] Basic Arithmetics
- [x] Variables
- [x] If Statements
- [x] elif
- [x] else
- [x] While Loops
- [x] For Loops
- [x] Break
- [x] Continue
- [x] "Enhanced" for loop (in the form of `forEach`)
- [ ] Try-except Blocks
- [x] Functions
- [x] Lambdas (anonymous functions)
- [x] Default Arguments
- [x] Rest Parameters
- [x] Standard Library
- [x] Std
- [x] String
- [x] OS
- [x] I/O interfaces
- [x] Math
- [ ] Networking
- [x] Classes
- [x] Class Methods
- [x] Inheritance
- [ ] Abstract Class (Interface)
- [x] Import
- [ ] Concurrency
- [ ] Virtual Machine Compiler
### Others
- [x] Assignment Shorthands (e.g, `+=`, `*=`)
- [x] String Interpolation
- [ ] Optional Type Annotations
- [x] Multi-line Comments
- [x] Vim Highlighter
- [ ] VSCode Highlighter
- [x] Transpiler (to JavaScript)
- [ ] Newline As Statement Separator
## Contribution
Bug reports and contributions are always welcome :)
Please be sure to add test files if you want to add new features (see [tests directory](https://github.com/bichanna/slap/tree/master/tests#tests) for more info).
## Credits
I learned a lot from
- [Oak programming language](https://github.com/thesephist/oak) by [thesephist](https://github.com/thesephist)
- [Bob Nystrom (munificent)](https://github.com/munificent)'s great book, [*Crafting Interpreters*](https://craftinginterpreters.com/).