Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 0 additions & 26 deletions json/internal_types.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
42 changes: 0 additions & 42 deletions json/internal_types_wbtest.mbt

This file was deleted.

15 changes: 0 additions & 15 deletions json/lex_main.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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~)
}
Expand Down
5 changes: 1 addition & 4 deletions json/lex_misc.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
4 changes: 3 additions & 1 deletion json/parse_error_test.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
2 changes: 1 addition & 1 deletion json/parse_test.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down