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:
@@ -1,2 +1,2 @@
|
||||
var a = a == null
|
||||
IO.write(a) // expect: true
|
||||
IO.print(a) // expect: true
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
var a
|
||||
IO.write(a) // expect: null
|
||||
IO.print(a) // expect: null
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// skip: Variables should not be in scope in their initializer.
|
||||
{
|
||||
var a = a + 1 // expect error
|
||||
IO.write(a)
|
||||
IO.print(a)
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
class Foo {
|
||||
bar {
|
||||
var a = "a"
|
||||
IO.write(a) // expect: a
|
||||
IO.print(a) // expect: a
|
||||
var b = a + " b"
|
||||
IO.write(b) // expect: a b
|
||||
IO.print(b) // expect: a b
|
||||
var c = a + " c"
|
||||
IO.write(c) // expect: a c
|
||||
IO.print(c) // expect: a c
|
||||
var d = b + " d"
|
||||
IO.write(d) // expect: a b d
|
||||
IO.print(d) // expect: a b d
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
var a = "outer"
|
||||
{
|
||||
IO.write(a) // expect: outer
|
||||
IO.print(a) // expect: outer
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
{
|
||||
var a
|
||||
IO.write(a) // expect: null
|
||||
IO.print(a) // expect: null
|
||||
}
|
||||
|
||||
@@ -255,5 +255,5 @@
|
||||
var a253 = a252
|
||||
var a254 = a253
|
||||
var a255 = a254
|
||||
IO.write(a255) // expect: value
|
||||
IO.print(a255) // expect: value
|
||||
}
|
||||
|
||||
@@ -259,7 +259,7 @@
|
||||
var a253 = a252
|
||||
var a254 = a253
|
||||
var a255 = a254
|
||||
IO.write(a255) // expect: value a
|
||||
IO.print(a255) // expect: value a
|
||||
}
|
||||
|
||||
{
|
||||
@@ -519,6 +519,6 @@
|
||||
var b253 = b252
|
||||
var b254 = b253
|
||||
var b255 = b254
|
||||
IO.write(b255) // expect: value b
|
||||
IO.print(b255) // expect: value b
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,11 +3,11 @@ var a = "out"
|
||||
if (true) {
|
||||
var a = "in"
|
||||
}
|
||||
IO.write(a) // expect: out
|
||||
IO.print(a) // expect: out
|
||||
|
||||
// Create a local scope for the 'else' expression.
|
||||
var b = "out"
|
||||
if (false) "dummy" else {
|
||||
var b = "in"
|
||||
}
|
||||
IO.write(b) // expect: out
|
||||
IO.print(b) // expect: out
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
{
|
||||
var a = "first"
|
||||
IO.write(a) // expect: first
|
||||
IO.print(a) // expect: first
|
||||
}
|
||||
|
||||
{
|
||||
var a = "second"
|
||||
IO.write(a) // expect: second
|
||||
IO.print(a) // expect: second
|
||||
}
|
||||
|
||||
@@ -4,4 +4,4 @@ var i = 0
|
||||
while ((i = i + 1) <= 1) {
|
||||
var a = "inner"
|
||||
}
|
||||
IO.write(a) // expect: outer
|
||||
IO.print(a) // expect: outer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
{
|
||||
var a = "outer"
|
||||
{
|
||||
IO.write(a) // expect: outer
|
||||
IO.print(a) // expect: outer
|
||||
var a = "inner"
|
||||
IO.write(a) // expect: inner
|
||||
IO.print(a) // expect: inner
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
var a = "global"
|
||||
{
|
||||
var a = "shadow"
|
||||
IO.write(a) // expect: shadow
|
||||
IO.print(a) // expect: shadow
|
||||
}
|
||||
IO.write(a) // expect: global
|
||||
IO.print(a) // expect: global
|
||||
@@ -3,6 +3,6 @@
|
||||
var a = "outer"
|
||||
{
|
||||
var a = a + " inner"
|
||||
IO.write(a) // expect: outer inner
|
||||
IO.print(a) // expect: outer inner
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
var a = "local"
|
||||
{
|
||||
var a = "shadow"
|
||||
IO.write(a) // expect: shadow
|
||||
IO.print(a) // expect: shadow
|
||||
}
|
||||
IO.write(a) // expect: local
|
||||
IO.print(a) // expect: local
|
||||
}
|
||||
@@ -1 +1 @@
|
||||
IO.write(notDefined) // expect error
|
||||
IO.print(notDefined) // expect error
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
fn {
|
||||
IO.write(notDefined) // expect error
|
||||
IO.print(notDefined) // expect error
|
||||
}.call
|
||||
|
||||
Reference in New Issue
Block a user