aboutsummaryrefslogtreecommitdiff
path: root/src/parser/event_parser
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-01-27 22:12:49 +0000
committerAleksey Kladov <[email protected]>2018-01-27 22:12:49 +0000
commitb7ae5bbba22cb7968756b40240bcbca1f64ff6b0 (patch)
treed6d2572461b013be548864ff2ca8516702fca3f9 /src/parser/event_parser
parentda9bfacd98758438a5e733f1a3c42d8244c74eed (diff)
Simplify
Diffstat (limited to 'src/parser/event_parser')
-rw-r--r--src/parser/event_parser/grammar/items.rs21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/parser/event_parser/grammar/items.rs b/src/parser/event_parser/grammar/items.rs
index 38a4657aa..7706690cc 100644
--- a/src/parser/event_parser/grammar/items.rs
+++ b/src/parser/event_parser/grammar/items.rs
@@ -103,18 +103,27 @@ fn struct_item(p: &mut Parser) {
103} 103}
104 104
105fn named_fields(p: &mut Parser) { 105fn named_fields(p: &mut Parser) {
106 p.curly_block(|p| comma_list(p, EOF, |p| { 106 assert!(p.at(L_CURLY));
107 p.bump();
108 while !p.at(R_CURLY) && !p.at(EOF) {
107 named_field(p); 109 named_field(p);
108 true 110 if !p.at(R_CURLY) {
109 })); 111 p.expect(COMMA);
112 }
113 }
114 p.expect(R_CURLY);
110 115
111 fn named_field(p: &mut Parser) { 116 fn named_field(p: &mut Parser) {
112 let field = p.start(); 117 let field = p.start();
113 visibility(p); 118 visibility(p);
114 if p.expect(IDENT) && p.expect(COLON) { 119 if p.expect(IDENT) {
120 p.expect(COLON);
115 types::type_ref(p); 121 types::type_ref(p);
116 }; 122 field.complete(p, NAMED_FIELD);
117 field.complete(p, NAMED_FIELD); 123 } else {
124 field.abandon(p);
125 p.err_and_bump("expected field declaration");
126 }
118 } 127 }
119} 128}
120 129