diff options
author | Aleksey Kladov <[email protected]> | 2018-08-23 22:48:10 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-08-23 22:48:10 +0100 |
commit | cf7d4a2a243cac1975b9b28d47ed91a6bd01b34f (patch) | |
tree | 0a1730599ff089623b3bb1946fc061f124f2e410 /crates/libsyntax2/src/grammar | |
parent | dd64a155e9dd24fd2a81f8c634fdb396632de472 (diff) |
Simplify
Diffstat (limited to 'crates/libsyntax2/src/grammar')
-rw-r--r-- | crates/libsyntax2/src/grammar/expressions/mod.rs | 54 |
1 files changed, 26 insertions, 28 deletions
diff --git a/crates/libsyntax2/src/grammar/expressions/mod.rs b/crates/libsyntax2/src/grammar/expressions/mod.rs index feef5f1d6..3da539699 100644 --- a/crates/libsyntax2/src/grammar/expressions/mod.rs +++ b/crates/libsyntax2/src/grammar/expressions/mod.rs | |||
@@ -45,35 +45,33 @@ enum Op { | |||
45 | } | 45 | } |
46 | 46 | ||
47 | fn current_op(p: &Parser) -> (u8, Op) { | 47 | fn current_op(p: &Parser) -> (u8, Op) { |
48 | if p.at_compound2(PLUS, EQ) { | 48 | if let Some(t) = p.next3() { |
49 | return (1, Op::Composite(PLUSEQ, 2)); | 49 | match t { |
50 | } | 50 | (L_ANGLE, L_ANGLE, EQ) => |
51 | if p.at_compound2(MINUS, EQ) { | 51 | return (1, Op::Composite(SHLEQ, 3)), |
52 | return (1, Op::Composite(MINUSEQ, 2)); | 52 | (R_ANGLE, R_ANGLE, EQ) => |
53 | } | 53 | return (1, Op::Composite(SHREQ, 3)), |
54 | if p.at_compound3(L_ANGLE, L_ANGLE, EQ) { | 54 | _ => (), |
55 | return (1, Op::Composite(SHLEQ, 3)); | 55 | } |
56 | } | ||
57 | if p.at_compound3(R_ANGLE, R_ANGLE, EQ) { | ||
58 | return (1, Op::Composite(SHREQ, 3)); | ||
59 | } | ||
60 | if p.at_compound2(PIPE, PIPE) { | ||
61 | return (3, Op::Composite(PIPEPIPE, 2)); | ||
62 | } | ||
63 | if p.at_compound2(AMP, AMP) { | ||
64 | return (4, Op::Composite(AMPAMP, 2)); | ||
65 | } | ||
66 | if p.at_compound2(L_ANGLE, EQ) { | ||
67 | return (5, Op::Composite(LTEQ, 2)); | ||
68 | } | ||
69 | if p.at_compound2(R_ANGLE, EQ) { | ||
70 | return (5, Op::Composite(GTEQ, 2)); | ||
71 | } | ||
72 | if p.at_compound2(L_ANGLE, L_ANGLE) { | ||
73 | return (9, Op::Composite(SHL, 2)); | ||
74 | } | 56 | } |
75 | if p.at_compound2(R_ANGLE, R_ANGLE) { | 57 | |
76 | return (9, Op::Composite(SHR, 2)); | 58 | if let Some(t) = p.next2() { |
59 | match t { | ||
60 | (PLUS, EQ) => return (1, Op::Composite(PLUSEQ, 2)), | ||
61 | (MINUS, EQ) => return (1, Op::Composite(MINUSEQ, 2)), | ||
62 | (STAR, EQ) => return (1, Op::Composite(STAREQ, 2)), | ||
63 | (SLASH, EQ) => return (1, Op::Composite(SLASHEQ, 2)), | ||
64 | (PIPE, EQ) => return (1, Op::Composite(PIPEEQ, 2)), | ||
65 | (AMP, EQ) => return (1, Op::Composite(AMPEQ, 2)), | ||
66 | (CARET, EQ) => return (1, Op::Composite(CARETEQ, 2)), | ||
67 | (PIPE, PIPE) => return (3, Op::Composite(PIPEPIPE, 2)), | ||
68 | (AMP, AMP) => return (4, Op::Composite(AMPAMP, 2)), | ||
69 | (L_ANGLE, EQ) => return (5, Op::Composite(LTEQ, 2)), | ||
70 | (R_ANGLE, EQ) => return (5, Op::Composite(GTEQ, 2)), | ||
71 | (L_ANGLE, L_ANGLE) => return (9, Op::Composite(SHL, 2)), | ||
72 | (R_ANGLE, R_ANGLE) => return (9, Op::Composite(SHR, 2)), | ||
73 | _ => (), | ||
74 | } | ||
77 | } | 75 | } |
78 | 76 | ||
79 | let bp = match p.current() { | 77 | let bp = match p.current() { |