Skip to content

Commit f33e750

Browse files
Lenny222marijnh
authored andcommitted
---
yaml --- r: 6911 b: refs/heads/master c: 6f5a0a3 h: refs/heads/master i: 6909: 0fb3fa0 6907: c6ba643 6903: e53803a 6895: 5a713b2 6879: 6598ac3 6847: 90af989 6783: 0d2cd6f 6655: 3940b4b v: v3
1 parent 8b4a2d8 commit f33e750

File tree

5 files changed

+21
-10
lines changed

5 files changed

+21
-10
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 047b02d5bc2675dd993aa2378703cba34a0e35bc
2+
refs/heads/master: 6f5a0a3b3ba6fc444ce722049cadcfb26a96dc35

trunk/src/comp/syntax/parse/parser.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -910,13 +910,10 @@ fn parse_bottom_expr(p: parser) -> @ast::expr {
910910
ex = ast::expr_fail(some(e));
911911
} else { ex = ast::expr_fail(none); }
912912
} else if eat_word(p, "log_full") {
913-
expect(p, token::LPAREN);
914913
let lvl = parse_expr(p);
915-
expect(p, token::COMMA);
916914
let e = parse_expr(p);
917915
ex = ast::expr_log(2, lvl, e);
918-
hi = p.get_hi_pos();
919-
expect(p, token::RPAREN);
916+
hi = e.span.hi;
920917
} else if eat_word(p, "log") {
921918
let e = parse_expr(p);
922919
ex = ast::expr_log(1, mk_lit_u32(p, 1u32), e);

trunk/src/comp/syntax/print/pprust.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -919,12 +919,8 @@ fn print_expr(s: ps, &&expr: @ast::expr) {
919919
0 { word_nbsp(s, "log_err"); print_expr(s, expr); }
920920
2 {
921921
word_nbsp(s, "log_full");
922-
popen(s);
922+
word(s.s, " ");
923923
print_expr(s, lexp);
924-
word(s.s, ",");
925-
space_if_not_bol(s);
926-
print_expr(s, expr);
927-
pclose(s);
928924
}
929925
}
930926
}

trunk/src/libstd/json.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ tag json {
3434
list(@[json]);
3535
/* Variant: dict */
3636
dict(map::hashmap<str,json>);
37+
/* Variant: null */
38+
null;
3739
}
3840

3941
/*
@@ -233,6 +235,14 @@ fn from_str_bool(s: str) -> (option::t<json>, str) {
233235
}
234236
}
235237

238+
fn from_str_null(s: str) -> (option::t<json>, str) {
239+
if (str::starts_with(s, "null")) {
240+
(some(null), str::slice(s, 4u, str::byte_len(s)))
241+
} else {
242+
(none, s)
243+
}
244+
}
245+
236246
fn from_str_helper(s: str) -> (option::t<json>, str) {
237247
let s = str::trim_left(s);
238248
if str::is_empty(s) { ret (none, s); }
@@ -243,6 +253,7 @@ fn from_str_helper(s: str) -> (option::t<json>, str) {
243253
'{' { from_str_dict(s) }
244254
'0' to '9' | '-' | '+' | '.' { from_str_float(s) }
245255
't' | 'f' { from_str_bool(s) }
256+
'n' { from_str_null(s) }
246257
_ { ret (none, s); }
247258
}
248259
}

trunk/src/test/stdtest/json.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ import option;
55
import std::json::*;
66
import option::{none, some};
77

8+
#[test]
9+
fn test_from_str_null() {
10+
assert(from_str("null") == some(null));
11+
}
12+
813
#[test]
914
fn test_from_str_num() {
1015
assert(from_str("3") == some(num(3f)));
@@ -31,6 +36,7 @@ fn test_from_str_bool() {
3136
fn test_from_str_list() {
3237
assert(from_str("[]") == some(list(@[])));
3338
assert(from_str("[true]") == some(list(@[boolean(true)])));
39+
assert(from_str("[null]") == some(list(@[null])));
3440
assert(from_str("[3, 1]") == some(list(@[num(3f), num(1f)])));
3541
assert(from_str("[2, [4, 1]]") ==
3642
some(list(@[num(2f), list(@[num(4f), num(1f)])])));
@@ -44,6 +50,7 @@ fn test_from_str_list() {
4450
fn test_from_str_dict() {
4551
assert(from_str("{}") != none);
4652
assert(from_str("{\"a\": 3}") != none);
53+
assert(from_str("{\"a\": null}") != none);
4754
assert(from_str("{\"a\": }") == none);
4855
assert(from_str("{\"a\" }") == none);
4956
assert(from_str("{\"a\"") == none);

0 commit comments

Comments
 (0)