diff options
author | Aleksey Kladov <[email protected]> | 2018-07-30 15:02:51 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-07-30 15:02:51 +0100 |
commit | d4366940976a3d150a8b5bf92dc24f0162d4d62c (patch) | |
tree | 5d43e0d49dd2cdb322a3cd367655929dc3e3d3ef /src/parser/grammar/expressions.rs | |
parent | 69c385e8105c7fad07a5728979e86a2a6a5e88ba (diff) |
Path expressions
Diffstat (limited to 'src/parser/grammar/expressions.rs')
-rw-r--r-- | src/parser/grammar/expressions.rs | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/src/parser/grammar/expressions.rs b/src/parser/grammar/expressions.rs index 40f41535e..ece698248 100644 --- a/src/parser/grammar/expressions.rs +++ b/src/parser/grammar/expressions.rs | |||
@@ -2,7 +2,16 @@ use super::*; | |||
2 | 2 | ||
3 | // test expr_literals | 3 | // test expr_literals |
4 | // fn foo() { | 4 | // fn foo() { |
5 | // let _ = 92; | 5 | // let _ = true; |
6 | // let _ = false; | ||
7 | // let _ = 1; | ||
8 | // let _ = 2.0; | ||
9 | // let _ = b'a'; | ||
10 | // let _ = 'b'; | ||
11 | // let _ = "c"; | ||
12 | // let _ = r"d"; | ||
13 | // let _ = b"e"; | ||
14 | // let _ = br"f"; | ||
6 | // } | 15 | // } |
7 | pub(super) fn literal(p: &mut Parser) -> bool { | 16 | pub(super) fn literal(p: &mut Parser) -> bool { |
8 | match p.current() { | 17 | match p.current() { |
@@ -21,6 +30,9 @@ pub(super) fn expr(p: &mut Parser) { | |||
21 | if literal(p) { | 30 | if literal(p) { |
22 | return; | 31 | return; |
23 | } | 32 | } |
33 | if paths::is_path_start(p) { | ||
34 | return path_expr(p); | ||
35 | } | ||
24 | 36 | ||
25 | match p.current() { | 37 | match p.current() { |
26 | L_PAREN => tuple_expr(p), | 38 | L_PAREN => tuple_expr(p), |
@@ -35,3 +47,16 @@ fn tuple_expr(p: &mut Parser) { | |||
35 | p.expect(R_PAREN); | 47 | p.expect(R_PAREN); |
36 | m.complete(p, TUPLE_EXPR); | 48 | m.complete(p, TUPLE_EXPR); |
37 | } | 49 | } |
50 | |||
51 | // test path_expr | ||
52 | // fn foo() { | ||
53 | // let _ = a; | ||
54 | // let _ = a::b; | ||
55 | // let _ = ::a::<b>; | ||
56 | // } | ||
57 | fn path_expr(p: &mut Parser) { | ||
58 | assert!(paths::is_path_start(p)); | ||
59 | let m = p.start(); | ||
60 | paths::expr_path(p); | ||
61 | m.complete(p, PATH_EXPR); | ||
62 | } | ||