Optimization of string and vector with references and less functional code, bugfix of closing over references

This commit is contained in:
Nathan Braswell
2015-08-04 14:57:56 -04:00
parent d59cb5e252
commit e1dbe08c0a
8 changed files with 67 additions and 42 deletions

View File

@@ -0,0 +1,2 @@
9
9

View File

@@ -0,0 +1,17 @@
import io:*
fun func(it: ref int) {
it++
fun() {
it++
println(it)
}()
}
fun main(): int {
var it = 7
func(it)
println(it)
return 0
}

View File

@@ -7,7 +7,7 @@ import symbol:*
fun main():int {
/*var a = load_grammer(read_file(string("../krakenGrammer.kgm")))*/
//var a = load_grammer(read_file(string("../krakenGrammer.kgm")))
/*var a = load_grammer(read_file(string("grammer.kgm")))*/
var a = load_grammer(read_file(string("grammer2.kgm")))
println(a.to_string())
@@ -42,9 +42,9 @@ fun main():int {
/*lex.set_input(read_file(string("test_grammer.krak")))*/
/*lex.set_input(string("ccdahas spacedhas*/
/*returndaaaaaaaaaaaaaa"))*/
lex.set_input(string("hibyed"))
//lex.set_input(string("hibyed"))
println("woo lexing:")
range(8).for_each(fun(i: int) { println(lex.next().to_string()); } )
//range(8).for_each(fun(i: int) { println(lex.next().to_string()); } )
/*range(80).for_each(fun(i: int) { println(lex.next().to_string()); } )*/
println(a.to_string())
a.calculate_state_automaton()

View File

@@ -66,38 +66,26 @@ Copied: 303 to 304
Destroyed: 303
Destroyed: 302
Copied: 104 to 105
Copied: 105 to 106
Destroyed: 105
Copied: 204 to 205
Copied: 205 to 206
Destroyed: 205
Copied: 304 to 305
Copied: 305 to 306
Destroyed: 305
Destroyed: 104
Destroyed: 204
Destroyed: 304
Destroyed: 301
Destroyed: 201
Destroyed: 101
Copied: 106 to 107
Copied: 107 to 108
Destroyed: 107
Copied: 206 to 207
Copied: 207 to 208
Destroyed: 207
Copied: 306 to 307
Copied: 307 to 308
Destroyed: 307
Destroyed: 106
Copied: 105 to 106
Copied: 205 to 206
Copied: 305 to 306
Destroyed: 105
Destroyed: 205
Destroyed: 305
Destroyed: 206
Copied: 306 to 307
Destroyed: 306
Destroyed: 208
Copied: 308 to 309
Destroyed: 308
done
Destroyed: 108
Destroyed: 309
Destroyed: 106
Destroyed: 307
Destroyed: 300
Destroyed: 200
Destroyed: 100