aboutsummaryrefslogtreecommitdiff
path: root/src/parser/grammar
diff options
context:
space:
mode:
Diffstat (limited to 'src/parser/grammar')
-rw-r--r--src/parser/grammar/expressions.rs23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/parser/grammar/expressions.rs b/src/parser/grammar/expressions.rs
index 7991b1921..4861536f8 100644
--- a/src/parser/grammar/expressions.rs
+++ b/src/parser/grammar/expressions.rs
@@ -26,7 +26,7 @@ pub(super) fn literal(p: &mut Parser) -> Option<CompletedMarker> {
26} 26}
27 27
28pub(super) fn expr(p: &mut Parser) { 28pub(super) fn expr(p: &mut Parser) {
29 let mut lhs = atom_expr(p); 29 let mut lhs = prefix_expr(p);
30 30
31 while let Some(m) = lhs { 31 while let Some(m) = lhs {
32 match p.current() { 32 match p.current() {
@@ -36,6 +36,27 @@ pub(super) fn expr(p: &mut Parser) {
36 } 36 }
37} 37}
38 38
39fn prefix_expr(p: &mut Parser) -> Option<CompletedMarker> {
40 match p.current() {
41 AMPERSAND => Some(ref_expr(p)),
42 _ => atom_expr(p)
43 }
44}
45
46// test ref_expr
47// fn foo() {
48// let _ = &1;
49// let _ = &mut &f();
50// }
51fn ref_expr(p: &mut Parser) -> CompletedMarker {
52 assert!(p.at(AMPERSAND));
53 let m = p.start();
54 p.bump();
55 p.eat(MUT_KW);
56 expr(p);
57 m.complete(p, REF_EXPR)
58}
59
39fn atom_expr(p: &mut Parser) -> Option<CompletedMarker> { 60fn atom_expr(p: &mut Parser) -> Option<CompletedMarker> {
40 match literal(p) { 61 match literal(p) {
41 Some(m) => return Some(m), 62 Some(m) => return Some(m),