diff options
author | Aleksey Kladov <[email protected]> | 2018-08-05 14:15:40 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-08-05 14:15:40 +0100 |
commit | ed96926df715a856604a53e177e34ce445e89b7d (patch) | |
tree | d8e9d5cb24d012cdae1501d475e5f73a2e9befa5 /src | |
parent | 1e1e2e83c462b7efacaa0e33812beed72a88ab5f (diff) |
methods with type params
Diffstat (limited to 'src')
-rw-r--r-- | src/grammar/expressions/mod.rs | 31 | ||||
-rw-r--r-- | src/yellow/red.rs | 1 |
2 files changed, 18 insertions, 14 deletions
diff --git a/src/grammar/expressions/mod.rs b/src/grammar/expressions/mod.rs index baff0da52..4421a444c 100644 --- a/src/grammar/expressions/mod.rs +++ b/src/grammar/expressions/mod.rs | |||
@@ -35,7 +35,7 @@ struct Restrictions { | |||
35 | 35 | ||
36 | enum Op { | 36 | enum Op { |
37 | Simple, | 37 | Simple, |
38 | Composite(SyntaxKind, u8) | 38 | Composite(SyntaxKind, u8), |
39 | } | 39 | } |
40 | 40 | ||
41 | // test expr_binding_power | 41 | // test expr_binding_power |
@@ -52,16 +52,16 @@ enum Op { | |||
52 | // } | 52 | // } |
53 | fn current_op(p: &Parser) -> (u8, Op) { | 53 | fn current_op(p: &Parser) -> (u8, Op) { |
54 | if p.at_compound2(L_ANGLE, EQ) { | 54 | if p.at_compound2(L_ANGLE, EQ) { |
55 | return (2, Op::Composite(LTEQ, 2)) | 55 | return (2, Op::Composite(LTEQ, 2)); |
56 | } | 56 | } |
57 | if p.at_compound2(R_ANGLE, EQ) { | 57 | if p.at_compound2(R_ANGLE, EQ) { |
58 | return (2, Op::Composite(GTEQ, 2)) | 58 | return (2, Op::Composite(GTEQ, 2)); |
59 | } | 59 | } |
60 | if p.at_compound2(PLUS, EQ) { | 60 | if p.at_compound2(PLUS, EQ) { |
61 | return (1, Op::Composite(PLUSEQ, 2)) | 61 | return (1, Op::Composite(PLUSEQ, 2)); |
62 | } | 62 | } |
63 | if p.at_compound2(MINUS, EQ) { | 63 | if p.at_compound2(MINUS, EQ) { |
64 | return (1, Op::Composite(MINUSEQ, 2)) | 64 | return (1, Op::Composite(MINUSEQ, 2)); |
65 | } | 65 | } |
66 | 66 | ||
67 | let bp = match p.current() { | 67 | let bp = match p.current() { |
@@ -90,7 +90,7 @@ fn expr_bp(p: &mut Parser, r: Restrictions, bp: u8) { | |||
90 | Op::Simple => p.bump(), | 90 | Op::Simple => p.bump(), |
91 | Op::Composite(kind, n) => { | 91 | Op::Composite(kind, n) => { |
92 | p.bump_compound(kind, n); | 92 | p.bump_compound(kind, n); |
93 | }, | 93 | } |
94 | } | 94 | } |
95 | lhs = bin_expr(p, r, lhs, op_bp); | 95 | lhs = bin_expr(p, r, lhs, op_bp); |
96 | } | 96 | } |
@@ -115,8 +115,7 @@ fn unary_expr(p: &mut Parser, r: Restrictions) -> Option<CompletedMarker> { | |||
115 | p.bump(); | 115 | p.bump(); |
116 | p.eat(MUT_KW); | 116 | p.eat(MUT_KW); |
117 | REF_EXPR | 117 | REF_EXPR |
118 | 118 | } | |
119 | }, | ||
120 | // test deref_expr | 119 | // test deref_expr |
121 | // fn foo() { | 120 | // fn foo() { |
122 | // **&1; | 121 | // **&1; |
@@ -125,7 +124,7 @@ fn unary_expr(p: &mut Parser, r: Restrictions) -> Option<CompletedMarker> { | |||
125 | m = p.start(); | 124 | m = p.start(); |
126 | p.bump(); | 125 | p.bump(); |
127 | DEREF_EXPR | 126 | DEREF_EXPR |
128 | }, | 127 | } |
129 | // test not_expr | 128 | // test not_expr |
130 | // fn foo() { | 129 | // fn foo() { |
131 | // !!true; | 130 | // !!true; |
@@ -134,10 +133,10 @@ fn unary_expr(p: &mut Parser, r: Restrictions) -> Option<CompletedMarker> { | |||
134 | m = p.start(); | 133 | m = p.start(); |
135 | p.bump(); | 134 | p.bump(); |
136 | NOT_EXPR | 135 | NOT_EXPR |
137 | }, | 136 | } |
138 | _ => { | 137 | _ => { |
139 | let lhs = atom::atom_expr(p, r)?; | 138 | let lhs = atom::atom_expr(p, r)?; |
140 | return Some(postfix_expr(p, lhs)) | 139 | return Some(postfix_expr(p, lhs)); |
141 | } | 140 | } |
142 | }; | 141 | }; |
143 | unary_expr(p, r); | 142 | unary_expr(p, r); |
@@ -148,7 +147,7 @@ fn postfix_expr(p: &mut Parser, mut lhs: CompletedMarker) -> CompletedMarker { | |||
148 | loop { | 147 | loop { |
149 | lhs = match p.current() { | 148 | lhs = match p.current() { |
150 | L_PAREN => call_expr(p, lhs), | 149 | L_PAREN => call_expr(p, lhs), |
151 | DOT if p.nth(1) == IDENT => if p.nth(2) == L_PAREN { | 150 | DOT if p.nth(1) == IDENT => if p.nth(2) == L_PAREN || p.nth(2) == COLONCOLON { |
152 | method_call_expr(p, lhs) | 151 | method_call_expr(p, lhs) |
153 | } else { | 152 | } else { |
154 | field_expr(p, lhs) | 153 | field_expr(p, lhs) |
@@ -176,13 +175,17 @@ fn call_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker { | |||
176 | // test method_call_expr | 175 | // test method_call_expr |
177 | // fn foo() { | 176 | // fn foo() { |
178 | // x.foo(); | 177 | // x.foo(); |
179 | // y.bar(1, 2,); | 178 | // y.bar::<T>(1, 2,); |
180 | // } | 179 | // } |
181 | fn method_call_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker { | 180 | fn method_call_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker { |
182 | assert!(p.at(DOT) && p.nth(1) == IDENT && p.nth(2) == L_PAREN); | 181 | assert!( |
182 | p.at(DOT) && p.nth(1) == IDENT | ||
183 | && (p.nth(2) == L_PAREN || p.nth(2) == COLONCOLON) | ||
184 | ); | ||
183 | let m = lhs.precede(p); | 185 | let m = lhs.precede(p); |
184 | p.bump(); | 186 | p.bump(); |
185 | name_ref(p); | 187 | name_ref(p); |
188 | type_args::type_arg_list(p, true); | ||
186 | arg_list(p); | 189 | arg_list(p); |
187 | m.complete(p, METHOD_CALL_EXPR) | 190 | m.complete(p, METHOD_CALL_EXPR) |
188 | } | 191 | } |
diff --git a/src/yellow/red.rs b/src/yellow/red.rs index e124fc76e..91c4cd77f 100644 --- a/src/yellow/red.rs +++ b/src/yellow/red.rs | |||
@@ -1,4 +1,5 @@ | |||
1 | use std::ptr; | 1 | use std::ptr; |
2 | |||
2 | use parking_lot::RwLock; | 3 | use parking_lot::RwLock; |
3 | use {yellow::GreenNode, TextUnit}; | 4 | use {yellow::GreenNode, TextUnit}; |
4 | 5 | ||