diff --git a/json/lex_main.mbt b/json/lex_main.mbt index 9e290a65c..327ff3c90 100644 --- a/json/lex_main.mbt +++ b/json/lex_main.mbt @@ -30,67 +30,67 @@ fn lex_value( for ; ; { match read_char(ctx) { Some('\t' | ' ' | '\n' | '\r') => continue - Some('{') => return Ok(LBrace) - Some('[') => return Ok(LBracket) + Some('{') => break Ok(LBrace) + Some('[') => break Ok(LBracket) Some(']') => if allow_rbracket { - return Ok(RBracket) + break Ok(RBracket) } else { - return Err(invalid_char(ctx, shift=-1)) + break Err(invalid_char(ctx, shift=-1)) } Some('n') => { lex_assert_char(ctx, 'u')? lex_assert_char(ctx, 'l')? lex_assert_char(ctx, 'l')? - return Ok(Null) + break Ok(Null) } Some('t') => { lex_assert_char(ctx, 'r')? lex_assert_char(ctx, 'u')? lex_assert_char(ctx, 'e')? - return Ok(True) + break Ok(True) } Some('f') => { lex_assert_char(ctx, 'a')? lex_assert_char(ctx, 'l')? lex_assert_char(ctx, 's')? lex_assert_char(ctx, 'e')? - return Ok(False) + break Ok(False) } Some('-') => match read_char(ctx) { Some('0') => { let n = lex_zero(ctx, start=ctx.offset - 2)!! - return Ok(Number(n)) + break Ok(Number(n)) } Some(c2) => { if c2 >= '1' && c2 <= '9' { let n = lex_decimal_integer(ctx, start=ctx.offset - 2)!! - return Ok(Number(n)) + break Ok(Number(n)) } - return Err(invalid_char(ctx, shift=-1)) + break Err(invalid_char(ctx, shift=-1)) } - None => return Err(InvalidEof) + None => break Err(InvalidEof) } Some('0') => { let n = lex_zero(ctx, start=ctx.offset - 1)!! - return Ok(Number(n)) + break Ok(Number(n)) } Some('1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9') => { let n = lex_decimal_integer(ctx, start=ctx.offset - 1)!! - return Ok(Number(n)) + break Ok(Number(n)) } Some('"') => { let s = lex_string(ctx)? - return Ok(String(s)) + break Ok(String(s)) } Some(c) => { if c > '\x7f' && non_ascii_whitespace.contains(c) { continue } - return Err(invalid_char(ctx, shift=-1)) + break Err(invalid_char(ctx, shift=-1)) } - None => return Err(InvalidEof) + None => break Err(InvalidEof) } } } diff --git a/json/lex_number.mbt b/json/lex_number.mbt index 732e02863..d357b5c6a 100644 --- a/json/lex_number.mbt +++ b/json/lex_number.mbt @@ -15,16 +15,16 @@ fn lex_decimal_integer(ctx : ParseContext, ~start : Int) -> Double!ParseError { for ; ; { match read_char(ctx) { - Some('.') => return lex_decimal_point(ctx, ~start)! - Some('e' | 'E') => return lex_decimal_exponent(ctx, ~start)! + Some('.') => break lex_decimal_point(ctx, ~start)! + Some('e' | 'E') => break lex_decimal_exponent(ctx, ~start)! Some(c) => { if c >= '0' && c <= '9' { continue } ctx.offset -= 1 - return lex_number_end(ctx, start, ctx.offset)! + break lex_number_end(ctx, start, ctx.offset)! } - None => return lex_number_end(ctx, start, ctx.offset)! + None => break lex_number_end(ctx, start, ctx.offset)! } } } @@ -33,7 +33,7 @@ fn lex_decimal_point(ctx : ParseContext, ~start : Int) -> Double!ParseError { match read_char(ctx) { Some(c) => if c >= '0' && c <= '9' { - return lex_decimal_fraction(ctx, ~start)! + lex_decimal_fraction(ctx, ~start)! } else { raise invalid_char(ctx, shift=-1) } @@ -46,22 +46,22 @@ fn lex_decimal_point(ctx : ParseContext, ~start : Int) -> Double!ParseError { fn lex_decimal_fraction(ctx : ParseContext, ~start : Int) -> Double!ParseError { for ; ; { match read_char(ctx) { - Some('e' | 'E') => return lex_decimal_exponent(ctx, ~start)! + Some('e' | 'E') => break lex_decimal_exponent(ctx, ~start)! Some(c) => { if c >= '0' && c <= '9' { continue } ctx.offset -= 1 - return lex_number_end(ctx, start, ctx.offset)! + break lex_number_end(ctx, start, ctx.offset)! } - None => return lex_number_end(ctx, start, ctx.offset)! + None => break lex_number_end(ctx, start, ctx.offset)! } } } fn lex_decimal_exponent(ctx : ParseContext, ~start : Int) -> Double!ParseError { match read_char(ctx) { - Some('+') | Some('-') => return lex_decimal_exponent_sign(ctx, ~start)! + Some('+') | Some('-') => lex_decimal_exponent_sign(ctx, ~start)! Some(c) => { if c >= '0' && c <= '9' { return lex_decimal_exponent_integer(ctx, ~start)! @@ -104,26 +104,26 @@ fn lex_decimal_exponent_integer( continue } ctx.offset -= 1 - return lex_number_end(ctx, start, ctx.offset)! + break lex_number_end(ctx, start, ctx.offset)! } - None => return lex_number_end(ctx, start, ctx.offset)! + None => break lex_number_end(ctx, start, ctx.offset)! } } } fn lex_zero(ctx : ParseContext, ~start : Int) -> Double!ParseError { match read_char(ctx) { - Some('.') => return lex_decimal_point(ctx, ~start)! - Some('e' | 'E') => return lex_decimal_exponent(ctx, ~start)! + Some('.') => lex_decimal_point(ctx, ~start)! + Some('e' | 'E') => lex_decimal_exponent(ctx, ~start)! Some(c) => { if c >= '0' && c <= '9' { ctx.offset -= 1 raise invalid_char(ctx) } ctx.offset -= 1 - return lex_number_end(ctx, start, ctx.offset)! + lex_number_end(ctx, start, ctx.offset)! } - None => return lex_number_end(ctx, start, ctx.offset)! + None => lex_number_end(ctx, start, ctx.offset)! } }