@@ -616,9 +616,13 @@ description:
616616 module_declaration
617617 { PARSER.parse_tree.add_item(stack_expr($1 )); }
618618 | udp_declaration
619+ { PARSER.parse_tree.add_item(stack_expr($1 )); }
619620 | interface_declaration
621+ { PARSER.parse_tree.add_item(stack_expr($1 )); }
620622 | program_declaration
623+ { PARSER.parse_tree.add_item(stack_expr($1 )); }
621624 | package_declaration
625+ { PARSER.parse_tree.add_item(stack_expr($1 )); }
622626 | attribute_instance_brace package_item
623627 { add_attributes($2 , $1 );
624628 PARSER.parse_tree.add_item(stack_expr($2 )); }
@@ -713,9 +717,31 @@ module_keyword:
713717 ;
714718
715719interface_declaration:
716- TOK_INTERFACE TOK_ENDINTERFACE
720+ interface_nonansi_header
721+ timeunits_declaration_opt
722+ interface_item_brace
723+ TOK_ENDINTERFACE
724+ { $$ = $1 ; }
717725 ;
718726
727+ interface_nonansi_header:
728+ attribute_instance_brace
729+ TOK_INTERFACE
730+ lifetime_opt
731+ interface_identifier
732+ {
733+ init ($$, ID_verilog_interface);
734+ stack_expr ($$).set (ID_base_name, stack_expr ($4 ).id ());
735+ }
736+ package_import_declaration_brace
737+ parameter_port_list_opt
738+ list_of_ports_opt
739+ ' ;'
740+ {
741+ $$ = $5 ;
742+ }
743+ ;
744+
719745program_declaration:
720746 TOK_PROGRAM TOK_ENDPROGRAM
721747 ;
@@ -724,32 +750,42 @@ class_declaration:
724750 TOK_CLASS class_identifier
725751 ' ;'
726752 {
727- $$ = $1 ;
753+ init ($$, ID_verilog_class);
754+ stack_expr ($$).set (ID_base_name, stack_expr ($2 ).id ());
728755 push_scope (stack_expr ($2 ).id (), " ::" );
729756 }
730757 class_item_brace
731758 TOK_ENDCLASS
732759 {
760+ $$ = $4 ;
733761 pop_scope ();
734762 }
735763 ;
736764
737765package_declaration:
738766 attribute_instance_brace TOK_PACKAGE
767+ { init ($$, ID_verilog_package); }
739768 lifetime_opt
740769 package_identifier ' ;'
741770 {
742- $$ = $1 ;
743- push_scope (stack_expr ($4 ).id (), " ::" );
771+ push_scope (stack_expr ($5 ).id (), " ::" );
744772 }
745773 timeunits_declaration_opt
746774 package_item_brace
747- TOK_ENDPACKAGE
775+ TOK_ENDPACKAGE endpackage_identifier_opt
748776 {
749777 pop_scope ();
778+ $$ = $3 ;
779+ addswap ($$, ID_module_items, $9 );
780+ stack_expr ($$).set (ID_base_name, stack_expr ($5 ).id ());
750781 }
751782 ;
752783
784+ endpackage_identifier_opt:
785+ /* Optional */
786+ | TOK_COLON package_identifier
787+ ;
788+
753789timeunits_declaration_opt:
754790 /* Optional */
755791 ;
@@ -939,6 +975,38 @@ config_declaration:
939975bind_directive:
940976 TOK_BIND
941977 ;
978+
979+ // System Verilog standard 1800-2017
980+ // A.1.6 Interface items
981+
982+ interface_or_generate_item:
983+ attribute_instance_brace module_common_item
984+ | attribute_instance_brace extern_tf_declaration
985+ ;
986+
987+ extern_tf_declaration:
988+ TOK_EXTERN method_prototype ' ;'
989+ | TOK_EXTERN TOK_FORKJOIN task_prototype ' ;'
990+ ;
991+
992+ interface_item_brace:
993+ /* Optional */
994+ | interface_item_brace interface_item
995+ ;
996+
997+ interface_item:
998+ port_declaration ' ;'
999+ | non_port_interface_item
1000+ ;
1001+
1002+ non_port_interface_item:
1003+ generate_region
1004+ | interface_or_generate_item
1005+ | program_declaration
1006+ /* | modport_declaration */
1007+ | interface_declaration
1008+ /* | timeunits_declaration */
1009+ ;
9421010
9431011// System Verilog standard 1800-2017
9441012// A.1.9 Class items
@@ -3920,8 +3988,7 @@ genvar_identifier: identifier;
39203988hierarchical_parameter_identifier: hierarchical_identifier
39213989 ;
39223990
3923- interface_identifier:
3924- ;
3991+ interface_identifier: TOK_NON_TYPE_IDENTIFIER;
39253992
39263993module_identifier: TOK_NON_TYPE_IDENTIFIER;
39273994
0 commit comments