json(vm): fix birth dispatch; unify constructor naming (Box.birth/N); JsonNode factories return JsonNodeInstance; quick: enable heavy JSON with probe; builder: NYASH_BUILDER_DEBUG_LIMIT guard; json_query_min(core) harness; docs/tasks updated
This commit is contained in:
@ -24,6 +24,15 @@ box JsonScanner {
|
||||
me.line = 1
|
||||
me.column = 1
|
||||
}
|
||||
|
||||
// Runtime-safe initializer (bypass constructor arg loss on some VM paths)
|
||||
reset_text(input_text) {
|
||||
me.text = input_text
|
||||
me.position = 0
|
||||
me.length = input_text.length()
|
||||
me.line = 1
|
||||
me.column = 1
|
||||
}
|
||||
|
||||
// ===== 基本読み取りメソッド =====
|
||||
|
||||
@ -233,6 +242,10 @@ box JsonScanner {
|
||||
// 整数部分
|
||||
if me.current() == "0" {
|
||||
me.advance()
|
||||
// 先頭0の直後に数字が続くのは無効(例: 01)
|
||||
if me.is_digit_char(me.current()) {
|
||||
return null
|
||||
}
|
||||
} else {
|
||||
if me.is_digit_char(me.current()) {
|
||||
loop(not me.is_eof() and me.is_digit_char(me.current())) {
|
||||
@ -312,7 +325,10 @@ box JsonScanner {
|
||||
i = i + 1
|
||||
}
|
||||
} else {
|
||||
// 通常のエスケープ
|
||||
// 通常のエスケープ(\" \\ \/ \b \f \n \r \t のみ)
|
||||
if not (escaped == "\"" or escaped == "\\" or escaped == "/" or escaped == "b" or escaped == "f" or escaped == "n" or escaped == "r" or escaped == "t") {
|
||||
return null
|
||||
}
|
||||
me.advance()
|
||||
}
|
||||
} else {
|
||||
|
||||
@ -15,7 +15,8 @@ box JsonTokenizer {
|
||||
birth(input_text) {
|
||||
// Avoid static module wrapper to ensure constructor args are preserved on VM path
|
||||
// (create_scanner(...) lost the argument under VM fallback in some cases)
|
||||
me.scanner = new JsonScanner(input_text)
|
||||
me.scanner = new JsonScanner("")
|
||||
me.scanner.reset_text(input_text)
|
||||
me.tokens = new ArrayBox()
|
||||
me.errors = new ArrayBox()
|
||||
}
|
||||
@ -60,6 +61,14 @@ box JsonTokenizer {
|
||||
|
||||
return me.tokens
|
||||
}
|
||||
|
||||
// Explicitly set input text (guards against constructor-arg loss)
|
||||
set_input(input_text) {
|
||||
if me.scanner == null {
|
||||
me.scanner = new JsonScanner("")
|
||||
}
|
||||
me.scanner.reset_text(input_text)
|
||||
}
|
||||
|
||||
// 次のトークンを1つ取得
|
||||
next_token() {
|
||||
|
||||
Reference in New Issue
Block a user