New kraken with import and #lang passed start symbol

This commit is contained in:
Nathan Braswell
2021-01-02 13:55:07 -05:00
parent 4ed9af307f
commit 6c0a46099a
4 changed files with 53 additions and 43 deletions

View File

@@ -1,38 +1,41 @@
#lang (with_import "./new_kraken.kp" new_kraken_untyped)
{
let my_var = 1337
(println $"this is string interpolation: $(+ 1 3 4) <- cool right? another $my_var yep even variables")
#lang (with_import "./new_kraken.kp" new_kraken_untyped) new_kraken_start_symbol
obj Point( x y ) {
add |self other| { Point((+ self.x other.x) (+ self.y other.y)) }
sub |self other| { Point((- self.x other.x) (- self.y other.y)) }
to_str |self| { str("x: " self.x ", y: " self.y) }
}
let my_var = 1337
(println $"this is string interpolation: $(+ 1 3 4) <- cool right? another $my_var yep even variables")
fun say_hi(name) {
println("hayo" name)
}
fun test() {
let plus_1 = |x| (+ x 1)
let a = 1
let b = plus_1(a)
println("some" b)
say_hi("Marcus")
let p1 = Point(1 2)
let p2 = Point(3 4)
let p3 = p1.add(p2)
let p4 = p1.sub(p2)
say_hi("Charlie/Betty")
println("p1:" p1.to_str)
println("p2:" p2.to_str)
println("p3:" p3.to_str)
println("p4:" p4.to_str)
(+ a b)
}
println("Test result is" test())
obj Point( x y ) {
add |self other| { Point((+ self.x other.x) (+ self.y other.y)) }
sub |self other| { Point((- self.x other.x) (- self.y other.y)) }
to_str |self| { str("x: " self.x ", y: " self.y) }
}
fun say_hi(name) {
println("hayo" name)
}
fun test() {
let plus_1 = |x| (+ x 1)
let a = 1
let b = plus_1(a)
println("some" b)
say_hi("Marcus")
let p1 = Point(1 2)
let p2 = Point(3 4)
let p3 = p1.add(p2)
let p4 = p1.sub(p2)
say_hi("Charlie/Betty")
println("p1:" p1.to_str)
println("p2:" p2.to_str)
println("p3:" p3.to_str)
println("p4:" p4.to_str)
println("before + a b" (+ a b))
(with_import "./import_test.kp" (println "after + a b" (+ a b)))
println("post after + a b" (+ a b))
with_import "./import_test.kp":
println("post new impot after + a b" (+ a b))
}
println("Test result is" test())