language: add unary plus & minus, post increment & decrement operators, non-newline print builtin. fix block comments (#4)

This commit is contained in:
a dinosaur authored and GitHub committed 2023-09-11 00:34:10 -04:00
1 parent c3afd790b5
commit 8d310e337a
18 files changed
+235 -32

No files matched your search

+20
View File
@@ -0,0 +1,20 @@
/* Barber shop sign generator! */
func generatePole(width, height) {
var i = 0
while i < height {
let index = i++ mod width
var j = 0
while j < width {
if j == index { print("#") } else { print("_") }
j++
}
println()
}
}
export func main() {
println("nobody:")
println()
println("barber pole:")
generatePole(6, 18)
}
+6
View File
@@ -0,0 +1,6 @@
export func main() {
let constant = -42
println("constant set by unary minus: ", constant)
println("constant modified by unary minus:", -constant)
println("constant modified by unary plus: ", +constant)
}