Lioness • Cub • SavannaKit
Lioness is a high-level, dynamic, programming language designed for mathematical purposes. This project includes a lexer, parser, compiler and interpreter. All of these are 100% written in Swift without dependencies.
The syntax of Lioness is inspired by Swift, and its feature set is akin to shader languages such as GLSL.
The standard library (abbreviated: stdlib) contains basic functions for number manipulation, including: max/min, ceil, floor, trigonometry, etc. However, more trivial functions, such as to calculate prime numbers, are not considered relevant for the standard library.
The following Lioness code calculates factorials recursively:
func factorial(x) returns {
if x > 1 {
return x * factorial(x - 1)
}
return 1
}
a = factorial(5) // a = 120
The following Lioness code uses a do times
loop:
a = 1
n = 10
do n times {
a += a
}
// a = 1024
More examples can be found here.
+
, -
, /
, *
and ^
^
means "to the power of", e.g. 2^10
equals 1024+=
for +
true
or false
for
while
do times
repeat while
break
continue
if
/ else
/ else if
statementsSince the project does not rely on any dependencies, running it requires no setup.
Open Lioness.xcworkspace
(preferably in the latest non-beta version of Xcode) and run the macOS Example
target. The example will run the code in A.lion
. The output will be printed to the console.
Add to your Package.swift
file's dependencies
section:
.Package(url: "https://github.com/louisdh/lioness.git",
majorVersion: 0, minor: 5)
Add the following line to your Podfile
:
pod 'Lioness', '~> 0.5'
Add the following line to your Cartfile
:
github "louisdh/lioness" ~> 0.5
Run carthage update
to build the framework and drag the built Lioness.framework
into your Xcode project.
Please note: Lioness is currently in beta
The Standard Library is currently under active development. There currently is no one document with everything from the stdlib. The best place to look for what's available is in the source files.
guard
statementLioness source files can easily be created with Xcode, see XcodeTemplate.md for instructions.
A detailed explanation of the project's architecture can be found here.
This project is available under the MIT license. See the LICENSE file for more info.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。