aboutsummaryrefslogtreecommitdiff
path: root/src/parser/grammar/mod.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-02-17 22:06:48 +0000
committerAleksey Kladov <[email protected]>2018-02-17 22:06:48 +0000
commitc6f4a06b4297f498da4bc2cd747aa38effb855b0 (patch)
treea383a2e71da6029bbd6a5669b5f9d2b99a1b0a92 /src/parser/grammar/mod.rs
parent8c4c5b5b802a204bfeef52e215358ae838900f1f (diff)
G: value_parameters, patterns & let statement
Diffstat (limited to 'src/parser/grammar/mod.rs')
-rw-r--r--src/parser/grammar/mod.rs20
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;
30mod attributes; 30mod attributes;
31mod expressions; 31mod expressions;
32mod types; 32mod types;
33mod patterns;
33mod paths; 34mod paths;
34mod type_params; 35mod 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: ()) {}
88fn fn_value_parameters(p: &mut Parser) { 94fn 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
94fn fn_ret_type(p: &mut Parser) { 114fn fn_ret_type(p: &mut Parser) {