diff options
Diffstat (limited to 'src/parser/grammar/mod.rs')
-rw-r--r-- | src/parser/grammar/mod.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/parser/grammar/mod.rs b/src/parser/grammar/mod.rs index ee0263203..54a63a547 100644 --- a/src/parser/grammar/mod.rs +++ b/src/parser/grammar/mod.rs | |||
@@ -30,6 +30,7 @@ mod items; | |||
30 | mod attributes; | 30 | mod attributes; |
31 | mod expressions; | 31 | mod expressions; |
32 | mod types; | 32 | mod types; |
33 | mod patterns; | ||
33 | mod paths; | 34 | mod paths; |
34 | mod type_params; | 35 | mod type_params; |
35 | 36 | ||
@@ -85,10 +86,29 @@ fn abi(p: &mut Parser) { | |||
85 | abi.complete(p, ABI); | 86 | abi.complete(p, ABI); |
86 | } | 87 | } |
87 | 88 | ||
89 | // test fn_value_parameters | ||
90 | // fn a() {} | ||
91 | // fn b(x: i32) {} | ||
92 | // fn c(x: i32, ) {} | ||
93 | // fn d(x: i32, y: ()) {} | ||
88 | fn fn_value_parameters(p: &mut Parser) { | 94 | fn fn_value_parameters(p: &mut Parser) { |
89 | assert!(p.at(L_PAREN)); | 95 | assert!(p.at(L_PAREN)); |
90 | p.bump(); | 96 | p.bump(); |
97 | while !p.at(EOF) && !p.at(R_PAREN) { | ||
98 | value_parameter(p); | ||
99 | if !p.at(R_PAREN) { | ||
100 | p.expect(COMMA); | ||
101 | } | ||
102 | } | ||
91 | p.expect(R_PAREN); | 103 | p.expect(R_PAREN); |
104 | |||
105 | fn value_parameter(p: &mut Parser) { | ||
106 | let m = p.start(); | ||
107 | patterns::pattern(p); | ||
108 | p.expect(COLON); | ||
109 | types::type_(p); | ||
110 | m.complete(p, VALUE_PARAMETER); | ||
111 | } | ||
92 | } | 112 | } |
93 | 113 | ||
94 | fn fn_ret_type(p: &mut Parser) { | 114 | fn fn_ret_type(p: &mut Parser) { |