diff --git a/Examples/test-suite/doxygen_parsing_enums.i b/Examples/test-suite/doxygen_parsing_enums.i index 5c48f4801..b7a39871f 100644 --- a/Examples/test-suite/doxygen_parsing_enums.i +++ b/Examples/test-suite/doxygen_parsing_enums.i @@ -32,4 +32,9 @@ SOME_ITEM_30 ///< Post comment for the third item }; + enum SomeEnumWithTrailingComma + { + SOME_ITEM_100, ///< Post comment after comma. + SOME_ITEM_200, ///< Post comment after last comma. + }; %} diff --git a/Examples/test-suite/java/doxygen_parsing_enums_proper_runme.java b/Examples/test-suite/java/doxygen_parsing_enums_proper_runme.java index a8527e364..ef1f06af5 100644 --- a/Examples/test-suite/java/doxygen_parsing_enums_proper_runme.java +++ b/Examples/test-suite/java/doxygen_parsing_enums_proper_runme.java @@ -55,6 +55,10 @@ public class doxygen_parsing_enums_proper_runme { wantedComments.put("doxygen_parsing_enums_proper.SomeAnotherEnum2.SOME_ITEM_20", "Post comment for the second item \n" + ""); + wantedComments.put("doxygen_parsing_enums_proper.SomeEnumWithTrailingComma.SOME_ITEM_100", + "Post comment after comma."); + wantedComments.put("doxygen_parsing_enums_proper.SomeEnumWithTrailingComma.SOME_ITEM_200", + "Post comment after last comma."); // and ask the parser to check comments for us System.exit(parser.check(wantedComments)); diff --git a/Examples/test-suite/java/doxygen_parsing_enums_simple_runme.java b/Examples/test-suite/java/doxygen_parsing_enums_simple_runme.java index f68fff151..85ec0cb55 100644 --- a/Examples/test-suite/java/doxygen_parsing_enums_simple_runme.java +++ b/Examples/test-suite/java/doxygen_parsing_enums_simple_runme.java @@ -47,6 +47,10 @@ public class doxygen_parsing_enums_simple_runme { " The comment for the first item \n" + " \n" + ""); + wantedComments.put("doxygen_parsing_enums_simple.doxygen_parsing_enums_simpleConstants.SOME_ITEM_100", + "Post comment after comma."); + wantedComments.put("doxygen_parsing_enums_simple.doxygen_parsing_enums_simpleConstants.SOME_ITEM_200", + "Post comment after last comma."); // and ask the parser to check comments for us System.exit(parser.check(wantedComments)); diff --git a/Examples/test-suite/java/doxygen_parsing_enums_typesafe_runme.java b/Examples/test-suite/java/doxygen_parsing_enums_typesafe_runme.java index 7c7f05ccc..4e5f4b489 100644 --- a/Examples/test-suite/java/doxygen_parsing_enums_typesafe_runme.java +++ b/Examples/test-suite/java/doxygen_parsing_enums_typesafe_runme.java @@ -55,6 +55,10 @@ public class doxygen_parsing_enums_typesafe_runme { wantedComments.put("doxygen_parsing_enums_typesafe.SomeAnotherEnum2.SOME_ITEM_30", "Post comment for the third item \n" + ""); + wantedComments.put("doxygen_parsing_enums_typesafe.SomeEnumWithTrailingComma.SOME_ITEM_100", + "Post comment after comma."); + wantedComments.put("doxygen_parsing_enums_typesafe.SomeEnumWithTrailingComma.SOME_ITEM_200", + "Post comment after last comma."); // and ask the parser to check comments for us diff --git a/Examples/test-suite/java/doxygen_parsing_enums_typeunsafe_runme.java b/Examples/test-suite/java/doxygen_parsing_enums_typeunsafe_runme.java index 8c7dfeda0..428649196 100644 --- a/Examples/test-suite/java/doxygen_parsing_enums_typeunsafe_runme.java +++ b/Examples/test-suite/java/doxygen_parsing_enums_typeunsafe_runme.java @@ -55,6 +55,10 @@ public class doxygen_parsing_enums_typeunsafe_runme { wantedComments.put("doxygen_parsing_enums_typeunsafe.SomeAnotherEnum2.SOME_ITEM_10", "Post comment for the first item \n" + ""); + wantedComments.put("doxygen_parsing_enums_typeunsafe.SomeEnumWithTrailingComma.SOME_ITEM_100", + "Post comment after comma."); + wantedComments.put("doxygen_parsing_enums_typeunsafe.SomeEnumWithTrailingComma.SOME_ITEM_200", + "Post comment after last comma."); // and ask the parser to check comments for us System.exit(parser.check(wantedComments)); diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 4046e480e..b526da907 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -1650,7 +1650,7 @@ static String *add_qualifier_to_declarator(SwigType *type, SwigType *qualifier) /* C declarations */ %type c_declaration c_decl c_decl_tail c_enum_key c_enum_inherit c_enum_decl c_enum_forward_decl c_constructor_decl; -%type enumlist enumlist_tail enumlist_item edecl_with_dox edecl; +%type enumlist enumlist_item edecl_with_dox edecl; /* C++ declarations */ %type cpp_declaration cpp_class_decl cpp_forward_class_decl cpp_template_decl cpp_alternate_rettype; @@ -6374,21 +6374,31 @@ optional_ignored_defines | empty ; -optional_ignored_define_after_comma - : empty - | COMMA - | COMMA constant_directive - ; - /* Enum lists - any #define macros (constant directives) within the enum list are ignored. Trailing commas accepted. */ -enumlist : enumlist_item optional_ignored_define_after_comma { +enumlist : enumlist_item { Setattr($1,"_last",$1); $$ = $1; } - | enumlist_item enumlist_tail optional_ignored_define_after_comma { - set_nextSibling($1, $2); - Setattr($1,"_last",Getattr($2,"_last")); - Setattr($2,"_last",NULL); + | enumlist_item DOXYGENPOSTSTRING { + Setattr($1,"_last",$1); + set_comment($1, $2); + $$ = $1; + } + | enumlist_item COMMA enumlist { + if ($3) { + set_nextSibling($1, $3); + Setattr($1,"_last",Getattr($3,"_last")); + Setattr($3,"_last",NULL); + } + $$ = $1; + } + | enumlist_item COMMA DOXYGENPOSTSTRING enumlist { + if ($4) { + set_nextSibling($1, $4); + Setattr($1,"_last",Getattr($4,"_last")); + Setattr($4,"_last",NULL); + } + set_comment($1, $3); $$ = $1; } | optional_ignored_defines { @@ -6396,17 +6406,6 @@ enumlist : enumlist_item optional_ignored_define_after_comma { } ; -enumlist_tail : COMMA enumlist_item { - Setattr($2,"_last",$2); - $$ = $2; - } - | enumlist_tail COMMA enumlist_item { - set_nextSibling(Getattr($1,"_last"), $3); - Setattr($1,"_last",$3); - $$ = $1; - } - ; - enumlist_item : optional_ignored_defines edecl_with_dox optional_ignored_defines { $$ = $2; } @@ -6419,19 +6418,6 @@ edecl_with_dox : edecl { $$ = $2; set_comment($2, $1); } - | edecl DOXYGENPOSTSTRING { - $$ = $1; - set_comment($1, $2); - } - | DOXYGENPOSTSTRING edecl { - $$ = $2; - set_comment(previousNode, $1); - } - | DOXYGENPOSTSTRING edecl DOXYGENPOSTSTRING { - $$ = $2; - set_comment(previousNode, $1); - set_comment($2, $3); - } ; edecl : identifier {