@@ -11,6 +11,7 @@ use crate::ast::WithDecl;
1111use crate :: ast:: { ComponentDeclaration , InterfaceDeclaration } ;
1212use crate :: data:: Diagnostic ;
1313use vhdl_lang:: syntax:: parser:: ParsingContext ;
14+ use vhdl_lang:: VHDLStandard :: VHDL2019 ;
1415
1516pub fn parse_optional_generic_list (
1617 ctx : & mut ParsingContext < ' _ > ,
@@ -81,7 +82,11 @@ pub fn parse_component_declaration(
8182 let generic_list = parse_optional_generic_list ( ctx) ?;
8283 let port_list = parse_optional_port_list ( ctx) ?;
8384 ctx. stream . expect_kind ( End ) ?;
84- ctx. stream . expect_kind ( Component ) ?;
85+ if ctx. standard < VHDL2019 {
86+ ctx. stream . expect_kind ( Component ) ?;
87+ } else {
88+ ctx. stream . pop_if_kind ( Component ) ;
89+ }
8590 let end_ident = ctx. stream . pop_optional_ident ( ) ;
8691 let end_token = ctx. stream . expect_kind ( SemiColon ) ?;
8792
@@ -101,6 +106,7 @@ mod tests {
101106 use crate :: ast:: Ident ;
102107 use crate :: syntax:: test:: Code ;
103108 use crate :: SrcPos ;
109+ use crate :: VHDLStandard :: VHDL2019 ;
104110
105111 fn to_component (
106112 ident : WithDecl < Ident > ,
296302 ) ;
297303 assert_eq ! ( result, Ok ( Some ( vec![ code. s1( "foo : natural" ) . port( ) ] ) ) , ) ;
298304 }
305+
306+ #[ test]
307+ pub fn component_vhdl2019 ( ) {
308+ Code :: with_standard (
309+ "\
310+ component foo is
311+ end;
312+ " ,
313+ VHDL2019 ,
314+ )
315+ . parse_ok_no_diagnostics ( parse_component_declaration) ;
316+
317+ Code :: with_standard (
318+ "\
319+ component foo is
320+ end component;
321+ " ,
322+ VHDL2019 ,
323+ )
324+ . parse_ok_no_diagnostics ( parse_component_declaration) ;
325+
326+ Code :: with_standard (
327+ "\
328+ component foo is
329+ end component foo;
330+ " ,
331+ VHDL2019 ,
332+ )
333+ . parse_ok_no_diagnostics ( parse_component_declaration) ;
334+ }
299335}
0 commit comments