feat: rename IO.write to IO.print and add Unicode escape support in strings

Rename the IO.write method to IO.print, which now prints without a trailing newline, and add a new IO.print method that appends a newline after output. Update all benchmark, example, and test files to use IO.print instead of IO.write. Additionally, implement Unicode escape sequence parsing in the compiler's string tokenizer, supporting \uXXXX and \u{...} syntax with proper UTF-8 encoding for code points up to U+10FFFF.
This commit is contained in:
Bob Nystrom
2014-01-05 20:27:12 +00:00
parent e23e0ce6a3
commit c72db7d594
159 changed files with 1690 additions and 1599 deletions
+4 -4
View File
@@ -4,15 +4,15 @@ var g = null
{
var local = "local"
f = fn {
IO.write(local)
IO.print(local)
local = "after f"
IO.write(local)
IO.print(local)
}
g = fn {
IO.write(local)
IO.print(local)
local = "after g"
IO.write(local)
IO.print(local)
}
}
@@ -2,7 +2,7 @@ var f = null
fn(param) {
f = fn {
IO.write(param)
IO.print(param)
}
}.call("param")
@@ -3,7 +3,7 @@ var f = null
class Foo {
method(param) {
f = fn {
IO.write(param)
IO.print(param)
}
}
}
+1 -1
View File
@@ -3,7 +3,7 @@ var f = null
{
var local = "local"
f = fn {
IO.write(local)
IO.print(local)
}
}
+1 -1
View File
@@ -4,7 +4,7 @@ var foo = null
var local = "local"
class Foo {
method {
IO.write(local)
IO.print(local)
}
}
+3 -3
View File
@@ -7,9 +7,9 @@ fn {
fn {
var c = "c"
f = fn {
IO.write(a)
IO.write(b)
IO.write(c)
IO.print(a)
IO.print(b)
IO.print(c)
}
}.call
}.call
+1 -1
View File
@@ -1,6 +1,6 @@
{
var local = "local"
fn {
IO.write(local) // expect: local
IO.print(local) // expect: local
}.call
}
+1 -1
View File
@@ -2,7 +2,7 @@
var local = "local"
class Foo {
method {
IO.write(local)
IO.print(local)
}
}
@@ -3,8 +3,8 @@ var f = null
{
var a = "a"
f = fn {
IO.write(a)
IO.write(a)
IO.print(a)
IO.print(a)
}
}
+1 -1
View File
@@ -3,7 +3,7 @@
{
var a = "a"
f = fn IO.write(a)
f = fn IO.print(a)
}
{
+1 -1
View File
@@ -2,5 +2,5 @@ var global = "global"
// TODO: Forward reference to global declared after use.
fn {
IO.write(global) // expect: global
IO.print(global) // expect: global
}.call
+2 -2
View File
@@ -3,11 +3,11 @@ var global = "global"
class Foo {
method {
IO.write(global)
IO.print(global)
}
static classMethod {
IO.write(global)
IO.print(global)
}
}