From c8910b0683dfc9ad88d440c22cef71c263837997 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 11 Feb 2018 23:32:49 +0300 Subject: G: for type --- src/parser/grammar/types.rs | 12 ++++++++++++ src/syntax_kinds.rs | 2 ++ 2 files changed, 14 insertions(+) (limited to 'src') diff --git a/src/parser/grammar/types.rs b/src/parser/grammar/types.rs index a4967a00a..c25517a51 100644 --- a/src/parser/grammar/types.rs +++ b/src/parser/grammar/types.rs @@ -9,6 +9,7 @@ pub(super) fn type_(p: &mut Parser) { AMPERSAND => reference_type(p), UNDERSCORE => placeholder_type(p), FN_KW | UNSAFE_KW | EXTERN_KW => fn_pointer_type(p), + FOR_KW => for_type(p), IDENT => path_type(p), _ => { p.error("expected type"); @@ -166,6 +167,17 @@ fn fn_pointer_type(p: &mut Parser) { m.complete(p, FN_POINTER_TYPE); } +// test for_type +// type A = for<'a> fn() -> (); +fn for_type(p: &mut Parser) { + assert!(p.at(FOR_KW)); + let m = p.start(); + p.bump(); + type_params::list(p); + type_(p); + m.complete(p, FOR_TYPE); +} + fn path_type(p: &mut Parser) { assert!(p.at(IDENT)); let m = p.start(); diff --git a/src/syntax_kinds.rs b/src/syntax_kinds.rs index db0f51beb..537a80417 100644 --- a/src/syntax_kinds.rs +++ b/src/syntax_kinds.rs @@ -109,6 +109,7 @@ pub enum SyntaxKind { REFERENCE_TYPE, PLACEHOLDER_TYPE, FN_POINTER_TYPE, + FOR_TYPE, EXTERN_BLOCK, ENUM_VARIANT, NAMED_FIELD, @@ -244,6 +245,7 @@ impl SyntaxKind { REFERENCE_TYPE => &SyntaxInfo { name: "REFERENCE_TYPE" }, PLACEHOLDER_TYPE => &SyntaxInfo { name: "PLACEHOLDER_TYPE" }, FN_POINTER_TYPE => &SyntaxInfo { name: "FN_POINTER_TYPE" }, + FOR_TYPE => &SyntaxInfo { name: "FOR_TYPE" }, EXTERN_BLOCK => &SyntaxInfo { name: "EXTERN_BLOCK" }, ENUM_VARIANT => &SyntaxInfo { name: "ENUM_VARIANT" }, NAMED_FIELD => &SyntaxInfo { name: "NAMED_FIELD" }, -- cgit v1.2.3