mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 15:18:49 +00:00
Make core:odin use a string for the source rather than []byte
This commit is contained in:
@@ -69,7 +69,7 @@ File :: struct {
|
|||||||
pkg: ^Package,
|
pkg: ^Package,
|
||||||
|
|
||||||
fullpath: string,
|
fullpath: string,
|
||||||
src: []byte,
|
src: string,
|
||||||
|
|
||||||
docs: ^Comment_Group,
|
docs: ^Comment_Group,
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ collect_package :: proc(path: string) -> (pkg: ^ast.Package, success: bool) {
|
|||||||
}
|
}
|
||||||
file := ast.new(ast.File, NO_POS, NO_POS);
|
file := ast.new(ast.File, NO_POS, NO_POS);
|
||||||
file.pkg = pkg;
|
file.pkg = pkg;
|
||||||
file.src = src;
|
file.src = string(src);
|
||||||
file.fullpath = fullpath;
|
file.fullpath = fullpath;
|
||||||
pkg.files[fullpath] = file;
|
pkg.files[fullpath] = file;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ Flags :: distinct bit_set[Flag; u32];
|
|||||||
Tokenizer :: struct {
|
Tokenizer :: struct {
|
||||||
// Immutable data
|
// Immutable data
|
||||||
path: string,
|
path: string,
|
||||||
src: []byte,
|
src: string,
|
||||||
err: Error_Handler,
|
err: Error_Handler,
|
||||||
|
|
||||||
flags: Flags,
|
flags: Flags,
|
||||||
@@ -31,7 +31,7 @@ Tokenizer :: struct {
|
|||||||
error_count: int,
|
error_count: int,
|
||||||
}
|
}
|
||||||
|
|
||||||
init :: proc(t: ^Tokenizer, src: []byte, path: string, err: Error_Handler = default_error_handler) {
|
init :: proc(t: ^Tokenizer, src: string, path: string, err: Error_Handler = default_error_handler) {
|
||||||
t.src = src;
|
t.src = src;
|
||||||
t.err = err;
|
t.err = err;
|
||||||
t.ch = ' ';
|
t.ch = ' ';
|
||||||
@@ -87,7 +87,7 @@ advance_rune :: proc(using t: ^Tokenizer) {
|
|||||||
case r == 0:
|
case r == 0:
|
||||||
error(t, t.offset, "illegal character NUL");
|
error(t, t.offset, "illegal character NUL");
|
||||||
case r >= utf8.RUNE_SELF:
|
case r >= utf8.RUNE_SELF:
|
||||||
r, w = utf8.decode_rune(src[read_offset:]);
|
r, w = utf8.decode_rune_in_string(src[read_offset:]);
|
||||||
if r == utf8.RUNE_ERROR && w == 1 {
|
if r == utf8.RUNE_ERROR && w == 1 {
|
||||||
error(t, t.offset, "illegal UTF-8 encoding");
|
error(t, t.offset, "illegal UTF-8 encoding");
|
||||||
} else if r == utf8.RUNE_BOM && offset > 0 {
|
} else if r == utf8.RUNE_BOM && offset > 0 {
|
||||||
|
|||||||
Reference in New Issue
Block a user