From 197a2e6fefd45627920cfb9bbca24b446e5a7c89 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 30 Jan 2018 22:53:19 +0300 Subject: G: type_parameter_list --- src/parser/event_parser/grammar/items/mod.rs | 26 +++++++++++++++++++++++++- src/parser/event_parser/grammar/paths.rs | 13 +++++++++++-- 2 files changed, 36 insertions(+), 3 deletions(-) (limited to 'src/parser/event_parser') diff --git a/src/parser/event_parser/grammar/items/mod.rs b/src/parser/event_parser/grammar/items/mod.rs index 0a50fffc1..4d8783735 100644 --- a/src/parser/event_parser/grammar/items/mod.rs +++ b/src/parser/event_parser/grammar/items/mod.rs @@ -103,8 +103,32 @@ fn type_param_list(p: &mut Parser) { assert!(p.at(IDENT)); let m = p.start(); p.bump(); + if p.eat(COLON) { + loop { + let has_paren = p.eat(L_PAREN); + p.eat(QUESTION); + if p.at(FOR_KW) { + //TODO + } + if p.at(LIFETIME) { + p.bump(); + } else if paths::is_path_start(p) { + paths::type_path(p); + } else { + break; + } + if has_paren { + p.expect(R_PAREN); + } + if !p.eat(PLUS) { + break; + } + } + } + if p.at(EQ) { + types::type_ref(p) + } m.complete(p, TYPE_PARAM); - //TODO: bounds } } diff --git a/src/parser/event_parser/grammar/paths.rs b/src/parser/event_parser/grammar/paths.rs index a254ab05e..bf3c8aedd 100644 --- a/src/parser/event_parser/grammar/paths.rs +++ b/src/parser/event_parser/grammar/paths.rs @@ -1,10 +1,18 @@ use super::*; -pub(crate) fn is_path_start(p: &Parser) -> bool { +pub(super) fn is_path_start(p: &Parser) -> bool { AnyOf(&[IDENT, SELF_KW, SUPER_KW, COLONCOLON]).is_ahead(p) } -pub(crate) fn use_path(p: &mut Parser) { +pub(super) fn use_path(p: &mut Parser) { + path(p) +} + +pub(super) fn type_path(p: &mut Parser) { + path(p) +} + +fn path(p: &mut Parser) { if !is_path_start(p) { return; } @@ -24,6 +32,7 @@ pub(crate) fn use_path(p: &mut Parser) { } } + fn path_segment(p: &mut Parser, first: bool) { let segment = p.start(); if first { -- cgit v1.2.3