diff options
| author | Paul Woolcock <pwoolcoc+github@gmail.com> | 2012-01-29 21:33:08 -0500 |
|---|---|---|
| committer | Marijn Haverbeke <marijnh@gmail.com> | 2012-01-30 18:21:01 +0100 |
| commit | e1251f7b0045281123dcbb1ffc80320b324bd814 (patch) | |
| tree | 3cfcc51c163d2450c41c2e59621131478ec9177f /src/comp/syntax/parse/parser.rs | |
| parent | e1f15a71e3dc1d24454594e068ed3df2271448e3 (diff) | |
| download | rust-e1251f7b0045281123dcbb1ffc80320b324bd814.tar.gz rust-e1251f7b0045281123dcbb1ffc80320b324bd814.zip | |
Change all ternary ops to if/then/else
All the files below had at least one instance of the ternary operator present in the source. All have been changed to the equivalent if/then/else expression.
Diffstat (limited to 'src/comp/syntax/parse/parser.rs')
| -rw-r--r-- | src/comp/syntax/parse/parser.rs | 44 |
1 files changed, 34 insertions, 10 deletions
diff --git a/src/comp/syntax/parse/parser.rs b/src/comp/syntax/parse/parser.rs index e6b278d5168..9678c69b1df 100644 --- a/src/comp/syntax/parse/parser.rs +++ b/src/comp/syntax/parse/parser.rs @@ -538,8 +538,11 @@ fn parse_arg(p: parser) -> ast::arg { fn parse_fn_block_arg(p: parser) -> ast::arg { let m = parse_arg_mode(p); let i = parse_value_ident(p); - let t = eat(p, token::COLON) ? parse_ty(p, false) : - @spanned(p.span.lo, p.span.hi, ast::ty_infer); + let t = if eat(p, token::COLON) { + parse_ty(p, false) + } else { + @spanned(p.span.lo, p.span.hi, ast::ty_infer) + }; ret {mode: m, ty: t, ident: i, id: p.get_id()}; } @@ -676,7 +679,12 @@ fn parse_path(p: parser) -> @ast::path { fn parse_path_and_ty_param_substs(p: parser, colons: bool) -> @ast::path { let lo = p.span.lo; let path = parse_path(p); - if colons ? eat(p, token::MOD_SEP) : p.token == token::LT { + let b = if colons { + eat(p, token::MOD_SEP) + } else { + p.token == token::LT + }; + if b { let seq = parse_seq_lt_gt(some(token::COMMA), {|p| parse_ty(p, false)}, p); @spanned(lo, seq.span.hi, {types: seq.node with path.node}) @@ -1504,7 +1512,11 @@ fn parse_pat(p: parser) -> @ast::pat { _ { true } } { let name = parse_path(p); - let sub = eat(p, token::AT) ? some(parse_pat(p)) : none; + let sub = if eat(p, token::AT) { + some(parse_pat(p)) + } else { + none + }; pat = ast::pat_ident(name, sub); } else { let enum_path = parse_path_and_ty_param_substs(p, true); @@ -1546,7 +1558,11 @@ fn parse_local(p: parser, allow_init: bool) -> @ast::local { fn parse_let(p: parser) -> @ast::decl { fn parse_let_style(p: parser) -> ast::let_style { - eat(p, token::BINOP(token::AND)) ? ast::let_ref : ast::let_copy + if eat(p, token::BINOP(token::AND)) { + ast::let_ref + } else { + ast::let_copy + } } let lo = p.span.lo; let locals = [(parse_let_style(p), parse_local(p, true))]; @@ -1786,11 +1802,19 @@ fn parse_fn_decl(p: parser, purity: ast::purity) } fn parse_fn_block_decl(p: parser) -> ast::fn_decl { - let inputs = eat(p, token::OROR) ? [] : - parse_seq(token::BINOP(token::OR), token::BINOP(token::OR), - seq_sep(token::COMMA), parse_fn_block_arg, p).node; - let output = eat(p, token::RARROW) ? parse_ty(p, false) : - @spanned(p.span.lo, p.span.hi, ast::ty_infer); + let inputs = if eat(p, token::OROR) { + [] + } else { + parse_seq(token::BINOP(token::OR), + token::BINOP(token::OR), + seq_sep(token::COMMA), + parse_fn_block_arg, p).node + }; + let output = if eat(p, token::RARROW) { + parse_ty(p, false) + } else { + @spanned(p.span.lo, p.span.hi, ast::ty_infer) + }; ret {inputs: inputs, output: output, purity: ast::impure_fn, |
