slap
slap copied to clipboard
🖐 A dynamically- and strongly-typed, object-oriented programming language
The SLAP Programming Language
| Doc |WARNING!! THIS LANGUAGE IS IN DEVELOPMENT (AND FOR LEARNING PURPOSES). ANYTHING CAN CHANGE AT ANY MOMENT.
🖐 SLAP stands for "SLow And Powerless." And I hope to make it "Powerful" 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).
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 for more info).
Credits
I learned a lot from
- Oak programming language by thesephist
- Bob Nystrom (munificent)'s great book, Crafting Interpreters.