Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/odddollar/Leafscript
Lightweight programming language (proof of concept)
https://github.com/odddollar/Leafscript
Last synced: 5 days ago
JSON representation
Lightweight programming language (proof of concept)
- Host: GitHub
- URL: https://github.com/odddollar/Leafscript
- Owner: odddollar
- License: mit
- Created: 2020-09-22T11:39:06.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2022-05-18T03:56:35.000Z (over 2 years ago)
- Last Synced: 2024-08-01T19:55:25.657Z (3 months ago)
- Language: Go
- Homepage:
- Size: 769 KB
- Stars: 28
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-programming-languages - Leafscript - Leafscript is a lightweight programming language created as a proof of concept by someone with no idea how to write a language. It's written entirely in Golang, and was inspired by the speed and simplicity of Lua. (Uncategorized / Uncategorized)
README
# Leafscript
Leafscript is a lightweight programming language created as a proof of concept by someone with no idea how to write a language.
It's written entirely in Golang, and was inspired by the speed and simplicity of Lua. It can be compiled from source to a binary .exe file using the command: ```go build Leafscipt```## Usage
Programs can be run from the command line using the Leafscript binary file.```leafscript --run [PATH TO .lfs FILE] --debug [SET TO FALSE BY DEFAULT]```
E.g.
```leafscript --run program.lfs```
Includes a basic debugger that prints a list of all variables every line. E.g.
```leafscript --run program.lfs --debug true```
## Features
It supports:
- Creating and modifying variables (strings, ints and floats)
- Performing mathematical operations on numeric variables
- String concatenation
- For loops
- If/else statements
- Breaks in for loops
- Nested if/for
- Basic debugging mode that prints all variables every lineNo plans to implement in near future
- Array variables
- Error messages## Examples
***Ensure tabs are used to indent and not spaces. Spaces do not work***
Additional language examples are contained within the "Examples" file
#### Find all the factors of a number
```
var number = inputint "Enter a number to find factors of: "for x math number+1
if math number%x == 0
print concat math x & " is a factor of " & math number
endif
endfor
```#### Print all binary numbers from 0 to 15
```
for x 2
for y 2
for z 2
for i 2
print concat math x & " " & math y & " " & math z & " " & math i
endfor
endfor
endfor
endfor
```#### Print all primes up to a given number
```
var number = inputint "Enter a number to find primes up to: "
var total = 0for x math number
var y = 0
for i math x
if math x%i == 0
var y = math y+1
endif
endforif math y < 2
print concat math x & " is prime"
var total = math total+1
endif
endforprint concat math total & " primes found"
```## Changelog
#### v1.0
- Initial release
#### v1.1
- Modified command line interface to use more robust argparse library
- Added ability to package .lfs files to .exe using PackageFile.exe#### v1.1.1
- Fixed imports
#### v1.2
- Removed poor implementation of packaging files to binary