aboutsummaryrefslogtreecommitdiff
path: root/src/grammar/expressions/mod.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-08-05 16:16:52 +0100
committerAleksey Kladov <[email protected]>2018-08-05 16:16:52 +0100
commit720861bcff4b9f67ca4def66e2996015811fa90b (patch)
tree9bed19490f802860e0c17532eaed853dfeb548bb /src/grammar/expressions/mod.rs
parentb0291cd8c2ec1d6d164caaa743f7484416e9b3f5 (diff)
Lopps && logical ops
Diffstat (limited to 'src/grammar/expressions/mod.rs')
-rw-r--r--src/grammar/expressions/mod.rs25
1 files changed, 16 insertions, 9 deletions
diff --git a/src/grammar/expressions/mod.rs b/src/grammar/expressions/mod.rs
index 0312a757a..18e3f5798 100644
--- a/src/grammar/expressions/mod.rs
+++ b/src/grammar/expressions/mod.rs
@@ -56,27 +56,34 @@ enum Op {
56// x += 1; 56// x += 1;
57// 1 + 1 <= 2 * 3; 57// 1 + 1 <= 2 * 3;
58// z -= 3 >= 0; 58// z -= 3 >= 0;
59// true || true && false;
59// } 60// }
60fn current_op(p: &Parser) -> (u8, Op) { 61fn current_op(p: &Parser) -> (u8, Op) {
61 if p.at_compound2(L_ANGLE, EQ) {
62 return (3, Op::Composite(LTEQ, 2));
63 }
64 if p.at_compound2(R_ANGLE, EQ) {
65 return (3, Op::Composite(GTEQ, 2));
66 }
67 if p.at_compound2(PLUS, EQ) { 62 if p.at_compound2(PLUS, EQ) {
68 return (1, Op::Composite(PLUSEQ, 2)); 63 return (1, Op::Composite(PLUSEQ, 2));
69 } 64 }
70 if p.at_compound2(MINUS, EQ) { 65 if p.at_compound2(MINUS, EQ) {
71 return (1, Op::Composite(MINUSEQ, 2)); 66 return (1, Op::Composite(MINUSEQ, 2));
72 } 67 }
68 if p.at_compound2(PIPE, PIPE) {
69 return (3, Op::Composite(PIPEPIPE, 2));
70 }
71 if p.at_compound2(AMPERSAND, AMPERSAND) {
72 return (4, Op::Composite(AMPERSANDAMPERSAND, 2));
73 }
74 if p.at_compound2(L_ANGLE, EQ) {
75 return (5, Op::Composite(LTEQ, 2));
76 }
77 if p.at_compound2(R_ANGLE, EQ) {
78 return (5, Op::Composite(GTEQ, 2));
79 }
73 80
74 let bp = match p.current() { 81 let bp = match p.current() {
75 EQ => 1, 82 EQ => 1,
76 DOTDOT => 2, 83 DOTDOT => 2,
77 EQEQ | NEQ => 3, 84 EQEQ | NEQ => 5,
78 MINUS | PLUS => 4, 85 MINUS | PLUS => 6,
79 STAR | SLASH => 5, 86 STAR | SLASH => 7,
80 _ => 0, 87 _ => 0,
81 }; 88 };
82 (bp, Op::Simple) 89 (bp, Op::Simple)