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
+2 -2
View File
@@ -11,6 +11,6 @@ class Foo {
}
var foo = new Foo
IO.write(foo.closeOverGet.call) // expect: Foo field
IO.print(foo.closeOverGet.call) // expect: Foo field
foo.closeOverSet.call
IO.write(foo.closeOverGet.call) // expect: new value
IO.print(foo.closeOverGet.call) // expect: new value
+1 -1
View File
@@ -1,5 +1,5 @@
class Foo {
write { IO.write(_field) }
write { IO.print(_field) }
}
(new Foo).write // expect: null
+5 -5
View File
@@ -8,11 +8,11 @@ class Foo {
}
write {
IO.write(_a)
IO.write(_b)
IO.write(_c)
IO.write(_d)
IO.write(_e)
IO.print(_a)
IO.print(_b)
IO.print(_c)
IO.print(_d)
IO.print(_e)
}
}
+3 -3
View File
@@ -1,17 +1,17 @@
class Outer {
method {
_field = "outer"
IO.write(_field) // expect: outer
IO.print(_field) // expect: outer
class Inner {
method {
_field = "inner"
IO.write(_field) // expect: inner
IO.print(_field) // expect: inner
}
}
(new Inner).method
IO.write(_field) // expect: outer
IO.print(_field) // expect: outer
}
}
+1 -1
View File
@@ -11,7 +11,7 @@ class Node {
_left.write
}
IO.write(_value)
IO.print(_value)
if (_right is Node) {
_right.write
+1 -1
View File
@@ -1,5 +1,5 @@
class Foo {
write { IO.write(_field) } // Compile a use of the field...
write { IO.print(_field) } // Compile a use of the field...
init { _field = "value" } // ...before an assignment to it.
}