From 63e2ed4e75bc16cdd1882be031d026469b49dbc4 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 31 Jul 2018 19:37:40 +0300 Subject: Nodes for type args --- src/parser/grammar/type_args.rs | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'src/parser/grammar') diff --git a/src/parser/grammar/type_args.rs b/src/parser/grammar/type_args.rs index adac73e7e..6b2217012 100644 --- a/src/parser/grammar/type_args.rs +++ b/src/parser/grammar/type_args.rs @@ -16,7 +16,7 @@ pub(super) fn list(p: &mut Parser, colon_colon_required: bool) { }; while !p.at(EOF) && !p.at(R_ANGLE) { - types::type_(p); + type_arg(p); if !p.at(R_ANGLE) && !p.expect(COMMA) { break; } @@ -24,3 +24,25 @@ pub(super) fn list(p: &mut Parser, colon_colon_required: bool) { p.expect(R_ANGLE); m.complete(p, TYPE_ARG_LIST); } + +// test type_arg +// type A = B<'static, i32, Item=u64> +fn type_arg(p: &mut Parser) { + let m = p.start(); + match p.current() { + LIFETIME => { + p.bump(); + m.complete(p, LIFETIME_ARG); + }, + IDENT if p.nth(1) == EQ => { + p.bump(); + p.bump(); + types::type_(p); + m.complete(p, ASSOC_TYPE_ARG); + }, + _ => { + types::type_(p); + m.complete(p, TYPE_ARG); + }, + } +} -- cgit v1.2.3