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
+3 -3
View File
@@ -4,6 +4,6 @@ var c = "c"
// Assignment is right-associative.
a = b = c
IO.write(a) // expect: c
IO.write(b) // expect: c
IO.write(c) // expect: c
IO.print(a) // expect: c
IO.print(b) // expect: c
IO.print(c) // expect: c
+4 -4
View File
@@ -1,8 +1,8 @@
var a = "before"
IO.write(a) // expect: before
IO.print(a) // expect: before
a = "after"
IO.write(a) // expect: after
IO.print(a) // expect: after
IO.write(a = "arg") // expect: arg
IO.write(a) // expect: arg
IO.print(a = "arg") // expect: arg
IO.print(a) // expect: arg
+4 -4
View File
@@ -1,10 +1,10 @@
fn {
var a = "before"
IO.write(a) // expect: before
IO.print(a) // expect: before
a = "after"
IO.write(a) // expect: after
IO.print(a) // expect: after
IO.write(a = "arg") // expect: arg
IO.write(a) // expect: arg
IO.print(a = "arg") // expect: arg
IO.print(a) // expect: arg
}.call
+4 -4
View File
@@ -2,10 +2,10 @@
var a = "a"
var b = "b"
a = b = "chain"
IO.write(a) // expect: chain
IO.write(a) // expect: chain
IO.print(a) // expect: chain
IO.print(a) // expect: chain
// Assignment on RHS of variable.
var c = a = "var"
IO.write(a) // expect: var
IO.write(c) // expect: var
IO.print(a) // expect: var
IO.print(c) // expect: var