Leafscript
所属分类:编程语言基础
开发工具:GO
文件大小:0KB
下载次数:0
上传日期:2022-05-18 03:56:35
上 传 者:
sh-1993
说明: 轻量级编程语言(概念证明)
(Lightweight programming language (proof of concept))
文件列表:
Examples/ (0, 2022-05-17)
Examples/Binary counter.lfs (140, 2022-05-17)
Examples/Break statement.lfs (68, 2022-05-17)
Examples/Concatenating strings.lfs (196, 2022-05-17)
Examples/Creating variables.lfs (132, 2022-05-17)
Examples/Find primes.lfs (310, 2022-05-17)
Examples/Finding factors of a number.lfs (175, 2022-05-17)
Examples/For loop.lfs (149, 2022-05-17)
Examples/Getting user input.lfs (245, 2022-05-17)
Examples/Getting variable values.lfs (209, 2022-05-17)
Examples/If statement.lfs (177, 2022-05-17)
LICENSE (1066, 2022-05-17)
go.mod (127, 2022-05-17)
go.sum (459, 2022-05-17)
main.go (932, 2022-05-17)
supporting/ (0, 2022-05-17)
supporting/doconcat.go (739, 2022-05-17)
supporting/domath.go (569, 2022-05-17)
supporting/dostring.go (343, 2022-05-17)
supporting/for.go (1228, 2022-05-17)
supporting/if.go (1663, 2022-05-17)
supporting/input.go (200, 2022-05-17)
supporting/lexer.go (2988, 2022-05-17)
supporting/print.go (577, 2022-05-17)
supporting/readfile.go (642, 2022-05-17)
supporting/variables.go (2473, 2022-05-17)
# 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 line
No 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 = 0
for x math number
var y = 0
for i math x
if math x%i == 0
var y = math y+1
endif
endfor
if math y < 2
print concat math x & " is prime"
var total = math total+1
endif
endfor
print 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
近期下载者:
相关文件:
收藏者: