diff --git a/json/internal_types.mbt b/json/internal_types.mbt index 89653efbb5..9d48099be8 100644 --- a/json/internal_types.mbt +++ b/json/internal_types.mbt @@ -33,32 +33,6 @@ fn ParseContext::make( } } -///| -priv struct CharClass(Array[(Char, Char)]) - -///| -fn CharClass::of(array : Array[(Char, Char)]) -> CharClass { - CharClass(array) -} - -///| -fn CharClass::contains(self : CharClass, c : Char) -> Bool { - let CharClass(self) = self - for left = 0, right = self.length(); left < right; { - let middle = (left + right) / 2 - let (min, max) = self[middle] - if c < min { - continue left, middle - } else if c > max { - continue middle + 1, right - } else { - break true - } - } else { - false - } -} - ///| priv enum Token { Null diff --git a/json/internal_types_wbtest.mbt b/json/internal_types_wbtest.mbt deleted file mode 100644 index eee8f0e2e2..0000000000 --- a/json/internal_types_wbtest.mbt +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2026 International Digital Economy Academy -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -///| -test "CharClass::contains/simple_case" { - let char_class = CharClass::of([('a', 'z')]) - inspect(char_class.contains('a'), content=true) - inspect(char_class.contains('m'), content=true) - inspect(char_class.contains('z'), content=true) - inspect(char_class.contains('A'), content=false) -} - -///| -test "CharClass::contains/multiple_ranges" { - let char_class = CharClass::of([('a', 'f'), ('m', 'r'), ('x', 'z')]) - inspect(char_class.contains('a'), content=true) - inspect(char_class.contains('p'), content=true) - inspect(char_class.contains('y'), content=true) - inspect(char_class.contains('g'), content=false) - inspect(char_class.contains('w'), content=false) -} - -///| -test "CharClass::contains/boundary_case" { - let char_class = CharClass::of([('a', 'c'), ('e', 'h')]) - inspect(char_class.contains('a'), content=true) - inspect(char_class.contains('c'), content=true) - inspect(char_class.contains('e'), content=true) - inspect(char_class.contains('h'), content=true) - inspect(char_class.contains('d'), content=false) -} diff --git a/json/lex_main.mbt b/json/lex_main.mbt index 8d9ff1c91c..85df30256f 100644 --- a/json/lex_main.mbt +++ b/json/lex_main.mbt @@ -12,18 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -///| -let non_ascii_whitespace : CharClass = CharClass::of([ - ('\u00A0', '\u00A0'), - ('\u1680', '\u1680'), - ('\u2000', '\u200A'), - ('\u2028', '\u2029'), - ('\u202F', '\u202F'), - ('\u205F', '\u205F'), - ('\u3000', '\u3000'), - ('\uFEFF', '\uFEFF'), -]) - ///| fn ParseContext::lex_value( ctx : ParseContext, @@ -87,9 +75,6 @@ fn ParseContext::lex_value( return String(s) } Some(c) => { - if c > '\u{7f}' && non_ascii_whitespace.contains(c) { - continue - } let shift = -c.utf16_len() ctx.invalid_char(shift~) } diff --git a/json/lex_misc.mbt b/json/lex_misc.mbt index 577606d073..21ae9e3bef 100644 --- a/json/lex_misc.mbt +++ b/json/lex_misc.mbt @@ -118,10 +118,7 @@ fn ParseContext::lex_skip_whitespace(ctx : ParseContext) -> Unit { for { match ctx.read_char() { Some('\t' | ' ' | '\n' | '\r') => continue - Some(c) => { - if c > '\u{7f}' && non_ascii_whitespace.contains(c) { - continue - } + Some(_) => { ctx.offset -= 1 break } diff --git a/json/parse_error_test.mbt b/json/parse_error_test.mbt index 7e81dd83c2..eda65f3494 100644 --- a/json/parse_error_test.mbt +++ b/json/parse_error_test.mbt @@ -24,7 +24,9 @@ test "parse error branches" { guard (try? @json.parse("nullx")) is Err(InvalidChar(_, _)) else { fail("expected InvalidChar for trailing data") } - inspect(@json.parse("\u{00A0}null"), content="Null") + guard (try? @json.parse("\u{00A0}null")) is Err(InvalidChar(_, _)) else { + fail("expected InvalidChar for leading non-breaking space") + } guard (try? @json.parse("tx")) is Err(InvalidChar(_, _)) else { fail("expected InvalidChar for invalid literal") } diff --git a/json/parse_test.mbt b/json/parse_test.mbt index d89a90778f..cfe93ab2c6 100644 --- a/json/parse_test.mbt +++ b/json/parse_test.mbt @@ -222,7 +222,7 @@ test "parses escaped characters" { ///| test "parses whitespace" { - let json = test_parse("{\t \u00A0\uFEFF\n\r\u2028\u2029\u2003}") + let json = test_parse("{\t \n\r}") assert_eq(json, Json::object({})) } //endregion