Release v0.7.0
It has been a long time since the last release, and as such, a lot of progress has been made, including upgrades to the LLVM backend, a new C backend, new language features, and a lot of bug fixes. Let's begin!
Upgrade to LLVM 13
LLVM 13 is now required to build Skull. Previously it was using LLVM 10, which is widely supported, but has less features compared to the newer versions.
Fix order of operations
The expression AST parser has been rewritten to respect order of operations. Previously, expressions where evaluated right-to-left, and had no concept of operator precedence. Now, everything is evaluated left-to-right, and an operator precedence system (similar, but different to C) has been introduced.
Add new C backend
Skull pograms can now be compiled into C code, which can be compiled on (almost) any system. Simply use the --c-backend
flag to enable:
$ skull file.sk --c-backend
# this will output a file called ".file.sk.c", which can be changed with the -o flag
Add optimization flags for LLVM backend
The -O1
, -O2
, and -O3
flags (similar to GCC/Clang) has been added, which allows for optimizing Skull code using LLVM's vast suite of optimization passes:
$ cat tmp.sk
f(x: Int) Int {
if x is 0 {
return 0
}
return x + f(x - 1)
}
return f(3)
$ skull tmp.sk -E -O2
; ModuleID = 'tmp.sk'
source_filename = "tmp.sk"
; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn
define i64 @.tmp() local_unnamed_addr #0 {
entry:
ret i64 6
}
attributes #0 = { mustprogress nofree norecurse nosync nounwind readnone willreturn }
Here, LLVM is smart enough to evaluate f(3)
, despite f
being a recursive function (it is tail-recursive, since the call to f
is at the end, but still very cool).
Add LLVM debug information
Debug info can now be turned on via the -g
flag, which adds line/column info to statements, functions, expressions, and if/elif/else/while blocks. Debug info is currently not available for the C backend.
Add break
and continue
statements
Both the C and LLVM backends now support the break
and continue
statements in while loops.
while true {
if true {
break
}
else {
continue
}
}
Add noop
statement
Since if/while/function blocks are no longer allowed to be empty, a new noop statement has been added to explicitly state that nothing should happen. It is similar to Python's pass
statement, and it basically does nothing.
# A dummy function
f() { noop }
f()
Add NaN
NaN
(not a number) is now a built-in floating point literal.
Lots of minor improvements
- Add
--help
and--version
long options - Add
--werror
flag to turn all warnings into errors - Emit error when output file is a directory
- Emit warning when file starts with BOM
- Emit warning when function is unused
- Emit warning when explicit types can be trivially deduced
- Emit warning if condition is always true/false
- Emit warning when variables should be const, or is unused
- Add ability to export constant variables
export pi := 3.1415
- Add COLOR environment variable to enable colored errors
- Allow for comments and unreachable statements after return
- Allow for long hex escapes
emoji := "\x1F480"
- Allow for booleans in
is
operator
x := true is false